Skip to content

Commit

Permalink
scripts/gdb: fix issue with dmesg.py and python 3.X
Browse files Browse the repository at this point in the history
When built against Python 3, GDB differs in the return type for its
read_memory function, causing the lx-dmesg command to fail.

Now that we have an improved read_16() we can use the new
read_memoryview() abstraction to make lx-dmesg return valid data on both
current Python APIs

Tested with python 3.4 and 2.7
Tested with gdb 7.7

Link: http://lkml.kernel.org/r/28477b727ff7fe3101fd4e426060e8a68317a639.1462865983.git.jan.kiszka@siemens.com
Signed-off-by: Dom Cote <[email protected]>
[[email protected]: Adjusted commit log to better reflect code changes]
Tested-by: Kieran Bingham <[email protected]> (Py2.7,Py3.4,GDB10)
Signed-off-by: Kieran Bingham <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Dom Cote authored and torvalds committed May 24, 2016
1 parent 321958d commit d21d5b9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/gdb/linux/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ def invoke(self, arg, from_tty):
if log_first_idx < log_next_idx:
log_buf_2nd_half = -1
length = log_next_idx - log_first_idx
log_buf = inf.read_memory(start, length)
log_buf = utils.read_memoryview(inf, start, length).tobytes()
else:
log_buf_2nd_half = log_buf_len - log_first_idx
log_buf = inf.read_memory(start, log_buf_2nd_half) + \
inf.read_memory(log_buf_addr, log_next_idx)
a = utils.read_memoryview(inf, start, log_buf_2nd_half)
b = utils.read_memoryview(inf, log_buf_addr, log_next_idx)
log_buf = a.tobytes() + b.tobytes()

pos = 0
while pos < log_buf.__len__():
Expand Down

0 comments on commit d21d5b9

Please sign in to comment.