Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
ghc-utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ben Gamari
ghc-utils
Commits
8af731c1
Commit
8af731c1
authored
Dec 07, 2020
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdb: Be more cautious when search for containing closure
parent
e0150433
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
gdb/ghc_gdb/find_refs.py
gdb/ghc_gdb/find_refs.py
+19
-19
No files found.
gdb/ghc_gdb/find_refs.py
View file @
8af731c1
...
...
@@ -153,28 +153,28 @@ def find_containing_closure(inferior: gdb.Inferior,
bs
=
None
try
:
bs
=
inferior
.
read_memory
(
start
.
addr
(),
word_size
)
addr
=
Ptr
.
unpack
(
bs
)
sym
=
find_symbol_name
(
addr
)
# Is this an info table pointer?
if
sym
is
not
None
and
sym
.
endswith
(
'_info'
):
# and sym.value == addr:
info
=
ghc_heap
.
get_itbl
(
gdb
.
parse_and_eval
(
'(StgClosure *) %d'
%
start
.
addr
()))
if
int
(
info
[
'type'
])
in
closure
.
stack_frame_types
:
return
find_containing_stack
(
inferior
,
addr
)
nptrs
=
int
(
info
[
'layout'
][
'payload'
][
'ptrs'
])
#print(ptr, i, info, nptrs)
if
int
(
info
[
'type'
])
==
closure
.
ClosureType
.
IND_STATIC
:
if
ptr
.
addr
()
-
start
.
addr
()
>
8
:
# Only trace the indirectee of IND_STATICs
return
None
elif
i
<=
nptrs
+
5
:
# A bit of fudge for the headers
return
start
else
:
print
(
'suspicious info table: too far (field=%s, info@%s=%s, nptrs=%d, i=%d)'
%
(
ptr
,
start
,
sym
,
nptrs
,
i
))
return
None
except
gdb
.
MemoryError
:
continue
addr
=
Ptr
.
unpack
(
bs
)
sym
=
find_symbol_name
(
addr
)
# Is this an info table pointer?
if
sym
is
not
None
and
sym
.
endswith
(
'_info'
):
# and sym.value == addr:
info
=
ghc_heap
.
get_itbl
(
gdb
.
parse_and_eval
(
'(StgClosure *) %d'
%
start
.
addr
()))
if
int
(
info
[
'type'
])
in
closure
.
stack_frame_types
:
return
find_containing_stack
(
inferior
,
addr
)
nptrs
=
int
(
info
[
'layout'
][
'payload'
][
'ptrs'
])
#print(ptr, i, info, nptrs)
if
int
(
info
[
'type'
])
==
closure
.
ClosureType
.
IND_STATIC
:
if
ptr
.
addr
()
-
start
.
addr
()
>
8
:
# Only trace the indirectee of IND_STATICs
return
None
elif
i
<=
nptrs
+
5
:
# A bit of fudge for the headers
return
start
else
:
print
(
'suspicious info table: too far (field=%s, info@%s=%s, nptrs=%d, i=%d)'
%
(
ptr
,
start
,
sym
,
nptrs
,
i
))
return
None
return
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment