Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
c2d393df
Commit
c2d393df
authored
12 years ago
by
Frans Kaashoek
Browse files
Options
Downloads
Patches
Plain Diff
Decode getcallerpcs() (thanks to Peter Froehlich)
parent
95692c4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
depcs
+48
-0
48 additions, 0 deletions
depcs
with
48 additions
and
0 deletions
depcs
0 → 100644
+
48
−
0
View file @
c2d393df
#!/usr/bin/env python
# Decode a stack trace from getcallerpcs() to kernel symbols.
# Peter H. Froehlich <phf@acm.org>, 600.318/418, Spring 2011
#
# $ ./depcs 1072fa 1073c4 106d4a 103024 102fdd 0 0 0 0 0
# 1078010 ['mappages']
# 1078212 ['setupkvm']
# 1076554 ['kvmalloc']
# 1060900 ['mainc']
# 1060829 ['jmpkstack']
import
sys
# read the symbols, mapping each address to all known names
raw
=
{}
with
open
(
"
kernel.sym
"
)
as
f
:
for
s
in
f
:
adr
,
sym
=
s
.
strip
().
split
()
adr
=
int
(
adr
,
16
)
if
adr
in
raw
:
raw
[
adr
].
append
(
sym
)
else
:
raw
[
adr
]
=
[
sym
]
# for a given address, we need to determine what range it
# lies in; there are fancy data structures or this, which
# we ignore; let's just sort the keys instead
sort
=
sorted
(
raw
.
keys
())
# now we can find the least key greater than an address;
# if there's none, we use the last address we know; doh!
def
least
(
x
):
for
i
in
range
(
len
(
sort
)
-
1
):
if
sort
[
i
]
<=
x
<
sort
[
i
+
1
]:
return
sort
[
i
]
return
sort
[
-
1
]
# therefore we can decode a backtrace (ignoring address
# 0 since it's useless for xv6)
for
adr
in
sys
.
argv
[
1
:]:
adr
=
int
(
adr
,
16
)
if
adr
!=
0
:
print
adr
,
raw
[
least
(
adr
)]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment