public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: William Adair <will.adair01@gmail.com>
To: Andrew Dinn <adinn@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: GDB Incorrectly Reads & Resolves Shared Library Symbols [MinGW-w64]
Date: Tue, 3 Nov 2020 18:20:19 -0500	[thread overview]
Message-ID: <CAHj+M4LeUx2vhtVmv8WWGg8rM=CMAJspK1tRzXCoOEmnA7GDZw@mail.gmail.com> (raw)
In-Reply-To: <c5892a8f-baa9-8edb-8cff-73a5c928062e@redhat.com>

Andrew,

Great feedback. It was a bit tricky to figure out how GDB was executing at
first in main(), but I realized that backtrace_command_1 was the function
I'm looking for in the stack.c file. The stack trace eventually hits
print_frame_info()->print_frame() [which relies on find_frame_sal()] ->
find_frame_funname -> lookup_minimal_symbol_by_pc() ->
lookup_minimal_symbol_by_pc_section()
A few immediate questions come to mind: What is the minimal symbol table?
How can I verify that PC is pointing to the section that the actual symbol
being executed resides in? Lastly, there's a comment: This code assumes
that the minimal symbols are sorted by ascending address values. Does this
imply that if the actual symbol for the PC has a lower address than the PC
that the symbol will be wrong? (I wonder if this is what is happening in my
case...)

Thanks everyone for your time.

On Sun, Nov 1, 2020 at 1:28 PM Andrew Dinn <adinn@redhat.com> wrote:

> On 31/10/2020 23:26, William Adair via Gdb wrote:
> > Can anyone recommend a way to start debugging GDB? I've found that when I
> > compile a 32-bit shared library that GDB is unable to correctly resolve
> the
> > symbols in the image and set breakpoints. Even when I reach a segfault
> and
> > print the backtrace, the symbols are incorrect or flat out missing. I
> > already verified that the image has .debug_* sections as would be
> required
> > for DWARF debugging, so I'm perplexed as to why GDB cannot correctly
> > resolve it and am looking for guidance.
> Well you can, of course, use your currently installed gdb to debug gdb.
>
> Build gdb from a downloaded src tree using
>
>   make install PREFIX=/path/to/install/dir CFLAGS=-g CXXFLAGS=-g.
>
> Then run
>
>   gdb --fullname /path/to/my/newly/built/gdb.
>
> When you type run you will enter a nested gdb that you can debug.
>
> Hint: before typing run type
>
> (gdb) set prompt (outer)
>
> That way you can distinguish prompts in the outer gdb from prompts in
> the inner gdb.
>
> n.b.b. make sure to type a space after (outer) or your typing will start
> right next to the closing bracket
> regards,
>
> After that all you need to do is familiarize wiht the gdb source!
>
>
> Andrew Dinn
> -----------
>
>

  reply	other threads:[~2020-11-03 23:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31 23:26 William Adair
2020-11-01 14:53 ` Hannes Domani
2020-11-01 15:44   ` William Adair
2020-11-01 18:28 ` Andrew Dinn
2020-11-03 23:20   ` William Adair [this message]
2020-11-04  9:39     ` Andrew Dinn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHj+M4LeUx2vhtVmv8WWGg8rM=CMAJspK1tRzXCoOEmnA7GDZw@mail.gmail.com' \
    --to=will.adair01@gmail.com \
    --cc=adinn@redhat.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).