Author Topic: No console output window while debugging console app on Mac OS X  (Read 22053 times)

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Hello,

If I may, I would like to ask for help in getting a console window displayed while debugging a simple console app on OS X.


More info…

I am developing a console application (driver app) that is used to test/verify a Window/Linux/OS X porting package I am developing for a VOIP project.

The porting package and the console app development is going well. I use CodeBlocks SVN 6215 (built from the sources) on Mac OS X Snow Leopard 10.6.3.

Question 1:
Is it possible while debugging to get a console output window displayed?

I searched this forum to see if I was missing some simple configuration setting. I did see the following post:

Console app run/debugging for MacOSX:
http://forums.codeblocks.org/index.php?topic=4608.0

…but I still am not able to get the debugged console app’s console window displayed while debugging. Hmmm… strange….

I am aware of the settings in the “Setting->Environment dialog named:

“Shell to run command in:”
“Terminal to launch console programs:”


They are currently set to:

/bin/sh -c
osascript -e 'tell app "Terminal" to do script "$SCRIPT"'

It is probably some simple error I am making that is causing the apps console window to not display while I am debugging but I can’t seem to figure it out.


Thank you for your help,

edwin



Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12192
    • Travis build status
Re: No console output window while debugging console app on Mac OS X
« Reply #1 on: June 04, 2010, 09:13:14 pm »
Do you see the console when you hit the run button?
If yes, can you provide the debugger's debug log!

This log is shown by going to Settings -> Compiler & Debugger -> Debugger -> Display debugger's log...

Also you should check if you debugger (gdb from apple probably) supports the tty command...
C::B should have executed the:
> tty /dev/pts/2
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #2 on: June 04, 2010, 09:25:29 pm »
Hi oBFusCATed,

Thank you for your quick reply.

I do not see the console when I hit the run button (when I run the consol app target using CodeBlocks).

Other than the console window not being displayed, everything else seems normal for the debug sessions.

I can get you whatever info you might need if you can help…


edwin



Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #3 on: June 04, 2010, 09:39:38 pm »
Hi oBFusCATed,

I enabled the debugger log and ran the console app within the debugger again…

The log was generated but I do not see any tty “gdb commands”… should I?



Other Info:

Here is the result of “gdb –version”:

GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar  5 04:43:10 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".


Looks like gdb supports the –tty command line switch. Here is some of the text of “man gdb” from the Mac box:

SYNOPSIS
       gdb    [-help] [-nx] [-q] [-batch] [-cd=dir] [-f] [-b bps] [-tty=dev] [-s symfile]
   [-e prog] [-se prog] [-c core] [-x cmds] [-d dir] [prog[core|procID]]



edwin


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: No console output window while debugging console app on Mac OS X
« Reply #4 on: June 04, 2010, 09:45:01 pm »
I am aware of the settings in the “Setting->Environment dialog named:

“Shell to run command in:”
“Terminal to launch console programs:”


They are currently set to:

/bin/sh -c
osascript -e 'tell app "Terminal" to do script "$SCRIPT"'

The default setting is:
Code: [Select]
osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script "$SCRIPT"' -e 'end tell'

The only difference is that it also tells it to "activate",
i.e. bring the window to the front.

It should still have launched, just in the background...

Quote
It is probably some simple error I am making that is causing the apps console window to not display while I am debugging but I can’t seem to figure it out.

In the build log you should have a line like "Executing:"

You could try running that yourself, in a Terminal window.

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #5 on: June 04, 2010, 10:26:42 pm »
Hi oBFusCATed,

If I go to a console window and execute the command:

osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script "$SCRIPT"' -e 'end tell'

An new console window gets created and the “value” contained in $SCRIPT is executed. For the test, the $SCRIPT value contains nothing.


I did look over the debug log. Hmmm….. I do not see any line with text “Execuing”.

Do you think I should post the log to this thread for you to look at?


Thank you,


edwin



Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12192
    • Travis build status
Re: No console output window while debugging console app on Mac OS X
« Reply #6 on: June 04, 2010, 10:47:00 pm »
1. Post both logs.
2. Does the "Run" command show the terminal?  (executed with Build -> Run) ?
If it doesn't this means that it is not a debugger problem, but something else.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: No console output window while debugging console app on Mac OS X
« Reply #7 on: June 04, 2010, 10:56:10 pm »
An new console window gets created and the “value” contained in $SCRIPT is executed. For the test, the $SCRIPT value contains nothing.

$SCRIPT is a variable with the program to run, possibly with environment and arguments

Quote
I did look over the debug log. Hmmm….. I do not see any line with text “Execuing”.

It should be in the Build log, not the Debug log (you did hit Build/Run, yes ? not Debug/Start)

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #8 on: June 07, 2010, 05:45:50 pm »

Hi oBFusCATed and afb,

Thank you for your help so far.

I understand what you are both suggesting…. I performed a few tests since last Friday. I am performing all of these tests with my project’s Debug build.


Build->Run (Fails from within the IDE if there are spaces in the path to the executable)
I tried performing a “Build->Run” and two terminal windows were displayed. The shell echoed an error that “the path could not be found”. Instantly it looked like “spaces in the path” issues from what I saw.

I specified a new output path in the build project that contained no spaces and the “Build->Run” then did function properly.


Long story short –I then performed “Build->Run” and “Debug->Start” tests. Here are the results:


Build->Run test:

1)
Removed spaces from the executabe's path.

2)
Rebuilt the Debug image.

3) Performed a "Build->Run". Everything worked:

Build Log:
 
Checking for existence: /Development/VOIPMediaEngine/PortingLayerTest/bin/DebugMac32/PortingLayerTest
Executing: osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script "/Development/VOIPMediaEngine/PortingLayerTest/bin/DebugMac32/PortingLayerTest "' -e 'end tell'  (in /Development/VOIPMediaEngine/PortingLayerTest/bin/DebugMac32)
Process terminated with status 0 (0 minutes, 0 seconds)


Debugger Log:

Contained nothing.



Debug->Start test:

1)
Performed a "Debug->Start". This did not work – No terminal window was displayed


Build Log:

-------------- Build: Debug Mac32 in PortingLayerTest ---------------
Target is up to date. Nothing to be done. 


Debugger Log:

DYLD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args bin/DebugMac32/PortingLayerTest
Working dir : /Development/VOIPMediaEngine/PortingLayerTest/
> set prompt >>>>>>cb_gdb:
Reading symbols for shared libraries ... done
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar  5 04:43:10 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /Applications/AppNew/CodeBlocks.app/Contents/Resources/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> cd bin/DebugMac32
>>>>>>cb_gdb:
> directory /Development/VOIPMediaEngine/PortingLayerTest/
>>>>>>cb_gdb:
> directory /Development/VOIPMediaEngine/
>>>>>>cb_gdb:
> run
Reading symbols for shared libraries +
+
. done
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Program exited normally.
>>>>>>cb_gdb:
> quit



I can run additional tests if needed.

Thank you both,

edwin



Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12192
    • Travis build status
Re: No console output window while debugging console app on Mac OS X
« Reply #9 on: June 07, 2010, 07:48:47 pm »
I've looked at the code and the tty thing is compiled only for wxgtk = linux/freebsd

Code: [Select]

   #ifdef __WXGTK__
    // create xterm and issue tty "/dev/pts/#" to GDB where
    // # is the tty for the newly created xterm
    m_bIsConsole = (target && target->GetTargetType() == ttConsoleOnly);
    if (m_bIsConsole)
    {
        if (RunNixConsole() > 0 )
        {   wxString gdbTtyCmd;
            gdbTtyCmd << wxT("tty ") << m_ConsoleTty;
            m_State.GetDriver()->QueueCommand(new DebuggerCmd(m_State.GetDriver(), gdbTtyCmd, true));
            DebugLog(wxString::Format( _("Queued:[%s]"), gdbTtyCmd.c_str()) );
        }
    }//if
   #endif//def __WXGTK__


An easy fix (if it works) is to replace
#ifdef __WXGTK__
with
#ifndef __WXMSW__

or to use if (!platform::windows)

But I can test it, because I don't have a osx running...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: No console output window while debugging console app on Mac OS X
« Reply #10 on: June 07, 2010, 08:58:42 pm »
I've looked at the code and the tty thing is compiled only for wxgtk = linux/freebsd

Yeah, it would need porting. The AppleScript thing is only for Build/Run, not Debug/Start.

Quote
An easy fix (if it works) is to replace
#ifdef __WXGTK__
with
#ifndef __WXMSW__

The code would look more like /dev/ttyp#, than /dev/pts/# (a little BSD vs. GNU thing)


Most likely the current wxGTK code is broken on FreeBSD too, as it seems to be rather Linux-specific ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12192
    • Travis build status
Re: No console output window while debugging console app on Mac OS X
« Reply #11 on: June 07, 2010, 09:04:32 pm »
I've never tried it on freebsd and no one has reported that is broken (at least recently)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #12 on: June 07, 2010, 09:41:09 pm »
Thanks to both of you for posting this additional information…

If you two gents would like me to modify the source code and run a few tests, I can certainly make an effort to squeeze it in to my schedule to try to verify an update/fix. I would need your suggested code changes for testing seeing I am not completely up to speed with all the CodeBlocks source code and internal logic yet.

Thank you,

edwin


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: No console output window while debugging console app on Mac OS X
« Reply #13 on: June 08, 2010, 08:35:43 am »
I've never tried it on freebsd and no one has reported that is broken (at least recently)

I spoke too soon, /dev/pts/ was mostly in the comments - it should be fine with /dev/ttyp:

Code: [Select]
ps x -o tty,pid,command

So the suggested fix should be good (haven't tried it yet).

Offline edwin

  • Multiple posting newcomer
  • *
  • Posts: 38
Re: No console output window while debugging console app on Mac OS X
« Reply #14 on: June 08, 2010, 01:28:02 pm »
I can test a possible change/fix if either of you can spoon feed me a bit more…

So if I implement the following change:

Quote
An easy fix (if it works) is to replace
#ifdef __WXGTK__
with
#ifndef __WXMSW__

…that is our best bet to get the debug terminal window working on OS X and that would also not break the build for Windows and Linux using the same code base?

I have a build environment all ready to go and could test a change as soon as I can squeeze it in.

Thank you for your efforts. Supurb support.

edwin