Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: need ideas ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 2341 of 2472
Post > Topic >>

Re: need ideas on how to debug code generator

by Joel Yliluoma <bisqwit@[EMAIL PROTECTED] > Feb 28, 2008 at 06:34 AM

On Sun, 24 Feb 2008 21:47:50 -0800, Ram Bhamidipaty wrote:
> Hi,
>
> I have a small code generator - for 32 bit x86 machines, unfortunately
it
> has some bugs :-(. My problem is that the generated code fails
> "once in a while" sometimes it can go for 20-40 iterations before
failing.
>
> I have a collection of test cases where I verify the correctness of
> various simple constructs -- things like load, store, add, sub, etc.
> Those all pass.
>
> The test case in question generates a code sequence of about 400 bytes.
It
> fails by seg faulting, unfortunately gdb is unable to print out a
> useful stack trace.
>
> What are some techniques that people have used for debugging code
> generators?

I am assuming you use a combination of a mprotect(..., PROT_EXEC)
and a cast into a function pointer to run generated code.

GDB can do generated code debugging tolerably, if you use a combination
of "display /i $pc", "stepi" and "disassemble <address1> <address2>".

When the program segfaults, you'll get the address and the exact
opcode that caused the segfault, and you can use disassemble to find
out about the surrounding context.  Additionally, you can use "display
/i $registername" and "stepi" to singlestep through the generated
program.

((Reposting, because I did not receive a moderation queuing
notification.))

--
Joel Yliluoma - http://iki.fi/bisqwit/
 




 5 Posts in Topic:
need ideas on how to debug code generator
Ram Bhamidipaty <rambh  2008-02-24 21:47:50 
Re: need ideas on how to debug code generator
Thomas Have <thomas@[E  2008-02-25 17:59:42 
Re: need ideas on how to debug code generator
Nils <n.pipenbrinck@[E  2008-02-26 02:55:34 
Re: need ideas on how to debug code generator
"Bartc" <bc@  2008-02-27 18:07:17 
Re: need ideas on how to debug code generator
Joel Yliluoma <bisqwit  2008-02-28 06:34:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 2:45:27 CDT 2008.