kernel_optimize_test/scripts/gdb/linux
André Draszik d6c9708737 scripts/gdb: make lx-dmesg command work (reliably)
lx-dmesg needs access to the log_buf symbol from printk.c.
Unfortunately, the symbol log_buf also exists in BPF's verifier.c and
hence gdb can pick one or the other.  If it happens to pick BPF's
log_buf, lx-dmesg doesn't work:

  (gdb) lx-dmesg
  Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 0x0:
  Error occurred in Python command: Cannot access memory at address 0x0
  (gdb) p log_buf
  $15 = 0x0

Luckily, GDB has a way to deal with this, see
  https://sourceware.org/gdb/onlinedocs/gdb/Symbols.html

  (gdb) info variables ^log_buf$
  All variables matching regular expression "^log_buf$":

  File <linux.git>/kernel/bpf/verifier.c:
  static char *log_buf;

  File <linux.git>/kernel/printk/printk.c:
  static char *log_buf;
  (gdb) p 'verifier.c'::log_buf
  $1 = 0x0
  (gdb) p 'printk.c'::log_buf
  $2 = 0x811a6aa0 <__log_buf> ""
  (gdb) p &log_buf
  $3 = (char **) 0x8120fe40 <log_buf>
  (gdb) p &'verifier.c'::log_buf
  $4 = (char **) 0x8120fe40 <log_buf>
  (gdb) p &'printk.c'::log_buf
  $5 = (char **) 0x8048b7d0 <log_buf>

By being explicit about the location of the symbol, we can make lx-dmesg
work again.  While at it, do the same for the other symbols we need from
printk.c

Link: http://lkml.kernel.org/r/20170526112222.3414-1-git@andred.net
Signed-off-by: André Draszik <git@andred.net>
Tested-by: Kieran Bingham <kieran@bingham.xyz>
Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-02 15:07:38 -07:00
..
__init__.py scripts/gdb: add empty package initialization script 2015-02-28 09:57:51 -08:00
.gitignore scripts/gdb: add constants.py to .gitignore 2016-07-15 14:54:27 +09:00
constants.py.in Revert "scripts/gdb: add a Radix Tree Parser" 2016-07-15 14:54:27 +09:00
cpus.py scripts/gdb: cast CPU numbers to integer 2016-05-23 17:04:14 -07:00
dmesg.py scripts/gdb: make lx-dmesg command work (reliably) 2017-06-02 15:07:38 -07:00
lists.py scripts/gdb: provide kernel list item generators 2016-05-23 17:04:14 -07:00
Makefile scripts/gdb: rebuild constants.py on dependancy change 2016-07-15 14:54:27 +09:00
modules.py scripts/gdb: support !CONFIG_MODULES gracefully 2016-05-23 17:04:14 -07:00
proc.py scripts/gdb: add mount point list command 2016-05-23 17:04:14 -07:00
symbols.py scripts/gdb: Perform path expansion to lx-symbol's arguments 2016-07-15 14:54:27 +09:00
tasks.py scripts/gdb: add lx_thread_info_by_pid helper 2016-05-23 17:04:14 -07:00
utils.py scripts/gdb: improve types abstraction for gdb python scripts 2016-05-23 17:04:14 -07:00