[Dwarf-discuss] dwarf information for mutiple statements at thesame line.

Michael Eager eager
Thu Jul 13 00:49:49 GMT 2006


Jim Blandy wrote:
> On 7/11/06, Ron Brender <ron.brender at charter.net> wrote:
>> I believe Michael is correct. Basically, just treat every token in the
>> macro expansion as though it occurred at the location of the macro
>> invocation

> In other words, the source for Keith's call to f1 is on the line
> defining the macro --- why shouldn't the debug info say so?  Why is
> the post-processed program the "real" program, and the code as it
> exists in the user's file not?  It seems more useful to put it the
> other way around.

I think that the problem is that macros have two distinct and
disparate uses:  one is as a simple form of inlined function,
like Keith's example.  In that case, giving the location of the
macro definition is reasonable (although I'm not fully convinced).

The other use is as a source unit, for example, a call to any of
the functions defined as macros in stdio.h.

Consider this small piece of code:

1:  #include <stdio.h>
2:  int foo()
3:  {
4:      int c;
5:      c = getc(stdin);
6:      return c;
7:  }

The "function call" on line 5 is actually a macro defined in
stdio.h.  (In GCC, this actually defined as a call to
_IO_getc(), but I've seen multi-line implementations.)

What is the best description for the source location of instruction
that is generated by this call?   foo.c:5 or stdio.h:459?

The policy has been to assign line coordinates based on the
user's source code.  If this were changed for macro expansions,
and instead the line coordinates of the macro definition were
used, I'm not sure that there would be any way for a debugger to
find the user's source for this call instruction.  If foo:5 never
appears in the line table, how would a debugger place a
breakpoint on it?   Certainly you could place a breakpoint at
stdio.h:459, but is that really what you wanted to do?

I think it would be desirable to have a mapping between
the instructions generated in a macro expansion, but I think
that it is not as simple as replacing the user source location
with the macro definition location in the line table.

-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077





More information about the Dwarf-discuss mailing list