Skip to content

GDB fails with "Assertion `SYMBOL_OBJFILE_OWNED (symbol)' failed." when step debugging the Linux kernel in gem5 #88

Open
@cirosantilli

Description

@cirosantilli

Start with lkmc f7734ae which has binutils-gdb 1690de78a3603a3a0ab8487ef896e75871bb0737

Then udpate gem5 to fe15312aae8007967812350f8cdac9ad766dcff7 and hack it to make linux use the memory mapped timer:

-    def generateDeviceTree(self, state):
-        node = FdtNode("timer")
-
-        node.appendCompatible(["arm,cortex-a15-timer",
-                               "arm,armv7-timer",
-                               "arm,armv8-timer"])
-        node.append(FdtPropertyWords("interrupts", [
-            1, int(self.int_phys_s.num) - 16, 0xf08,
-            1, int(self.int_phys_ns.num) - 16, 0xf08,
-            1, int(self.int_virt.num) - 16, 0xf08,
-            1, int(self.int_hyp.num) - 16, 0xf08,
-        ]))
-        clock = state.phandle(self.clk_domain.unproxy(self))
-        node.append(FdtPropertyWords("clocks", clock))
-
-        yield node
+    #def generateDeviceTree(self, state):
+    #    node = FdtNode("timer")
+
+    #    node.appendCompatible(["arm,cortex-a15-timer",
+    #                           "arm,armv7-timer",
+    #                           "arm,armv8-timer"])
+    #    node.append(FdtPropertyWords("interrupts", [
+    #        1, int(self.int_phys_s.num) - 16, 0xf08,
+    #        1, int(self.int_phys_ns.num) - 16, 0xf08,
+    #        1, int(self.int_virt.num) - 16, 0xf08,
+    #        1, int(self.int_hyp.num) - 16, 0xf08,
+    #    ]))
+    #    clock = state.phandle(self.clk_domain.unproxy(self))
+    #    node.append(FdtPropertyWords("clocks", clock))
+
+    #    yield node
 
 class GenericTimerMem(PioDevice):
     type = 'GenericTimerMem'
@@ -428,6 +428,24 @@ class GenericTimerMem(PioDevice):
     int_phys = Param.ArmSPI("Physical Interrupt")
     int_virt = Param.ArmSPI("Virtual Interrupt")
 
+    def generateDeviceTree(self, state):
+        node = FdtNode("timer")
+        node = self.generateBasicPioDeviceNode(
+            state,
+            'timer',
+            self.base,
+            0x30000,
+            [
+                int(self.int_phys.num),
+                int(self.int_virt.num)
+            ]
+
+        )
+        node.appendCompatible(["arm,armv7-timer-mem"])
+        clock = state.phandle(self.clk_domain.unproxy(self))
+        node.append(FdtPropertyWords("clocks", clock))
+        yield node

then run:

./run --gdb-wait --tmux --tmux-program gdb --tmux-args arch_timer_mem_find_best_frame -aA -eg --gem5-worktree master

We are left at the calling point and not inside the function as expected:

frame = arch_timer_mem_find_best_frame(timer_mem);

Then in GDB just do a step:

s

and we get:

symtab.c:6025: internal-error: symtab* symbol_symtab(const symbol*): Assertion `SYMBOL_OBJFILE_OWNED (symbol)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

This is a bug, please report it.  For instructions, see:
<http://www.gnu.org/software/gdb/bugs/>.

Traceback (most recent call last):
  File "/work/linux-kernel-module-cheat/run-gdb", line 258, in <module>
    Main().cli()
  File "/work/linux-kernel-module-cheat/cli_function.py", line 267, in cli
    exit_status = self.cli_noexit(*args, **kwargs)
  File "/work/linux-kernel-module-cheat/cli_function.py", line 258, in cli_noexit
    return self._do_main(vars(args))
  File "/work/linux-kernel-module-cheat/cli_function.py", line 152, in _do_main
    return self.main(**self._get_args(kwargs))
  File "/work/linux-kernel-module-cheat/common.py", line 1289, in main
    ret = self.timed_main()
  File "/work/linux-kernel-module-cheat/run-gdb", line 254, in timed_main
    cwd=self.env['linux_build_dir']
  File "/work/linux-kernel-module-cheat/shell_helpers.py", line 403, in run_cmd
    raise e
Exception: Command exited with status: -6

The GDB CLI generated by LKMC is:

/work/linux-kernel-module-cheat/out/buildroot/build/default/aarch64/host/usr/bin/aarch64-buildroot-linux-gnu-gdb \
  -ex 'add-auto-load-safe-path /work/linux-kernel-module-cheat/out/linux/default/aarch64' \
  -ex 'file /work/linux-kernel-module-cheat/out/linux/default/aarch64/vmlinux' \
  -ex 'target remote localhost:7000' \
  -ex 'break arch_timer_mem_find_best_frame' \
  -ex continue \
  -ex 'lx-symbols /work/linux-kernel-module-cheat/out/kernel_modules/aarch64/kernel_modules' \
;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions