libstdc++.so.6.0.17-gdb.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # -*- python -*-
  2. # Copyright (C) 2009, 2010 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 = '/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/share/gcc-4.7.3/python'
  20. libdir = '/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/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. # Load the pretty-printers.
  48. from libstdcxx.v6.printers import register_libstdcxx_printers
  49. register_libstdcxx_printers (gdb.current_objfile ())