public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Adding user-defined symbols to GDB
@ 2022-01-26 23:55 Matthew Rinaldi
  2022-01-27  1:53 ` Sterling Augustine
  2022-01-28 16:25 ` Jan Vrany
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Rinaldi @ 2022-01-26 23:55 UTC (permalink / raw)
  To: gdb

Hello,

I have a list of symbols that I have parsed out from a section within
the binary. The data is not in any standard symbol table format. I have
extracted the symbol's name and address. I want to add these symbols to
GDB, but it is non-trivial. The solutions that I have seen for adding
new user-defined symbols do not look ideal for a seemingly simple task.

Example: https://github.com/mahaloz/decomp2gef/blob/main/decomp2gef.py#L247

Is it possible to have a feature/command where the user could add
symbols directly to GDB without the use of an objfile?

I brought it up with Simon Marchi, and he said the following:
> But off-hand, I don't see why this wouldn't be possible. Each objfile
> could have a list of user-defined symbols, that lookup_symbol_in_objfile
> would search in addition to the other regular methods.

Thank you,
Matthew Rinaldi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding user-defined symbols to GDB
  2022-01-26 23:55 Adding user-defined symbols to GDB Matthew Rinaldi
@ 2022-01-27  1:53 ` Sterling Augustine
  2022-01-28 16:25 ` Jan Vrany
  1 sibling, 0 replies; 3+ messages in thread
From: Sterling Augustine @ 2022-01-27  1:53 UTC (permalink / raw)
  To: Matthew Rinaldi; +Cc: gdb

I don't know of a way to do it without an objfile, but the method in that
script is far more complicated than it needs to be.

I would have to work out the details, but a linker script with simple
symbol-value assignments could easily produce this.

symbol0 = value0
symbol1 = value1

then run ld with the right options so it doesn't pull in startfiles and
what not. Then add-symbol-file from inside gdb.

On Wed, Jan 26, 2022 at 3:55 PM Matthew Rinaldi via Gdb <gdb@sourceware.org>
wrote:

> Hello,
>
> I have a list of symbols that I have parsed out from a section within
> the binary. The data is not in any standard symbol table format. I have
> extracted the symbol's name and address. I want to add these symbols to
> GDB, but it is non-trivial. The solutions that I have seen for adding
> new user-defined symbols do not look ideal for a seemingly simple task.
>
> Example:
> https://github.com/mahaloz/decomp2gef/blob/main/decomp2gef.py#L247
>
> Is it possible to have a feature/command where the user could add
> symbols directly to GDB without the use of an objfile?
>
> I brought it up with Simon Marchi, and he said the following:
> > But off-hand, I don't see why this wouldn't be possible. Each objfile
> > could have a list of user-defined symbols, that lookup_symbol_in_objfile
> > would search in addition to the other regular methods.
>
> Thank you,
> Matthew Rinaldi
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Adding user-defined symbols to GDB
  2022-01-26 23:55 Adding user-defined symbols to GDB Matthew Rinaldi
  2022-01-27  1:53 ` Sterling Augustine
@ 2022-01-28 16:25 ` Jan Vrany
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Vrany @ 2022-01-28 16:25 UTC (permalink / raw)
  To: Matthew Rinaldi, gdb

Hi,

On Wed, 2022-01-26 at 18:55 -0500, Matthew Rinaldi via Gdb wrote:
> Hello,
>
> I have a list of symbols that I have parsed out from a section within
> the binary. The data is not in any standard symbol table format. I have
> extracted the symbol's name and address. I want to add these symbols to
> GDB, but it is non-trivial. The solutions that I have seen for adding
> new user-defined symbols do not look ideal for a seemingly simple task.
>
> Example: https://github.com/mahaloz/decomp2gef/blob/main/decomp2gef.py#L247
>
> Is it possible to have a feature/command where the user could add
> symbols directly to GDB without the use of an objfile?
>
> I brought it up with Simon Marchi, and he said the following:
> > But off-hand, I don't see why this wouldn't be possible. Each objfile
> > could have a list of user-defined symbols, that lookup_symbol_in_objfile
> > would search in addition to the other regular methods.
>

I'm working in context of (language) VMs and have similar problem.
I have all my support code written in Python so it'd be nice if I could
do this kind of thing also from Python (as opposed to using "jit-reader"
interface to do this part or generating elf/PE/coff).

Maybe we can provide Python API similar to one of jit-reader to allow
one to build a symtab(s) and add them to (either existing of freshly
created) objfiles? We can provide "gdb.SymtabBuilder" python object to build
a symtab and then "install" it into objfile just like finalize_symtab()
does in jit.c (perhaps we can factor out some common code).

Jan

> Thank you,
> Matthew Rinaldi




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-28 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 23:55 Adding user-defined symbols to GDB Matthew Rinaldi
2022-01-27  1:53 ` Sterling Augustine
2022-01-28 16:25 ` Jan Vrany

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).