From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28391 invoked by alias); 27 May 2011 23:14:24 -0000 Received: (qmail 28380 invoked by uid 22791); 27 May 2011 23:14:23 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from exprod5og104.obsmtp.com (HELO exprod5og104.obsmtp.com) (64.18.0.178) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 23:14:08 +0000 Received: from il93mgrg01.am.mot-mobility.com ([144.188.21.13]) (using TLSv1) by exprod5ob104.postini.com ([64.18.4.12]) with SMTP ID DSNKTeAwPypxym5QlLrGQVK9HvCoO8ZL1lQt@postini.com; Fri, 27 May 2011 16:14:08 PDT Received: from il93mgrg01.am.mot-mobility.com ([10.176.129.42]) by il93mgrg01.am.mot-mobility.com (8.14.3/8.14.3) with ESMTP id p4RNBeMr011296 for ; Fri, 27 May 2011 19:11:40 -0400 (EDT) Received: from mail-px0-f169.google.com (mail-px0-f169.google.com [209.85.212.169]) by il93mgrg01.am.mot-mobility.com (8.14.3/8.14.3) with ESMTP id p4RNAKA5011101 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 27 May 2011 19:11:40 -0400 (EDT) Received: by mail-px0-f169.google.com with SMTP id 9so1302580pxi.0 for ; Fri, 27 May 2011 16:14:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.223.6 with SMTP id v6mr423159wfg.204.1306538046158; Fri, 27 May 2011 16:14:06 -0700 (PDT) Received: by 10.142.53.6 with HTTP; Fri, 27 May 2011 16:14:06 -0700 (PDT) Date: Fri, 27 May 2011 23:14:00 -0000 Message-ID: Subject: Symbol file scope? From: Andrei Warkentin To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-CFilter-Loop: Reflected 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: 2011-05/txt/msg00660.txt.bz2 Hi, This is my first time posting on a GDB mailing list, so excuse me in advance if this has been covered before... I am using GDB to debug TianoCore UEFI firmware (http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Welcome) running in a virtual machine using an ICE-like gdb remote stub (gdbsx for Xen, or just QEMU gdb support). UEFI consists of a number of separate modules - UEFI core, various drivers and UEFI application (not applications, just one, like the EFI shell or a bootloader). All of these modules live in the same indentity-mapped address space, and interact with each other via "protocols", which are effectively just function dispatch tables published with the UEFI core. There is no concept of "processes", a backtrace weaves through many modulules (i.e. EFI shell called into Core, which called into fs driver, etc). The problem is globals. GDB expects globals to be unique, since it thinks it is debugging a program. Global search is done is "first fit". So it will start with the symtabs in the first object file that was "add-symbol-file"d and return in. It would be nice to be able to have globals be searched for first in the object file to which the current scope is in. Additionally, it would be nice to be able to implement "module scope" in the same fashion as "file scope", so you can look at globals in any module like this - (gdb) print &'DxeCore.dll'::gST $15 = (EFI_SYSTEM_TABLE **) 0x17fca6f0 (gdb) print &'IsaBusDxe.dll'::gST $16 = (EFI_SYSTEM_TABLE **) 0x17e21da4 I have a patch for 7.1 (I know...old) that I put together that basically - 1) Modifies lookup_symbol_global to use lookup_global_symbol_from_objfile before lookup_symbol_aux_symatbs or solib_global_lookup 2) Modifies lookup_symtab to match symbol object file as well. It returns the first symtab, which is good enough for lookup_symbol_global logic to work. (I basically wanted to avoid modifying c-exp, p-exp, etc, parsers) 3) Fixes location completion to match object file names as well. 4) Adds a list-symbol-files command to list all objfiles and their locations, or list only those that match objfile/source file names. I.e - gdb) list-symbol-files DiskIo.c Dispatcher.c EhciDxe.dll DiskIo.c: /home/fjnh84/mine/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe/DEBUG/DiskIoDxe.dll .text, [0x17e4c240-0x17e4f440) Dispatcher.c: /home/fjnh84/mine/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll .text, [0x17fb1240-0x17fcb8c0) EhciDxe.dll: /home/fjnh84/mine/edk2/Build/OvmfIa32/DEBUG_GCC44/IA32/MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe/DEBUG/EhciDxe.dll .text, [0x17deb240-0x17df3920) I have a patch here - https://github.com/andreiw/andreiw-wip/blob/master/gdb/0001-GDB-Initial-prototype-of-symbol-file-scope-module-sc.patch I realize I need to rebase it on latest gdb. I wanted to get the GDB folks' feedback before I did anything else with this :-). Thank you for your time, A