nav_jan
nav_jan

Reputation: 2553

apply breakpoint at the start of each function

Is there any command in gdb by which one can apply breakpoint at the start of each function in a .C file.

I need this as i have a very big C file which i need to debug and it contains more than 100 functions and i need to find all the functions called during run time.

Upvotes: 1

Views: 107

Answers (3)

jeb
jeb

Reputation: 82400

I'm not sure if it's a good idea to use the debugger that way for solving your search.

I would add at the beginning of each function a single assignment and one struct at the file start.

struct {
   int foo;
   int bar;
   ...
   int lastFunctionName;
} sFunc;

void foo()
{
  sFunc.foo=1;
  ...
}

void bar()
{
  sFunc.bar=1;
  ...
}

Then you can run your program and it collects the informations for you.

Upvotes: 1

fnokke
fnokke

Reputation: 1161

The manual states that there is an option rbreak regexp which lets you set a regexp to break on all functions matching that regexp. Given that you are in one file (one module?) maybe all the functions are prefixed in the same way?

Upvotes: 0

Jeremy D
Jeremy D

Reputation: 4855

rbreak file:regex

If you look at this page : http://sourceware.org/gdb/download/onlinedocs/gdb/Set-Breaks.html#Set-Breaks

Look also at the past thread : gdb, set breakpoint on all functions in a file

Upvotes: 1

Related Questions