Frage

edit: ok, i wont give up.

i tried to set this up in codeblocks, but that doesnt work well either:

Starting debugger: C:\MinGW\bin\gdb-python27.exe -nx -fullname  -quiet 
done
Setting breakpoints
Attaching to program with pid: 7760
Debugger name and version: GNU gdb (GDB) 7.5
Attaching to process 7760
> source C:\MinGW\bin\.gdbinit
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 917, in register_libstdcxx_printers
    register_type_printers(obj)
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 855, in register_type_printers
    add_one_type_printer(obj, 'basic_string', pfx + 'string')
  File "C:\MinGW\share\gcc-4.8.1\python\libstdcxx\v6\printers.py", line 846, in add_one_type_printer
    gdb.types.register_type_printer(obj, printer)
  File "c:\mingw\share\gdb/python\gdb\types.py", line 179, in register_type_printer
    locus.type_printers.insert(0, printer)
AttributeError: 'module' object has no attribute 'type_printers'
C:\MinGW\bin\.gdbinit:7: Error in sourced command file:
Error while executing Python code.
Error while executing Python code.
> python print sys.version
2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
> show version
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Debugger name and version: GNU gdb (GDB) 7.5

so it looks as if this has nothing to do with eclipse messing things up, but the script misbehaving.


edit: i just fired up msys, navigated to the same path eclipse suposedly does (2-environment-cd D:/work/ludum-dare/Debug), set the same parameters (except 5-enable-pretty-printing since gdb-python doesnt seem to know that setting) and finally sourced .gdbinit It didnt even wince at doing that. no errors at all.

does anyone know how to find out what eclipse is trying to run when i click on debug?

Also i just tried the "standard create process launcher" which at first went smoothly, but scrolling up in the traces console, i saw it simply skips over the errors encountered in the python file.


edit: i just realized that not setting 5-enable-pretty-printing doesnt set _use_gdb_pp in printers.py, so it wont run the same way as in eclipse anyhow.

I guess pretty printing is broken in mingw+eclipse cdt


after following these steps: https://stackoverflow.com/a/14266862/3239702 i am facing the following output in eclipse:

610,711 2-environment-cd D:/work/ludum-dare/Debug
610,715 2^done
610,715 (gdb) 
610,716 3-gdb-set breakpoint pending on
610,725 3^done
610,725 (gdb) 
610,726 4-gdb-set detach-on-fork on
610,735 4^done
610,735 (gdb) 
610,736 5-enable-pretty-printing
610,745 5^done
610,745 (gdb) 
610,746 6-gdb-set python print-stack none
610,755 6^done
610,755 (gdb) 
610,756 7-gdb-set print object on
610,765 7^done
610,765 (gdb) 
610,766 8-gdb-set print sevenbit-strings on
610,775 8^done
610,775 (gdb) 
610,776 9-gdb-set host-charset UTF-8
610,785 9^done
610,785 (gdb) 
610,786 10-gdb-set target-charset WINDOWS-1252
610,795 10^done
610,795 (gdb) 
610,795 11-gdb-set target-wide-charset UTF-16
610,805 11^done
610,805 (gdb) 
610,822 12source D:\work\ludum-dare\.gdbinit
610,825 &"source D:\\work\\ludum-dare\\.gdbinit\n"
610,896 &"Traceback (most recent call last):\n"
610,896 &"  File \"<string>\", line 4, in <module>\n"
610,896 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 917, in regis\
ter_libstdcxx_printers\n"
610,915 &"    register_type_printers(obj)\n"
610,915 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 855, in regis\
ter_type_printers\n"
610,917 &"    add_one_type_printer(obj, 'basic_string', pfx + 'string')\n"
610,917 &"  File \"C:/MinGW/share/gcc-4.8.1/python\\libstdcxx\\v6\\printers.py\", line 846, in add_o\
ne_type_printer\n"
610,918 &"    gdb.types.register_type_printer(obj, printer)\n"
610,918 &"  File \"c:\\mingw\\share\\gdb/python\\gdb\\types.py\", line 176, in register_type_printer\
\n"
610,928 &"    locus.type_printers.insert(0, printer)\n"
610,928 &"AttributeError: 'module' object has no attribute 'type_printers'\n"
610,928 &"D:\\work\\ludum-dare\\.gdbinit:6: Error in sourced command file:\n"
610,928 &"Error while executing Python code.\n"
610,928 12^error,msg="D:\\work\\ludum-dare\\.gdbinit:6: Error in sourced command file:\nError while \
executing Python code."
610,929 (gdb) 

i have searched the web for other people who have this problem but it looks like i got the jackpot. i got: Eclipse IDE for C/C++ Developers

Version: Kepler Service Release 1 Build id: 20130919-0819


my mingw installer is all updated, and gdb-python27 is installed from:

gdb-python-7.5.1-mingw32-bin.tar.lzma

python 2.7.6 32bit User Environment Variables:

PYTHONHOME = C:\Python27
PYTHONPATH = C:\Python27\Lib
PATH = c:\mingw\bin

Global Environment Variables: contains much more, i only post the relevant part:

PATH = C:\Python27\;

edit: i just tried the python scripts from svn ( svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python ) of course i changed the path in my .gdbinit accordingly. the output in the "gdb traces" console is mostly the same, except for a couple of line numbers which differ, but the errors in those lines are identical, so i supose there just was some refactoring or something like that going on.

and also my .gdbinit file as it is now. before the svn checkout, the commented line was used instead of line 4:

python
import sys
# sys.path.insert(0, 'C:/MinGW/share/gcc-4.8.1/python')
sys.path.insert(0, 'D:/work/libstdc++-v3/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end

edit: tried to debug that printers.py script: i added some prints to the register_libstdcxx_printers function:

def register_libstdcxx_printers (obj):
    "Register libstdc++ pretty-printers with objfile Obj."
    global _use_gdb_pp
    global libstdcxx_printer
    print("initialy obj: " + str(obj))
    print("_use_gdb_pp: " + str(_use_gdb_pp))
    if _use_gdb_pp:
        gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
    else:
        if obj is None:
            obj = gdb
        obj.pretty_printers.append(libstdcxx_printer)
    print("after gdb.printing.register_pretty_printer(obj, libstdcxx_printer): obj: " + str(obj))
    register_type_printers(obj)

the output of this is:

559,740 ~"initialy obj: None\n"
559,740 ~"_use_gdb_pp: True\n"
559,740 ~"after gdb.printing.register_pretty_printer(obj, libstdcxx_printer): obj: None\n"

i cant really blame it to not find the attribute 'type_printers' on None, now can i? i suppose that None comes from line 6 in my .gdbinit :

register_libstdcxx_printers (None)
War es hilfreich?

Lösung

MinGW GDB 7.5.1 uses Python Scripts from normal GDB 7.6. Therefore the Scripts fail.

After i copied the syscalls and python folders out of

http://ftp.gnu.org/gnu/gdb/gdb-7.5.1.tar.gz

and tried everything again, it miraculously worked.

Starting debugger: C:\MinGW\bin\gdb-python27.exe -nx -fullname  -quiet 
done
Setting breakpoints
Attaching to program with pid: 7428
Debugger name and version: GNU gdb (GDB) 7.5
Attaching to process 7428
Continuing...
At D:\work\ludum-dare\src\main.cpp:39
Continuing...
At D:\work\ludum-dare\src\main.cpp:41
Continuing...
At D:\work\ludum-dare\src\componentEntitySystem\componentEntitySystem.cpp:393
> print funcText
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x24504f4 "'ces:getEntitiesWithComponent(\"position\")'"}}
> source C:\MingW\bin\.gdbinit
> print funcText
$2 = "'ces:getEntitiesWithComponent(\"position\")'"

So, "nice job" to the person who put the gdb 7.6 python scripts into the MinGW GDB 7.5.1 package. NOT.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top