Usually i start debug a java program by type jdb
in terminal, then it will enter debugging mode, then i can input something like "stop at com.android.contacts.dirtyImport.DirtyImportManager:95" to tell jdb to stop at certain line.
通常我在终端输入jdb来调试一个java程序,然后它就会进入调试模式,然后我就可以输入“stop at com. android.contacks . dirtyimport”之类的内容。不礼貌的经理:95”告诉加多宝在某条线上停下来。
Now here is the question: how can i combine these two cmds input one. Something like "jdb < stop at com.android.contacts.dirtyImport.DirtyImportManager:95". The reason i have this requirement is that i want to let vim automatic generate debug info and enter debug mode, stop make breakpoint.
现在的问题是:如何将这两个cmds输入结合起来。比如“jdb < stop at com. android.contacase . dirtyimportant . dirtyimport. dirtyimport.com”。我有这个要求的原因是我想让vim自动生成调试信息并进入调试模式,停止make断点。
2 个解决方案
#1
3
One option is to prepend a line to the standard input:
一种选择是在标准输入前加上一行:
{ echo "stop at com.android.contacts.dirtyImport.DirtyImportManager:95"; cat; } | jdb
This starts a subshell ({}
) that first prints the given line with echo
and then reads the standard input and prints the read lines to the standard output (cat
). The whole input is piped into jdb.
这将启动一个子shell({}),该子shell首先使用echo打印给定的行,然后读取标准输入并将读取行打印到标准输出(cat)。整个输入通过管道传输到jdb。
This, however, confuses some programs that distinguish between terminal input and pipe input. In this case, you'll want to have a look at the program's reference, as debuggers often support executing commands from a file (as gdb
with -x
).
然而,这混淆了一些区分终端输入和管道输入的程序。在本例中,您将希望看到程序的引用,因为调试器通常支持从文件(如gdb和-x)执行命令。
#2
0
I'm not sure but you might looking into generating expect
scripts. Here is a tutorial, which does something with gdb
automation.
我不确定,但是您可能会考虑生成expect脚本。这里有一个教程,它使用了gdb自动化。
#1
3
One option is to prepend a line to the standard input:
一种选择是在标准输入前加上一行:
{ echo "stop at com.android.contacts.dirtyImport.DirtyImportManager:95"; cat; } | jdb
This starts a subshell ({}
) that first prints the given line with echo
and then reads the standard input and prints the read lines to the standard output (cat
). The whole input is piped into jdb.
这将启动一个子shell({}),该子shell首先使用echo打印给定的行,然后读取标准输入并将读取行打印到标准输出(cat)。整个输入通过管道传输到jdb。
This, however, confuses some programs that distinguish between terminal input and pipe input. In this case, you'll want to have a look at the program's reference, as debuggers often support executing commands from a file (as gdb
with -x
).
然而,这混淆了一些区分终端输入和管道输入的程序。在本例中,您将希望看到程序的引用,因为调试器通常支持从文件(如gdb和-x)执行命令。
#2
0
I'm not sure but you might looking into generating expect
scripts. Here is a tutorial, which does something with gdb
automation.
我不确定,但是您可能会考虑生成expect脚本。这里有一个教程,它使用了gdb自动化。