Tex4066
Tex4066

Reputation: 357

Determine which breakpoint was hit?

I am trying to write a GDB script that "listens" to a remote target and responds to the start of one of two processes. I have the targeting part done but am stuck on identifying which breakpoint is hit.

The script would look something like this:

break *0x400de0    # Process 1 start addr
break *0x40f650    # Process 2 start addr
c                  # <- GDB waits here for one of the two processes to begin
# hits one of two breakpoints #
if (??? == "0x400de0")
    # do something
else
    # do something else

However, I'm somewhat stuck on getting the address at the breakpoint into a variable. I've looked into using frame which prints the current address, however I have no idea how to get that into a variable to use for comparison.

Upvotes: 0

Views: 207

Answers (1)

Christian B
Christian B

Reputation: 701

I think you're looking for:

if ($pc == 0x400de0)

Upvotes: 1

Related Questions