javadebuggingbreakpointsexpectrlwrap

Automate debug java with rlwrap


I use rlwrap to debug a Java process

rlwrap jdb -attach 192.168.5.55:9999

When the breakpoint stop:

> stop in  comm.app.aaa.func
> set a = 0
> cont

I do that few times, each time the breakpoint stop

How can I do that automatically without wait for breakpoint?


Solution

  • You can try using expect to automate your flow. Sample expect script:

    #!/usr/bin/expect -f
    
    set timeout 120
    spawn jdb -attach 192.168.5.55:9999
    
    expect "> "
    send "stop in comm.app.aaa.func\n"
    
    for {set i 0} {$i < 10} {incr i} {
        expect -re {\[\d\] }
        send "set a = 0\n"
        expect -re {\[\d\] }
        send "cont\n"
    }