Skip to contentSkip to conversation

gdbserver-xen frustration on x86_64

DISCUSSION Tim Barbour 3 participants 8 messages Jun 22, 2007 – Jul 15, 2007

lore
Share & tools
lore
#0 lore raw

I originally sent the message below to xen-tools, but received no response. I would really appreciate some help.

I am writing a significant piece of Free Software (persistent memory for the Linux kernel) and would like to use gdbserver-xen to debug it (on x86_64). Although I have been very careful, gdbserver-xen does not quite work, and I have no idea why (see forwarded message below). I subsequently tried using xen 3.1.0_rc10, only to get similarly poor behaviour from gdb (maybe I should try 3.1 as well).

I have spent quite some time fiddling with gdbserver-xen, and am rather disappointed to have nothing useful to show for it.

Any suggestions would be appreciated. If anyone is interested, I can provide more detailed information.

Tim

Hi,

This message was originally delivered to the list server on 2007-4-22 (see the log message from my mail server, below), but it does not appear in the list archives for April, so I am resending it. According to the "Welcome" mail I received from the list server, I subscribed to the list on 2007-4-19 (several days prior to sending the message).

Apr 22 16:42:57 [postfix/smtp] 25B151361B: to=<[email protected]>, relay=host01-bcn-london.deploy.xenoserver.org[217.147.82.46]:25, delay=13, delays=0.25/0.01/9.5/3.1, dsn=2.0.0, status=sent (250 OK id=1Hflj2-0001oJ-2Y)

Why should the mailing-list server ignore my post ? I have not received any kind of bounce message.

The text of my original message follows below.

I am trying to use gdbserver-xen to debug a paravirtualised XenoLinux VM on x86_64, but without much success.

I currently have xen 3.0.4 and xen-tools 3.0.4, built using the ebuilds from the Gentoo marineam-xen overlay. I built xen (not xen-tools), with debug=y (although I only want to debug a VM, not xen itself). The dom0 and domU kernels are both linux-2.6.16.40-xen (the latter built with CONFIG_DEBUG_KERNEL etc., and patched slightly to support a kernel module I am writing). I have followed the instructions at
http://lists.xensource.com/archives/html/xen-devel/2005-08/msg00981.html and also tell xengdb "set architecture i386:x86-64:intel".

gdbserver-xen seems to attach to the VM fine, e.g.

trb@elysium ~ $ sudo gdbserver-xen 127.0.0.1:9999 --attach 3 Attached; pid = 3
Listening on port 9999
Remote debugging from host 127.0.0.1

xengdb talks to gdbserver-xen, but it does not quite work. Below is an example xengdb session:

trb@elysium ~ $ xengdb /xen/boot/vmlinux-syms-2.6.16.40-xen-pmm

GNU gdb 6.2.1
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 "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) set architecture i386:x86-64:intel
The target architecture is assumed to be i386:x86-64:intel (gdb) target remote 127.0.0.1:9999
Remote debugging using 127.0.0.1:9999
[New Thread 0]
[Switching to Thread 0]
0xffffffff801073aa in hypercall_page ()
(gdb) bt
#0 0xffffffff801073aa in hypercall_page ()
Cannot access memory at address 0xffffffff80107000
(gdb) where
#0 0xffffffff801073aa in hypercall_page ()
(gdb) list
1 /*
2 * linux/arch/x86_64/kernel/head64.c -- prepare to run common code
3 *
4 * Copyright (C) 2000 Andrea Arcangeli <[email protected]> SuSE
5 *
6 * $Id: head64.c,v 1.22 2001/07/06 14:28:20 ak Exp $
7 *
8 * Jun Nakajima <[email protected]>
9 * Modified for Xen.
10 */
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint -2.
Error accessing memory address 0xffffffff80100000: Input/output error.

(gdb) break copy_process
Cannot access memory at address 0xffffffff80128f40 (gdb) q

The response to c (continue) is odd - I was not attempting to set a breakpoint (subsequently I did attempt to, which also failed).

When xengdb exits, the VM typically continues fine. But in this case it was not entirely unscathed. It was still booting when gdbserver-xen attached, and had just printed the third line beginning with "NET:"; after gdb quit, it printed the rest (and completed booting okay), where the "BUG: soft lockup detected on CPU#0! etc." seems suspiciously related to the debugging.

TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15

BUG: soft lockup detected on CPU#0!
CPU 0:
Modules linked in:
Pid: 0, comm: swapper Not tainted 2.6.16.40-xen-pmm #4
RIP: e030:[<ffffffff801073aa>] <ffffffff801073aa>{hypercall_page+938}
RSP: e02b:ffffffff8052ff28  EFLAGS: 00000246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff801073aa
RDX: 0000000000000001 RSI: 00000000deadbeef RDI: 00000000deadbeef
RBP: ffffffff8052ff50 R08: 0000000000000000 R09: ffff88000142e098
R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffffffff80518000(0000) knlGS:0000000000000000
CS:  e033 DS: 0000 ES: 0000

Call Trace: <ffffffff8010f339>{safe_halt+137} <ffffffff80109877>{xen_idle+119}
       <ffffffff8010a01c>{cpu_idle+92} <ffffffff80108406>{rest_init+38}
       <ffffffff80531865>{start_kernel+517} <ffffffff8053120d>{_sinittext+525}

Sending DHCP requests .., OK
IP-Config: Got DHCP answer from 0.0.0.0, my address is 10.137.1.125 [...]

I would appreciate any suggestions as to how to get it working. The only thing I can think of is to try the latest unstable version of xen, but I hoped 3.0.4 would be new enough to support debugging a paravirtualised VM on x86_64 . Would it help to use unstable, and if so, what version (e.g. Hg tag) ? Since this is my main machine, I am a little nervous about running it on an unstable version of xen... . I could use a different physical machine for testing, but then I might as well just test on a native kernel, via kgdb.

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

I'm afraid the simple answer is that gdbserver-xen spends a lot of the time broken in one way or another because none of the core developers use it or test it. In this case it looks like guest memory can't be accessed for some reason -- do you get similar messages if you try to use tools/xentrace/xenctx binary on this VM? It looks like it might not be too hard to fix this particular issue, since it's rather un-subtle. :-)

-- Keir

Quoted 23 lines · Tim Barbour

I originally sent the message below to xen-tools, but received no response. I would really appreciate some help.

I am writing a significant piece of Free Software (persistent memory for the Linux kernel) and would like to use gdbserver-xen to debug it (on x86_64). Although I have been very careful, gdbserver-xen does not quite work, and I have
no idea why (see forwarded message below). I subsequently tried using xen 3.1.0_rc10, only to get similarly poor behaviour from gdb (maybe I should try 3.1 as well).

I have spent quite some time fiddling with gdbserver-xen, and am rather disappointed to have nothing useful to show for it.

Any suggestions would be appreciated. If anyone is interested, I can provide more detailed information.

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 6 lines · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of the time broken in one way or another because none of the core developers use it or test it. In this case it looks like guest memory can't be accessed for some reason -- do you get similar messages if you try to use tools/xentrace/xenctx binary on this VM? It looks like it might not be too hard to fix this particular issue, since it's rather un-subtle. :-)

Thank you for the suggestion.

I have not used tools/xentrace/xenctx before, but it looks as if it is working okay. I append its output below, followed by the corresponding output from xengdb (using gdbserver-xen). I tried xenctx on its own, then I attached gdbserver-xen to the VM, and used both together, so they should produce the same stack trace.

What further diagnostic information would be useful ?

Tim

trb@elysium ~ OK sudo /usr/lib/xen/bin/xenctx --stack-trace -f -s /xen/boot/System.map-2.6.18-pmm 4
rip: ffffffff802063aa hypercall_page+0x3aa
rsp: ffffffff806c9f10
rax: 00000000 rbx: 00000000 rcx: ffffffff802063aa rdx: deadbeef
rsi: deadbeef rdi: deadbeef rbp: ffffffff806c9f48
r8: 00000011 r9: ffffffff8071fe58 r10: 100031311 r11: 00000246
r12: 00000000 r13: 00000000 r14: 00000000 r15: 00000000
cs: 0000e033 ds: 00000000 fs: 00000000 gs: 00000000

Stack:
 0000000000000000 000121efe71d8a36 ffffffff8020e8c3 000121efe71d8a36
 0000000000000000 ffffffff806c9f48 ffffffff806ff004 ffffffff806c9f58
 ffffffff80209455 ffffffff806c9f78 ffffffff80208cba 0000000000000000
 0000000000000800 ffffffff806c9f88 ffffffff802073b6 ffffffff806c9fa8

Code:
00 00 00 00 00 00 00 00 00 00 00 51 41 53 b8 1d 00 00 00 0f 05 <41> 5b 59 c3 00 00 00 00 00 00 00

Stack Trace:
* [<ffffffff802063aa>] hypercall_page+0x3aa <--

|   0000000000000000   
|   000121efe71d8a36   
|   ffffffff8020e8c3   
|   000121efe71d8a36   
|   0000000000000000   
|   ffffffff806c9f48   
|   ffffffff806ff004   
|-- ffffffff806c9f58
| [<ffffffff80209455>] xen_idle+0x75
|-- ffffffff806c9f78
| [<ffffffff80208cba>] cpu_idle+0x5a
|   0000000000000000   
|   0000000000000800   
|-- ffffffff806c9f88
| [<ffffffff802073b6>] rest_init+0x26
|-- ffffffff806c9fa8
| [<ffffffff806d28d5>] start_kernel+0x275
|   0000000000000000   
|   ffffffff8070c180   
|-- ffffffff806c9fe8
| [<ffffffff806d220d>] __init_begin+0x20d
|   ffff800000000000   
|   ffff804000000000   
|   00000007ffffffff   
|   0000000000000000   
|   0000000000000000   
|   0000000000000000   
|-- 0000000000000000

trb@elysium ~ OK

trb@elysium ~ OK sudo gdbserver-xen 127.0.0.1:9999 --attach 4 Attached; pid = 4
Listening on port 9999
Remote debugging from host 127.0.0.1

trb@elysium /usr/local/src/linux-2.6.18-xen-pmm OK xengdb /xen/boot/vmlinux-syms-2.6.18-pmm
GNU gdb 6.2.1
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 "x86_64-unknown-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) set architecture i386:x86-64:intel
The target architecture is assumed to be i386:x86-64:intel (gdb) target remote 127.0.0.1:9999
Remote debugging using 127.0.0.1:9999
[New Thread 0]
[Switching to Thread 0]
0xffffffff802063aa in hypercall_page ()
(gdb) bt
#0 0xffffffff802063aa in hypercall_page () Cannot access memory at address 0xffffffff806c9f20 (gdb)

#3 lore raw
In reply to Keir Fraser
Quoted 3 lines · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of the time broken in one way or another because none of the core developers use it or test it.

So what debugger do the core developers use or how do they debug things ?

Tim

#4 lore raw

Tim,

Did you get any response?

-Kaushik

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tim Barbour
Sent: Friday, June 29, 2007 11:51 AM
To: Keir Fraser
Cc: [email protected]
Subject: Re: [Xen-devel] gdbserver-xen frustration on x86_64

Quoted 1 line · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of

the time

Quoted 1 line

broken in one way or another because none of the core developers use

it or

Quoted 1 line

test it.

So what debugger do the core developers use or how do they debug things ?

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw

Thank you for asking.

I got no response at all. IIRC, your question is only the second response I have have ever received on this topic, despite several posts (starting with xen-tools).

I am now using kgdb to debug my project.

Please CC: me on any responses, as I unsubscribed from xen-devel yesterday.

Tim

Quoted 31 lines · Kaushik Barde

Tim,

Did you get any response?

-Kaushik

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tim Barbour
Sent: Friday, June 29, 2007 11:51 AM
To: Keir Fraser
Cc: [email protected]
Subject: Re: [Xen-devel] gdbserver-xen frustration on x86_64

Quoted 1 line · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of

the time

Quoted 1 line

broken in one way or another because none of the core developers use

it or

Quoted 1 line

test it.

So what debugger do the core developers use or how do they debug things ?

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

No problem, will do that.

We may end-up doing the same.

But can you debug xen (not dom0 code) with kgdb effectively?

Best.

-Kaushik

-----Original Message-----
From: Tim Barbour [mailto:[email protected]]
Sent: Saturday, July 14, 2007 6:19 PM
To: Kaushik Barde
Cc: [email protected]; Keir Fraser; [email protected]
Subject: RE: [Xen-devel] gdbserver-xen frustration on x86_64

Thank you for asking.

I got no response at all. IIRC, your question is only the second response I have
have ever received on this topic, despite several posts (starting with xen-tools).

I am now using kgdb to debug my project.

Please CC: me on any responses, as I unsubscribed from xen-devel yesterday.

Tim

Quoted 10 lines · Kaushik Barde

Tim,

Did you get any response?

-Kaushik

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tim

Barbour

Quoted 9 lines

Sent: Friday, June 29, 2007 11:51 AM
To: Keir Fraser
Cc: [email protected]
Subject: Re: [Xen-devel] gdbserver-xen frustration on x86_64

Quoted 1 line · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of

the time

Quoted 1 line

broken in one way or another because none of the core developers

use

Quoted 4 lines

it or

Quoted 1 line

test it.

So what debugger do the core developers use or how do they debug

things

Quoted 8 lines

?

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw
In reply to Kaushik Barde

If a bug crashes Xen then the printed backtrace is almost always sufficient. Kdump can also be useful if we want to post-mortem analyse the heap. For more subtle bugs, we almost always look to find a workload that reliably repros the issue, and then we add custom tracing to Xen to narrow down the possibilities. This latter kind of bug is not really amenable to debugging with a traditional debugger.

-- Keir

Quoted 31 lines · Kaushik Barde

Tim,

Did you get any response?

-Kaushik

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Tim Barbour
Sent: Friday, June 29, 2007 11:51 AM
To: Keir Fraser
Cc: [email protected]
Subject: Re: [Xen-devel] gdbserver-xen frustration on x86_64

Quoted 1 line · Keir Fraser

I'm afraid the simple answer is that gdbserver-xen spends a lot of

the time

Quoted 1 line

broken in one way or another because none of the core developers use

it or

Quoted 1 line

test it.

So what debugger do the core developers use or how do they debug things ?

Tim

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel