Is it possible to run code inside gdb? For example, if I were debugging a .c file, and I wanted to get the strlen() of a character array at a particular point in time, I can't just type in strlen(str) into the buffer - it is an invalid command. What can I do?
Asked
Active
Viewed 4,548 times
6
-
You could try using the print command, I am not sure if it allows you to call arbitrary functions though – BlackBear Feb 16 '14 at 18:38
-
Not only is it possible (in most cases), you can even set and hit breakpoints inside code you explicitly evaluate – Leeor Feb 16 '14 at 20:06
1 Answers
7
From gdb prompt call strlen(the_char_array). Eg.,
(gdb) call strlen(the_char_array)

Nipun Talukdar
- 4,975
- 6
- 30
- 42