I think there is a bug when debugging. (I'm using windows XP and Mingw from TDragon.
My program was linked to the debug library of opencv. which are located in:
F:\test1\lib\***
the source file is located in
F:\opencv\src\cxcore\***
It seems that I can't set break points in the source file. GDB complaints that :
> break "F:/opencv/src/cxcore/cxarray.cpp:104"
No source file named F:/opencv/src/cxcore/cxarray.cpp.
Breakpoint 3 ("F:/opencv/src/cxcore/cxarray.cpp:104) pending.
>>>>>>cb_gdb:
But my source file is exactly named "F:/opencv/src/cxcore/cxarray.cpp", my program will call some function in the cxarray.cpp.
Also, another problem is I can't "step into" the source code. ( This functionality is available in the last svn release).
The problem seems happens in this SVN version. The last version works well as I can remember.
I search the forum and found some related discussion.
I download the zip from the thread:
http://forums.codeblocks.org/index.php/topic,4896.msg38390.html#msg38390
And still it can't set break point in the DLL source file.
Some one can explain it?
Thanks.
ollydbg,
Just a thought, but TDM's release of GCC 4.3.2 TDM-2 dated 1008-12-09 includes a fix that solved a similar debug problem that I was having. This was for break points in a header file so it may not apply, but you might consider it if you are using an earlier release.
HI, Thanks for your hint. Actually, I already use the TDM's 4.3.2 TDM-2 2008-12-09 as you mentioned.
Maybe, it is related to the "setting break point in a header file" issue, maybe not, I'm not sure. :(
The problem seems comes from "How does the compiler and GDB handle with the path of source file".
I test the zip file from :
http://forums.codeblocks.org/index.php/topic,4896.msg38390.html#msg38390
There are two build targets. One is a exe file. The other is a DLL file.
The exe file will load the DLL file when it runs. Both of these targets were build with Debug enabled. So, I think that in the "TestDLL.dll", there are some part to reference it's source file path.
I put the project in "C:\DebugTest"
main.cpp was located in "C:\DebugTest\TestApp"
dllmain.cpp was located in "C:\DebugTest\TestDLL"
But I can't set break point in the "dllmain.cpp".
GDB reported:
>>>>>>cb_gdb:
> break "C:/DebugTest/TestDLL/dllmain.cpp:16"
No source file named C:/DebugTest/TestDLL/dllmain.cpp in loaded symbols.
Breakpoint 2 ("C:/DebugTest/TestDLL/dllmain.cpp:16) pending.
It is very confused that sometimes the compiler can use the "relative source file path", and sometimes, they use full path. So does the GDB. (I'm not sure how does the linker handle the path related issue).
So, I'm totally lost in this problem :(, can someone give a clarification? Thanks.
Thanks jens.
I have this option enable by default.
see the attachment image.
I also enable the full compiler output, when compiling, the output are here:
-------------- Build: TestDLL in cb_debug_test ---------------
[ 50.0%] mingw32-g++.exe -Wall -g -ID:\SourceCode\Libraries\wxWidgets2.8\src\msw -c C:\DebugTest\TestDLL\dllmain.cpp -o .objs\TestDLL\dllmain.o
[100.0%] mingw32-g++.exe -shared -Wl,--out-implib=bin\libTestDLL.a -Wl,--dll .objs\TestDLL\dllmain.o -o bin\TestDLL.dll
Creating library file: bin\libTestDLL.a
Output size is 22.46 KB
-------------- Build: TestApp in cb_debug_test ---------------
[ 50.0%] mingw32-g++.exe -Wall -g -I. -ID:\SourceCode\Libraries\wxWidgets2.8\src\msw -c C:\DebugTest\TestApp\main.cpp -o .objs\TestApp\main.o
C:\DebugTest\TestApp\main.cpp: In function 'void LoadDllPlugin()':
C:\DebugTest\TestApp\main.cpp:103: warning: unused variable 'status'
[100.0%] mingw32-g++.exe -o bin\TestApp.exe .objs\TestApp\main.o -mwindows
Output size is 32.17 KB
Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 1 warnings
When debugging the exe file, I still can't set break point in anywhere in the "dllmain.cpp".
If you have enough time, you could help to test the zip file in that thread. Thanks.
http://forums.codeblocks.org/index.php?action=dlattach;topic=4896.0;attach=1707
correct! setting break points in the code below works!
// a sample exported function
void __declspec(dllexport) MyFunction(const LPCSTR sometext)
{
/** SET BREAK POINT HERE VVVVVVVVVVV **/
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
/** SET BREAK POINT HERE ^^^^^^^^^^^^ **/
}
The breakpoints can't be set in the function of DllMain.
[attachment deleted by admin]
The breakpoints can't be set in the function of DllMain.
I can set breakpoints in any of the three functions dllmain.cpp and in MyFunction without problems.
And gdb stops there of course.
g++ is 4.2.1-dw2:
C:\Dokumente und Einstellungen\jens>g++ -v
Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.2.1-2-src/configure --with-gcc --enable-libgomp --host=mingw32 --build=mingw32 --target=mingw32 --prog
ram-suffix=-dw2 --with-arch=i486 --with-tune=generic --disable-werror --prefix=/mingw --with-local-prefix=/mingw --enable-thread
s --disable-nls --enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-win32-registry --disable-sjlj-exceptions --enable-li
bstdcxx-debug --enable-cxx-flags=-fno-function-sections -fno-data-sections --enable-version-specific-runtime-libs --disable-boot
strap
Thread model: win32
gcc version 4.2.1-dw2 (mingw32-2)
gdb is 6.7.50 on my XP partition:
GNU gdb 6.7.50.20071127
Copyright (C) 2007 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".
Iwill test it with gdb 6.8 on w2k too, this evening.
It is very interesting, when I renamed the project folder name from "C:\DebugTest" to "C:\DebugTest1".
Then I open the cbp file and debug without rebuild the project. Then the gdb complaint that: (I'm using the TDM-mingw version)
Command-line: D:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet -args bin/TestApp.exe
Working dir : C:\DebugTest1\
> set prompt >>>>>>cb_gdb:
(gdb) >>>>>>cb_gdb:
> show version
GNU gdb 6.8
Copyright (C) 2008 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".
>>>>>>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 debugevents on
>>>>>>cb_gdb:
> set disassembly-flavor att
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined in loaded symbols.
>>>>>>cb_gdb:
> show directories
Source directories searched: $cdir;$cwd
>>>>>>cb_gdb:
> directory C:/DebugTest1/
>>>>>>cb_gdb:
> break "C:/DebugTest1/TestApp/main.cpp:26"
No source file named C:/DebugTest1/TestApp/main.cpp in loaded symbols.
Breakpoint 1 ("C:/DebugTest1/TestApp/main.cpp:26) pending.
>>>>>>cb_gdb:
You can see when gdb started, it use the command line:
Command-line: D:\Program Files\CodeBlocks\MinGW\bin\gdb.exe -nx -fullname -quiet -args bin/TestApp.exe
which has a parameter "-fullname", so I can't set break points in anywhere of the source file. Because the debug information in both exe and DLL file were reference to " C:\DebugTest\***".
As a workaround, I should rebuild the Target.
--- src/plugins/compilergcc/compilerMINGWgenerator.cpp (revision 5387)
+++ src/plugins/compilergcc/compilerMINGWgenerator.cpp (working copy)
@@ -36,7 +36,10 @@
wxString result = CompilerCommandGenerator::SetupIncludeDirs(compiler, target);
m_VerStr = compiler->GetVersionString();
wxString pch_prepend;
- bool IsGcc4 = m_VerStr.Left(1).IsSameAs(_T("4"));
+// bool IsGcc4 = m_VerStr.Left(1).IsSameAs(_T("4"));
+ // MinGW TDM 4.3.2-2: http://www.tdragon.net/recentgcc/
+ // compiler->GetVersionString() return is empty string
+ bool IsGcc4 = true;
// for PCH to work, the very first include dir *must* be the object output dir
// *only* if PCH is generated in the object output dir
--- src/plugins/compilergcc/compilerMINGWgenerator.cpp (revision 5387)
+++ src/plugins/compilergcc/compilerMINGWgenerator.cpp (working copy)
@@ -36,7 +36,10 @@
wxString result = CompilerCommandGenerator::SetupIncludeDirs(compiler, target);
m_VerStr = compiler->GetVersionString();
wxString pch_prepend;
- bool IsGcc4 = m_VerStr.Left(1).IsSameAs(_T("4"));
+// bool IsGcc4 = m_VerStr.Left(1).IsSameAs(_T("4"));
+ // MinGW TDM 4.3.2-2: http://www.tdragon.net/recentgcc/
+ // compiler->GetVersionString() return is empty string
+ bool IsGcc4 = true;
// for PCH to work, the very first include dir *must* be the object output dir
// *only* if PCH is generated in the object output dir
This patch is not necessary. Run the following script at Script Console -
ShowInfo(GetCompilerFactory().GetCompilerVersionString(_T("gcc")))
It should show you GCC version no. See following screenshot (showing result in my pc).
(http://img175.imageshack.us/img175/2937/gccverrz9.th.png) (http://img175.imageshack.us/my.php?image=gccverrz9.png)
I can't get the version use script.
and my config:
set PATH=%CD%\bin;%PATH%
set CPATH=%CD%\include;%CD%\lib\mingw\mingw32\4.3.2\include;%CD%\lib\mingw\mingw32\4.3.2\include\c++
set LIBRARY_PATH=%CD%\lib;%CD%\lib\mingw\mingw32\4.3.2
[attachment deleted by admin]
If possible, you can try svn r5390 and see if the issue is fixed for you.
thans! I confirm this question exist also.
I can't give MinGW TDM-2's version with r5390.
please post the output of the gcc (C- not C++-executable) you have configured in toolchain executables tab, if called with "--version" on commandline.
Please call it with absolute path as configured in the settings: <Compiler's installation directory>\bin\<C compiler> --version
Make sure you have not accidently added "bin" to the "Compiler's installation directory" in the settings !!
Thanks, it works, setting breaking points in dummy code also works.
so, in the header file:
#ifdef __cplusplus
extern "C"
{
#endif
void MyFunction(const LPCSTR sometext);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
#ifdef __cplusplus
}
#endif
#endif
After add the dummy code in each case of DllMain.
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
static int a = 0;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
a++;
break;
case DLL_PROCESS_DETACH:
// detach from process
a++;
break;
case DLL_THREAD_ATTACH:
// attach to thread
a++;
break;
case DLL_THREAD_DETACH:
// detach from thread
a++;
break;
}
return TRUE; // succesful
}
I can set break points in the line of "a++", and it works. Thanks.
Hi,
I've got a problem compiling C::B as an rpm-package for current development version of Mandriva Linux 2009.1 distribution. I guess the problem is that when building rpm packages this distribution forces the use of GCC option -Werror=format-security and it produces several error messages like this:
wiz.cpp: In member function 'void Wiz::CopyFiles(cbProject*, const wxString&, const wxString&)':
wiz.cpp:757: error: format not a string literal and no format arguments
make[4]: *** [wiz.lo] Error 1
make[4]: Leaving directory `/home/olelukoie/rpmbuild/BUILD/codeblocks/src/plugins/scriptedwizard'
Is it possible to fix and make C::B compilable with this option? (As I said there are several other messages of the same error type).
Crash Report
-------------------
Error occured on Friday, January 16, 2009 at 11:24:16.
D:\CB_Pack\codeblocks\codeblocks.exe caused an Access Violation at location 619f37e7 in module D:\CB_Pack\codeblocks\codeblocks.dll Writing to location 7c9106ab.
Registers:
eax=7c9106ab ebx=079eff00 ecx=00000000 edx=7c910732 esi=0000001f edi=060186f8
eip=619f37e7 esp=079efdd0 ebp=079efdd0 iopl=0 nv up ei pl nz ac pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010212
Call stack:
619F37E7 D:\CB_Pack\codeblocks\codeblocks.dll:619F37E7 _Z11DumpLiteralR11SQObjectPtr
617FF8EC D:\CB_Pack\codeblocks\codeblocks.dll:617FF8EC _ZN12cbThreadPool11GetNextTaskEv
618010B4 D:\CB_Pack\codeblocks\codeblocks.dll:618010B4 _ZN12cbThreadPool14cbWorkerThread5EntryEv
100A2FFD D:\CB_Pack\codeblocks\wxbase28u_gcc_cb.dll:100A2FFD _Z22wxMutexGuiLeaveOrEnterv
100A3476 D:\CB_Pack\codeblocks\wxbase28u_gcc_cb.dll:100A3476 _ZN8wxThreadD1Ev
77C3A3B0 C:\WINDOWS\system32\msvcrt.dll:77C3A3B0 _endthreadex
7C80B50B C:\WINDOWS\system32\kernel32.dll:7C80B50B GetModuleFileNameA
Patch needed for Windows NON-PCH building of C::B main project.
Tim S
Index: src/sdk/macrosmanager.cpp
===================================================================
--- src/sdk/macrosmanager.cpp (revision 5406)
+++ src/sdk/macrosmanager.cpp (working copy)
@@ -12,6 +12,7 @@
#ifndef CB_PRECOMP
#include <wx/menu.h>
+ #include "cbworkspace.h"
#include "projectmanager.h"
#include "editormanager.h"
#include "logmanager.h"
Index: src/plugins/compilergcc/compilerMINGW.cpp
===================================================================
--- src/plugins/compilergcc/compilerMINGW.cpp (revision 5406)
+++ src/plugins/compilergcc/compilerMINGW.cpp (working copy)
@@ -18,6 +18,7 @@
#include <wx/filename.h>
#include <wx/filefn.h>
#include "manager.h"
+#include "macrosmanager.h"
#include "logmanager.h"
#include "compilerMINGWgenerator.h"
Please let's CodeCompletion support sort:
Index: plugins/codecompletion/codecompletion.cpp
===================================================================
--- plugins/codecompletion/codecompletion.cpp (revision 5422)
+++ plugins/codecompletion/codecompletion.cpp (working copy)
@@ -935,6 +935,8 @@
return -5;
}
+ arr.Sort();
+
// select tokens
MultiSelectDlg dlg(Manager::Get()->GetAppWindow(), arr, true);
if (dlg.ShowModal() == wxID_OK)
a bug
code:
template <typename X>
int Bugtest(X _x)
{
return sizeof(_x); //set breakpoint here
}
int main()
{
int t_ix = 1;
cout << Bugtest(t_ix) << endl;
char t_cx = '0';
cout << Bugtest(t_cx) << endl;
return 0;
}
on first break, open zhe disassembly window, can find the asm code like:
00417758 push ebp
00417759 mov ebp,esp
0041775B mov eax,0x4
00417760 leave
00417761 ret
current eip is 41775b
continue,
on second break, the current eip is 417750, but the disassembly window show the asm code is same as the first,
can't find the current asm code.
my english is pool, sorry
I tested it, but there's no problem.
In first break, the disassembly code is like below:
00417758 push ebp
00417759 mov ebp,esp
0041775B mov eax,0x4
00417760 leave
00417761 ret
In second break, the disassembly code is like below:
00417744 push ebp
00417745 mov ebp,esp
00417747 sub esp,0x4
0041774A mov eax,DWORD PTR [ebp+0x8]
0041774D mov BYTE PTR [ebp-0x4],al
00417750 mov eax,0x1
00417755 leave
00417756 ret
So, it works fine in my computer. I'm using TDM-mingw.