* Debugging new code using debug-info from old code
@ 2008-05-08 0:29 Lokesh Kumar
2008-05-08 18:44 ` Michael Snyder
0 siblings, 1 reply; 2+ messages in thread
From: Lokesh Kumar @ 2008-05-08 0:29 UTC (permalink / raw)
To: gdb
Hi all,
I am trying to debug a "transformed" C code using the debugging
information of the "original" C code. Essentially, my code goes
through some transformations that keeps its semantic structure same
but add some extraneous function calls distributed throughout the
code.
I want that when a user debugs this new code, all the new additions
are hidden away from him/her and (s)he feels as if (s)he is debugging
the original code. What this means is that there should exists an
underlying mapping between the transformed code and original code so
that it could map the debugging commands for original code into
corresponding commands for transformed code.
I started out by trying to load the symbol table of the original
executable while debugging the transformed binary but that doesn't
seem to help since the function addresses and everything else has
changed. My second thoughts seem to suggest that if I can update the
debugging information in the transformed binary as per my original
code, I may get what I want. However, I am not sure how this will work
if there were some compile-time optimizations in one code and not in
another but I am not thinking about that now.
I think I can use some help here. Does anyone here have a better idea
on how to do it ? Or perhaps, how can I update the debugging
information from one binary to another ?
Thanks in advance,
-Lokesh
--
"It is not God that is worshipped but the group or authority that
claims to speak in His name. Sin becomes disobedience to authority not
violation of integrity."
Lokesh Kumar
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Debugging new code using debug-info from old code
2008-05-08 0:29 Debugging new code using debug-info from old code Lokesh Kumar
@ 2008-05-08 18:44 ` Michael Snyder
0 siblings, 0 replies; 2+ messages in thread
From: Michael Snyder @ 2008-05-08 18:44 UTC (permalink / raw)
To: Lokesh Kumar; +Cc: gdb
On Wed, 2008-05-07 at 17:29 -0700, Lokesh Kumar wrote:
> Hi all,
>
> I am trying to debug a "transformed" C code using the debugging
> information of the "original" C code. Essentially, my code goes
> through some transformations that keeps its semantic structure same
> but add some extraneous function calls distributed throughout the
> code.
>
> I want that when a user debugs this new code, all the new additions
> are hidden away from him/her and (s)he feels as if (s)he is debugging
> the original code. What this means is that there should exists an
> underlying mapping between the transformed code and original code so
> that it could map the debugging commands for original code into
> corresponding commands for transformed code.
>
> I started out by trying to load the symbol table of the original
> executable while debugging the transformed binary but that doesn't
> seem to help since the function addresses and everything else has
> changed. My second thoughts seem to suggest that if I can update the
> debugging information in the transformed binary as per my original
> code, I may get what I want. However, I am not sure how this will work
> if there were some compile-time optimizations in one code and not in
> another but I am not thinking about that now.
>
> I think I can use some help here. Does anyone here have a better idea
> on how to do it ? Or perhaps, how can I update the debugging
> information from one binary to another ?
This has been done before -- for instance, this is how the
original "cfront" c++ compiler worked. "cfront" would pre-process
the C++ source code and generate a transformed C program file,
which would then be compiled.
In order to make debuggers (notably gdb) display the un-preprocessed
C++ source instead of the processed C source, cfront would generate
"#line" directives in the output (C) program that referred back to
lines within the input (C++) program.
So, if your transformed output file contains some code that
is associated with, say, line 1000 of your input source file,
you would instrument the output file with a line directive
that would look something like
#line 1000 'input.c'
Try it. You can add some line directives by hand and
compile the code to experiment with the debugger behavior.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-08 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-08 0:29 Debugging new code using debug-info from old code Lokesh Kumar
2008-05-08 18:44 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox