This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Infinite backtrace and (corrupt stack?) messages on ARM with gdb-6.5


Hi all,

Environment:
cross gdb-6.5 running on cygwin, gcc-3.4.4-glibc-2.3.5 for ARM,
Eclipse and CDT as a front end.

When debugging a multithreaded application on ARM I get inifinite
backtrace showing pthread_start_thread(). When using Eclipse as a
GDB front-end I had to use "set backtrace limit" to limit the
backtrace to a sensible value, otherwise the Eclipse debugger hangs
forever when the program hits a breakpoint.

While the thread with the breakpoint has inifinite backtrace the
other thread shows "Previous frame identical to this frame (corrupt
stack?)" (Eclipse doesn't show a call stack at all; command line
GDB shows the frames up to this message).

Reading the newsgroups I found that many people had similar problems
(is there a solution available?).

I found the hint to use DWARF CFI to set the function called by
pthread_create() or maybe pthread_create() itself to unwindable.
Can anybody tell me how to do it for this sample program?

Regards Olav

>>>>

compiler-run:
arm-softfloat-linux-gnu-g++ -O0 -g3 -Wall -c -fmessage-length=0
-MMD -MP -MF"threads.d" -MT"threads.d" -o"threads.o" "../threads.cpp"

linker-run:
arm-softfloat-linux-gnu-g++  -o"threads"  ./threads.o   -lpthread

>>>>

#include <pthread.h>
#include <stdio.h>
#include <unistd.h>


void* thread_function1(void*) {
    int a = 0;

    while (1) {
        for (int i=0 ; i<100; i++) {
            a += i;
        }
        printf("Thread 1: %d\n", a);
        sleep(3);
    }
    return NULL;
}

void* thread_function2(void*) {
  int a = 0;

  while (1) {
      for (int i=0 ; i<100; i++) {
        a += i;
      }
      printf("Thread 2: %d\n", a);
      sleep(2);
  }
  return NULL;
}

int main(int argc, char **argv) {
  pthread_t thread1, thread2;

  // create all the threads
  pthread_create( &thread1, NULL, thread_function1, NULL );
  pthread_create( &thread2, NULL, thread_function2, NULL );
  sleep(1);

  // wait for threads to end (.. I know this can't happen)
  pthread_join( thread1, NULL );
  pthread_join( thread2, NULL );

  return 0;
}





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]