diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/examples/python/file_extract.py | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2 |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/examples/python/file_extract.py')
-rwxr-xr-x | lldb/examples/python/file_extract.py | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/lldb/examples/python/file_extract.py b/lldb/examples/python/file_extract.py index 3afc0c3..7a617e9 100755 --- a/lldb/examples/python/file_extract.py +++ b/lldb/examples/python/file_extract.py @@ -4,16 +4,17 @@ import string import struct import sys + class FileExtract: '''Decode binary data from a file''' - - def __init__(self, f, b = '='): + + def __init__(self, f, b='='): '''Initialize with an open binary file and optional byte order''' - + self.file = f self.byte_order = b self.offsets = list() - + def set_byte_order(self, b): '''Set the byte order, valid values are "big", "little", "swap", "native", "<", ">", "@", "="''' if b == 'big': @@ -32,18 +33,18 @@ class FileExtract: def is_in_memory(self): return False - - def seek(self, offset, whence = 0): + + def seek(self, offset, whence=0): if self.file: return self.file.seek(offset, whence) - raise ValueError + raise ValueError def tell(self): if self.file: return self.file.tell() - raise ValueError - - def read_size (self, byte_size): + raise ValueError + + def read_size(self, byte_size): s = self.file.read(byte_size) if len(s) != byte_size: return None @@ -53,12 +54,12 @@ class FileExtract: '''Push the current file offset and seek to "offset"''' self.offsets.append(self.file.tell()) self.file.seek(offset, 0) - + def pop_offset_and_seek(self): '''Pop a previously pushed file offset, or do nothing if there were no previously pushed offsets''' if len(self.offsets) > 0: self.file.seek(self.offsets.pop()) - + def get_sint8(self, fail_value=0): '''Extract a single int8_t from the binary file at the current file position, returns a single integer''' s = self.read_size(1) @@ -112,7 +113,7 @@ class FileExtract: return v else: return fail_value - + def get_sint64(self, fail_value=0): '''Extract a single int64_t from the binary file at the current file position, returns a single integer''' s = self.read_size(8) @@ -131,7 +132,11 @@ class FileExtract: else: return fail_value - def get_fixed_length_c_string(self, n, fail_value='', isprint_only_with_space_padding=False): + def get_fixed_length_c_string( + self, + n, + fail_value='', + isprint_only_with_space_padding=False): '''Extract a single fixed length C string from the binary file at the current file position, returns a single C string''' s = self.read_size(n) if s: @@ -174,7 +179,7 @@ class FileExtract: def get_n_sint16(self, n, fail_value=0): '''Extract "n" int16_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(2*n) + s = self.read_size(2 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'h', s) else: @@ -182,7 +187,7 @@ class FileExtract: def get_n_uint16(self, n, fail_value=0): '''Extract "n" uint16_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(2*n) + s = self.read_size(2 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'H', s) else: @@ -190,7 +195,7 @@ class FileExtract: def get_n_sint32(self, n, fail_value=0): '''Extract "n" int32_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(4*n) + s = self.read_size(4 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'i', s) else: @@ -198,7 +203,7 @@ class FileExtract: def get_n_uint32(self, n, fail_value=0): '''Extract "n" uint32_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(4*n) + s = self.read_size(4 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'I', s) else: @@ -206,7 +211,7 @@ class FileExtract: def get_n_sint64(self, n, fail_value=0): '''Extract "n" int64_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(8*n) + s = self.read_size(8 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'q', s) else: @@ -214,7 +219,7 @@ class FileExtract: def get_n_uint64(self, n, fail_value=0): '''Extract "n" uint64_t integers from the binary file at the current file position, returns a list of integers''' - s = self.read_size(8*n) + s = self.read_size(8 * n) if s: return struct.unpack(self.byte_order + ("%u" % n) + 'Q', s) else: |