public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Tavis Ormandy <taviso@gmail.com>, binutils@sourceware.org
Subject: Re: making stabs visible to gdb
Date: Fri, 5 Aug 2022 10:21:16 +0100	[thread overview]
Message-ID: <52303818-50b6-8525-d0c3-7399e2a1ddba@redhat.com> (raw)
In-Reply-To: <tcd02h$10nf$1@ciao.gmane.io>

Hi Tavis,

> Hello, I have a stripped binary I don't have the source for that I would
> like to debug in gdb. I thought writing some .stabs statements in gas
> would be a nice easy way to record the symbols I know about, like this:
> 
> .equ N_FUN, 0x24
> .equ N_PSYM, 0xa0
> .stabs "example:f-11", N_FUN, 0, 0, 0x8005bba
> .stabs "foo:p*-8", N_PSYM, 0, 0, 8
> .stabs "bar:p-10", N_PSYM, 0, 0, 12

If you assemble this and then run "objdump --debugging" on the resulting
object file (or linked executable), do you get the kind of output you
would expect, describing function "example" ?  If not, then this would
indicate that the stabs directives that you are using are wrong/incomplete.

> If I assemble that (as -gstabs), then add-symbol-file a.out, gdb knows
> about it but won't resolve it in backtraces.

You may find that asking this question on the gdb mailing list also helps.
Ie, it is possible that this is a gdb specific problem...

> What am I doing wrong?

My guess - you need to provide more stabs information.  Are you able to
compile a real C source file and capture the assembler output so that
you can compare the compiler generated stabs directives to your own ?

> Also, is there a better way to accomplish what I'm trying to do?

I don't think so.  There may be a gdb command that associates an address
with a symbol name, but I do not know what it is.  Sorry.

Cheers
   Nick



  reply	other threads:[~2022-08-05  9:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  5:11 Tavis Ormandy
2022-08-05  9:21 ` Nick Clifton [this message]
2022-08-05 14:50   ` Tom Tromey
2022-08-20  1:44     ` Tavis Ormandy
2022-08-20  4:49       ` Tavis Ormandy

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=52303818-50b6-8525-d0c3-7399e2a1ddba@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=taviso@gmail.com \
    /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).