Skip to contentSkip to conversation

Xenomai 2.4.9: Debugger freezes when stepping with gdb/gdbserver

Xenomai-help Andreas Glatz 2 participants 3 messages Aug 25, 2009 – Sep 3, 2009

lore
Share & tools
lore
#0 lore raw

Hi,

As I already told u, we upgraded to the newest Xenomai version (2.4.9) and now we are experiencing problems when trying to step through the application with gdb/gdbserver which we haven't seen with previous version of Xenomai/Linux kernel. Basically, if I run the whole thing as described below on Xenomai 2.4.8 (with the alignment patch) everything works fine...

Configuration:
- MPC8360
- Linux 2.6.30
- Ipipe 2.7-00
- Xenomai 2.4.9
- Alignment patch applied (see previous post)

I included some source code with this Email with which I verified that it's not just on our side :p

1) I cross-compiled the source with:

<snip>
powerpc-linux-gnu-gcc --version
powerpc-linux-gnu-gcc (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)

powerpc-linux-gnu-gcc -Wall -O0 -g -o main -I/opt/ROX-target/powerpc/usr/include/ -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -L/opt/ROX-target/powerpc//usr/lib -lpthread -lrtdk -lnative main.c
</snip>

2) I started gdbserver 6.8 on the target with:

<snip>
/root/gdbserver --multi :2345 &
</snip>

3) I started powerpc-linux-gnu-gdb (6.8) on my host:

<snip>
powerpc-linux-gnu-gdb -x gdbinit_ROX_MPC83XX_hu
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=powerpc-linux-gnu".
Breakpoint 1 at 0x10001c98: file main.c, line 37.
(gdb) b main.c:24
Breakpoint 2 at 0x10001b68: file main.c, line 24.
(gdb) run
Starting
program: /home/andreasglatz/ROX-RCLib/ROX-RCLibrary/ROX-MPC83XX/out/main [New Thread 3316]
Error while mapping shared library sections:
/usr/lib/librtdk.so.0: No such file or directory.
Error while mapping shared library sections:
/usr/lib/libnative.so.1: No such file or directory.
warning: .dynamic section for "/usr/powerpc-linux-gnu/lib/libgcc_s.so.1" is not at the expected address (wrong library or version mismatch?) [Switching to Thread 3316]

Breakpoint 1, main () at main.c:37
37 mlockall(MCL_CURRENT|MCL_FUTURE);
(gdb) c
Continuing.
[New Thread 3319]
[Switching to Thread 3319]

Breakpoint 2, first_task_body (cookie=0x10012390) at main.c:25
25 second_task_body, (void*)n2);
(gdb) s
rt_task_spawn (task=0x100123a0, name=0x10012398 "second", stksize=0, prio=2, mode=0,

    entry=0x10001b0c <second_task_body>, cookie=0x10012398)
    at /opt/ROX-target/powerpc/usr/include/native/task.h:322

322 int err = rt_task_create(task,name,stksize,prio,mode);
(gdb)

^C^CInterrupted while waiting for the program.
Give up (and stop debugging it)? (y or n) ^C^Cy

y
Ignoring packet error, continuing...
(gdb) Quit
(gdb)
The program is not being run.
(gdb)
</snip>

4) That's how it looks on the remote side, which
is still responsive:

<snip>
Remote debugging from host 10.200.19.189
Process /tmp/main created; pid = 3194
Info: In linux task
Info: In linux task
Info: In linux task
Info: In linux task
Info: In linux task
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 63 ('?')
input_interrupt, count = 1 c = 35 ('#')
input_interrupt, count = 1 c = 51 ('3')
input_interrupt, count = 1 c = 102 ('f')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 63 ('?')

rx5000:~#
</snip>

5) Additionally, dmesg shows that there was no crash. That's the info I got from /proc/xenomai :

<snip>

rx5000:~# cat /proc/xenomai/
affinity    faults      heap        irq         registry/   sched
timebases   timerstat/
apc         hal         interfaces/ latency     rtdm/       stat
timer       version
rx5000:~# cat /proc/xenomai/faults 
TRAP         CPU0
  0:            1    (Data or instruction access)
  1:            0    (Alignment)
  2:            0    (Altivec unavailable)
  3:            1    (Program check exception)
  4:            0    (Machine check exception)
  5:            0    (Unknown)
  6:            0    (Instruction breakpoint)
  7:            0    (Run mode exception)
  8:            0    (Single-step exception)
  9:            0    (Non-recoverable exception)
 10:            0    (Software emulation)
 11:            0    (Debug)
 12:            0    (SPE)
 13:            0    (Altivec assist)
 14:            0    (Cache-locking exception)
 15:            0    (Kernel FP unavailable)
rx5000:~# cat /proc/xenomai/sched 
CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT
  0  3196     3      0          0          master    XT         first
rx5000:~# cat /proc/xenomai/stat  
CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          1248       0     00500080  100.0  ROOT
  0  3196   1          1          0     00301380    0.0  first
  0  0      0          267261     0     00000000    0.0  IRQ512: [timer]
rx5000:~#
</snip>

Well, that's all I got for now... I'll try and recompile the kernel with debugging enabled tomorrow.

Again, everything works fine with 2.6.26, Xeno 2.4.8, ... :S

Andreas

#include <sys/mman.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <stdarg.h>
#include <native/task.h>
#include <rtdk.h>

RT_TASK first_task;
RT_TASK second_task;
const char n1[] = "first";
const char n2[] = "second";

void second_task_body(void* cookie)

{
	while(1) {
		rt_printf("Info: In %s task\n", (char*)cookie);
		rt_task_sleep(10000000);
	}	
}

void first_task_body(void* cookie)

{
	int err = rt_task_spawn(&second_task, n2, 0, 2, 0,
							second_task_body, (void*)n2);
	
	while(!err) {
		rt_printf("Info: In %s task\n", (char*)cookie);
		rt_task_sleep(10000000);
	}
}

int main(void)

{
	int err;

	mlockall(MCL_CURRENT|MCL_FUTURE);
	rt_print_auto_init(1);

	err = rt_task_spawn(&first_task, n1, 0, 3, 0,
						first_task_body, (void*)n1);
	if(!err) {
		while(1) {
			rt_printf("Info: In linux task\n");
			sleep(1);
		}
	}
	return err;
}

##
# Author: [email protected]
#
# This file contains commands required for

# starting a remote debug session, assuming that
# on the target gdbserver was started as follows:
#
# ./gdbserver --multi :2345 &
#

# Connect to the remote target
target extended-remote 10.200.19.228:2345

# Copy 'main' to remote target
remote put out/main /tmp/main

# Load symbol table
file out/main

# Set 'main' as main executable
set remote exec-file /tmp/main

# Set breakpoint at main()
b main

#1 lore raw
Quoted 55 lines · Andreas Glatz

Hi,

As I already told u, we upgraded to the newest Xenomai version (2.4.9) and now we are experiencing problems when trying to step through the application with gdb/gdbserver which we haven't seen with previous version of Xenomai/Linux kernel. Basically, if I run the whole thing as described below on Xenomai 2.4.8 (with the alignment patch) everything works fine...

Configuration:
- MPC8360
- Linux 2.6.30
- Ipipe 2.7-00
- Xenomai 2.4.9
- Alignment patch applied (see previous post)

I included some source code with this Email with which I verified that it's not just on our side :p

1) I cross-compiled the source with:

<snip>
powerpc-linux-gnu-gcc --version
powerpc-linux-gnu-gcc (GCC) 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)

powerpc-linux-gnu-gcc -Wall -O0 -g -o main

(quoted diff) +0 -2
-I/opt/ROX-target/powerpc/usr/include/ -D_GNU_SOURCE -D_REENTRANT
-D__XENO__ -L/opt/ROX-target/powerpc//usr/lib -lpthread -lrtdk -lnative

main.c
</snip>

2) I started gdbserver 6.8 on the target with:

<snip>
/root/gdbserver --multi :2345 &
</snip>

3) I started powerpc-linux-gnu-gdb (6.8) on my host:

<snip>
powerpc-linux-gnu-gdb -x gdbinit_ROX_MPC83XX_hu
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=powerpc-linux-gnu".

Quoted 8 lines

Breakpoint 1 at 0x10001c98: file main.c, line 37.
(gdb) b main.c:24
Breakpoint 2 at 0x10001b68: file main.c, line 24.
(gdb) run
Starting
program: /home/andreasglatz/ROX-RCLib/ROX-RCLibrary/ROX-MPC83XX/out/main [New Thread 3316]
Error while mapping shared library sections:

That sounds bad. Could you try bissecting the I-pipe support, namely 2.6.29.4-powerpc-2.5-01, 2.6.29.4-powerpc-2.6-00 and eventually 2.6.30-powerpc-2.6-03 if no difference arises between the first two? TIA,

Quoted 116 lines

/usr/lib/librtdk.so.0: No such file or directory.
Error while mapping shared library sections:
/usr/lib/libnative.so.1: No such file or directory.
warning: .dynamic section for "/usr/powerpc-linux-gnu/lib/libgcc_s.so.1" is not at the expected address (wrong library or version mismatch?) [Switching to Thread 3316]

Breakpoint 1, main () at main.c:37
37 mlockall(MCL_CURRENT|MCL_FUTURE);
(gdb) c
Continuing.
[New Thread 3319]
[Switching to Thread 3319]

Breakpoint 2, first_task_body (cookie=0x10012390) at main.c:25
25 second_task_body, (void*)n2);
(gdb) s
rt_task_spawn (task=0x100123a0, name=0x10012398 "second", stksize=0, prio=2, mode=0,

    entry=0x10001b0c <second_task_body>, cookie=0x10012398)
    at /opt/ROX-target/powerpc/usr/include/native/task.h:322

322 int err = rt_task_create(task,name,stksize,prio,mode);
(gdb)

^C^CInterrupted while waiting for the program.
Give up (and stop debugging it)? (y or n) ^C^Cy

y
Ignoring packet error, continuing...
(gdb) Quit
(gdb)
The program is not being run.
(gdb)
</snip>

4) That's how it looks on the remote side, which
is still responsive:

<snip>
Remote debugging from host 10.200.19.189
Process /tmp/main created; pid = 3194
Info: In linux task
Info: In linux task
Info: In linux task
Info: In linux task
Info: In linux task
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 63 ('?')
input_interrupt, count = 1 c = 35 ('#')
input_interrupt, count = 1 c = 51 ('3')
input_interrupt, count = 1 c = 102 ('f')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 63 ('?')

rx5000:~#
</snip>

5) Additionally, dmesg shows that there was no crash. That's the info I got from /proc/xenomai :

<snip>

rx5000:~# cat /proc/xenomai/
affinity    faults      heap        irq         registry/   sched
timebases   timerstat/
apc         hal         interfaces/ latency     rtdm/       stat
timer       version
rx5000:~# cat /proc/xenomai/faults 
TRAP         CPU0
  0:            1    (Data or instruction access)
  1:            0    (Alignment)
  2:            0    (Altivec unavailable)
  3:            1    (Program check exception)
  4:            0    (Machine check exception)
  5:            0    (Unknown)
  6:            0    (Instruction breakpoint)
  7:            0    (Run mode exception)
  8:            0    (Single-step exception)
  9:            0    (Non-recoverable exception)
 10:            0    (Software emulation)
 11:            0    (Debug)
 12:            0    (SPE)
 13:            0    (Altivec assist)
 14:            0    (Cache-locking exception)
 15:            0    (Kernel FP unavailable)
rx5000:~# cat /proc/xenomai/sched 
CPU  PID    PRI      PERIOD     TIMEOUT    TIMEBASE  STAT       NAME
  0  0       -1      0          0          master    R          ROOT
  0  3196     3      0          0          master    XT         first
rx5000:~# cat /proc/xenomai/stat  
CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
  0  0      0          1248       0     00500080  100.0  ROOT
  0  3196   1          1          0     00301380    0.0  first
  0  0      0          267261     0     00000000    0.0  IRQ512: [timer]
rx5000:~#
</snip>

Well, that's all I got for now... I'll try and recompile the kernel with debugging enabled tomorrow.

Again, everything works fine with 2.6.26, Xeno 2.4.8, ... :S

Andreas

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.
#2 lore raw

Hi Philippe,

Quoted 39 lines · Philippe Gerum
Quoted 29 lines · Andreas Glatz

Hi,

As I already told u, we upgraded to the newest Xenomai version (2.4.9) and now we are experiencing problems when trying to step through the application with gdb/gdbserver which we haven't seen with previous version of Xenomai/Linux kernel. Basically, if I run the whole thing as described below on Xenomai 2.4.8 (with the alignment patch) everything works fine...

Configuration:
- MPC8360
- Linux 2.6.30
- Ipipe 2.7-00
- Xenomai 2.4.9
- Alignment patch applied (see previous post)

<snip>
powerpc-linux-gnu-gdb -x gdbinit_ROX_MPC83XX_hu
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i486-linux-gnu --target=powerpc-linux-gnu".

Quoted 8 lines

Breakpoint 1 at 0x10001c98: file main.c, line 37.
(gdb) b main.c:24
Breakpoint 2 at 0x10001b68: file main.c, line 24.
(gdb) run
Starting
program: /home/andreasglatz/ROX-RCLib/ROX-RCLibrary/ROX-MPC83XX/out/main [New Thread 3316]
Error while mapping shared library sections:

Quoted 4 lines

That sounds bad. Could you try bissecting the I-pipe support, namely 2.6.29.4-powerpc-2.5-01, 2.6.29.4-powerpc-2.6-00 and eventually 2.6.30-powerpc-2.6-03 if no difference arises between the first two? TIA,

Finally I found some time to investigate that gdb/gdbserver issue.

The good news is that it doesn't seem to be Xenomai or Ipipe related.

I could reproduce the same problem with a test application which used pthread_create instead of rt_task_create. And further investigation confirmed that gdbserver hangs when trying to single step because it doesn't receive SIGSTOP from the kernel for a child process which was created (gdbserver stops all the threads of an application when single stepping...).

So something must have changed in 2.6.30 as everything runs fine on 2.6.26. I have to admit though that I haven't checked yet if things run fine on a Vanilla kernel.

I think, I'm gonna do that first and try to report it to a gdb NG.

Andreas