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

Ron Brender ron.brender
Thu Jul 13 12:43:32 GMT 2006


Jim Blandy wrote:
> On 7/12/06, Michael Eager <eager at eagercon.com> wrote:
>> 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?
> 
> If you can't set a breakpoint on line 5, then I certainly agree that's
> a serious loss of functionality.  I can see why one would want
> "hierarchical line numbers" of the sort Brian mentions.  So this is a
> good "why not" example.

Right. If you can only associate one line with an instruction I would
argue that the outer (macro invocation) line is the better and more 
useful one.

If the debugger traceback tells me I am stopped in stdio.h but cannot 
attribute that back to the location of a macro expansion that occurred 
in my source, then I will be at best confused and at worst quite lost!

> But this distinction:
> 
>> 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.
> 
> doesn't make sense to me, or at least it isn't supported by your
> example.  It seems to me that the 'getc' use in your example is
> exactly like Keith's example --- a simple form of inlined function.
> If there's a lot going on there, you certainly want to be able to step
> through it, just as you would an inlined function.

Consider Keith's example macro again, namely

     #define    MY_CODE    f1(); f2();

Now suppose I "call" that macro as in

     int x = MYCODE;

Although that macro definition might look like a pseudo-function, this 
invocation doesn't quite fit that model. The assignment to x, whose 
source is outside the expansion, semantically occurs "in the middle" of 
the expansion. If you "step through the expansion" where does the first 
step break: before or after the assignment? And if before, then is there 
another break after as well? Also note that part of the expansion is 
part of a declaration and part is not.

> I guess the catch is that you'd like the *option* of stepping through
> the macro call.  Simply attributing instructions to macro definition
> locations would effectively require you to step through it.

Fun stuff!

Ron





More information about the Dwarf-discuss mailing list