Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 629273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:43:40+00:00 2026-05-13T19:43:40+00:00

I am trying to write tests that interact with GDB but am having trouble

  • 0

I am trying to write tests that interact with GDB but am having trouble capturing the output. I would like for a log file to be generated which looks like what would have been seen in a terminal had the test been executed by hand. GDB is proving to be very stubborn when it comes to capturing its output however.

I’ve been able to write Expect scripts which are able to interact with GDB and whose output can be redirected to a log file but I don’t want to write my tests in TCL. I’m hoping to use Groovy, which is compatible with Java. For some reason with Perl’s Expect and ExpectJ the program output always goes to the terminal and can’t be redirected to a file.

I tried starting a GDB process from Java using ProcessBuilder and it mostly works but the output of print statements never appear on stdout and can’t be captured. I thought if Expect works then I’d launch expect from Java and have it interact with GDB but in this case most of the program output is lost, never appearing in the stdout of the created process.

So my question is, how can I write a test in Groovy (Java would be fine as well) which interacts with GDB and can capture all of the output?

Pseudo-code:

process = "gdb -q".execute()
waitForPrompt()
send("file exec")
waitForPrompt()
send("run")
send("quit")

Log file:

(gdb) file exec
Reading symbols from exec...done.
(gdb) run
Starting program: exec
<... output ...>

Program exited normally.
(gdb) quit
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:43:41+00:00Added an answer on May 13, 2026 at 7:43 pm

    One possibility is that the GDB output is being dumped on standard error and you are only capturing standard output. You should be able to fix this with a redirect, something like this I think:

     process = "gdb -q 2&>1".execute()
    

    A second guess is that it may be worth checking what “show interactive-mode” says in the working and non-working cases. If they differ try “set interactive-mode off” before you do anything else.

    A third option is to use GDB’s logging facility to write the log file (“set logging file ” and “set logging on”) and avoid having to capture the output yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write Selenium tests for HTML that's structured like this: <table> <tr
I'm trying to write some c++ code that tests if a string is in
Trying to write a code at the moment that basically tests to see if
Im trying to write some unit tests for a couple of merthods that are
I'm trying to write tests for some legacy code with PHPUnit 3.4.9, but it
I have an HttpServlet that I'm trying to write tests for and have mocked
I'm trying to write unit tests for an application that reports on Entries in
I'm trying to write some unit tests for a JPA model that I've built
I am trying to write Watin tests for an intranet application that uses Integrated
I'm trying to write a Java unit test that tests the effects of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.