Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
CodeLinaro
public-release-test-restored
platform
vendor
qcom-opensource
tools
Commits
104ad209
Commit
104ad209
authored
10 years ago
by
Linux Build Service Account
Committed by
Gerrit - the friendly Code Review server
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "lrdp-v2: add hexdump functions"
parents
2728c61b
97cff249
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
linux-ramdump-parser-v2/parser_util.py
+46
-1
46 additions, 1 deletion
linux-ramdump-parser-v2/parser_util.py
linux-ramdump-parser-v2/ramdump.py
+14
-2
14 additions, 2 deletions
linux-ramdump-parser-v2/ramdump.py
with
60 additions
and
3 deletions
linux-ramdump-parser-v2/parser_util.py
+
46
−
1
View file @
104ad209
# Copyright (c) 2013, The Linux Foundation. All rights reserved.
# Copyright (c) 2013
-2014
, The Linux Foundation. All rights reserved.
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 and
# it under the terms of the GNU General Public License version 2 and
...
@@ -14,6 +14,7 @@ import platform
...
@@ -14,6 +14,7 @@ import platform
import
glob
import
glob
import
re
import
re
import
string
import
string
import
sys
_parsers
=
[]
_parsers
=
[]
...
@@ -160,3 +161,47 @@ def get_system_type():
...
@@ -160,3 +161,47 @@ def get_system_type():
return
'
Linux
'
return
'
Linux
'
if
plat
==
'
Darwin
'
:
if
plat
==
'
Darwin
'
:
return
'
Darwin
'
return
'
Darwin
'
def
_get_printable
(
n
,
fillchar
=
'
.
'
):
if
n
is
None
:
return
c
=
chr
(
n
)
if
c
in
string
.
printable
[:
string
.
printable
.
index
(
'
'
)
+
1
]:
return
c
return
fillchar
def
_xxd_line
(
addr
,
data
):
printable
=
[
_get_printable
(
d
)
for
d
in
data
]
data
=
[
'
{:02x}
'
.
format
(
d
)
for
d
in
data
]
printable
+=
[
'
'
]
*
(
16
-
len
(
printable
))
data
+=
[
'
'
]
*
(
16
-
len
(
data
))
return
"
{:08x}: {:}{:} {:}{:} {:}{:} {:}{:} {:}{:} {:}{:} {:}{:} {:}{:} {:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}{:}
\n
"
.
format
(
addr
,
*
(
data
+
printable
)
)
def
xxd
(
address
,
data
,
file_object
=
None
):
"""
Dumps data to stdout, in the format of `xxd
'
. data should be a list
of integers.
>>>
xxd
(
0x1000
,
[
0xde
,
0xad
,
0xbe
,
0xef
,
112
,
105
,
122
,
122
,
97
,
0
,
0
,
42
,
43
,
44
,
45
,
90
])
00001000
:
dead
beef
7069
7
a7a
6100
002
a
2
b2c
2
d5a
....
pizza
..
*+
,
-
Z
"""
f
=
file_object
or
sys
.
stdout
bb
=
[]
n
=
0
for
i
in
data
:
bb
.
append
(
i
)
if
n
==
15
:
f
.
write
(
_xxd_line
(
address
,
bb
))
bb
=
[]
n
=
0
address
+=
16
else
:
n
+=
1
if
len
(
bb
):
f
.
write
(
_xxd_line
(
address
,
bb
))
if
__name__
==
"
__main__
"
:
import
doctest
doctest
.
testmod
()
This diff is collapsed.
Click to expand it.
linux-ramdump-parser-v2/ramdump.py
+
14
−
2
View file @
104ad209
...
@@ -22,7 +22,7 @@ from tempfile import NamedTemporaryFile
...
@@ -22,7 +22,7 @@ from tempfile import NamedTemporaryFile
import
gdbmi
import
gdbmi
from
print_out
import
print_out_str
from
print_out
import
print_out_str
from
mmu
import
Armv7MMU
,
Armv7LPAEMMU
,
Armv8MMU
from
mmu
import
Armv7MMU
,
Armv7LPAEMMU
,
Armv8MMU
from
parser_util
import
cleanupString
import
parser_util
FP
=
11
FP
=
11
SP
=
13
SP
=
13
...
@@ -975,7 +975,7 @@ class RamDump():
...
@@ -975,7 +975,7 @@ class RamDump():
ebi
[
0
].
seek
(
offset
)
ebi
[
0
].
seek
(
offset
)
a
=
ebi
[
0
].
read
(
length
)
a
=
ebi
[
0
].
read
(
length
)
if
trace
:
if
trace
:
print_out_str
(
'
result = {0}
'
.
format
(
cleanupString
(
a
)))
print_out_str
(
'
result = {0}
'
.
format
(
parser_util
.
cleanupString
(
a
)))
print_out_str
(
'
lenght = {0}
'
.
format
(
len
(
a
)))
print_out_str
(
'
lenght = {0}
'
.
format
(
len
(
a
)))
return
a
return
a
...
@@ -1089,6 +1089,18 @@ class RamDump():
...
@@ -1089,6 +1089,18 @@ class RamDump():
return
None
return
None
return
struct
.
unpack
(
format_string
,
s
)
return
struct
.
unpack
(
format_string
,
s
)
def
hexdump
(
self
,
address
,
length
,
virtual
=
True
,
file_object
=
None
):
"""
Does a hexdump (in the format of `xxd
'
). `length
'
is in bytes. If
given, will write to `file_object
'
, otherwise will write to
stdout.
"""
parser_util
.
xxd
(
address
,
[
self
.
read_byte
(
address
+
i
,
virtual
=
virtual
)
or
0
for
i
in
xrange
(
length
)],
file_object
=
file_object
)
def
per_cpu_offset
(
self
,
cpu
):
def
per_cpu_offset
(
self
,
cpu
):
per_cpu_offset_addr
=
self
.
addr_lookup
(
'
__per_cpu_offset
'
)
per_cpu_offset_addr
=
self
.
addr_lookup
(
'
__per_cpu_offset
'
)
if
per_cpu_offset_addr
is
None
:
if
per_cpu_offset_addr
is
None
:
...
...
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