diff options
Diffstat (limited to 'hurd/debugging')
-rw-r--r-- | hurd/debugging/gdb.mdwn | 15 | ||||
-rw-r--r-- | hurd/debugging/gdb/noninvasive_debugging.mdwn | 16 | ||||
-rw-r--r-- | hurd/debugging/glibc.mdwn | 92 | ||||
-rw-r--r-- | hurd/debugging/rpctrace.mdwn | 53 | ||||
-rw-r--r-- | hurd/debugging/subhurd.mdwn | 90 | ||||
-rw-r--r-- | hurd/debugging/translator.mdwn | 15 | ||||
-rw-r--r-- | hurd/debugging/translator/capturing_stdout_and_stderr.mdwn | 37 | ||||
-rw-r--r-- | hurd/debugging/translator/gdb.mdwn | 53 |
8 files changed, 371 insertions, 0 deletions
diff --git a/hurd/debugging/gdb.mdwn b/hurd/debugging/gdb.mdwn new file mode 100644 index 00000000..1fede74f --- /dev/null +++ b/hurd/debugging/gdb.mdwn @@ -0,0 +1,15 @@ +[[!meta copyright="Copyright © 2007, 2008 Free Software Foundation, Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +The [[GNU_debugger_*GDB*|/gdb]] works on GNU/Hurd +systems as it does on other system, but has some additional [hurd-specific +features](http://sourceware.org/gdb/current/onlinedocs/gdb_19.html#Hurd%20Native) +to offer, such as [[noninvasive_debugging]] (for avoiding [[deadlock]]s), for +example. diff --git a/hurd/debugging/gdb/noninvasive_debugging.mdwn b/hurd/debugging/gdb/noninvasive_debugging.mdwn new file mode 100644 index 00000000..fa7a3c5b --- /dev/null +++ b/hurd/debugging/gdb/noninvasive_debugging.mdwn @@ -0,0 +1,16 @@ +[[!meta copyright="Copyright © 2007, 2008 Free Software Foundation, Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +Sometimes using [[GDB]] on a [[system_server|translator]] can result in a [[deadlock]]. You +can however still use GDB by using the [`set +noninvasive`](http://sourceware.org/gdb/current/onlinedocs/gdb_19.html#Hurd%20Native) +option. This indicates to GDB to not stop the program but allows you to +nevertheless examine its state. Thus, you can get [[/gdb/backtrace]]s and values of +variables (and watch them change underneath you). diff --git a/hurd/debugging/glibc.mdwn b/hurd/debugging/glibc.mdwn new file mode 100644 index 00000000..905dd0da --- /dev/null +++ b/hurd/debugging/glibc.mdwn @@ -0,0 +1,92 @@ +[[!meta copyright="Copyright © 2007, 2008 Free Software Foundation, Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +Here are some hints about how to approach testing after nontrivial changes to +glibc have been done. + +--- + +First step is having the build of glibc succeed. This is actually more +difficult than one might expect as it involves (towards the end of the build +process -- unless you are [[building/cross-compiling]], of course -- that the +newly created libraries and loader actually work: they'll be used to run the +`rpcgen` program. If that step doesn't succeed, it'll look similar to this: + + [...] + CPP='gcc -E -x c-header' [...]/build/elf/ld.so.1 --library-path [...] [...]/build/sunrpc/rpcgen [...] + Segmentation fault + +--- + +Unless [[building/cross-compiling]], the next thing you'll probably want to do +is running the test suite, or parts of it. + +Here is a list of known failures: + +[TODO]. + +--- + +If you've been doing simple changes to glibc functions that end up in +`libc.so`, you may test them like this (like for a `strerror_l` implementation +in this case): + + $ LD_PRELOAD=./libc.so ./ld.so ./a.out 10 1073741928 de_DE.utf8 + 1073741928 (0x40000068): Computer bought the farm + 1073741928 (0x40000068): Der Computer hat den Bauernhof erworben + +You usually will only have luck using the new `libc.so` (from +`[glibc-build]/libc.so`) in combination together with the new `ld.so` (from +`[glibc-build]/elf/ld.so`): + + $ LD_PRELOAD=./libc.so ./a.out 10 1073741928 de_DE.utf8 + Killed + $ LD_PRELOAD=./libc.so /lib/ld.so ./a.out 10 1073741928 de_DE.utf8 + Killed + +Make sure static linking is working OK at all. Running the +`[glibc-build]/elf/sln` program (a stripped-down `ln` that is statically +linked) ought to test that. Also, static linking under various conditions will +already have been tested when running the test suite, especially in `elf/` and +`dlfcn/`. + +Make sure static linking with cthreads is working. If you can get an +`ext2fs.static` compiled and linked against the new glibc, that is good. + +[TODO]. + +Then debug its startup as a normal program on your working hurd. + + $ [...]/ext2fs.static --help + [...] + +Then try its full server startup. + + $ settrans -ca node [...]/ext2fs.static BACKING_STORE + $ ls -l node/ + [...] + +Make sure dynamic linking for servers is working. If you haven't broken the +ABI, you can just use an existing `/hurd/foobar` binary, started the way +glibc's `testrun.sh` does it. + +[TODO]: Is this the correct way to do that? + + $ settrans -ca node [glibc]/build/testrun.sh /hurd/ext2fs BACKING_STORE + $ cd node/ + [...] + +--- + +Test it in a [[subhurd]]. + +--- + +Test it on a real system. diff --git a/hurd/debugging/rpctrace.mdwn b/hurd/debugging/rpctrace.mdwn new file mode 100644 index 00000000..de46c08d --- /dev/null +++ b/hurd/debugging/rpctrace.mdwn @@ -0,0 +1,53 @@ +[[!meta copyright="Copyright © 2007, 2008, 2009, 2010 Free Software Foundation, +Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +*rpctrace* is -- roughly -- an equivavlent to Linux's *strace* or Solaris' or +BSD's *truss*. It is used to trace [[remote_procedure_call|rpc]]s a process is +doing. + +See `rpctrace --help` about how to use it. + + +# Issues and Patches + +[[!tag open_issue_hurd]] + +* <http://savannah.gnu.org/patch/?2104> -- don't assert that local port names + are valid +* <http://savannah.gnu.org/bugs/?3939> -- `rpctrace`d program hangs when signal + that terminates or suspends it is sent + * <http://savannah.gnu.org/patch/?1633> -- terminated with `C-c` `rpctrace`d + programs hang +* <http://savannah.gnu.org/patch/?5580> -- more readable output + +* IRC, unknown channel, unknown date + + <youpi> how to rpctrace a translator ? + <youpi> ah, just settrans /usr/bin/rpctrace... + <youpi> hum, it hung, and killing it got a Mach panic (thread in unexpected + state) ... + +* IRC, unknown channel, unknown date + + <antrik> hm... for a funny effect, try running rpctrace on + /servers/socket/1, and then use dpkg... ;-) + +* IRC, unknown channel, unknown date. + + <youpi> the problem of rpctrace is that it's a man in the middle :) + <youpi> so in principle, by design authentication stuff shouldn't work + <antrik> I don't think the Hurd auth mechanism in any way prevents or tries to prevent man-in-the-middle... + <youpi> maybe, but just try, you'll see all kinds of issue as soon as you have authentication stuff + <youpi> and the basic reason is that being a man in the middle needs special care + <youpi> which rpctrace doesn't completely do + <antrik> it's a while since I have dived into rpctrace; but AIUI, it should work just fine if the proxying is done properly + <antrik> note that there is a number of known bugs in rpctrace, for which zhengda has sent patches... though I haven't reviewed all of them I think + <antrik> there are some nasty Mach operations that are really hard to proxy -- but I don't think the auth mechanism needs any of these... diff --git a/hurd/debugging/subhurd.mdwn b/hurd/debugging/subhurd.mdwn new file mode 100644 index 00000000..7b5b07b1 --- /dev/null +++ b/hurd/debugging/subhurd.mdwn @@ -0,0 +1,90 @@ +# General Information + +* [[/hurd/subhurd]] + +--- + +# Debugging the Hurd Startup Process + +_one.full_ is the subhurd's root file system image and has been installed as +follows: [TODO] + +_Wx_ translates to terminal window _x_. + +W1 + + $ fsysopts one.full/ --readonly + $ sudo boot -I -d -s -D one.full/ one.full/boot/script.boot one.full.ext2 + Pausing. . . + +(In theory it shouldn't be neccessary to run the subhurd as user _root_, but in +practice [that doesn't work at the +moment](http://savannah.gnu.org/bugs/?17341).) + +W2 + + $ ps -Af + [...] + root 851 385 p4 0:00.01 boot -I -d -s -D one.full/ one.full/boot/script.boot one.full.ext2 + - 853 1 ? 0:00.00 ? + - 854 1 ? 0:00.00 ? + [...] + $ sudo gdb /var/tmp/one.full/hurd/ext2fs.static + [...] + (gdb) attach 853 + Attaching to program `/var/tmp/one.full/hurd/ext2fs.static', pid 853 + warning: Can't modify tracing state for pid 853: No signal thread + Can't fetch registers from thread 1: No such thread + +(The _boot_ program [could be modified to print out the +pids](http://savannah.gnu.org/bugs/?19254), so that one wouldn't have to fumble +with _ps_.) + +W3 + + $ sudo gdb /var/tmp/one.full/lib/ld.so.1 + [...] + (gdb) set solib-absolute-prefix /var/tmp/one.full + (gdb) attach 854 + Attaching to program `/var/tmp/one.full/lib/ld.so.1', pid 854 + warning: Can't modify tracing state for pid 854: No signal thread + Can't fetch registers from thread 1: No such thread + +W1 + + [<Enter>.] + /hurd/ext2fs.static --bootflags=-dsf --host-priv-port=38 --device-master-port=43 --exec-server-task=47 -Tdevice pseudo-root + /lib/ld.so.1 /hurd/exec + +Now that this step has been accomplished, you can set break points in GDB, etc. + +W2 + + (gdb) continue + Continuing. + warning: Can't wait for pid 853: No child processes + +W1 + + Hurd server bootstrap: ext2fs.static[pseudo-root] exec + +W3 + + (gdb) continue + Continuing. + warning: Can't wait for pid 854: No child processes + + Program received signal EXC_BAD_ACCESS, Could not access memory. + __mach_port_mod_refs (task=1, name=139802, right=1, delta=-1) + at /var/tmp/glibc-2_5-branch/build_--without-tls_--without-__thread/mach/RPC_mach_port_mod_refs.c:132 + 132 InP->Head.msgh_reply_port = __mig_get_reply_port(); + (gdb) x/i $pc + 0x168f2 <__mach_port_mod_refs+82>: call 0x151b0 <__mig_get_reply_port> + +--- + +Sources: + +* [[subhurd/running_a_subhurd]] +* <http://lists.gnu.org/archive/html/bug-hurd/2007-02/msg00030.html> +* [[Thomas_Schwinge|tschwinge]]'s mind diff --git a/hurd/debugging/translator.mdwn b/hurd/debugging/translator.mdwn new file mode 100644 index 00000000..d439e17b --- /dev/null +++ b/hurd/debugging/translator.mdwn @@ -0,0 +1,15 @@ +[[!meta copyright="Copyright © 2008 Free Software Foundation, Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +[[!inline +pages="hurd/debugging/translator/* and !*/discussion" +show=0 +feeds=no +actions=yes]] diff --git a/hurd/debugging/translator/capturing_stdout_and_stderr.mdwn b/hurd/debugging/translator/capturing_stdout_and_stderr.mdwn new file mode 100644 index 00000000..b7cfc3c9 --- /dev/null +++ b/hurd/debugging/translator/capturing_stdout_and_stderr.mdwn @@ -0,0 +1,37 @@ +[[!meta copyright="Copyright © 2008, 2009, 2010 Free Software Foundation, +Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +Sometimes it may already be helpful to capture a translator's `stdout` and +`stderr`, for example in this situation where [[translator/pfinet]] was +silently dying all the time, without any console output: + + $ sudo settrans -fgap ↩ + /servers/socket/2 ↩ + /bin/sh -c '/hurd/pfinet -i eth0 -a [...] > /tmp/stdout 2> /tmp/stderr' + $ [...] + $ cat /tmp/stdout + NET4: Linux TCP/IP 1.0 for NET4.0 + IP Protocols: ICMP, UDP, TCP + TCP: Hash tables configured (ehash 65536 bhash 65536) + $ cat /tmp/stderr + pfinet: ../../hurd.work/pfinet/ethernet.c:196: ethernet_xmit: Unexpected error: (os/device) invalid IO size. + +(Trying to run [[GDB]] in this case was of no help -- due to a bug in GDB +(supposedly) it wouldn't catch the fault.) + +Be made aware that both `stdout` and `stderr` will be block bufferend and no +longer line buffered when doing such a redirection, so you'll have to arrange +for appropriate `fflush`es on these, or force them to be line buffered again +using the appropriate glibc magic (`setvbuf`). Otherwise you'll see text in +the output files only if either glibc herself decides to flush (after some KiB +of text) the after translator exits. + +There is also a [[related open issue|open_issues/translator_stdout_stderr]]. diff --git a/hurd/debugging/translator/gdb.mdwn b/hurd/debugging/translator/gdb.mdwn new file mode 100644 index 00000000..82a50736 --- /dev/null +++ b/hurd/debugging/translator/gdb.mdwn @@ -0,0 +1,53 @@ +[[!meta copyright="Copyright © 2007, 2008 Free Software Foundation, Inc."]] + +[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable +id="license" text="Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no Invariant +Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license +is included in the section entitled +[[GNU Free Documentation License|/fdl]]."]]"""]] + +Say you want to try running file system server ([[`ext2fs`|translator/ext2fs]], +[[`jfs`|translator/jfs]], ...) against a modified version of +[[`libpager`|libpager]] and debug the latter one using [[debugging/GDB]]. + +Set the [[hurd/translator]] like this: + + $ settrans -fgap ↩ + jfs.img.i ↩ + /usr/bin/env ↩ + LD_LIBRARY_PATH=~tschwinge/tmp/hurd/hurd.ogi/build/libpager ↩ + "$PWD"/jfs.obj/jfs ↩ + "$PWD"/jfs.img + +Then, when starting GDB, start it like this (or use an equivalent method, of +course): + + $ LD_LIBRARY_PATH=~tschwinge/tmp/hurd/hurd.ogi/build/libpager ↩ + gdb ↩ + ~tschwinge/tmp/jfs/jfs.obj/jfs 15436 + GNU gdb 6.5-debian + [...] + Reading symbols from /lib/libdiskfs.so.0.3...Reading symbols from /lib/debug/lib/libdiskfs.so.0.3...done. + done. + Loaded symbols for /lib/libdiskfs.so.0.3 + Reading symbols from /devel4/tschwinge/tmp/hurd/hurd.ogi/build/libpager/libpager.so.0.3...done. + Loaded symbols for /devel4/tschwinge/tmp/hurd/hurd.ogi/build/libpager/libpager.so.0.3 + Reading symbols from /lib/libstore.so.0.3...Reading symbols from /lib/debug/lib/libstore.so.0.3...done. + done. + Loaded symbols for /lib/libstore.so.0.3 + [...] + (gdb) break pager_demuxer + Breakpoint 1 at 0x105c98d: file ../../libpager/demuxer.c, line 27. + [...] + Breakpoint 1, pager_demuxer (inp=0x12bded0, outp=0x12bbec0) at ../../libpager/demuxer.c:27 + 27 { + (gdb) list + 22 /* Demultiplex a single message directed at a pager port; INP is the + 23 message received; fill OUTP with the reply. */ + 24 int + 25 pager_demuxer (mach_msg_header_t *inp, + [...] + +Voilà. |