Shop OBEX P1 Docs P2 Docs Learn Events
Debug Questions — Parallax Forums

Debug Questions

SuracSurac Posts: 176
edited 2020-09-22 06:45 in Propeller 2
In the "good old days" i had a monitor program on my z80 and 6502 machines that let me run program in singe step and have a look at memory, registers and flags.

So now i have a P2:

can a monitor program running in one cog access the cogram or lutram of an other cog?
is there a way to singlestep a program without code instrumentation? or place a breakpoint into the code if it is in cogram/hubram?
an we save the two falgs and restore them later?

Comments

  • So no monitor program on P2?
  • cgraceycgracey Posts: 14,155
    Sorry, I didn't see this earlier.

    It is possible to do what you are talking about, but you would need to read the debug-interrupt documentation and implement some debugger.

    In the future, we will have this automated, but for now, you need to cook up your own solution.

    OzPropDev does have a single-stepping debugger, but he needs to document and post it, in order for everyone to be able to use it.

  • Well there is the monitor in ROM @Cluso99 wrote.

    It does display HUB/LUT/COG ram, and can read files from SD. You can call it from your program by jmp-ing into the ROM.

    There is a thread on the forum explaining how to use it. Does not support single stepping as far as I followed.

    Enjoy!

    Mike
  • Cluso99Cluso99 Posts: 18,069
    Here is a link to the ROM Serial/Monitor/Debugger thread...

    forums.parallax.com/discussion/170638/p2-rom-monitor-debugger-rev-1-rev-2-silicon

    It is both a set of "callable" routines, and has a "monitor" call too, as well as being able to go straight to the "monitor" after power-up by a simple serial command.

    And there is this thread too...

    https://forums.parallax.com/discussion/168502/p2-rom-booter-serial-flash-sd-card-monitor-and-taqoz-features-and-operation/p1
  • Sorry guys
    I'm hoping to get my debugger stuff wrapped up this weekend so I can post it next week.
    Here's a capture of some simple demo code and how the debugger is invoked.
    'Demo_01
    
    con
            _clkfreq = 180_000_000
            baud = 460_800
            rx = 34 '63
            tx = 36 '62
    
            #0,halted,run
    
    obj
    
    zdebug:  "P2_Debug_3.0.66"
    
    pub oz()
    
            zdebug.start(7,baud,rx,tx,0,0)
            zdebug.pasm(16,@code,0,halted,string("demo_pasm"))
            cogstop(0)
    
    dat             org
    
    code          getct     pa
                  testb     pa,#26 wc
                  drvc      #16
                  jmp       #code
    
                  long      0[16]
    
    and here's a capture of some debugger output.
    Stack contents, flag states and program counter related info is shown.
                 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ P2 Debugger V3.0.66 ozpropdev 2020 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    STACK:   TOS $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 BOS
    INFO: Cog#1 ATN:0 BRK:$00 RDFAST:$00000 XBYTE $000 BYTECODE:$e1 LUT:$000 I=[7:0]
    nc:nz 00000: fd63ec1a                  GETCT   PA
    Cog1: "demo_pasm" Halt>>disas 0 3_
    00000: fd63ec1a                  GETCT   PA
    00001: f417ec1a                  TESTB   PA,#$1a WC
    00002: fd64205a                  DRVC    #$10
    00003: fd9ffff0                  JMP     #$ffff0 (rel) #$0 (abs)
    Cog1: "demo_pasm" Halt>>_STEP
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ P2 Debugger V3.0.66 ozpropdev 2020 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    STACK:   TOS $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 BOS
    INFO: Cog#1 ATN:0 BRK:$00 RDFAST:$00000 XBYTE $000 BYTECODE:$09 LUT:$000 I=[7:0]
    nc:nz 00001: f417ec1a                  TESTB   PA,#$1a WC
    Cog1: "demo_pasm" Halt>>_STEP
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ P2 Debugger V3.0.66 ozpropdev 2020 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    STACK:   TOS $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 BOS
    INFO: Cog#1 ATN:0 BRK:$00 RDFAST:$00000 XBYTE $000 BYTECODE:$09 LUT:$000 I=[7:0]
     C:nz 00002: fd64205a                  DRVC    #$10
    Cog1: "demo_pasm" Halt>>_STEP
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ P2 Debugger V3.0.66 ozpropdev 2020 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    STACK:   TOS $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 $00000000 BOS
    INFO: Cog#1 ATN:0 BRK:$00 RDFAST:$00000 XBYTE $000 BYTECODE:$09 LUT:$000 I=[7:0]
     C:nz 00003: fd9ffff0                  JMP     #$ffff0 (rel) #$0 (abs)
    Cog1: "demo_pasm" Halt>>_STEP
    
    

  • Exactly what I need, thank you all
Sign In or Register to comment.