Reputation: 173
#include<stdio.h>
#include<string.h>
int main(void)
{
int f;
char duma[] = "asd char";
f = strlen(duma);
}
So when I run it in debugger and in "watch" table type strlen(data) its getting back a message like word like strlen() does not exist or something like that, the mean is that strlen does not exist, however in locals f = strlen(duma) i mean its making the calculations and show me the number of chars in the array. In Immediate its just the same like in watch strlen does not exist ...
So any suggestions how can i fix it ???
Thanks in advance
Upvotes: 2
Views: 368
Reputation: 10393
If your doubt is that, you cannot step into strlen function, then the reason is strlen is from the standard library and you cannot step into that function as they are normally stripped of debugging symbols.
The user defined functions are compiled with options to retain the debugging symbols and hence you can step-into those function calls and see the execution line by line.
To have symbols from these routines available, you must satisfy two
requirements for GDB:
* You must have debug versions of the libraries available.
* GDB must know where to find them.
And as others have indicated you cannot put a watch on functions, you can watch variables to know when their state changes.
Upvotes: 0
Reputation: 340516
You might be running into the following restriction on the debugger's expression evaluator:
Edit:
I don't think I'm right about the 'intrinsic' part. I was initially testing with VS2010 (which is what I had most readily available) - VS2010 seems to be able to evaluate strlen(duma)
with no problem.
When I moved to a machine that had VS2008 on it (sorry - VS2005 isn't installed right now...), the debugger was unable to evaluate strlen(duma)
regardless of the settings for strlen()
being intrinsic or not.
One more edit:
In VS2008 I couldn't get strlen(duma)
to evaluate in the debugger watch window. However, I was able to get myStrlen(duma)
to evaluate in the watch window, where myStrlen()
was the obvious wrapper that did nothing but return strlen()
. This may be a workaround for you (or you might want to upgrade to VS2010).
Upvotes: 0
Reputation: 3034
strlen is a function and not a variable. The debugger would have to call the function every step to update the right value. This would not be very efficient. In any way, the debugger requires you to enter variable names there, not functions.
Upvotes: 1
Reputation: 23168
A "watch" is for variables not functions, with a few exceptions. In general, you don't want to put functions in a watch window because they can have side effects and change the state of your program every time they display.
For code like that, you should put f
in the watch window, not strlen(duma)
.
Upvotes: 2