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 837141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:05:52+00:00 2026-05-15T05:05:52+00:00

I attached to a program with gdb in OSX and I want to use

  • 0

I attached to a program with gdb in OSX and I want to use CFShow in the gdb console etc. However, nothing shows up. printf shows nothing as well:

(gdb) call (int) printf("Hello\n")
$10 = 6
(gdb) call (int) printf("Hello World!\n")
$11 = 13

Apple suggests the following tip for when attaching with gdb, to make the output appear in the gdb console:

(gdb) call (void) close(1)
(gdb) call (void) close(2)
(gdb) shell tty
/dev/ttyp1
(gdb) call (int) open("/dev/ttyp1", 2, 0)
$1 = 1
(gdb) call (int) open("/dev/ttyp1", 2, 0)
$2 = 2

In xcode’s gdb console tty gives “not a tty“, so I tried it in gdb in a terminal. There tty does work but after redirecting stdout there’s still no output. Also no output if I direct stdout to a file.. :/

Any salvation?

Update/More-details:


On some programs (like TextMate) this method does work. The application I was trying to debug is /Developer/Applications/Audio/AU\ Lab.app. For some reason this trick does not work there..
Update: seems the real explanation is rather:

If after attaching I redirect stdout before calling printf for the first time, it works! If I first printf and only then redirect output, output shows up only after doing printf("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n") and then pressing enter (to repeat last command) 327 times.

So I guess redirecting stdout somehow makes libc confused and makes it use a buffer of 2**14 bytes for some reason?

  • 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-15T05:05:53+00:00Added an answer on May 15, 2026 at 5:05 am

    The problem could be related to a peculiarity of your setup. Here are a couple of further suggestions you could try to identify the source of the problem:

    1. First, check the way the debugger is launched – are you using the command line in the Terminal or is it through some GUI which may submit additional command line arguments beyond your control? (You mentioned XCode, but I don’t see why you would debug the program you mentioned through XCode? And actually I am not sure how XCode executes gdb, so please try to stick to the terminal for now!)

    2. Do you have an init-file in your home directory (a file called .gdbinit or so) that configures gdb with some options you are unaware of? Here is a description of what gdb does on startup: http://sourceware.org/gdb/current/onlinedocs/gdb/Startup.html#Startup

    3. According to the manual page, using the -n option on startup will prevent loading any configuration files: http://sourceware.org/gdb/current/onlinedocs/gdb/Mode-Options.html#Mode-Options Does your problem still persist if you use this switch?

    4. One particular set of commands regards gdb’s logging behavior: http://sourceware.org/gdb/current/onlinedocs/gdb/Logging-Output.html#Logging-Output Can you execute show logging at the console and check what happens to the output?

    5. What is the output of show inferior-tty? If it is set to "" then it will be the same as your gdb console (which is fine). Otherwise, program output will go somewhere else, but this cannot explain the issue you had with output disappearing form interactive gdb commands!

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

Sidebar

Related Questions

I want to create a program, that will use SQL Server 2008 database. During
I have a Windows Mobile program that accesses an attached device through a third-party
I've implemented the attached command behavior pattern found here and it works well to
Is it possible to control gdb from the debugged program? I'm hoping for a
Attached is a quick program written under interview conditions that is designed to flatten
I have program using gtkmm, gtkglextmm and exiv2. I want to include these libraries
I program my IComSat board attached to an Arduino Uno. It works, but the
I have a Java program that used a BufferedImage attached to a jPanel to
Hi I write a program for solving 9 problem by bfs which is attached
In my program, I use a scroll view as the background view. Then, I

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.