Hi all,
I'm using CodeBlocks to develope plugins for Maya which is a DCC software. Everything works fine on CentOS7, I wrote down these steps in my blog:
http://www.cnblogs.com/yaoyansi/p/3946600.html,
http://www.cnblogs.com/yaoyansi/p/3959745.htmlBut now I have to switch to another machine which is CentOS6.4, the new system environment is:
- CentOS Release 6.4(Final), Kernel Linux 2.6.32-358.el6.x86_64,
- codeblocks-10.05-2.el6.x86_64.rpm, codeblocks-contrib-devel-10.05-2.el6.x86_64.rpm, codeblocks-contrib-libs-10.05-2.el6.x86_64.rpm, codeblocks-devel-10.05-2.el6.x86_64.rpm, codeblocks-libs-10.05-2.el6.x86_64.rpm.
- gcc-4.4.7-3.el6(x86_64)
- gcc-c++-4.4.7-3.el6(x86_64)
- gdb-7.2-60.el6(x86_64)
- gdb-gdbserver-7.2-60.el6(x86_64)
- gdbm-1.8.0-36.el6(x86_64)
I created a simple console project helloworld.cbp with the CodeBlock wizard, set a breakpoint, and pressed the following GUI menu items, such as 'Debug/Start', 'Debug/Next Line', 'Debug/Continue'. Everything works fine. And here is the debug log:
------------------log in window 'Debugger', begin-----------------------------------
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/
Adding source dir: /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/
Adding file: bin/Debug/helloworld
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)
At /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:7
At /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:8
Continuing...
Program exited normally.
Debugger finished with status 0
-------------------log in window 'Debugger', end ----------------------------------
-------------------log in window 'Debugger(debug)', begin-------------------------------------------
LD_LIBRARY_PATH=.:/job/BFX/gene/lib:/job/BFX/gene/lib64
Command-line: /usr/bin/gdb -nx -fullname -quiet -args bin/Debug/helloworld
Working dir : /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/
Reading symbols from /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/bin/Debug/helloworld...
done.
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: xterm -T 'Program Console' -e sleep 105532
>>>>>>cb_gdb:
> show version
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)
Copyright (C) 2010 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
>>>>>>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
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/
>>>>>>cb_gdb:
> break "/mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:7"
Executing: ps x -o tty,pid,command
Breakpoint 2 at 0x400818: file /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp, line 7.
>>>>>>cb_gdb:
PS result: ? 27780 ps x -o tty,pid,command
PS result: ? 27775 /usr/bin/gdb -nx -fullname -quiet -args bin/Debug/helloworld
PS result: ? 26845 /usr/libexec/notification-daemon
PS result: ? 26540 gedit
PS result: ? 25532 codeblocks
PS result: pts/5 25166 bash
PS result: ? 22656 gnome-system-monitor
PS result: ? 20785 /usr/bin/gnome-keyring-daemon --daemonize --login
PS result: pts/2 18409 /usr/java/jre1.7.0_45/bin/java -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=25 -Xmx768m -Xverify:none -Dsun.io.useCanonCaches=false -jar /j/HOME/yys/tools/smartgit/smartgit/lib/bootloader.jar
PS result: pts/2 18347 /bin/bash ./smartgit.sh
PS result: pts/2 18299 /bin/bash
PS result: ? 15644 /usr/libexec/gvfsd-metadata
PS result: pts/1 15254 /bin/bash
PS result: pts/0 14308 bash
PS result: ? 14307 gnome-pty-helper
PS result: ? 14306 gnome-terminal
PS result: ? 14172 /usr/libexec/gvfsd-computer --spawner :1.7 /org/gtk/gvfs/exec_spaw/2
PS result: ? 14046 /usr/lib64/thunderbird/thunderbird-bin
PS result: ? 13990 pidgin
PS result: ? 13901 /usr/libexec/ibus-engine-pinyin --ibus
PS result: ? 13900 /usr/libexec/ibus-x11 --kill-daemon
PS result: ? 13898 python /usr/share/ibus/ui/gtk/main.py
PS result: ? 13896 /usr/libexec/ibus-gconf
PS result: ? 13395 /usr/libexec/gvfsd-burn --spawner :1.7 /org/gtk/gvfs/exec_spaw/1
PS result: ? 13365 /usr/libexec/gconf-im-settings-daemon
PS result: ? 13362 /usr/bin/ibus-daemon -r --xim
PS result: ? 13346 /usr/libexec/pulse/gconf-helper
PS result: ? 13344 /usr/libexec/gdm-user-switch-applet --oaf-activate-iid=OAFIID:GNOME_FastUserSwitchApplet_Factory --oaf-ior-fd=40
PS result: ? 13342 /usr/libexec/notification-area-applet --oaf-activate-iid=OAFIID:GNOME_NotificationAreaApplet_Factory --oaf-ior-fd=32
PS result: ? 13340 /usr/libexec/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory --oaf-ior-fd=26
PS result: ? 13337 /usr/bin/gnote --panel-applet --oaf-activate-iid=OAFIID:GnoteApplet_Factory --oaf-ior-fd=20
PS result: ? 13297 gnome-screensaver
PS result: ? 13228 /usr/libexec/gvfsd-trash --spawner :1.7 /org/gtk/gvfs/exec_spaw/0
PS result: ? 13222 /usr/libexec/gvfs-afc-volume-monitor
PS result: ? 13206 /usr/libexec/gvfs-gphoto2-volume-monitor
PS result: ? 13151 /usr/libexec/wnck-applet --oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory --oaf-ior-fd=19
PS result: ? 13150 gpk-update-icon
PS result: ? 13149 /usr/libexec/gvfs-gdu-volume-monitor
PS result: ? 13147 /usr/libexec/trashapplet --oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory --oaf-ior-fd=25
PS result: ? 13144 /usr/libexec/im-settings-daemon
PS result: ? 13139 gnome-power-manager
PS result: ? 13135 /usr/libexec/evolution/2.32/evolution-alarm-notify
PS result: ? 13131 /usr/libexec/gdu-notification-daemon
PS result: ? 13129 gnome-volume-control-applet
PS result: ? 13128 /usr/libexec/polkit-gnome-authentication-agent-1
PS result: ? 13127 nm-applet --sm-disable
PS result: ? 13126 bluetooth-applet
PS result: ? 13121 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=19
PS result: ? 13119 nautilus
PS result: ? 13117 gnome-panel
PS result: ? 13116 /usr/bin/pulseaudio --start --log-target=syslog
PS result: ? 13110 metacity
PS result: ? 13089 /usr/libexec/gvfsd
PS result: ? 13087 seahorse-daemon
PS result: ? 13085 /usr/libexec/gnome-settings-daemon
PS result: ? 13077 /usr/libexec/gconfd-2
PS result: ? 13039 /bin/dbus-daemon --fork --print-pid 6 --print-address 8 --session
PS result: ? 13038 dbus-launch --sh-syntax --exit-with-session
PS result: ? 13029 gnome-session
PS result: ? 13020 /usr/bin/gnome-keyring-daemon --daemonize --login
PS result: ? 5129 /usr/bin/gnome-keyring-daemon --daemonize --login
PS result: TT PID COMMAND
Console Execution error:failed to find console tty.
> run
Breakpoint 2, main () at /mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:7
/mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:7:62:beg:0x400818
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.107.el6.x86_64 libgcc-4.4.7-3.el6.x86_64 libstdc++-4.4.7-3.el6.x86_64
>>>>>>cb_gdb:
> info locals
No locals.
>>>>>>cb_gdb:
> info args
No arguments.
>>>>>>cb_gdb:
> info frame
Stack level 0, frame at 0x7fffffffe110:
rip = 0x400818 in main (/mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:7); saved rip 0x3ad861ecdd
source language c++.
Arglist at 0x7fffffffe100, args:
Locals at 0x7fffffffe100, Previous frame's sp is 0x7fffffffe110
Saved registers:
rbp at 0x7fffffffe100, rip at 0x7fffffffe108
>>>>>>cb_gdb:
> disassemble
Dump of assembler code for function main():
0x0000000000400814 <+0>: push rbp
0x0000000000400815 <+1>: mov rbp,rsp
=> 0x0000000000400818 <+4>: mov esi,0x400988
0x000000000040081d <+9>: mov edi,0x600d40
0x0000000000400822 <+14>: call 0x4006e8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
0x0000000000400827 <+19>: mov esi,0x400708
0x000000000040082c <+24>: mov rdi,rax
0x000000000040082f <+27>: call 0x4006f8 <_ZNSolsEPFRSoS_E@plt>
0x0000000000400834 <+32>: mov eax,0x0
0x0000000000400839 <+37>: leave
0x000000000040083a <+38>: ret
End of assembler dump.
>>>>>>cb_gdb:
> next
******************* 8 Hello world!****************
/mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:8:137:beg:0x400834
>>>>>>cb_gdb:
> info locals
No locals.
>>>>>>cb_gdb:
> info args
No arguments.
>>>>>>cb_gdb:
> info frame
Stack level 0, frame at 0x7fffffffe110:
rip = 0x400834 in main (/mnt/sg_home/yys/dev/miscellaneous/helloworld/helloworld/main.cpp:8); saved rip 0x3ad861ecdd
source language c++.
Arglist at 0x7fffffffe100, args:
Locals at 0x7fffffffe100, Previous frame's sp is 0x7fffffffe110
Saved registers:
rbp at 0x7fffffffe100, rip at 0x7fffffffe108
>>>>>>cb_gdb:
> cont
Program exited normally.
>>>>>>cb_gdb:
> quit
-------------------log in window Debugger(debug), end -----------------------------------------------
Now I'm trying to build my plugin for Maya and debug my plugin. Here is the steps:
- I don't know that my CentOS6.4(Final) has several default packages for CMake. They are cmake-2.6.4-5.el6(x86_64), cmake28-2.8.11.2-1.el6(x86_64), cmake-gui-2.6.4-5.el6(x86_64), cmake28-gui-2.8.11.2-1.el6(x86_64), and these packages are not installed at all. Because I don't know about this, I download and install the latest cmake packages for CentOS6 from pkgs.org, they are cmake-2.8.12.2-4.el6.x86_64.rpm and cmake-gui-2.8.12.2-4.el6.x86_64.rpm.
- I use CMake2.8.12.2 to generate the CodeBlocks project scripts (in CMake script, CMAKE_CXX_FLAGS_DEBUG is set to '-g', CMAKE_BUILD_TYPE is set to 'Debug').
- launch the generated CodeBlocks project script,
- In "Settings / Compiler and debugger settings / Global compiler settings / Compiler Flags", I make sure that '-g' is turned on.
- Rebuild workspace , here is the build log:
-------------- Clean: all in mystring ---------------
Cleaned "mystring - all"
-------------- Build: all in mystring ---------------
Using makefile: Makefile
[ 33%] Building CXX object src/CMakeFiles/mystring.dir/mystring.cpp.o
[ 66%]
Building CXX object src/CMakeFiles/mystring.dir/plugin.cpp.o
[100%] Building CXX object src/CMakeFiles/mystring.dir/main.cpp.o
Linking CXX shared library /j/HOME/yys/dev/mybox/mystring/plug-ins/mystring.so
[100%] Built target mystring
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
- press menu item "Debug / Attach to Process" to attach CodeBlocks debugger to Maya. Now Maya is blocked and there is a lot of message in Debugger window.
- set a breakpoint, and here is the log in 'CodeBlock Debugger(debug)' window:
>>>>>>cb_gdb:
> break "/mnt/sg_home/yys/dev/mybox/mystring/src/main.cpp:8"
No source file named /mnt/sg_home/yys/dev/mybox/mystring/src/main.cpp.
Breakpoint 2 ("/mnt/sg_home/yys/dev/mybox/mystring/src/main.cpp:8) pending.
In fact, the directory /mnt/sg_home equals to /j/HOME, so /mnt/sg_home/yys/dev/mybox/mystring/src/main.cpp and /j/HOME/yys/dev/mybox/mystring/src/main.cpp are the same file. I don' know why gdb complains about this.
- press menu item 'Debug/Continue', then Maya crashes, I can't debug my code at all. Here is the log in 'CodeBlock Debugger(debug)' window:
>>>>>>cb_gdb:
> run
[Thread debugging using libthread_db enabled]
Catchpoint 1 (exception thrown), 0x0000003ae52bccb0 in __cxa_throw () from /usr/lib64/libstdc++.so.6
>>>>>>cb_gdb:
I hope that I described my problem clearly, and could you tell me why Maya crashes when I press 'Debug/Continue'? and how to solve this problem?
Regards