1

I have read the following SO question: Do specific action when certain breakpoint hits in gdb

Here, we use 'command' to decide what to do when the SPECIFIED Breakboint Gets Hit.

My Question is:

Suppose I put Breakpoints on ALL the Functions matching a given pattern:

gdb$rbreak func_

=> 100 Breakpoints (say)

When I execute this Code, I want to do the SAME Action - on hitting Each of these functions.

Hence, I cannot define something like:

command break_point_number 

// since I don't know how many breakpoints will be there

Can somebody please suggest me:

How can I do a specific action-set when ANY Breakpoint gets Hit in GDB?

Thanks.

1 Answer 1

3

With a new enough version of gdb you can use a range:

(gdb) rbreak whatever
... gdb creates breakpoints N, N+1, ..., M
(gdb) commands N-M
> stuff
> end

I forget exactly when this feature went in.

With an older version of gdb, I'm not sure it can easily be done.

It can be done with difficulty: use set logging to write output to a file, then "info break", then "shell" to run scripts to edit the file into gdb commands, then "source". This is very painful.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.