0

There is a awkward thing, might be not good one to ask, but I want to hear if anyone had similar experience before. I am debugging a huge c source code, and I find where error occurs. it is inside a recursive function.

bool interpret(...)
 {
  switch(..)
  ....
  ....
   case INSTR_GETLINK:
   {
   LmnInstrVar linki, atomi, posi;
   READ_VAL(LmnInstrVar, instr, linki);
   READ_VAL(LmnInstrVar, instr, atomi);
   READ_VAL(LmnInstrVar, instr, posi);

  warry_set(rc, linki,
            LMN_SATOM_GET_LINK(wt(rc, atomi), posi),
            LMN_SATOM_GET_ATTR(wt(rc, atomi), posi),
            TT_ATOM);

  break;
 } 
 ....

}

segmentation fault occurs at "warry_set". bad thing is error dose not occur at first time at that line, it occurs after several times. and this "interpret" function called himself in many other places.

I wanted to find out after how many steps error occurs at "warry_set". I set break point at it by line number. I try to find out,"continue 100", I changed the number many times problem is, sometime "continue 100" reports error, that make me think, error occurs within 100 time at "warry_set". sometime error occurs, between 100-200. I mean by using continue , I could not decide how many steps lead error. I think there is nothing wrong find out exact time of error by this way. but I simply did not occur at certain exact time..

how can I find out exact time of error? experienced guys, please give some suggestion, or correct me if I am doing wrong. also, how to find "warry_set"definition? "step" did not go in that function, and "info function warry_set" did find nothing. :( "whatis warry_set" says , there is no such symbol, maybe I am not loading every symbol.

Thank you in advance

arslan
  • 2,034
  • 7
  • 34
  • 61

1 Answers1

1

While you might be able to figure out a way to set a good conditional breakpoint, it will probably be far easier to add to warry_set() writing a message to a file (or the console) maybe including its interesting parameters values.

wallyk
  • 56,922
  • 16
  • 83
  • 148
  • Thanks, that sounds nice way to do it. – arslan May 17 '14 at 05:50
  • one more question, GDB, how can I find the definition of function? I mean, I wan to know where the "warry_set" defined, but could not find it. I am a newbie in linux, so.. – arslan May 17 '14 at 05:51
  • @alim: The easiest way would be to set a breakpoint on the function and see if it reports a source code filename and line number. `break warry_set`. – wallyk May 17 '14 at 06:01
  • break warry_set says function warry_set is not defined. without no definition, no exact time of error, that become a big problem for me – arslan May 17 '14 at 06:30
  • @alim: Try typing `break warry_set` and then hit the key (maybe a few times) to see if it provides what it needs. – wallyk May 17 '14 at 06:47
  • Function "warry_set" not defined. Make breakpoint pending on future shared library load? it said that, what is shared library, it is c stuff or something also? – arslan May 17 '14 at 06:54
  • @alim: I meant try typing `break warry_set` (without Enter) and then hit the key (maybe a few times)... – wallyk May 19 '14 at 14:22
  • I find it. warry_set is a macro. I have to include macro symbols to debug it. searching for how to do it. thanks for you answers :) – arslan May 20 '14 at 06:13