質問

I am attempting to write a gdb function that loops until the passed parameter equals the program counter.

I am working with a primitive CPU, 68332. No hardware breakpoints. No OS that supports GDB software breakpoints, just a single instruction step. GDB provides the 'software' emulation of 'nexti count'. The JTAG provides a run to address.

However, the JTAG, for some reason, overwhelms the CPU when used to run to address, and I get bus errors. I can only seem to reliably use 'step' single instruction.

If I use GDB to 'step' to the address, I don't get bus errors.

Below is my attempt at such a GDB function.

define mtia
    if $argc == 1 then
    set $address = *(unsigned char*)$arg0
    while($address != $pc)
      nexti
    end
end

I just can't seem to get the syntax correct to be able to get GDB to accept and run the function.

What is the correct syntax?

役に立ちましたか?

解決

The correct syntax for the GDB command function above is

define mtia
    if $argc == 1 then
    set $address = (unsigned char*)$arg0
    while($address != $pc)
      nexti
    end
end

I had an asterisk in front of (unsigned char*). This removed the pointer type. This caused a syntax error with $address != $pc as $pc is considered a pointer.

This function performs a single assembly instruction step, until the address passed into the function is reached. Slow, but on the old M68332 CPU, this is all I have.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top