[Bug tdep/25211] New: m68hc11 sim fails to remap registers when writing INIT

f4grx+bzsw at f4grx dot net sourceware-bugzilla@sourceware.org
Thu Nov 21 09:47:00 GMT 2019


            Bug ID: 25211
           Summary: m68hc11 sim fails to remap registers when writing INIT
           Product: gdb
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tdep
          Assignee: unassigned at sourceware dot org
          Reporter: f4grx+bzsw at f4grx dot net
  Target Milestone: ---


I am using gdb-8.3.1 built with --target=m68hc11-elf

My code is pure hand written assembly with no frame pointer.

The first opcodes of my program are remapping the HC11 registers to address
zero (instead of hardware default 0x1000) using the following hc11 opcodes:

.equ INIT 0x3D
ldaa #0
staa INIT+0x1000

Resulting in valid machine code:

b7 10 3d

This works in a real hc11.

However, m68hc11-elf-run produces the following result:

$ m68hc11-elf-run monitor.elf
/m68hc11: hw_attach_address: no parent attach method
program stopped with signal 6 (Aborted).

The output in m68hc11-elf-gdb with target sim is identical.

I recompiled gdb with -O0 and -g and managed to trace the issue to the function
m68hc11cpu_io_write in file sim/m68hc11/dv-m68hc11.c

at line 1032, the function hw_detach_address is called with first parameter
hw_parent(me). Same at line 1038, hw_attach_address is called with the same
first parameter.

I have noticed that my program runs when I replace this first parameter by me
instead of hw_parent(me).

After making this change, my program is perfectly simulated. Single step does
not seem to work correctly but that's another issue, and direct execution

So here is a trivial patch that fixes this bug:

diff -r gdb-8.3.1/sim/m68hc11/dv-m68hc11.c
<             hw_detach_address (hw_parent (me), M6811_IO_LEVEL,
>             hw_detach_address (me, M6811_IO_LEVEL,
<             hw_attach_address (hw_parent (me), M6811_IO_LEVEL,
>             hw_attach_address (me, M6811_IO_LEVEL,

Could that be confirmed and fixed in the next version of gdb?

Sorry if my report is unusual, this is the first time I'm doing this.

Thank you.

You are receiving this mail because:
You are on the CC list for the bug.

More information about the Gdb-prs mailing list