public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Maximilian Schneider <max@schneidersoft.net>, gdb@sourceware.org
Subject: Re: GDB call and p func() on embedded target
Date: Wed, 18 Aug 2021 16:49:36 -0400	[thread overview]
Message-ID: <39e739a1-c7b8-18ae-b78f-ee1bfdfa6e20@polymtl.ca> (raw)
In-Reply-To: <d796cd29afa49d704df187624ee7f07cf167544b.camel@schneidersoft.net>

On 2021-08-18 4:31 p.m., Maximilian Schneider wrote:
> Thank you for the great information!
> 
> Turns out it was the start address. Since gdb is setting up a frame to
> call my function and then return to the start address; it is no wonder
> that it does not work. 0 is neither ram not flash so sw breakpoints
> will not work there. HW breakpoints probably won't work there either.
> 
> I added -e 0x2000000 to the compilation to set an explicit entry point
> and huzza it works :)

Ok, good news!

> If gdb is already putting code on the stack to call my function why not
> implement a sw breakpoint there? Why return to start?
> 
> Why does gdb care at all what the start address is? Since this is an
> external loader that lives in ram and has no main() i don't see what
> the point of the entry point is.

GDB just needs a place it can put a breakpoint and redirect execution
to, to get back control when the inferior function call is done.  It
just happens that the entry point usually works fine for that, at least
when you are talking about a program that runs on an OS like Linux.  I
guess it just doesn't work in all cases, such as yours.

As we saw, other architectures do use the stack for this, they have
gdbarch_call_dummy_location return ON_STACK and implement
gdbarch_push_dummy_code.  I suppose you would have to make the ARM
architecture do that to make it work properly in your case.

Simon

      reply	other threads:[~2021-08-18 20:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-14 10:28 Maximilian Schneider
2021-08-14 13:05 ` Simon Marchi
2021-08-14 15:54   ` Maximilian Schneider
2021-08-16  1:14     ` Simon Marchi
2021-08-18 20:31       ` Maximilian Schneider
2021-08-18 20:49         ` Simon Marchi [this message]

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=39e739a1-c7b8-18ae-b78f-ee1bfdfa6e20@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb@sourceware.org \
    --cc=max@schneidersoft.net \
    /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).