From 7f6df2946cf9ec53b9d8cda2400172fd364046ce Mon Sep 17 00:00:00 2001 From: jinger7281 Date: Thu, 4 Jul 2024 15:17:25 +0800 Subject: [PATCH] Update gdbinit fix wrong path of libstdcxx python script --- gdb/gdbinit | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/gdbinit b/gdb/gdbinit index 57b4abb4d3f..40b4b074460 100644 --- a/gdb/gdbinit +++ b/gdb/gdbinit @@ -1,6 +1,15 @@ python import sys -sys.path.insert(0, sys.path[0] + '/../../%GCC_NAME%/python') +import os +from os import path +dir_of_gcc = list(filter(lambda x: x.startswith('gcc'), os.listdir('/usr/share'))) +if len(dir_of_gcc) > 0: + dir_of_gcc = path.join('/usr/share', dir_of_gcc[0], 'python') + if not path.exists(dir_of_gcc): + dir_of_gcc = sys.path[0] +else: + dir_of_gcc = sys.path[0] +sys.path.insert(0, dir_of_gcc) from libstdcxx.v6.printers import register_libstdcxx_printers register_libstdcxx_printers (None) -end \ No newline at end of file +end