Skip to content

Tips and Tricks for Troubleshooting

Cupertino Miranda edited this page Nov 18, 2020 · 1 revision

Table of Contents

Debugging the guest

Run QEMU with its gdbstub: qemu-system-arc ... -S -s ...

  • -S: Do not start CPU at startup!
  • -s: Shorthand for -gdb tcp::1234 (open a gdbserver on TCP port 1234).

Then run GDB as: arc-elf32-gdb ... -ex 'target remote :1234' ...

Evaluating registers in GDB

Most of the registers are listed by info registers in GDB. However, there is a bunch of them that you must know their name to evaluate them (or you can use info registers all to enlist them all, but beware of this bug):

mpu_build
mpuen
mpurdb0 ... mpurdb15
mpurdp0 ... mpurdp15

If you really want to know which registers are supported, then look into qemu/gdb-xml/arc-*.xml.

Logging of sub-systems in QEMU

By passing the -d flag to QEMU and specifying one or more of the items below, you can see detailed logging about them.

  • int: Interrupts and exceptions related
  • mmu: MMU and MPU related
  • in_asm: Prints the guest instructions that are being executed. By default, these instructions are printed in (basic) blocks. That should give you a good idea what is being done, but if you want instructions to be reported one at a time, append -singlestep to QEMU flags.
  • help: Will print all sub-systems that you can use with -d.

You can use , to combine the items, e.g. qemu-system-arc .. -d int,in_asm,mmu ....

An example run of QEMU with MPU

qemu-system-arc -M arc-sim -m 128M -nographic -no-reboot -monitor none -serial stdio \
                -d mmu,int -singlestep -global cpu.mpu-numreg=8 -kernel check_mpu.elf

...
[MPU] ,--------.-------.------------.--------.-----------------------.--------------.------------.
[MPU] | region | valid |  address   |  size  |   effective address   | kernel perm. | user perm. |
[MPU] |--------+-------+------------+--------+-----------------------+--------------+------------|
[MPU] |   00   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   01   | true  | 0x00004000 |  32  B | 0x00004000-0x00004020 |     r--      |    ---     |
[MPU] |   02   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   03   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   04   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   05   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   06   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |   07   | false | 0x00000000 |   0  B | 0x00000000-0x00000000 |     ---      |    ---     |
[MPU] |  def.  |       |            |        |                       |     ---      |    rwx     |
[MPU] `--------^-------^------------^--------^-----------------------^--------------^------------'
[MPU] looking up: addr=0x0000030e
[MPU] default region will be used.
[MPU] TLB update: addr=0x0000030e, prot=rwx, mmu_idx=0, page_size=8192
[MPU] looking up: addr=0x00004000
[MPU] region match: region=1, base=0x00004000
[MPU] TLB update: addr=0x00004000, prot=r--, mmu_idx=0, page_size=1
...
[EXCP] exception 6 (Protection Violation) at pc=0x0000045c
[EXCP] isr=0x134 vec=0x18 ecr=0x00060204
[EXCP] RTIE @0x00000552 ECR:0x00060204
...

Tracing

Please visit the dedicated page for that.

Clone this wiki locally