Some question about modifying registers!

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Some question about modifying registers!

    Hi,
    I have several questions about using J-Link GDB Server. Does anyone have similar issues?

    1. I use GDB to connect to J-Link GDB Server, I can view all register values by "monitor regs".
    But "monitor reg r8 = 0x12345678" always modify the USR mode R8. How can I modify other mode registers?

    2. GDB command "info reg" always show different values of J-Link monitor "CPU Regs", why?

    3. GDB reports wrong value of CPSR, I can see another thread is asking that.

    4. When I free run a program using GDB, can I launch J-Link Commander to halt the program?
  • Hello vicsiu,

    >>1. I use GDB to connect to J-Link GDB Server, I can view all register values by "monitor regs".
    >>But "monitor reg r8 = 0x12345678" always modify the USR mode R8. How can I modify other mode registers?
    This is fixed in the latest beta version. Now r8 of the currently active mode is modified. (For R8 this means only a difference if the cor is in FIQ mode. For all other modes R8 is the same one)

    >>2. GDB command "info reg" always show different values of J-Link monitor "CPU Regs", why?
    We have checked this and it is working fine. If you modified a register the "flush regs" GDB command needs to be executed in order to synchronize the register cache of the GDB.
    Otherwise the GDB will read the register values from its internal cache.

    >>3. GDB reports wrong value of CPSR, I can see another thread is asking that.
    Also corrected in the latest beta version.

    >>4. When I free run a program using GDB, can I launch J-Link Commander to halt the program?
    You can do this but we do not recommend it since halting the CPU using JLink.exe will modify the register values and from
    there on the GDB Server will read the modified (wrong) values during the debug session.
    In order to halt a target which has been started by "c/continue" use Strg+C in the command line version of the GDB.


    The latest beta version is available for download on our website:
    segger.com/download_jlink_beta.html

    Best regards
    Alex
  • Dear Alex,

    Thanks for your replies. I have some follow up questions, please see below.

    >> >>1. I use GDB to connect to J-Link GDB Server, I can view all register values by "monitor regs".
    >> >>But "monitor reg r8 = 0x12345678" always modify the USR mode R8. How can I modify other mode registers?
    >> This is fixed in the latest beta version. Now r8 of the currently active mode is modified.
    >> (For R8 this means only a difference if the cor is in FIQ mode. For all other modes R8 is the same one)
    Vic> Thanks! But how do I modify other mode registers? E.g. Modify R14_ABT while in USR mode. Can you support command like "monitor reg r14_abt = 0x12345678"?

    >> >>2. GDB command "info reg" always show different values of J-Link monitor "CPU Regs", why?
    >> We have checked this and it is working fine. If you modified a register the "flush regs" GDB command needs to be executed in order to synchronize >> the register cache of the GDB.
    >> Otherwise the GDB will read the register values from its internal cache.
    Vic> Thank you for the explanation, I will take a try.

    >> >>3. GDB reports wrong value of CPSR, I can see another thread is asking that.
    >> Also corrected in the latest beta version.

    >> >>4. When I free run a program using GDB, can I launch J-Link Commander to halt the program?
    >> You can do this but we do not recommend it since halting the CPU using JLink.exe will modify the register values and from
    >> there on the GDB Server will read the modified (wrong) values during the debug session.
    >> In order to halt a target which has been started by "c/continue" use Strg+C in the command line version of the GDB.
    Vic> I am using yagarto insight (win32), which sometimes cannot halt the program in free run (or even source-level single step). That's the reason I want to halt the program safely and promptly.

    Thanks!
    Vic
  • Hi,

    I tried v4.09b, "monitor reg cpsr = 0x000000d3", then "monitor reg cpsr", it shows "Reading register (CPSR = 0xFFFFFFD3)".

    And "monitor regs" gives below...
    PC = 00000000, CPSR = 000000D3 (SVC mode, ARM FIQ dis. IRQ dis.)
    R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
    R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
    USR: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000
    R13=00000000, R14=00000000
    FIQ: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000
    R13=00000000, R14=00000000, SPSR=00000010
    SVC: R13=00000000, R14=00000000, SPSR=00000010
    ABT: R13=00000000, R14=00000000, SPSR=00000010
    IRQ: R13=00000000, R14=00000000, SPSR=00000010
    UND: R13=00000000, R14=00000000, SPSR=00000010

    Please help.

    Vic