libstdc++.so.6.0.21-gdb.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- python -*-
  2. # Copyright (C) 2009-2015 Free Software Foundation, Inc.
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. import sys
  16. import gdb
  17. import os
  18. import os.path
  19. pythondir = '/srv/openwrt/ar71xx/build/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/share/gcc-5.3.0/python'
  20. libdir = '/srv/openwrt/ar71xx/build/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/mips-openwrt-linux-musl/lib'
  21. # This file might be loaded when there is no current objfile. This
  22. # can happen if the user loads it manually. In this case we don't
  23. # update sys.path; instead we just hope the user managed to do that
  24. # beforehand.
  25. if gdb.current_objfile () is not None:
  26. # Update module path. We want to find the relative path from libdir
  27. # to pythondir, and then we want to apply that relative path to the
  28. # directory holding the objfile with which this file is associated.
  29. # This preserves relocatability of the gcc tree.
  30. # Do a simple normalization that removes duplicate separators.
  31. pythondir = os.path.normpath (pythondir)
  32. libdir = os.path.normpath (libdir)
  33. prefix = os.path.commonprefix ([libdir, pythondir])
  34. # In some bizarre configuration we might have found a match in the
  35. # middle of a directory name.
  36. if prefix[-1] != '/':
  37. prefix = os.path.dirname (prefix) + '/'
  38. # Strip off the prefix.
  39. pythondir = pythondir[len (prefix):]
  40. libdir = libdir[len (prefix):]
  41. # Compute the ".."s needed to get from libdir to the prefix.
  42. dotdots = ('..' + os.sep) * len (libdir.split (os.sep))
  43. objfile = gdb.current_objfile ().filename
  44. dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir)
  45. if not dir_ in sys.path:
  46. sys.path.insert(0, dir_)
  47. # Call a function as a plain import would not execute body of the included file
  48. # on repeated reloads of this object file.
  49. from libstdcxx.v6 import register_libstdcxx_printers
  50. register_libstdcxx_printers(gdb.current_objfile())