From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44514 invoked by alias); 9 Jan 2018 03:38:55 -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 44502 invoked by uid 89); 9 Jan 2018 03:38:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=H*c:alternative, response! X-HELO: mail-ot0-f172.google.com Received: from mail-ot0-f172.google.com (HELO mail-ot0-f172.google.com) (74.125.82.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jan 2018 03:38:53 +0000 Received: by mail-ot0-f172.google.com with SMTP id x15so10271186ote.0 for ; Mon, 08 Jan 2018 19:38:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7CzpN+nBeP5u2NyFdRvlrE02ck+WJEEmWYaxnjDps/s=; b=NcD+MsloO3ZeSgLBDi+ueydrZx+Db+shEnCQhrxtaeAfXxnfBrm2j6+zv8UdzwcZK4 ZQ0AzToLksZaIo6KZrGth90O6teoCZU0c3meY6L/UvWIRn114I2YQc7oKXAaZPvXB+We u46w0KKlCSxvGRPZeFVskj/ExMzH5KGPuHhkDJnR83KBFGTaOkGQg3qNJnmQrKGYo2pB fe55Ne8XrJ3jnmi9aAZ4vfwPOyzO1NO8/N2Cz7t1N0VqBLIJWVx/7G4//D6wgCY/mcQf D1UpjEpiUyzG5PepdX4xAEYeZTKNaxw29sD6heuZ5NxWSNdkX2kexDlJxq5xrMgVn/VP x//Q== X-Gm-Message-State: AKwxytc8D4qFdZUlLG7SopReK0mYaANgXXlOO99FWx38Tnuqyrgth0wA 857CrqoB446luB6t2ZX4hcBsjdjBAgQWHPI9/hA= X-Google-Smtp-Source: ACJfBosDbigy5IA1Ok3gCCx0eHXqZ6Bs84G0WuUinMftgO2SReiGV6zBdAyQwWNXk+9ndYex981+o3IDq4j8j591Oe4= X-Received: by 10.157.45.198 with SMTP id g64mr4001525otb.226.1515469131290; Mon, 08 Jan 2018 19:38:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.168.117.74 with HTTP; Mon, 8 Jan 2018 19:38:50 -0800 (PST) Received: by 10.168.117.74 with HTTP; Mon, 8 Jan 2018 19:38:50 -0800 (PST) In-Reply-To: References: <391c68d4-729a-edea-a6b9-1359229c30f8@ericsson.com> From: shravan Date: Tue, 09 Jan 2018 03:38:00 -0000 Message-ID: Subject: Re: How does GDB load source line information during dlopen calls To: Simon Marchi Cc: gdb@sourceware.org Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-01/txt/msg00007.txt.bz2 Thanks for the response! I did try add-symbol-file and have definitely enabled "-g" flags on the target library, but source line info is still missing (debug directories are set correctly too). Your prototype is interesting - it definitely suggests that add-symbol-file should be enough. I will retry this, and see if I can get a small example which I can easily share here. Fwiw, to help rule out some possibilities, I am able to get this working on lldb using create-module and then mapping the section by address On Jan 8, 2018 8:04 AM, "Simon Marchi" wrote: On 2018-01-05 01:48 AM, shravan wrote: > Hi all, > First time poster to this list - so please bear with me :) > I am currently working on a project that has a custom dynamic loader for > shared libraries in the ELF format - it does NOT use dlopen. When debugging > this dynamically loaded library, I am hoping to be able to single step > through the C source code of functions in the library in tui mode. > > If I had use dlopen this would work fine, but this does not work using the > custom dynamic loader. I am able to get the libraries symbols loaded with > "add-symbol-file". However the src line information is still not working. > For example "list someFunctionInLibrary" prints nothing and "layout src" > shows a blank screen > > I am hoping for any information or suggestions. Is there some way to hint > to gdb to load the source line information from a particular file at a > particular address? > > (Also please let me know if there is a better venue for the question). > > Thanks! > Shravan > Hi Shravan, For all I know, add-symbol-file should make GDB read the DWARF info of the library, like it does for a automatically loaded libraries. Are your libraries built with DWARF debug information? I just tried making a small library with: int bob (void) { return 42; } I am able to pretend that this library was loaded at an arbitrary offset and list lines from its source files: (gdb) add-symbol-file lib/libbob.so 0x1000000 add symbol table from file "lib/libbob.so" at .text_addr = 0x1000000 (y or n) y Reading symbols from lib/libbob.so...done. (gdb) list bob 1 int 2 bob (void) 3 { 4 return 42; 5 } (gdb) p &bob $1 = (int (*)(void)) 0x1000100 (gdb) list *0x1000100 0x1000100 is in bob (bob.c:3). 1 int 2 bob (void) 3 { 4 return 42; 5 } (gdb) b bob.c:4 Breakpoint 2 at 0x1000104: file bob.c, line 4. So I think add-symbol-file should work for you, there is probably a missing link somewhere. I don't think I can't help you without more information, or an actual program to debug. Simon