1

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.

nav_jan
  • 2,473
  • 4
  • 24
  • 42

3 Answers3

1
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

Community
  • 1
  • 1
Jeremy D
  • 4,787
  • 1
  • 31
  • 38
1

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.

jeb
  • 78,592
  • 17
  • 171
  • 225
  • actually initially I thought of adding `printf` at the start of each function but as I set there are hundred of functions in that particular file so it was really a cumbersome job :) +1 for your suggestion though – nav_jan Jun 29 '12 at 09:42
0

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?

fnokke
  • 1,121
  • 8
  • 18