[PATCH] Don't try to get the TIB address without an inferior

Hannes Domani via gdb-patches gdb-patches@sourceware.org
Fri Mar 6 17:06:00 GMT 2020


 Am Freitag, 6. März 2020, 17:57:30 MEZ hat Simon Marchi <simark@simark.ca> Folgendes geschrieben:

> On 2020-03-06 11:50 a.m., Hannes Domani via gdb-patches wrote:
>
> > The target_get_tib_address call always fails in this case, and there is an
> > error when changing the program with the file command:
> >
> > (gdb) file allocer64.exe
> > Reading symbols from allocer64.exe...
> > You can't do that when your target is `exec'
> >
> > Now it will skip this part, there is no need to rebase the executable without
> > an inferior anyways.
> >
> > gdb/ChangeLog:
> >
> > 2020-03-06  Hannes Domani  <ssbssa@yahoo.de>
> >
> >     * windows-tdep.c (windows_solib_create_inferior_hook):
> >     Check inferior_ptid.
> > ---
> >  gdb/windows-tdep.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
> > index 4e5d8303ca..a3bacc2211 100644
> > --- a/gdb/windows-tdep.c
> > +++ b/gdb/windows-tdep.c
> > @@ -843,7 +843,8 @@ windows_solib_create_inferior_hook (int from_tty)
> >      }
> >    CORE_ADDR tlb;
> >    gdb_byte buf[8];
> > -  if (target_get_tib_address (inferior_ptid, &tlb)
> > +  if (inferior_ptid != null_ptid
> > +      && target_get_tib_address (inferior_ptid, &tlb)
> >        && !target_read_memory (tlb + peb_offset, buf, ptr_bytes))
> >      {
> >        CORE_ADDR peb = extract_unsigned_integer (buf, ptr_bytes, byte_order);
>
>
> It won't really make much of a difference in practice, but I think it would be
> appropriate to use "target_has_memory" for this condition.

I just tried it, but exec_target::has_memory() returns true, although no
program is running:

(gdb) l
1153    bool
1154    exec_target::has_memory ()
1155    {
1156      /* We can provide memory if we have any file/target sections to read
1157         from.  */
1158      return (current_target_sections->sections
1159              != current_target_sections->sections_end);
1160    }
1161
1162    char *
(gdb) p current_program_space->target_sections
$4 = {
  sections = 0x11f70630,
  sections_end = 0x11f70710
}



More information about the Gdb-patches mailing list