Subject: Re: how do I build a debugger (-g) instbin in the build.sh world?
To: None <current-users@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: current-users
Date: 06/09/2003 02:42:49
In article <m19P8H4-000B44C@proven.weird.com>,
Greg A. Woods <current-users@NetBSD.ORG> wrote:
You don't need to. Just keep the core file, and re-compile the binary with
-g on your working system. Then you can use your old core with the new -g
binary.
christos
>How do I build a debugger-ready (-g) version of the 'instbin' binary in
>the build.sh world?
>
>I'm working on the the netbsd-1-6 branch at the moment but I suspect the
>answer is generic to -current.
>
>When I build the '-g' flag is passed to sparc--netbsdelf-gcc because I
>have it set to do so in /etc/mk.conf (my whole build is done this way),
>but of course the resulting 'instbin' file is still stripped. I'm just
>not quite sure how to (optionally) get the resulting objects to the
>final binary with their full symbol tables intact.
>
>I'm guessing the symbols I want are disappearing when the build runs
>commands like this one:
>
> sparc--netbsdelf-objcopy --strip-debug --keep-global-symbol
>_crunched_tset_stub tset.cro
>
>and so on.
>
>It would seem one has to manually edit the generated "instbin.mk" file
>to get rid of all the '--strip-debug' options, then remove all the
>"*.cro" files, and finally re-run:
>
> $TOOLSDIR/bin/nbmake-sparc -f instbin.mk STRIP=: all
>
>Hopefully there's an easier way.....
>
>
>The reason I as is I have a sysinst.core file that I'd like to debug.
>It was generated on a sparc, and it happened right at the end of an
>install.
>
>[Sun Jun 8 16:02:17 2003] The installation of NetBSD-1.6.1_STABLE is
>now complete. The system should
>[Sun Jun 8 16:02:17 2003] boot from hard disk. Follow the instructions
>in the INSTALL document about
>[Sun Jun 8 16:02:17 2003] final configuration of your system.
>[Sun Jun 8 16:02:17 2003]
>[Sun Jun 8 16:02:17 2003] At a minimum, you should edit /etc/rc.conf to
>match your needs. See
>[Sun Jun 8 16:02:17 2003] /etc/defaults/rc.conf for the default values.
>[Sun Jun 8 16:02:17 2003]
>ESC[13;28HESC(0lqqqqqqqqqqqqqqqqqqqqqqqkESC(BESC[14;28HESC(0xESC(B Hit
>enter to continue
>ESC(0xESC(BESC[15;28HESC(0xESC(BESC[15;52HESC(0xESC(BESC[16;
>28HESC(0xESC(B>ESC[7ma:
>okESC[16;52HESC[mESC(0xESC(BESC[17;28HESC(0mqqqqqqqqqqqqqqqqqqqqqqqjESC(BESC[16;29HESC[13;28HESC[KESC[14;28HESC[KESC[15;28HESC[KESC[16;28HESC[KESC[17;28
>HESC[KESC[13;28Hsysinst: pid 17 [eid 0:0, rid 0:0] exited on signal 11:
>dumped core [in //sysinst.core]
>[Sun Jun 8 16:02:23 2003]^MSegmentation fault - core dumped
>
>
># file sysinst sysinst.core
>sysinst: ELF 32-bit MSB executable, SPARC, version 1 (SYSV), for
>NetBSD, statically linked, stripped
>sysinst.core: ELF 32-bit MSB core file, SPARC, version 1 (SYSV),
>NetBSD-style, from 'sysinst' (signal 11)
># nm sysinst
>nm: sysinst: no symbols
># gdb sysinst sysinst.core
>GNU gdb 5.0nb1
>Copyright 2000 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 "sparc--netbsdelf"...(no debugging symbols found)...
>Core was generated by `sysinst'.
>Program terminated with signal 11, Segmentation fault.
>#0 0x1204c0 in ?? ()
>(gdb) where
>#0 0x1204c0 in ?? ()
>#1 0x121298 in ?? ()
>#2 0x11e34c in ?? ()
>#3 0x1060c in ?? ()
>#4 0x1030c in ?? ()
>(gdb)
>
>
>OK, after doing all the fiddling around to get the instfs and all the
>sources mounted in the right place (this freshly installed machine is
>the only one where I have the right version of gdb -- maybe $TOOLSDIR
>should include gdb?), rebuilding instbin by hand, I think this is where
>I've ended up:
>
># gdb /sometimes/almost/sysinst.gdb /sometimes/almost/sysinst.core
>GNU gdb 5.0nb1
>Copyright 2000 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 "sparc--netbsdelf"...
>
>warning: exec file is newer than core file.
>Core was generated by `sysinst'.
>Program terminated with signal 11, Segmentation fault.
>#0 0x1204c0 in process_menu (num=0) at menu_defs.c:1794
>1794 if (m->opts[sel].opt_menu != -1) {
>(gdb) where
>#0 0x1204c0 in process_menu (num=0) at menu_defs.c:1794
>#1 0x121298 in main (argc=1, argv=0xeffff89c)
> at
>/work/woods/m-NetBSD-1.6/distrib/utils/sysinst/arch/sparc/../../main.c:157
>#2 0x11e34c in _crunched_sysinst_stub (argc=1, argv=0xeffff89c, envp=0x11e338)
> at sysinst_stub.c:1
>#3 0x1060c in main (argc=1, argv=0xeffff89c) at instbin.c:67
>#4 0x1030c in ___start (argc=1, argv=0xeffff89c, envp=0x215110, cleanup=0,
> obj=0x0, ps_strings=0xeffffff0)
> at /work/woods/m-NetBSD-1.6/lib/csu/sparc_elf/crt0.c:97
>#5 0x10238 in _start ()
> at /work/woods/m-NetBSD-1.6/lib/csu/sparc_elf/../common_elf/crtbegin.c:167
>(gdb) list
>1789 endwin();
>1790 __m_endwin = 1;
>1791 }
>1792 if (m->opts[sel].opt_action)
>1793 done = (*m->opts[sel].opt_action)(m);
>1794 if (m->opts[sel].opt_menu != -1) {
>1795 if (m->opts[sel].opt_flags & OPT_SUB)
>1796 process_menu
>(m->opts[sel].opt_menu);
>1797 else
>1798 num = m->opts[sel].opt_menu;
>(gdb) print m
>$1 = (struct menudesc *) 0x33b000
>(gdb) print *m
>$2 = {title = 0x20 <Address 0x20 out of bounds>, y = 0, x = 32, h = 0, w = 32,
> mopt = 0, numopts = 32, cursel = 0, topline = 32, opts = 0x0, mw = 0x20,
> helpstr = 0x0, exitstr = 0x20 <Address 0x20 out of bounds>, post_act = 0,
> exit_act = 0x20}
>(gdb) print sel
>$3 = 0
>(gdb) print m->opts[0]
>Cannot access memory at address 0x0
>(gdb)
>
>
>
>--
> Greg A. Woods
>
>+1 416 218-0098; <g.a.woods@ieee.org>; <woods@robohack.ca>
>Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>