gdb problem with library calls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gdb problem with library calls



Hi,

 I compiled the simple program below, with arm-none-eabi-gcc -g -o
main main.c. (gcc 3.4.3)

 When I start arm-none-eabi-gdb on the program and type commands:

 % target sim
 % load main
 % break main
 % continue

 It runs fine in the first run. On the subsequent runs, printfs don't
print, and malloc returns 0. I can't actually step into these
functions. Also, sometimes it happens to be that, gdb loops in main,
i.e. after the last C statement, goes back to the first statement,
when I run the code by stepping. This looping then goes forever. On a
native gdb on my system (Gentoo/AMD64) the same program compiles and
debugs fine. What's the problem? Am I missing something here?

 Thanks,
 Bahadir



 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

 int main(int argc, char * argv[])
 {

     unsigned int u = 5;
     void * mem;
     int x = 0;

     printf("U is %d\n", u);
     mem = malloc(300);

     if(mem == 0) {
         x = 10;
     } else
         x = 2;

     printf("U is %d\n", u+x);

     free(mem);
     return 0;
 }