Lifetime of local variables
Martin Baulig
martin@gnome.org
Fri Apr 12 16:18:00 GMT 2002
Hi,
I was recently working a bit on debugging support for C# (using Mono)
and I need a way to tell GDB about the lifetime of local variables. In
C#, the JIT engine may decide to store two different variables at the
same stack offset if they aren't used throughout the whole function.
Now I was wondering how to do this - DWARF 2 already has a
`DW_AT_begin_scope' but unfortunately no `DW_AT_end_scope' - can we
add this or something similar as a GNU extension ?
After looking at the code, I found out that `struct symbol' contains a
`ranges' field which seems to do exactly what I want - but this field
isn't used anywhere.
The following patch
* adds a new DWARF 2 attribute DW_AT_end_scope to specify the end of
a local variable's scope.
* initializes SYMBOL_RANGES() in dwarf2read.c if DW_AT_begin_scope and
DW_AT_end_scope are specified.
[FIXME: According to the DWARF 2 specification, this attribute takes
an offset (DW_FROM_data), not an address - but I found now
way to get the current frame's address in new_symbol(), this
needs to be fixed.]
* checks whether the current PC is within the symbol's SYMBOL_RANGES()
when listing the local variables of a function and when printing a
variable.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-variable-scopes.patch
Type: text/x-patch
Size: 5169 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20020412/189f8b43/attachment.bin>
-------------- next part --------------
--
Martin Baulig
martin@gnome.org
More information about the Gdb
mailing list