Running GDB on C++ application from a Python Script (Automation) -


i'm encountering quite big frustration 1 of tasks. we're automating of our processes , there's step. run gdb command on backed core files. command rather simple:

gdb --batch --quiet -ex "set logging overwrite on" -ex "set logging file gdb.out" -ex "set pagination off" -ex "set logging on" -ex "pwd" -ex "run" -ex "backtrace full" -ex "info registers" -ex "info threads" -ex "thread apply backtrace full" -ex "set logging off" -ex "quit" binary core 

now there echo in there make file more readable -ex "echo \n\nstuff:\n"... can imagine. while command works flawlessly when executed manually terminal window, have perform python script. thought use subprocess module aid:

subprocess.popen(['gdb', '--batch', '--quiet', '-ex', '"set logging overwrite on"'...], binary, core) 

when run however, commands after each 'ex' e.g. set logging overwrite on not there. gdb reports: error unknown command "" , no output file created not file null bytes, kind of obvious. tried use stdin fed gdb inputs didn't work @ all, guess gdb doesn't use standard input. oh yeah... gdb module python not available in our organization on it's not 'you should install it' because can't that. i'd prefer solution exact situation. gdb subprocess.

ps: tried remove logging file , read out stdout process... didn't work. either process.stdout.read() returned empty string or when out string contained 4 lines , last 500 truncated.

our python version: 2.7.3

many tips! (i'm officially out of ideas.)

@edit:

tried put commands in external file , use --command option try trick it. result, no logging file created instead mentioned 5 lines printed stdout while rest remained same (nearly 500 lines truncated , lost in echo)

by removing quotes around commands seems have effect. logging files created formatting gdb command gone , gdb stuck around run > app.out.

gdb --batch --quiet -ex set logging overwrite on -ex set ...... -ex echo ??threads:? -ex info threads ... 

by looking running processes can see running gdb instance above command. looking out files can see gdb stuck @ run > app.out while doing nothing. if execute command manually quotes around commands never happens manually created core file kill -3 no errors should prevent gdb run app till end. upon checking gdb ... gdb (gdbception) thread in sigsuspend /lib64/libc.so.6 doesn't tell me honest.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -