Commit 52fcb20f authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

Fix gdbinit to handle dwo files correctly

We need to tell the location of dwo files to gdb too, to load debug information
correctly.
Reported in
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Y_2aYS6_DXA/qQCeeznpCwAJ

I also changed to use event handler for newly loaded objfiles.

Bug: crbug.com/439949, crbug.com/603286
Change-Id: Ib0b52c5553578333cd0dd44f11a9117345622844
Reviewed-on: https://chromium-review.googlesource.com/1068785Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561632}
parent fffb3583
# This is run-hook for source level debugging with -fdebug-prefix-map
# compile option.
define hook-run
python
# This is gdbinit for source level debugging with -fdebug-prefix-map compile
# option.
python
import os
for i in gdb.objfiles():
# Add source dir relative to build dir.
compile_dir = os.path.dirname(i.filename)
def get_current_debug_file_directories():
dir = gdb.execute("show debug-file-directory", to_string=True)
dir = dir[len('The directory where separate debug symbols are searched for is "'):-len('".')-1]
return set(dir.split(":"))
def add_debug_file_directory(dir):
# gdb has no function to add debug-file-directory, simulates that by using
# `show debug-file-directory` and `set debug-file-directory <directories>`.
current_dirs = get_current_debug_file_directories()
current_dirs.add(dir)
gdb.execute("set debug-file-directory %s" % ":".join(current_dirs),
to_string=True)
def newobj_handler(event):
compile_dir = os.path.dirname(event.new_objfile.filename)
if not compile_dir:
return
# Add source path
gdb.execute("dir %s" % compile_dir)
end
# Need to tell the location of .dwo files.
# https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
# https://crbug.com/603286#c35
add_debug_file_directory(compile_dir)
# Event hook for newly loaded objfiles.
# https://sourceware.org/gdb/onlinedocs/gdb/Events-In-Python.html
gdb.events.new_objfile.connect(newobj_handler)
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment