public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB call and p func() on embedded target
@ 2021-08-14 10:28 Maximilian Schneider
  2021-08-14 13:05 ` Simon Marchi
  0 siblings, 1 reply; 6+ messages in thread
From: Maximilian Schneider @ 2021-08-14 10:28 UTC (permalink / raw)
  To: gdb

Hello,

I am trying to call a function from withing a gdb debugging session on
an embedded target. However gdb never returns and when i stop it
manually the program counter is in a strange place. It appears that gdb
is not able to catch the return, and is continuing  execution from
before the core was halted... 

assume the function I want to call has prototype int32_t Init(void);

If I set the pc manually I can step throught the function until the
return without a problem.

I can even set a breakpoint on Init and then use p Init(). The
breakpoint will fire and I can step throught the code manually.

eg.

target remote localhost:3333
monitor reset halt
monitor reset init
file loader.elf
load loader.elf
set $sp=0x20010000
set $pc=&Init
b Init
p Init()
n
n
n
...

However without the breakpoint gdb never returns.
Is this a known problem? Is there a workaround?

Some background:
The purpose of this entire excercise is to arrive at a tool/set of
scripts that can be used to load and execute arbitrary code from RAM,
to fi. manipulate external memories or run tests.

Regards,
M


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-18 20:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-14 10:28 GDB call and p func() on embedded target 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 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).