[Crash-utility] [PATCH 1/2] symbols: expand kernel modules symtable before symbols translation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The kernel modules symbol translation may change after a c expression
evaluation.

without patch:
crash> mod -S
crash> struct blk_mq_ops 0xffffffffc00a7160
struct blk_mq_ops {
  queue_rq = 0xffffffffc00a45b0 <virtio_queue_rq>, <--symbol translated from kernel
  map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
  ...snip...
  complete = 0xffffffffc00a4370 <virtblk_request_done>,
  init_request = 0xffffffffc00a4260 <virtblk_init_request>,
  ...snip...
}
crash> px ((struct request *)0xffff880fdb246000)->q->mq_ops
$1 = (struct blk_mq_ops *) 0xffffffffc00a7160 <virtio_mq_ops>
crash> struct blk_mq_ops 0xffffffffc00a7160
struct blk_mq_ops {
  queue_rq = 0xffffffffc00a45b0 <floppy_module_init+1151>, <--symbol translated from module
  map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
  ...snip...
  complete = 0xffffffffc00a4370 <floppy_module_init+575>,
  init_request = 0xffffffffc00a4260 <floppy_module_init+303>,
  ...snip...
}

with patch:
crash> mod -S
crash> struct blk_mq_ops 0xffffffffc00a7160
struct blk_mq_ops {
  queue_rq = 0xffffffffc00a45b0 <floppy_module_init+1151>, <--symbol translated from module
  map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
  ...snip...
  complete = 0xffffffffc00a4370 <floppy_module_init+575>,
  init_request = 0xffffffffc00a4260 <floppy_module_init+303>,
  ..snip...
}
crash> px ((struct request *)0xffff880fdb246000)->q->mq_ops
$1 = (struct blk_mq_ops *) 0xffffffffc00a7160 <virtio_mq_ops>
crash> struct blk_mq_ops 0xffffffffc00a7160
struct blk_mq_ops {
  queue_rq = 0xffffffffc00a45b0 <floppy_module_init+1151>, <--symbol translated from module
  map_queue = 0xffffffff813015c0 <blk_mq_map_queue>,
  ...snip...
  complete = 0xffffffffc00a4370 <floppy_module_init+575>,
  init_request = 0xffffffffc00a4260 <floppy_module_init+303>,
  ...snip...
}

The root cause for the changing of symbol translation is, after "mod -S", the
kernel modules files "*.ko.debug" will be loaded. However the compile unit
symtable of the kernel modules may not get expanded. As a result, the symtable
of kernel modules, or obj_file->compunit_symtabs is nullptr, which don't take
any effect for gdb symbol translation, it is unexpected. A c expression
evaluation will trigger such an expansion.

This patch will make sure symtable always get expanded before gdb symbol
translation.

Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
---
 gdb-10.2.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index d81030d..31135ca 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -3187,3 +3187,20 @@ exit 0
        result = stringtab + symbol_entry->_n._n_n._n_offset;
      }
    else
+--- gdb-10.2/gdb/symtab.c.orig
++++ gdb-10.2/gdb/symtab.c
+@@ -2931,6 +2931,14 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
+ 
+   for (objfile *obj_file : current_program_space->objfiles ())
+     {
++#ifdef CRASH_MERGE
++      std::string objfile_name = objfile_filename(obj_file);
++
++      if (objfile_name.find(".ko") != std::string::npos) {
++          if (obj_file->sf && obj_file->compunit_symtabs == nullptr)
++              obj_file->sf->qf->expand_all_symtabs(obj_file);
++      }
++#endif
+       for (compunit_symtab *cust : obj_file->compunits ())
+ 	{
+ 	  const struct block *b;
\ No newline at end of file
-- 
2.40.1
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux