简体   繁体   English

运行C ++程序时出现GDB错误

[英]GDB error on running a C++ Program

The list of files in my directory (which is /home/ayush/Desktop/xapian-patch/xapian/xapian-letor/bin) is 我的目录(即/ home / ayush / Desktop / xapian-patch / xapian / xapian-letor / bin)中的文件列表为

xapian-prepare-trainingfile.1  xapian-prepare-trainingfile.cc xapian-prepare-trainingfile  xapian-prepare-trainingfile.o 

I am able to run the command ./xapian-prepare-trainingfile --db=/home/ayush/Documents/data/db /home/ayush/Documents/data/query.txt /home/ayush/Documents/data/qrel.txt /home/ayush/Documents/data/sample3.txt 我能够运行命令./xapian-prepare-trainingfile --db=/home/ayush/Documents/data/db /home/ayush/Documents/data/query.txt /home/ayush/Documents/data/qrel.txt /home/ayush/Documents/data/sample3.txt

However When I try to run the same command through GDB 但是,当我尝试通过GDB运行相同的命令时

gdb --args xapian-prepare-trainingfile --db=/home/ayush/Documents/data/db /home/ayush/Documents/data/query.txt /home/ayush/Documents/data/qrel.txt /home/ayush/Documents/data/sample3.txt

i get the error 我得到错误

"/home/ayush/Desktop/xapian-patch/xapian/xapian-letor/bin/xapian-prepare-trainingfile": not in executable format: File format not recognized

I want to know how the run the c++ command that I am able to run without any problems through GDB 我想知道如何通过GDB运行没有任何问题的c ++命令

"/home/ayush/Desktop/xapian-patch/xapian/xapian-letor/bin/xapian-prepare-trainingfile": not in executable format: File format not recognized

The most likely reason for above error is that ./xapian-prepare-trainingfile is a shell script, not an executable file. 出现上述错误的最可能原因是./xapian-prepare-trainingfile是Shell脚本,而不是可执行文件。

You can confirm this by running file xapian-prepare-trainingfile . 您可以通过运行file xapian-prepare-trainingfile来确认。

If it is a shell script, you'll need to run: 如果是shell脚本,则需要运行:

bash -x ./xapian-prepare-trainingfile ...

and figure out what actual executable it eventually invokes, and debug that . 并找出实际的可执行它最终调用和调试这一点

Another way: make a copy of xapian-prepare-trainingfile , edit it, and insert gdb --args just before the script exec s the actual binary. 另一种方法:复制xapian-prepare-trainingfile ,进行编辑, 然后在脚本exec实际的二进制文件之前插入gdb --args

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM