Skip to content

Commit 443d095

Browse files
pitroukou
authored andcommitted
ARROW-15423: [C++][Dev] Make GDB plugin auto-load friendly
When auto-loaded, a GDB plugin should attach itself to the specific objfile being debugged. This allows for potentially multiple inferiors being debugged at once, using different versions of Arrow C++. Closes #12236 from pitrou/ARROW-15423-gdb-auto-load Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent daa5c18 commit 443d095

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

cpp/gdb_arrow.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ def to_string(self):
18431843
"nonstd::sv_lite::basic_string_view": StringViewPrinter,
18441844
}
18451845

1846+
18461847
def arrow_pretty_print(val):
18471848
name = val.type.strip_typedefs().name
18481849
if name is None:
@@ -1891,4 +1892,17 @@ def arrow_pretty_print(val):
18911892
return ScalarPrinter(val)
18921893

18931894

1894-
gdb.pretty_printers.append(arrow_pretty_print)
1895+
def main():
1896+
# This pattern allows for two modes of use:
1897+
# - manual loading using `source gdb-arrow.py`: current_objfile()
1898+
# will be None;
1899+
# - automatic loading from the GDB `scripts-directory`: current_objfile()
1900+
# will be tied to the inferior being debugged.
1901+
objfile = gdb.current_objfile()
1902+
if objfile is None:
1903+
objfile = gdb
1904+
1905+
objfile.pretty_printers.append(arrow_pretty_print)
1906+
1907+
1908+
main()

0 commit comments

Comments
 (0)