This is the mail archive of the gdb@sources.redhat.com 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]

Threads variable relocation on x86_64


Dear GDB users,

I'm trying to debug a multithreaded programm on x86_64 platform and have
the following problem: wenn trying to switch between threads, it looks
like variable relocation is broken. This only appens when I use some
optimization (O1, O2, O3, Os) to build my test programm and the behavior
isn't always reproductible within GDB. However when debugging the same
program using DDD and switching between threads, DDD hangs every time.

Here some infos:
----------------
opteron:~ # uname -a
Linux opteron 2.6.5-7.97-smp #4 SMP Tue Mar 15 13:41:12 CET 2005 x86_64
x86_64 x86_64 GNU/Linux

opteron:~ # gcc -v
Reading specs from /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada
--disable-checking --libdir=/usr/lib64 --enable-libgcj
--with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib64
--with-system-zlib --enable-shared --enable-__cxa_atexit x86_64-suse-linux
Thread model: posix
gcc version 3.3.3 (SuSE Linux)

opteron:~ # gdb -v
GNU gdb 6.3
...
This GDB was configured as "x86_64-unknown-linux-gnu".

My test program:
----------------
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

void* MyThreadFunc1(void *arg);

int main(){
   pthread_t aThread1;
   pthread_t aThread2;

   pthread_create(&aThread1, NULL, MyThreadFunc1, NULL);
   pthread_create(&aThread2, NULL, MyThreadFunc1, NULL);
   pthread_join(aThread1, NULL);
   pthread_join(aThread2, NULL);

   printf("Exiting main\n");
   return 0;
}

void* MyThreadFunc1(void* arg){
    printf("Hello World from inside thread1!\n");
    while(1);
    return NULL;
}

Compilation command:
--------------------
gcc -g -Os -o hello_world hello_world.c -lpthread

>From GDB:
---------
(gdb) file hello_world
Reading symbols from /root/hello_world...done.
Using host libthread_db library "/lib64/tls/libthread_db.so.1".
(gdb) break 13
Breakpoint 1 at 0x40061f: file hello_world.c, line 13.
(gdb) run
Starting program: /root/hello_world
[Thread debugging using libthread_db enabled]
[New Thread 182898536608 (LWP 5597)]
[New Thread 1075837280 (LWP 5600)]
Hello World from inside thread1!
[New Thread 1077934432 (LWP 5601)]
Hello World from inside thread1!
[Switching to Thread 182898536608 (LWP 5597)]

Breakpoint 1, main () at hello_world.c:13
13         pthread_join(aThread1, NULL);
(gdb) thread 2
[Switching to thread 2 (Thread 1075837280 (LWP 5600))]#0  MyThreadFunc1
(arg=Variable "arg" is not available.
) at hello_world.c:22
22          while(1);


Did someone already face similar problem ? The major issue comes when
using DDD and switching between threads.
Should I use different compiler options ? I tried dwarf2 related flags,
no success.
The same tests are running well on a I32 platform.

Thanks in advance for any hints you could give me.

Best regards,
Marion


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