Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Luis Machado <luis.machado@linaro.org>,
	Paul Mathieu <paulmathieu@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] gdb: add support for handling core dumps on arm-none-eabi
Date: Tue, 6 Oct 2020 10:29:03 -0400	[thread overview]
Message-ID: <9d2c488d-8763-c17d-e93a-1dbad80bc293@simark.ca> (raw)
In-Reply-To: <cf20bcae-e839-da02-611a-50224066d842@linaro.org>

On 2020-10-06 8:45 a.m., Luis Machado wrote:
> On 10/6/20 1:32 AM, Paul Mathieu via Gdb-patches wrote:
>> Seems to me like current_inferior()->gdbarch is returning the
>> arm-linux gdbarch. Maybe this is because the main .elf executable
>> itself is recognized as arm-linux? I have virtually no control over
>> the executable image, so I would not be able to insert the same kind
>> of note section as I would for a core file to differentiate it from
>> arm-linux executables.
>
> I think there may be enough hints here and there to be able to tell
> those apart via an heuristic. Isn't there a particular note section or
> flag that you can fetch and tell it is not a Linux executable but a
> bare-metal one?

Just so we are on the same page as to why this is happening, can you try
to step into function "gdbarch_info_fill" while you're executable is
loaded?

What I think is happening is that gdbarch_lookup_osabi returns
GDB_OSABI_UNKNOWN, because no sniffer identified it.

So the default osabi of your build gets used instead:

    /* From the configured default.  */
    #ifdef GDB_OSABI_DEFAULT
      if (info->osabi == GDB_OSABI_UNKNOWN)
        info->osabi = GDB_OSABI_DEFAULT;
    #endif

So indeed, if there was a sniffer identifying the binary as a "none"
osabi, it would probably work.  The problem is, how do you write such a
sniffer?  It's easy to check for a Linux binary, you check for the os
abi ELF note.  But how do you identify a "none" binary?  You would have
to check that's it's not a Linux binary, not FreeBSD binary, not a
Windows binary, etc.

I don't really like the idea of having a "default" osabi that we fall
back on, because it can just silently get it wrong, like in this case.
I think it would make more sense for the fall back to be "none".
Because it's hard to detect a "none" binary, as explained above.

In the mean time, for your testing, you can force the osabi to none by
using "set osabi none" prior to loading anything.

Simon

  reply	other threads:[~2020-10-06 14:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 17:32 [PATCH] " Paul Mathieu via Gdb-patches
2020-10-02 17:51 ` Luis Machado via Gdb-patches
2020-10-02 21:54   ` Paul Mathieu via Gdb-patches
2020-10-02 21:59     ` Simon Marchi
2020-10-03  3:57     ` Simon Marchi
2020-10-03 18:14       ` [PATCH v2] " Paul Mathieu via Gdb-patches
2020-10-04 17:30         ` Paul Mathieu via Gdb-patches
2020-10-04 23:41         ` Simon Marchi
2020-10-06  4:32           ` Paul Mathieu via Gdb-patches
2020-10-06 12:45             ` Luis Machado via Gdb-patches
2020-10-06 14:29               ` Simon Marchi [this message]
2020-10-06 16:59                 ` Paul Mathieu via Gdb-patches
2020-10-06 17:37                   ` Simon Marchi
2020-10-05 12:58         ` Luis Machado via Gdb-patches
2020-10-05 13:24           ` Alan Hayward via Gdb-patches
2020-10-02 23:55 ` [PATCH] " Simon Marchi
2020-10-03  0:35   ` Paul Mathieu via Gdb-patches
2020-10-03  2:24     ` Simon Marchi

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=9d2c488d-8763-c17d-e93a-1dbad80bc293@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@linaro.org \
    --cc=paulmathieu@google.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