public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Question with hook-stop command
@ 2011-07-21  2:05 Amker.Cheng
  0 siblings, 0 replies; only message in thread
From: Amker.Cheng @ 2011-07-21  2:05 UTC (permalink / raw)
  To: gdb

Hi,
In my program, there are several hard coded breakpoint
instructions(bkpt for arm cortex-m processors).
I want to define hook-stop command to skip those bkpt insn and keep
target program running, here is what I've done:

define skip_bkpt
  printf "process bkpt"
  set $pc += 2
  c
end

define hook-stop
  set $insn = *(unsigned short *)$pc
  if ($insn == 0xbeab) #here 0xbeab is the bkpt insn's encoding
    skip_bkpt
  end
end

I assume that with these two commands, every time the program
encounters the bkpt(0xbeab) instruction,
gdb will just skip it and continue the target program.

But when running, seems hook-stop(and the continue command) get
executed only once, the GDB output like following:

(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
process bkpt

Program received signal SIGTRAP, Trace/breakpoint trap.
0x000022ac in initialise_monitor_handles ()
0x000022ac in initialise_monitor_handles ()

The instruction "0x000022ac" is another bkpt(0xbeab) instruction, Why
the hook-stop not get executed here?

So any suggestions? Thanks very much.

BTW the gdb version info is:

GNU gdb 7.3.50.20110609-cvs
......
This GDB was configured as "--host=i586-mingw32 --target=arm-none-eabi".


-- 
Best Regards.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-21  2:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-21  2:05 Question with hook-stop command Amker.Cheng

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).