User forums > Using Code::Blocks
Problem with debugger
Pecan:
Would you run an xterm
then :
sleep 81234
then :
ps x -o tty,pid,command
then paste the output to me.
thanks
I'm wondering if the number even shows up.
kramed:
The sleep command just sits there doing its thing....
--- Code: ---bash-3.1$ ps x -o tty,pid,command
TT PID COMMAND
tty1 1514 -bash
tty1 1540 /bin/sh /usr/X11R6/bin/startx
tty1 1556 /usr/X11R6/bin/xinit /usr/X11R6/lib/X11/xinit/xinitrc -- -auth /h
tty1 1567 /bin/sh /usr/X11R6/lib/X11/xinit/xinitrc
tty1 1569 /bin/sh /opt/kde/bin/startkde
? 1597 kdeinit Running...
? 1600 dcopserver [kdeinit] --nosid
? 1604 klauncher [kdeinit] --new-startup
? 1606 kded [kdeinit] --new-startup
tty1 1619 kwrapper ksmserver
? 1621 ksmserver [kdeinit]
? 1623 kwin [kdeinit] -session 108f363330000117208531500000062480000_117
? 1627 kdesktop [kdeinit]
? 1630 kicker [kdeinit]
? 1638 kaccess [kdeinit]
? 1642 superkaramba -session 108f363330000117285908400000027280029_11733
? 1644 superkaramba -session 108f363330000117290000100000036900010_11733
? 1645 superkaramba -session 108f363330000117290000300000036900011_11733
? 1694 konqueror [kdeinit] -session 108f36333000011733276760000007048003
? 4536 kompare -caption Kompare -icon kompare -miniicon kompare -o /home
? 8506 konsole [kdeinit] --ls
pts/1 8507 -bash
? 15990 xchat
? 20325 /bin/sh /usr/local/apps/firefox/firefox
? 20328 /bin/sh /usr/local/apps/firefox/run-mozilla.sh /usr/local/apps/fi
? 20333 /usr/local/apps/firefox/firefox-bin
? 21972 konsole [kdeinit] --ls
pts/3 21973 -bash
? 22093 konsole [kdeinit] --ls
pts/4 22094 -bash
? 22316 xterm
pts/5 22318 bash
pts/5 22373 sleep 81234
? 22394 xterm
pts/6 22396 bash
pts/6 22459 ps x -o tty,pid,command
? 25985 konqueror [kdeinit] --silent
? 27347 gaim
bash-3.1$
--- End code ---
Pecan:
Ok, I'm gonna make some debugging output statements, then send debuggergdb.cpp back to ya. standby...
Maybe we got a wxWidgets error. What version of wxWidgets are you compiling with?
kramed:
2.6.3 with Patch #2. I used the wiki as a guide. Im pretty sure wxGTK is installed fine, there were no errors.
Pecan:
Here are the last two routines in debuggergdb.cpp
please cut and paste them into your CB, run the console program and then give the "Debugger(debug)" output to me.
I've put two debugging statements in to try and identify the problem with the missing sleep parameter.
--- Code: ---// ----------------------------------------------------------------------------
int DebuggerGDB::RunNixConsole()
// ----------------------------------------------------------------------------
{
// start the xterm and put the shell to sleep with -e sleep 80000
// fetch the xterm tty so we can issue to gdb a "tty /dev/pts/#"
// redirecting program stdin/stdout/stderr to the xterm console.
#ifndef __WXMSW__
wxString cmd;
wxString title = wxT("Program Console");
m_nConsolePid = 0;
// for non-win platforms, use m_ConsoleTerm to run the console app
wxString term = Manager::Get()->GetConfigManager(_T("app"))->Read(_T("/console_terminal"), DEFAULT_CONSOLE_TERM);
//term.Replace(_T("$TITLE"), _T("'") + _T("*nixConsole") + _T("'"));
term.Replace(_T("$TITLE"), _T("'") + title + _T("'"));
cmd << term << _T(" ");
cmd << wxT("sleep ");
cmd << 80000 + ::wxGetProcessId(); //make a unique sleep command
wxString sleepPid; sleepPid << 80000 + ::wxGetProcessId();
DebugLog(wxString::Format(wxT("RunNixConsole.SleepPid_1 is[%s]"),sleepPid.c_str() ));
sleepPid = wxString::Format(wxT("%d"),80000+ ::wxGetProcessId());
DebugLog(wxString::Format(wxT("RunNixConsole.SleepPid_2 is[%s]"),sleepPid.c_str() ));
Manager::Get()->GetMacrosManager()->ReplaceEnvVars(cmd);
//Manager::Get()->GetMessageManager()->Log(m_PageIndex, _("Executing: %s"), cmd.c_str() );
DebugLog(wxString::Format( _("Executing: %s"), cmd.c_str()) );
//start xterm -e sleep {some unique # of seconds}
m_nConsolePid = wxExecute(cmd, wxEXEC_ASYNC);
if (m_nConsolePid <= 0) return -1;
// Issue the PS command to get the /dev/tty device name
// First, wait for the xterm to settle down, else PS won't see the sleep task
Manager::Yield();
::wxSleep(1);
m_ConsoleTty = GetConsoleTty(m_nConsolePid);
if (not m_ConsoleTty.IsEmpty() )
{ // show what we found as tty
DebugLog(wxString::Format(wxT("GetConsoleTTY[%s]ConsolePid[%d]"),m_ConsoleTty.c_str(),m_nConsolePid));
return m_nConsolePid;
}
// failed to find the console tty
DebugLog( wxT("Console Execution error:failed to find console tty."));
if (m_nConsolePid != 0)::wxKill(m_nConsolePid);
m_nConsolePid = 0;
#endif//ndef __WWXMSW__
return -1;
}
// ----------------------------------------------------------------------------
wxString DebuggerGDB::GetConsoleTty(int ConsolePid)
// ----------------------------------------------------------------------------
{
// execute the ps x -o command and read PS output to get the /dev/tty field
unsigned long ConsPid = ConsolePid;
wxString psCmd;
wxArrayString psOutput;
wxArrayString psErrors;
psCmd << wxT("ps x -o tty,pid,command");
DebugLog(wxString::Format( _("Executing: %s"), psCmd.c_str()) );
int result = wxExecute(psCmd, psOutput, psErrors, wxEXEC_SYNC);
psCmd.Clear();
if (result != 0)
{ psCmd << wxT("Result of ps x:") << result;
DebugLog(wxString::Format( _("Execution Error:"), psCmd.c_str()) );
return wxEmptyString;
}
wxString ConsTtyStr;
wxString ConsPidStr;
ConsPidStr << ConsPid;
//find task with our unique sleep time
wxString uniqueSleepTimeStr;
uniqueSleepTimeStr << wxT("sleep ") << 80000 + ::wxGetProcessId();
// search the output of "ps pid" command
int knt = psOutput.GetCount();
for (int i=knt-1; i>-1; --i)
{ psCmd = psOutput.Item(i);
DebugLog(wxString::Format( _("PS result: %s"), psCmd.c_str()) );
// find the pts/# or tty/# or whatever it's called
// by seaching the output of "ps x -o tty,pid,command" command.
// The output of ps looks like:
// TT PID COMMAND
// pts/0 13342 /bin/sh ./run.sh
// pts/0 13343 /home/pecan/devel/trunk/src/devel/codeblocks
// pts/0 13361 /usr/bin/gdb -nx -fullname -quiet -args ./conio
// pts/0 13362 xterm -font -*-*-*-*-*-*-20-*-*-*-*-*-*-* -T Program Console -e sleep 93343
// pts/2 13363 sleep 93343
// ? 13365 /home/pecan/proj/conio/conio
// pts/1 13370 ps x -o tty,pid,command
if (psCmd.Contains(uniqueSleepTimeStr))
do
{ // check for correct "sleep" line
if (psCmd.Contains(wxT("-T"))) break; //error;wrong sleep line.
// found "sleep 93343" string, extract tty field
ConsTtyStr = wxT("/dev/") + psCmd.BeforeFirst(' ');
DebugLog(wxString::Format( _("TTY is[%s]"), ConsTtyStr.c_str()) );
return ConsTtyStr;
}while(0);//if do
}//for
knt = psErrors.GetCount();
for (int i=0; i<knt; ++i)
DebugLog(wxString::Format( _("PS Error:%s"), psErrors.Item(i).c_str()) );
return wxEmptyString;
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version