Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke "bt" command using JDebug for bt stack trace option

I am using Jdebug system call using python and trying to automate the process of "bt" command as shown below.

It consists of two steps.

jdebug core-tarball.0.tgz

Response received:

Using '/tmp' as temporary  location
jdebug version: 5.0.0
[File is compressed. This may take a moment...]
....
[Current thread is 1 (LWP 100276)]

(gdb) 

As seen above (gdb) prompt is appear and now i need to pass "bt" command and to read back the response from gdb prompt.

Not sure how to send "bt" command via python or at shell script and read the response back.

I am looking to automate these two steps:

Step #1: jdebug filename 
Step #2  bt

[invoke 'bt' on gdb prompt and read back the response lines i.e. stack_trace information] via pyton or via os.system call.

like image 636
Ammad Avatar asked Feb 03 '26 16:02

Ammad


1 Answers

You can write to stdin using Popen of subprocess module:

from subprocess import Popen, PIPE
proc = Popen(['jdebug', 'core-tarball.0.tgz'], stdin=PIPE)
proc.stdin.write("bt\r")
like image 166
user9353542 Avatar answered Feb 06 '26 06:02

user9353542



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!