2

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.

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.

2 Answers 2

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.

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Can i plus this answer twice? You are totally a genius. I have searching this answer so long. But i still don't know what does { and cat used for? Could you give me any hints? Because after i remove any part of your command i won't run as i wish. Thank you again.
@user674199: Thanks. Expanded the answer.
0

I'm not sure but you might looking into generating expect scripts. Here is a tutorial, which does something with gdb automation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.