* symbol files in python
@ 2024-05-25 8:58 Dmitry.Neverov
2024-06-26 17:21 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry.Neverov @ 2024-05-25 8:58 UTC (permalink / raw)
To: gdb
I'm trying to filter out uninitialized variables in a frame by checking
their lines in python, something like this:
sal = frame.find_sal()
frame_line = sal.line
frame_file = sal.symtab.filename
block = frame.block()
while block is not None and block.is_valid():
for sym in block:
if sym.line >= frame_line:
continue
symtab = sym.symtab
if symtab is None or symtab.filename != frame_file:
continue
# otherwise show symbol as a variable
if block.function is not None:
break
block = block.superblock
Is it correct to expect that symbols in blocks inside a function will
have the same file as the function's frame?
I've noticed that if I add a breakpoint in type::set_num_fields()
(gdb/gdbtypes.h:1002), symtab.filename' for 'this' is 'gdb/mdebugread.c'
and not 'gdb/gdbtypes.h'. Is it expected?
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: symbol files in python
2024-05-25 8:58 symbol files in python Dmitry.Neverov
@ 2024-06-26 17:21 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2024-06-26 17:21 UTC (permalink / raw)
To: Dmitry.Neverov via Gdb; +Cc: Dmitry.Neverov
>>>>> "Dmitry" == Dmitry Neverov via Gdb <gdb@sourceware.org> writes:
Dmitry> I'm trying to filter out uninitialized variables in a frame by checking
Dmitry> their lines in python, something like this:
I suspect this will not yield good results when optimization is present.
I normally see this kind of thing as GIGO -- gdb does what the compiler
tells it. If the compiler thinks a variable is uninitialized at some
PC, it's free to omit that from the location list.
Dmitry> Is it correct to expect that symbols in blocks inside a function will
Dmitry> have the same file as the function's frame?
Not always, I think because of inlining. However I'm not really sure.
Compilers can emit pretty much anything they like.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-26 17:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-25 8:58 symbol files in python Dmitry.Neverov
2024-06-26 17:21 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).