From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25806 invoked by alias); 22 Feb 2010 15:27:40 -0000 Received: (qmail 25787 invoked by uid 22791); 22 Feb 2010 15:27:38 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40 X-Spam-Check-By: sourceware.org Received: from mail-ew0-f223.google.com (HELO mail-ew0-f223.google.com) (209.85.219.223) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Feb 2010 15:27:34 +0000 Received: by ewy23 with SMTP id 23so2971007ewy.4 for ; Mon, 22 Feb 2010 07:27:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.180.202 with SMTP id j52mr1283858wem.214.1266852451067; Mon, 22 Feb 2010 07:27:31 -0800 (PST) In-Reply-To: <201002221501.o1MF1Qrq024363@glazunov.sibelius.xs4all.nl> References: <20100210200303.GA19632@lucon.org> <20100218054312.GA9022@lucon.org> <20100218153402.GA27929@lucon.org> <20100218230135.GA17916@intel.com> <201002221342.o1MDgSZA029705@glazunov.sibelius.xs4all.nl> <6dc9ffc81002220617o1d348e68hc918d434118cadcb@mail.gmail.com> <201002221501.o1MF1Qrq024363@glazunov.sibelius.xs4all.nl> Date: Mon, 22 Feb 2010 15:27:00 -0000 Message-ID: <6dc9ffc81002220727k50e97d86waac51e92f5e3315@mail.gmail.com> Subject: Re: PATCH: Enable x86 XML target descriptions From: "H.J. Lu" To: Mark Kettenis Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00535.txt.bz2 On Mon, Feb 22, 2010 at 7:01 AM, Mark Kettenis wr= ote: >> Date: Mon, 22 Feb 2010 06:17:29 -0800 >> From: "H.J. Lu" >> >> >> +/* Get Linux/x86 target description from running target. =A0*/ >> >> + >> >> +static const struct target_desc * >> >> +amd64_linux_read_description (struct target_ops *ops) >> >> +{ >> >> + =A0if (gdbarch_ptr_bit (target_gdbarch) =3D=3D 64) >> >> + =A0 =A0return tdesc_amd64_linux; >> >> + =A0else >> >> + =A0 =A0return tdesc_i386_linux; >> >> +} >> >> + >> > >> > This made me wonder what happens if you attach to a process without >> > loading an executable first. =A0Currently this works, since GDB can >> > figure out what executable belongs to the the process and load the >> > executable automatically. =A0But I fear a chicken & egg problem here: >> > the gdbarch is derviced from the tdesc, but in order to determine the >> > tdesc you need a gdbarch. >> >> How do you attach to a process without loading an executable first? >> Gdb has to load something to debug. Do you have a testcase? I will >> fix it if it doesn't work already. > > $ gdb > ... > (gdb) attach PID > > It works fine. amd64_linux_read_description is called via (gdb) att 20026 Attaching to process 20026 Reading symbols from /export/home/hjl/bugs/gdb/xml/p...done. Detaching after fork from child process 20039. Breakpoint 3, amd64_linux_read_description (ops=3D0xa94900) at /export/gnu/import/git/gdb-avx/gdb/amd64-linux-nat.c:681 681 { Missing separate debuginfos, use: debuginfo-install expat-2.0.1-8.fc12.x86_64 glibc-2.11.1-2.2.f12.x86_64 ncurses-libs-5.7-3.20090207.fc12.x86_64 python-2.6.2-2.fc12.x86_64 python-libs-2.6.2-2.fc12.x86_64 zlib-1.2.3-23.fc12.x86_64 (top-gdb) bt #0 amd64_linux_read_description (ops=3D0xa94900) at /export/gnu/import/git/gdb-avx/gdb/amd64-linux-nat.c:681 #1 0x000000000054be91 in target_read_description ( target=3D) at /export/gnu/import/git/gdb-avx/gdb/target.c:2252 #2 0x00000000005c423a in target_find_description () at /export/gnu/import/git/gdb-avx/gdb/target-descriptions.c:279 #3 0x000000000051e266 in post_create_inferior (target=3D0xa74be0, from_tty= =3D1) at /export/gnu/import/git/gdb-avx/gdb/infcmd.c:402 #4 0x000000000051e36f in attach_command_post_wait ( args=3D, from_tty=3D1, async_exec=3D0) at /export/gnu/import/git/gdb-avx/gdb/infcmd.c:2249 #5 0x000000000051e7fd in attach_command (args=3D0xa77104 "20026", from_tty= =3D1) at /export/gnu/import/git/gdb-avx/gdb/infcmd.c:2426 #6 0x00000000004559eb in execute_command (p=3D0xa77108 "6", from_tty=3D1) at /export/gnu/import/git/gdb-avx/gdb/top.c:441 #7 0x0000000000535947 in command_handler (command=3D0xa77100 "") at /export/gnu/import/git/gdb-avx/gdb/event-top.c:511 #8 0x0000000000536564 in command_line_handler (rl=3D) at /export/gnu/import/git/gdb-avx/gdb/event-top.c:736 #9 0x00000000005fb487 in rl_callback_read_char () at /export/gnu/import/git/gdb-avx/readline/callback.c:205 #10 0x0000000000535a79 in rl_callback_read_char_wrapper ( ---Type to continue, or q to quit--- client_data=3D) at /export/gnu/import/git/gdb-avx/gdb/event-top.c:178 #11 0x00000000005343a8 in process_event () at /export/gnu/import/git/gdb-avx/gdb/event-loop.c:393 #12 0x00000000005354da in gdb_do_one_event (data=3D) at /export/gnu/import/git/gdb-avx/gdb/event-loop.c:458 #13 0x000000000052f75b in catch_errors (func=3D, func_args=3D, errstring=3D, mask=3D) at /export/gnu/import/git/gdb-avx/gdb/exceptions.c:510 #14 0x00000000004bf610 in tui_command_loop (data=3D) at /export/gnu/import/git/gdb-avx/gdb/tui/tui-interp.c:154 #15 0x000000000044d489 in captured_command_loop (data=3D) at /export/gnu/import/git/gdb-avx/gdb/main.c:226 #16 0x000000000052f75b in catch_errors (func=3D, func_args=3D, errstring=3D, mask=3D) at /export/gnu/import/git/gdb-avx/gdb/exceptions.c:510 #17 0x000000000044cebe in captured_main (data=3D) at /export/gnu/import/git/gdb-avx/gdb/main.c:905 #18 0x000000000052f75b in catch_errors (func=3D, func_args=3D, errstring=3D, mask=3D) ---Type to continue, or q to quit--- at /export/gnu/import/git/gdb-avx/gdb/exceptions.c:510 #19 0x000000000044c354 in gdb_main (args=3D0x0) at /export/gnu/import/git/gdb-avx/gdb/main.c:914 #20 0x000000000044c31e in main (argc=3D10957472, argv=3D) at /export/gnu/import/git/gdb-avx/gdb/gdb.c:33 (top-gdb) --=20 H.J.