Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: ollydbg on July 28, 2014, 05:13:30 pm

Title: Different behaviour when run the same command under GDB
Post by: ollydbg on July 28, 2014, 05:13:30 pm
Hi, I just want to try to open a wxPython window from GDB's python interface, so I create a simple python script, and use the "source sim.py" command to load it. I'm using gdb with python enabled build myself, and under WinXP.

Here is the sim.py
Code
import wx
app = wx.App()
frame = wx.Frame(None, -1, 'simple.py')
frame.Show()
app.MainLoop()

When I start GDB.exe from the command line, and type this command, I can see a window shown up, see the screen shot below:
(http://i683.photobucket.com/albums/vv194/ollydbg_cb/2014-07-28230509_zps79309703.png)

But if I start the GDB.exe from C::B's debugger plugin, and type the command "source sim.py" there, no window will be shown, here is the log:
Code
electing target: 
Debug
Adding source dir: E:\code\gdb\large-mem\test\
Adding source dir: E:\code\gdb\large-mem\test\
Adding file: E:\code\gdb\large-mem\test\bin\Debug\test.exe
Changing directory to: E:/code/gdb/large-mem/test/.
Set variable: PATH=.;D:\mingw-builds\473\mingw32\bin;D:\mingw-builds\473\mingw32;E:\code\msys\PortableGit-1.9.4-preview20140611\cmd;E:\code\common_bin;D:\opencv246build\build-gcc482-release\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;D:\Program Files\TortoiseSVN\bin;E:\code\DrMemory-Windows-1.6.1-2\bin;E:\code\wx-mingw-build-481-dw2\wxWidgets-2.8.12\lib\gcc_dll

[debug]Command-line: E:\code\gdb\mybuild\bin\gdb.exe -nx -fullname  -quiet -iex "set auto-load safe-path /" -args E:/code/gdb/large-mem/test/bin/Debug/test.exe
[debug]Working dir : E:\code\gdb\large-mem\test

Starting debugger: E:\code\gdb\mybuild\bin\gdb.exe -nx -fullname  -quiet -iex "set auto-load safe-path /" -args E:/code/gdb/large-mem/test/bin/Debug/test.exe
done

[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!

Setting breakpoints

[debug]Reading symbols from E:/code/gdb/large-mem/test/bin/Debug/test.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.8.50.20140717-cvs
[debug]Copyright (C) 2014 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.8.50.20140717-cvs

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source E:\code\gdb\mybuild\bin\my.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory E:/code/gdb/large-mem/test/
[debug]Source directories searched: E:/code/gdb/large-mem/test;$cdir;$cwd
[debug]>>>>>>cb_gdb:

> source sim.py

[debug]> source sim.py

Note that I even not run the debugee, just load it.

Not sure why there is difference between running a command in the gdb command line and in C::B.

I even try to run all the command like "set new-console on" in the gdb command line, this don't change the behavior. In-short, running command from C::B does not work quite well.

Any hints?

BTW: is it the wxExecute issue?
Code
int DebuggerGDB::LaunchProcess(const wxString& cmd, const wxString& cwd)
{
    if (m_pProcess)
        return -1;

    // start the gdb process
    m_pProcess = new PipedProcess(&m_pProcess, this, idGDBProcess, true, cwd);
    Log(_("Starting debugger: ") + cmd);
    m_Pid = wxExecute(cmd, wxEXEC_ASYNC, m_pProcess);
Title: Re: Different behaviour when run the same command under GDB
Post by: oBFusCATed on July 28, 2014, 09:33:41 pm
Probably something in the environment is different (PATH, PYTHON_PATH, etc).
Title: Re: Different behaviour when run the same command under GDB
Post by: ollydbg on July 29, 2014, 05:01:39 am
Thanks, I just checked those environment variables, but they are not the reasons.

I see that if GDB is a hidden process, the window created will be hidden, see the updated reply here: https://groups.google.com/d/msg/wxpython-users/zmPzeprFKf0/Z8tA65LKpwIJ
Title: Re: Different behaviour when run the same command under GDB
Post by: ollydbg on July 29, 2014, 08:45:26 am
Problem solved, see the solution here: https://groups.google.com/d/msg/wxpython-users/zmPzeprFKf0/CXHvtghohM8J
I just use the Windows API to set the window style under python's ctypes module.