GDB (xrefs)
Loading...
Searching...
No Matches
gdb
python
lib
gdb
dap
modules.py
Go to the documentation of this file.
1
# Copyright 2023 Free Software Foundation, Inc.
2
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
16
import
gdb
17
18
from
.server
import
capability, request
19
from
.startup
import
in_gdb_thread
20
21
22
@in_gdb_thread
23
def
module_id
(objfile):
24
"""Return the module ID for the objfile."""
25
return
objfile.username
26
27
28
@in_gdb_thread
29
def
is_module
(objfile):
30
"""Return True if OBJFILE represents a valid Module."""
31
return
objfile.is_valid()
and
objfile.owner
is
None
32
33
34
@in_gdb_thread
35
def
make_module
(objf):
36
"""Return a Module representing the objfile OBJF.
37
38
The objfile must pass the 'is_module' test."""
39
result = {
40
"id"
: module_id(objf),
41
"name"
: objf.username,
42
}
43
if
objf.is_file:
44
result[
"path"
] = objf.filename
45
return
result
46
47
48
@in_gdb_thread
49
def
_modules
(start, count):
50
# Don't count invalid objfiles or separate debug objfiles.
51
objfiles = [x
for
x
in
gdb.objfiles
()
if
is_module(x)]
52
if
count == 0:
53
# Use all items.
54
last = len(objfiles)
55
else
:
56
last = start + count
57
return
{
58
"modules"
: [make_module(x)
for
x
in
objfiles[start:last]],
59
"totalModules"
: len(objfiles),
60
}
61
62
63
@capability("supportsModulesRequest")
64
@request("modules")
65
def
modules(*, startModule: int = 0, moduleCount: int = 0, **args):
66
return
_modules
(startModule, moduleCount)
gdb.dap.modules.module_id
module_id(objfile)
Definition
modules.py:23
gdb.dap.modules._modules
_modules(start, count)
Definition
modules.py:49
gdb.dap.modules.is_module
is_module(objfile)
Definition
modules.py:29
gdb.dap.modules.make_module
make_module(objf)
Definition
modules.py:35
gdb.objfiles
objfiles()
Definition
__init__.py:216
Generated by
1.10.0