how to configure gdb to debug a script not a binar

2019-05-27 02:26发布

I'm trying to use gdb to debug Torch library binary file to . When I run from the command line : gdb --args th

I get the following error:

"/xxx/xxxx/torch/install/bin/th": not in executable format: File format not recognized

I checked if my current installation of gdb is 64 bit i installed gdb64 and when i run

gdb64 --args th

I still get the same error, the output of :

file /xxx/xxxx/torch/install/bin/th

is :

/xxx/xxxx/torch/install/bin/th: POSIX shell script, ASCII text executable, with very long lines 

I have learned that the problem is that the executable file is not a binary, but a script, so gdb is trying to debug the script instead.

My question is how to overcome this and let gdb debug the execution of the command itself. or even replace the Torch installation to be a binary execution instead of a script.

2条回答
萌系小妹纸
2楼-- · 2019-05-27 03:20

Try LLDB Debugger (lldb) instead which aims to replace GNU Debugger (gdb).

It's available by default on BSD/OS X, on Linux install via: sudo apt-get install lldb (or use yum).

For usage, check gdb to lldb command map page.

查看更多
可以哭但决不认输i
3楼-- · 2019-05-27 03:22

with some help from the comments i was able to run gdb over the torch script, through :

gdb64 /bin/bash    # check your gdb configuration either it's i686 or x86_64 
run /path/to/th    # th is the torch running script to be debugged
查看更多
登录 后发表回答