mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
Sane printk changes for 5.20
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEESH4wyp42V4tXvYsjUqAMR0iAlPIFAmLrn3IACgkQUqAMR0iA lPK7pBAAkcfykKgtRxvE65q06GsClGJMVM6wDe0iG0m71gRItz46Yly5HbuwaAwx 6DEQOlMnndjr8syznl/SoiIiAQcDGjzG8ZVcYw6JH4um03mk6uQw6YuKwxO8kieC 2/ZdFOVsHfui6lVXGxizi8UzT+oemXax5JsukOD5MsEOPAv+rw6vg5hrSiIFoQaO /nU8BeulfuZrnhz47xiNNxQWi7J3F0JVF4NlwK+avOhVw7kUgZcmsojQHopvQOxU e2HuByZ/9TkbNoQX/0ZX8aZ75XbebCfX9o39J4bLAUe4eqzOHDTEKg29BoXogSk4 NVjNVuVljmwcExox70Esst8Ckir2/DE7I5nKZ0/G+9JNoHKoHaG3rkZ3hqf5Q/Vh eahwRxab/NguUAZawk3NWpZ6B6dql8H6G+UhG0nsSTbUCLy5o02ynfai52TIhzb1 EPFVRSBWefiPHFtC86yyXE/3iZvgpJk72jXoVLEvBXHAGxkAD3UbaV+5PgYgFwNh TZO9u7tEe6Z67Cs3GZ7YfYPraULh5JmRkFgZMs04ycBRO9oQWdlaaR/UzZJ/P1TF IY8sYXDBFLeXGtDB65UMPlHymDm3Bcu0C7YSPa1rxuqlmsmDvYY/nxnDC/TOPYnp /jeRuoZ2IpuUL2XIHmIZQ6v8mYTetFkQMqC9qxZSCw3wqjW6Mwk= =PJYM -----END PGP SIGNATURE----- Merge tag 'printk-for-5.20-sane' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux Pull printk updates from Petr Mladek: - Allow reading kernel log in gdb even on 32 bits systems - More granular check of the buffer usage in printf selftest - Clang warning fix * tag 'printk-for-5.20-sane' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux: lib/test_printf.c: fix clang -Wformat warnings scripts/gdb: fix 'lx-dmesg' on 32 bits arch lib/test_printf.c: split write-beyond-buffer check in two
This commit is contained in:
commit
a1b02751d6
3 changed files with 32 additions and 12 deletions
|
@ -22,7 +22,6 @@ prb_desc_type = utils.CachedType("struct prb_desc")
|
|||
prb_desc_ring_type = utils.CachedType("struct prb_desc_ring")
|
||||
prb_data_ring_type = utils.CachedType("struct prb_data_ring")
|
||||
printk_ringbuffer_type = utils.CachedType("struct printk_ringbuffer")
|
||||
atomic_long_type = utils.CachedType("atomic_long_t")
|
||||
|
||||
class LxDmesg(gdb.Command):
|
||||
"""Print Linux kernel log buffer."""
|
||||
|
@ -68,8 +67,6 @@ class LxDmesg(gdb.Command):
|
|||
off = prb_data_ring_type.get_type()['data'].bitpos // 8
|
||||
text_data_addr = utils.read_ulong(text_data_ring, off)
|
||||
|
||||
counter_off = atomic_long_type.get_type()['counter'].bitpos // 8
|
||||
|
||||
sv_off = prb_desc_type.get_type()['state_var'].bitpos // 8
|
||||
|
||||
off = prb_desc_type.get_type()['text_blk_lpos'].bitpos // 8
|
||||
|
@ -89,9 +86,9 @@ class LxDmesg(gdb.Command):
|
|||
|
||||
# read in tail and head descriptor ids
|
||||
off = prb_desc_ring_type.get_type()['tail_id'].bitpos // 8
|
||||
tail_id = utils.read_u64(desc_ring, off + counter_off)
|
||||
tail_id = utils.read_atomic_long(desc_ring, off)
|
||||
off = prb_desc_ring_type.get_type()['head_id'].bitpos // 8
|
||||
head_id = utils.read_u64(desc_ring, off + counter_off)
|
||||
head_id = utils.read_atomic_long(desc_ring, off)
|
||||
|
||||
did = tail_id
|
||||
while True:
|
||||
|
@ -102,7 +99,7 @@ class LxDmesg(gdb.Command):
|
|||
desc = utils.read_memoryview(inf, desc_addr + desc_off, desc_sz).tobytes()
|
||||
|
||||
# skip non-committed record
|
||||
state = 3 & (utils.read_u64(desc, sv_off + counter_off) >> desc_flags_shift)
|
||||
state = 3 & (utils.read_atomic_long(desc, sv_off) >> desc_flags_shift)
|
||||
if state != desc_committed and state != desc_finalized:
|
||||
if did == head_id:
|
||||
break
|
||||
|
|
|
@ -35,13 +35,12 @@ class CachedType:
|
|||
|
||||
|
||||
long_type = CachedType("long")
|
||||
|
||||
atomic_long_type = CachedType("atomic_long_t")
|
||||
|
||||
def get_long_type():
|
||||
global long_type
|
||||
return long_type.get_type()
|
||||
|
||||
|
||||
def offset_of(typeobj, field):
|
||||
element = gdb.Value(0).cast(typeobj)
|
||||
return int(str(element[field].address).split()[0], 16)
|
||||
|
@ -129,6 +128,17 @@ def read_ulong(buffer, offset):
|
|||
else:
|
||||
return read_u32(buffer, offset)
|
||||
|
||||
atomic_long_counter_offset = atomic_long_type.get_type()['counter'].bitpos
|
||||
atomic_long_counter_sizeof = atomic_long_type.get_type()['counter'].type.sizeof
|
||||
|
||||
def read_atomic_long(buffer, offset):
|
||||
global atomic_long_counter_offset
|
||||
global atomic_long_counter_sizeof
|
||||
|
||||
if atomic_long_counter_sizeof == 8:
|
||||
return read_u64(buffer, offset + atomic_long_counter_offset)
|
||||
else:
|
||||
return read_u32(buffer, offset + atomic_long_counter_offset)
|
||||
|
||||
target_arch = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue