I'm just trying to learn to use gdb at this point. The program I'm using it on works perfectly fine; I'm not trying to debug it or anything; I'm just testing the functionality of gdb. Here's the source code:
#include <stdio.h> #include <ctype.h> #include <string.h> int main( int argc, char **argv ){ int wordcount = 0; int len = strlen( argv[1] ); for( int i = 0; i < len; i++ ){ if( isspace( argv[1][i] ) && !isspace( argv[1][i-1] ) ) wordcount++; } if( !isspace( argv[1][len-1] ) ) wordcount++; if( wordcount == 0 && len > 0 ) // if all characters were non-whitespace, wordcount = 1; // then there was exactly one word printf( "%d\n", wordcount ); return 0; } I started gdb and ran the program, setting breakpoints at lines 7 and 9. I used the backtrace and step commands, and I don't understand their output at all. When I typed "backtrace full" gdb gave me this:
#0 _start () at ../sysdeps/i386/elf/start.S:65 No locals. What exactly does this mean? What is _start? What is ../sysdeps/i386/elf/start.S:65? And how can there be no locals, when clearly I have declared wordcount and len? I have tried Google, but every tutorial I can find on gdb shows it producing completely different (more detailed) output from what I got. When I Google the string I got, I get a bunch of results on the ARM architecture.
-gflag to each compile command.-ggdb.iis0, what couldi-1be? That index is out of bounds.