Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrei Warkentin <andreiw@motorola.com>
To: gdb-patches@sourceware.org
Subject: Symbol file scope?
Date: Fri, 27 May 2011 23:14:00 -0000	[thread overview]
Message-ID: <BANLkTimdA21_Td4kqec5nKVnVoWCytwO6Q@mail.gmail.com> (raw)

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


             reply	other threads:[~2011-05-27 23:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-27 23:14 Andrei Warkentin [this message]
2011-05-31 17:09 ` Tom Tromey
2011-05-31 18:43   ` Andrei Warkentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTimdA21_Td4kqec5nKVnVoWCytwO6Q@mail.gmail.com \
    --to=andreiw@motorola.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox