python3.789
python3.789

Reputation: 326

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?

Upvotes: 2

Views: 99

Answers (2)

Sai Sandeep
Sai Sandeep

Reputation: 116

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"
}

Upvotes: 1

Akash Jain
Akash Jain

Reputation: 730

try creating a command file like somecommand.txt

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

and then feed the command to jdb

rlwrap jdb -attach 192.168.5.55:9999 < somecommand.txt

OR

run an inline script

echo -e "stop in comm.app.aaa.func\nset a = 0\ncont" | rlwrap jdb -attach 192.168.5.55:9999

Hope this helps

Upvotes: -1

Related Questions