TYPE_CHECK (type) gives a number of host bytes. So to get the type
length in bits we should use TYPE_CHECK (type) * HOST_CHAR_BITS. As far
as I know, GDB does not support any non-8bits bytes hosts, but it does
not hurt to make this change. It also underline that a GDB type’s
length is given in host bytes, not target byte.
When dealing with target bytes, we should use
gdbarch_addressable_memory_unit_size to get the size of a memory unit
(in multiple of 8 bits).
I have no idea how libpoke would behave if the target has a non 8bits
byte. Whatever libpoke does, this patch have GDB do the right thing.
This patch mostly contains changes which would have been comments in a
normal review.
b0c1ee0...
by
"Jose E. Marchesi" <email address hidden>
Integrate GNU poke in GDB
This patch integrates GNU poke (http://jemarch.net/poke) in GDB by
mean of libpoke. It allows the GDB user to execute Poke code from
within the debugger with access to the target memory, types and
values.
How this stuff works:
- GDB links with libpoke.so and uses the interface in libpoke.h.
This is also how the GNU poke application (the command-line
editor) is implemented.
All three commands make sure to start the poke incremental
compiler if it isn't running already.
- Access to the target's memory is provided by GDB by installing
a Foreign IO device in the incremental compiler. This is
`iod_if' in poke.c.
- Access to the terminal is provided by GDB by providing a
pk_term_if implementation to the incremental compiler. This is
`poke_term_if' in poke.c.
- Access to GDB values is provided by GDB by installing an alien
token handler in the incremental compiler. This is
`poke_alien_token_handler' in poke.c.
gdb/ChangeLog:
2021-05-10 Jose E. Marchesi <email address hidden>
* configure.ac: Support --enable-poke.
* configure: Regenerate.
* Makefile.in (POKE_OBS): Define based on @POKE_OBS@.
(DEPFILES): Add POKE_OBS.
* poke.c: New file.
gdb/doc/ChangeLog:
2021-05-10 Jose E. Marchesi <email address hidden>
* Makefile.in (GDB_DOC_FILES): Add poke.texi.
* poke.texi: New file.
* gdb.texinfo (Data): Add meny entry for Poke and @include poke.texi.
gdb/ctf: pass partial symtab's filename to buildsym_compunit
I noticed that the CTF symbol reader passes the objfile's name to all
buildsym_compunit instances it creates. The result is that all
compunit_symtabs created have the same name, that of the objfile:
Note that the first compunit_symtab still has libbabeltrace2.so.0.0.0 as
its name. This is because the CTF symbol reader really creates a
partial symtab named like this. It appears to be because the debug info
contains information that has been factored out of all CUs and is at the
"top-level" of the objfile, outside any real CU. So it creates a
partial symtab and an artificial CU that's named after the objfile.
gdb: print compunit_symtab name in "maint info symtabs"
I think it would make sense to print a compunit_symtab's name in "maint
info symtabs". If you are looking for a given CU in the list, that's
probably the field you will be looking at. As the doc of
compunit_symtab::name says, it is not meant to be a reliable file name,
it is for debugging purposes (and "maint info symtabs" exists for
debugging purposes).
gdb/ctf: don't create a buildsym_compunit when building partial symbols
I am trying to do some changes to buildsym_compunit, so I am auditing
the current uses. Something seems odd with this use of
buildsym_compunit (that this patch removes).
A buildsym_compunit is normally used when building a compunit_symtab.
That is, when expanding a partial symtab into a full compunit symtab.
In ctfread.c, a buildsym_compunit is created in ctf_start_archive, which
is only used when creating partial symtabs. At this moment, I don't
see how that's useful. ctf_start_archive creates a new
buildsym_compunit and starts a subfile. But that buildsym_compunit is
never used again. It's just overriden in ctf_start_symtab, which means
we leak the old buildsym_compunit, I suppose.
Remove ctf_start_archive completely. Add an assert in
ctf_start_symtab to verify that we are not overwriting an existing
buildsym_compunit (meaning we'd leak the existing one). This assert
triggers without the other part of the fix. When doing:
I noticed that GDB will display URLs in a few spots. This changes
them to be styled. Originally I thought I'd introduce a new "url"
style, but there aren't many places to use this, so I just reused
filename styling instead. This patch also changes the debuginfod URL
list to be printed one URL per line. I think this is probably a bit
easier to read.