define hook-run python import os for i in gdb.objfiles(): # Add source dir relative to build dir. compile_dir = os.path.dirname(i.filename) gdb.execute("dir %s" % compile_dir) end end |
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAPTJ0XFhqmUkVZQurabsMObUC7zN%3DR2jmSeaOnrTydJyvwV82w%40mail.gmail.com.
I was under the impression that the stuff in gdbinit was precisely intended to avoid the need to run GDB from the out/Debug directory? I can confirm that that isn't working though.
python import os def load_relative_path(): for i in gdb.objfiles(): # Add source dir relative to build dir. compile_dir = os.path.dirname(i.filename) gdb.execute("dir %s" % compile_dir) load_relative_path() end define hook-run python load_relative_path() end end define hook-break python load_relative_path() end end define hook-attach python load_relative_path() end end |
tikuta@tikuta:~/chromium/src$ gdb out/Release/base_unittests
GNU gdb (GDB) 7.9-gg19
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-grtev4-linux-gnu".
Type "show configuration" for configuration details.
<http://go/gdb-home FAQ: http://go/gdb-faq Email: c-toolchain-team IRC: gdb>
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Reading symbols from out/Release/base_unittests...done.
Unable to determine compiler version.
Skipping loading of libstdc++ pretty-printers for now.
Non-google3 binary detected.
(gdb) b main
Breakpoint 1 at 0xc906ce: file ../../base/test/run_all_base_unittests.cc, line 11.
(gdb) r
Starting program: /usr/local/google/home/tikuta/chromium/src/out/Release/base_unittests
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/ef/9474f02d7f7a3959b6dae0afe8e6acee1ac5ba.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/18/ad48fb80336dd6554ce9d61ecb3ccb7f6befa3.debug]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/45/2d8247a2b64710d413dfc84b6d7c8924aca427.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/7b/5f153d3f24f886129354bf9e6a32d01607e87a.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/cb/88f1fe155855433a969d01f052923b299701b8.debug]
Dwarf Error: wrong version in compilation unit header (is 0, should be 2, 3, or 4) [in module /usr/lib/debug/.build-id/76/1d39eb84070706076d19230afb6301781637cf.debug]
Breakpoint 1, main (argc=1, argv=0x7fffffffdba8) at ../../base/test/run_all_base_unittests.cc:11
11 base::TestSuite test_suite(argc, argv);
(gdb) list
6 #include "base/test/launcher/unit_test_launcher.h"
7 #include "base/test/test_suite.h"
8 #include "build/build_config.h"
9
10 int main(int argc, char** argv) {
11 base::TestSuite test_suite(argc, argv);
12 return base::LaunchUnitTests(
13 argc, argv,
14 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
15 }
(gdb) n
14 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
(gdb) p test_suite
$1 = {_vptr$TestSuite = 0xd54d78 <vtable for base::TestSuite+16>, at_exit_manager_ = {__ptr_ = {<std::__1::__compressed_pair_elem<base::AtExitManager*, 0, false>> = {
__value_ = 0x1b961daa8a80}, <std::__1::__compressed_pair_elem<std::__1::default_delete<base::AtExitManager>, 1, true>> = {<std::__1::default_delete<base::AtExitManager>> = {<No data fields>}, <No data fields>}, <No data fields>}}, trace_to_file_ = {path_ = {static kSeparators = 0x7ffff7e81270 <base::FilePath::kSeparators> "/", static kSeparatorsLength = 2, static kCurrentDirectory = <same as static member of an already seen type>,
static kParentDirectory = <same as static member of an already seen type>, static kExtensionSeparator = 46 '.', path_ = {<std::__1::__basic_string_common<true>> = {<No data fields>}, static __short_mask = 1,
static __long_mask = 1, __r_ = {<std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false>> = {__value_ = {{__l = {__cap_ = 0, __size_ = 0,
__data_ = 0x0}, __s = {{__size_ = 0 '\000', __lx = 0 '\000'}, __data_ = '\000' <repeats 22 times>}, __r = {__words = {0, 0,
0}}}}}, <std::__1::__compressed_pair_elem<std::__1::allocator<char>, 1, true>> = {<std::__1::allocator<char>> = {<No data fields>}, <No data fields>}, <No data fields>}, static npos = 18446744073709551615}},
started_ = false}, initialized_command_line_ = true, scoped_feature_list_ = {original_feature_list_ = {__ptr_ = {<std::__1::__compressed_pair_elem<base::FeatureList*, 0, false>> = {__value_ =
0x0}, <std::__1::__compressed_pair_elem<std::__1::default_delete<base::FeatureList>, 1, true>> = {<std::__1::default_delete<base::FeatureList>> = {<No data fields>}, <No data fields>}, <No data fields>}}, field_trial_override_ = {
ptr_ = 0x0}, field_trial_list_ = {__ptr_ = {<std::__1::__compressed_pair_elem<base::FieldTrialList*, 0, false>> = {
__value_ = 0x0}, <std::__1::__compressed_pair_elem<std::__1::default_delete<base::FieldTrialList>, 1, true>> = {<std::__1::default_delete<base::FieldTrialList>> = {<No data fields>}, <No data fields>}, <No data fields>}}},
printer_ = 0x0, assert_handler_ = {__ptr_ = {<std::__1::__compressed_pair_elem<logging::ScopedLogAssertHandler*, 0, false>> = {
__value_ = 0x0}, <std::__1::__compressed_pair_elem<std::__1::default_delete<logging::ScopedLogAssertHandler>, 1, true>> = {<std::__1::default_delete<logging::ScopedLogAssertHandler>> = {<No data fields>}, <No data fields>}, <No data fields>}}}
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/5f7174a9-9308-49e3-9173-8d0e56ab16d0%40chromium.org.