This is the mail archive of the gdb-patches@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]

SIGTRAP, SIGILL/SIGSEGV reported in cross debugging


Hi,

While cross-debugging , I found the cross-gdb reported SIGTRAP, SIGILL
or SIGSEGV if I set the breakpoint at the thread function. I did
preliminary investiagtion and provided two compact test cases to
reproduce this bug. I think this bug should be reported here.

I have tested both cases. This bug seems to be x86 specific.

1) The difference between test01.c and test02.c is "func" with or
without "printf".

2) Both test cases work well for native GDB on Intel, AMD, PPC.

3) Both test cases reproduced the bug for cross GDB on Intel and AMD 
with single CPU or SMP.
   test01.c reported SIGTRAP/SIGILL; test02.c reproted SIGRAP/SIGSEGV

4) Both work fine for PowerPC native or cross GDB

5) The bug can be reproduced for Host/Target with Linux kernel 2.4.*
and 2.6.*, whether Bebian or RedHat.

To simplify the description, I provide the test log on the same
machine with GDB/GDBSERVER.


Any idea?



Daniel Suyou He




========= TEST CASE 01 ====================

$ cat test01.c
#include <pthread.h>
#include <stdio.h>

void* func(void *unused)
{
   while (1);
}

/* The main program.  */

int main()
{
  pthread_t thread_id;
  pthread_create (&thread_id, NULL, func, NULL);
  while (1);
  return 0;
}


$ gcc -g test01.c -o test01 -lpthread

>>>> GDB

$ gdb test01
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x80483ea: file test01.c, line 14.
(gdb) b func
Breakpoint 2 at 0x80483d8: file test01.c, line 6.
(gdb) target remote ce2.engr.sjsu.edu:8888
Remote debugging using ce2.engr.sjsu.edu:8888
0x40000c20 in ?? ()
(gdb) c
Continuing.
[New Thread 1075226144]
[Switching to Thread 1075226144]

Breakpoint 1, main () at test01.c:14
14        pthread_create (&thread_id, NULL, func, NULL);
(gdb) n
15        while (1);
(gdb) n
[New Thread 1083616176]

Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1083616176]
0x080483d9 in func (unused=0x0) at test01.c:6
6          while (1);
(gdb) n

Program received signal SIGILL, Illegal instruction.
0x080483d9 in func (unused=0x0) at test01.c:6
6          while (1);
(gdb)


>>>> GDBSERVER

$ gdbserver :8888 test01
Process test01 created; pid = 6314
Listening on port 8888
Remote debugging from host 130.65.178.11

================= TEST CASE 02 =========================

$ cat test02.c
#include <pthread.h>
#include <stdio.h>

void* func(void *unused)
{
   printf("hello");
   while (1);
}

/* The main program.  */

int main()
{
  pthread_t thread_id;
  pthread_create (&thread_id, NULL, func, NULL);
  while (1);
  return 0;
}

$ gcc -g test01.c -o test01 -lpthread


>>>>GDB

$ gdb test02
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x8048428: file test02.c, line 15.
(gdb) b func
Breakpoint 2 at 0x804840a: file test02.c, line 6.
(gdb) target remote ce2.engr.sjsu.edu:8888
Remote debugging using ce2.engr.sjsu.edu:8888
0x40000c20 in ?? ()
(gdb) c
Continuing.
[New Thread 1075226144]
[Switching to Thread 1075226144]

Breakpoint 1, main () at test02.c:15
15        pthread_create (&thread_id, NULL, func, NULL);
(gdb) n
16        while (1);
(gdb) n
[New Thread 1083616176]

Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1083616176]
0x0804840b in func (unused=0x0) at test02.c:6
6          printf("hello");
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x0804840d in func (unused=0x0) at test02.c:6
6          printf("hello");
(gdb)


>>>>GDBSERVER

$ gdbserver :8888 test02
Process test02 created; pid = 6322
Listening on port 8888
Remote debugging from host 130.65.178.11



>>>> Here is the information of the machine on which I produced the bug.
But the bug reported here should have nothing to do with the machine.

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping        : 1
cpu MHz         : 2793.338
cache size      : 1024 KB
physical id     : 0
siblings        : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 3
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni
monitor ds_cpl cid
bogomips        : 5537.79

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      : Intel(R) Pentium(R) 4 CPU 2.80GHz
stepping        : 1
cpu MHz         : 2793.338
cache size      : 1024 KB
physical id     : 0
siblings        : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 3
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni
monitor ds_cpl cid
bogomips        : 5586.94

$ cat /proc/version
Linux version 2.6.8-2-686-smp (horms@tabatha.lab.ultramonkey.org) (gcc
version 3.3.5 (Debian 1:3.3.5-12)) #1 SMP Thu May 19 17:27:55 JST 2005


$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.5/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--enable-__cxa_atexit --with-system-zlib --enable-nls
--without-included-gettext --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc
i486-linux
Thread model: posix
gcc version 3.3.5 (Debian 1:3.3.5-13)


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