ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
GdbUtils
python
findlib.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
#
3
# File: GdbUtils/python/findlib.py
4
# Created: A while ago, sss
5
# Purpose: Look up a shared library by address.
6
#
7
8
9
import
gdb
10
import
os
11
from
get_inferior
import
get_inferior
12
13
14
def
findlib (addr, quiet = False):
15
inf = get_inferior()
16
if
inf
is
None
:
17
print
(
'No inferior.'
)
18
return
19
maps = open (
'/proc/%d/maps'
% inf)
20
loaded_lib =
None
21
for
l
in
maps.readlines():
22
if
l
and
l[-1] ==
'\n'
:
23
l = l[:-1]
24
ll = l.split()
25
(lo,hi) = ll[0].
split
(
'-'
)
26
lo = int(lo, 16)
27
hi = int(hi, 16)
28
lib =
None
29
if
lo <= addr < hi:
30
if
len(ll) >= 6
and
ll[5] !=
'[heap]'
:
31
lib = ll[5]
32
lib = os.path.basename (lib)
33
ipos = lib.find(
'.so'
)
34
if
ipos > 0:
35
lib = lib[:ipos+3]
36
if
quiet:
37
gdb.execute (
"shared "
+ os.path.basename (lib), to_string =
True
)
38
else
:
39
print
(lib)
40
gdb.execute (
"shared "
+ os.path.basename (lib))
41
loaded_lib = lib
42
return
loaded_lib
43
44
45
class
FindLib
(gdb.Command):
46
"""Look up a shared library by address.
47
48
findlib ADDR will look up the shared library containing ADDR, if any.
49
If found, then its symbols will be loaded.
50
"""
51
52
def
__init__
(self):
53
super (FindLib, self).__init__ (
"findlib"
, gdb.COMMAND_FILES)
54
55
def
invoke
(self, arg, from_tty):
56
addr = int(arg.split()[0], 0)
57
return
findlib (addr)
58
59
60
FindLib
()
61
python.findlib.FindLib
Definition
findlib.py:45
python.findlib.FindLib.invoke
invoke(self, arg, from_tty)
Definition
findlib.py:55
python.findlib.FindLib.__init__
__init__(self)
Definition
findlib.py:52
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
Generated on
for ATLAS Offline Software by
1.17.0