0

I have an executable file I put together from an demo powerpc assembly program I whipped together.

AssemblyProgram.s

.global _Start

.text
_Start:
    addi 3, 0, 0xa
    addi 4, 0, 0xb
    addi 5, 0, 0xc
    b .

All it does is load hex a, b, c into registers 3, 4, and 5. When I go to step through it in GDB, I am trying now to set a breakpoint on the instruction b . which is located at address 0x1000012 due to the linker script placement of the instructions.

I can set the breakpoint no problem, but when try to continue I get an error. My example session is shown below:

(gdb) target sim
Connected to the simulator.
(gdb) load assem-ABCRegs-ppceabi-ex.elf 
(gdb) x /4i 0x1000000
0x1000000 <_Start>: li      r3,10
0x1000004 <_Start+4>:   li      r4,11
0x1000008 <_Start+8>:   li      r5,12
0x100000c <_Start+12>:  b       0x100000c <_Start+12>
(gdb) b *0x1000000
Breakpoint 1 at 0x1000000
(gdb) run
Starting program: /home/default/PPC-Baremetal-Base/assem-ABCRegs-ppceabi-ex.elf 

Breakpoint 1, 0x01000000 in _Start ()
(gdb) si
0x01000004 in _Start ()
(gdb) b *0x1000012
Breakpoint 2 at 0x1000012
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 2.
Cannot access memory at address 0x1000012

(gdb) si
Warning:
Cannot insert breakpoint 2.
Cannot access memory at address 0x1000012

(gdb) d 2
(gdb) si
0x01000008 in _Start ()
(gdb) si
0x0100000c in _Start ()
(gdb) 

This is a trivial program, but it is just a learning program. I want to be able to set a breakpoint on a real program and continue (not step) through the execution until my breakpoint is hit if ever. Is this possible if I am not able to recompile?

EDIT:

The above test run tries to set a breakpoint at the wrong locations (in the middle of an instruction. Below is a proper run.

(gdb) target sim
Connected to the simulator.
(gdb) load assem-ABCRegs-ppceabi-ex.elf
(gdb) b *0x1000008
Breakpoint 1 at 0x1000008
(gdb) c
Starting program: /home/default/PPC-Baremetal-Base/assem-ABCRegs-ppceabi-ex.elf 

0x1000000 in _Start ()
0

Yes, you are able to debug programs without sources with gdb. You don;t need to recompile.

The potential problem source is in miscalculation of breakpoint address: address of your branch instruction is 0x100000c and not 0x1000012. This may explain why you can not set a breakpoint: there is no any instruction in a place where you are trying to put a breakpoint.

  • I see the error in my test I posted here, but I swear I did it on a valid break point address and still got the error. I am going to test and report back. – MrJman006 Oct 1 '15 at 15:33
  • Actually I figured out what was happening. You were right it was a mis-calculation on the break. What I get confused by now is, when I do this same process but with remote target instead of sim (i.e. through a QEMU boot up with -S -s options) It throws the error when I am about to leave the bios flash area and start executing kernel assembly instructions. Any idea on why that would be happening? – MrJman006 Oct 1 '15 at 18:34
  • @MrJman006 I'd suggest you to post it as another question. – w s Oct 2 '15 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.