Skip to content
Snippets Groups Projects
Commit 8416b9e5 authored by Mitchel Humpherys's avatar Mitchel Humpherys
Browse files

lrdp-v2: Introduce function to read C strings from structures

In lieu of a more generic way of reading fields from structures,
introduce another specialized structure field reader for reading C
strings.

Change-Id: I6aba392f59179fa70a065a08f19a694e87f683dd
parent e72eba9f
No related branches found
No related tags found
No related merge requests found
...@@ -1164,6 +1164,16 @@ class RamDump(): ...@@ -1164,6 +1164,16 @@ class RamDump():
field)) field))
return None return None
def read_structure_cstring(self, addr_or_name, struct_name, field,
max_length=100):
"""reads a C string from a structure field. The C string field will be
dereferenced before reading, so it should be a `char *', not a
`char []'.
"""
virt = self.resolve_virt(addr_or_name)
cstring_addr = virt + self.field_offset(struct_name, field)
return self.read_cstring(self.read_pointer(cstring_addr), max_length)
def read_cstring(self, addr_or_name, max_length, virtual=True, cpu=None): def read_cstring(self, addr_or_name, max_length, virtual=True, cpu=None):
addr = addr_or_name addr = addr_or_name
if virtual: if virtual:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment