From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8941 invoked by alias); 19 Aug 2014 18:01:45 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 8785 invoked by uid 89); 19 Aug 2014 18:01:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-pd0-f170.google.com Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 19 Aug 2014 18:01:35 +0000 Received: by mail-pd0-f170.google.com with SMTP id g10so9875337pdj.15 for ; Tue, 19 Aug 2014 11:01:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Uyk4K+OZrF3DeIbZkWxUBa+wgi5R3nnnavAX3+rDtWo=; b=jGduEyQ2ilLvAG1KrLirj1fdAvtkAYX5Tp41GgR/EJKrqOnweniFiwCgk9Ji/uscGa X1Px6GJEmoWIGtG83ehOvRT29LIzyhMrDWMpiFZAyYCgWYHoC2x6UAg0ghb1vY4vxFnU reQFeReGjS16SbcAhw2wPe9fdLmwQRWUoFEWENL4ybm4NNSk1845ZGm7M4Qtdpei3X1f /RbZP49YK4MAABYmHuWWlp8m5NUy+8IbN9hIIN8Pn5CwgHP7qDSKUOw+q3+RzNM017DV DmQ0azDT0MIm3RvqX5k7vcI46YmzBeTo+07BZqNTNbdVlAqeOv1e88LObI8YO4KszYBh xLKA== X-Gm-Message-State: ALoCoQlcJqZCmTVFdCVDcFoz2r1dhpXBzAkccxFXs6SCFpDHyV9Fb5C0iimk6QT7Nfq6J1N3LaDA MIME-Version: 1.0 X-Received: by 10.70.102.200 with SMTP id fq8mr22079754pdb.152.1408471289340; Tue, 19 Aug 2014 11:01:29 -0700 (PDT) Received: by 10.70.57.136 with HTTP; Tue, 19 Aug 2014 11:01:29 -0700 (PDT) In-Reply-To: <53F3776D.2010705@redhat.com> References: <53F3743F.3000106@redhat.com> <53F3776D.2010705@redhat.com> Date: Tue, 19 Aug 2014 18:01:00 -0000 Message-ID: Subject: Re: Debugging issue with gdbserver and a daemon on the target From: Laszlo Papp To: Pedro Alves Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00084.txt.bz2 On Tue, Aug 19, 2014 at 5:12 PM, Pedro Alves wrote: > On 08/19/2014 05:02 PM, Laszlo Papp wrote: >> On Tue, Aug 19, 2014 at 4:58 PM, Pedro Alves wrote: >>> On 08/19/2014 04:44 PM, Laszlo Papp wrote: >>> >>>> >>>> gdbserver --attach 192.168.0.32:2345 pid-of-my-daemon >>>> >>> >>>> (gdb) bt >>>> #0 0x44ad26ec in select () at ../sysdeps/unix/syscall-template.S:81 >>>> #1 0x0002ac08 in bar (timeout=10, name=0x42f30 "foo") at >>>> src/socket.c:906 >>>> #2 0x0003284c in main (argc=0, argv=0x0) at src/bar.c:679 >>>> (gdb) >>>> >>>> >>>> ... And then I do some communication with the daemon where the foo >>>> function is executed based on the logs, but the breakpoint is not hit. >>>> I wished to try hardware breakpoints, but they are not presented on my >>>> hardware. >>>> >>>> Furthermore, if I use the same workflow on a binary that is >>>> "one-shot", i.e. not running continuously as a daemon, the debugging >>>> workflow for stopping at main works with exactly the aforementioned >>>> software breakpoint issue. >>>> >>>> I am completely clueless at this point. Do you know how I can debug a >>>> daemon with gdbserver? >>> >>> "daemon" and "select" makes me think "fork". If the daemon is handling >>> requests by forking a child, and then it's the child that calls 'foo', >>> then this is expected, as GDBserver doesn't know how to follow forks >>> currently. It's WIP, patches have been posted. Meanwhile, the usual >>> thing to do it to attach to the child process the daemon spawns instead >>> of the main daemon pid. You'll usually do that by adding a busyloop in >>> the child somewhere, like: >>> >>> volatile int gdb_here; >>> >>> while (!gdb_here) >>> sleep (1); >>> >>> and after attaching to the child, do "print gdb_here = 1; continue". >>> >>> Thanks, >>> Pedro Alves >> >> Thanks Pedro for the prompt reply. Unfortunately, I am already >> attaching to the child right after the fork. I wonder if this can >> happen if some source file was missing? > > It shouldn't. Source files are only used for display. Where to > place a breakpoint is derived from the debug info in the binary. > > I'd suggest just trying to step through the code instead of > putting a break at "foo", and see if that much works. On an > arm system, stepping is actually implemented with magic > breakpoints behind the scenes. > >> Btw: >> >> gdbserver --version >> GNU gdbserver (GDB) 7.5.1 >> >> arm-polatis-linux-gnueabi-gdb --version >> GNU gdb (GDB) 7.5.1 >> > > Knee-jerk reaction is to suggest a more recent GDB/GDBserver. Note > building these isn't very hard. There aren't that many > dependencies. > > Thanks, > Pedro Alves Hmm, it seems that the stripped binary on the target and the one on the host were out-of-sync. This is really strange since I have not changed the source code. Seems different compilations still can get out-of-sync for the same code so that when I rebuild the same source code, I always need to update the binary on the target, too? Anyway, now I only have problems with finding the sources file to view them in cgdb. I do not know why it is wrong, but it seems to be. As you can see the paths are set up for dwarf correctly: readelf --debug-dump ./tmp/work/foo-foo-linux-gnueabi/foo-core-image-dbg/1.0-r0/rootfs/usr/bin/.debug/foo | grep DW_AT_comp_dir <35> DW_AT_comp_dir : /usr/src/debug///////////////////////////////////////////////////////////////////////////////////eglibc/2.17-r3/eglibc-2.17/libc/csu DW_AT_comp_dir : (indirect string, offset: 0x31): /usr/src/debug/eglibc/2.17-r3/eglibc-2.17/libc/csu <183> DW_AT_comp_dir : /usr/src/debug///////////////////////////////////////////////////////////////////////////////////eglibc/2.17-r3/eglibc-2.17/libc/csu <22d> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <102f> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <2e98> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <3e34> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <471a> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <4c5f> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <55b9> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <84b8> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar <94d1> DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar DW_AT_comp_dir : (indirect string, offset: 0x749): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/bar DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz <10cd9> DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz <127e6> DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz <132ab> DW_AT_comp_dir : (indirect string, offset: 0x3874): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/baz <13bf3> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1556d> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <162d4> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <17481> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <17900> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <18481> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1903f> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <19432> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <19524> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <19fe1> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1d2b4> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1dc34> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1f2c1> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1fa4f> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <1fe13> DW_AT_comp_dir : (indirect string, offset: 0x585a): /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh <203e4> DW_AT_comp_dir : (indirect string, offset: 0x7cfa): /usr/src/debug/flex/2.5.35-r3/flex-2.5.35 <2042a> DW_AT_comp_dir : (indirect string, offset: 0x31): /usr/src/debug/eglibc/2.17-r3/eglibc-2.17/libc/csu <2056c> DW_AT_comp_dir : (indirect string, offset: 0x7de0): /usr/src/debug/eglibc/2.17-r3/eglibc-2.17/libc/io <20833> DW_AT_comp_dir : /usr/src/debug///////////////////////////////////////////////////////////////////////////////////eglibc/2.17-r3/eglibc-2.17/libc/csu DW_AT_comp_dir DW_FORM_string DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_string DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_strp DW_AT_comp_dir DW_FORM_string ... yet, gdb says src/bar.c cannot be found even though it should be in the aforementioned /usr/src/debug/foo-git/AUTOINC+0c2cbe33e653afa335ca25156d293552001228fa-r0/git/meh path, provided my sysroot setting is good above, but if that was not good, it would not load the binaries anyway, right? So, if I set that path one line above with the "-d" option to gdb, then the source file can be viewed. What may be going on here? Thanks in advance. I am so desperately lost. :(