Author Topic: Help with debugging codeblocks build from sources  (Read 3061 times)

Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Help with debugging codeblocks build from sources
« on: June 17, 2021, 04:19:03 am »
Can someone point me to a doc/web page/thread or anything that will show to tell or let me know how to debug a build of the codeblocks.exe from source using the nightly 12458 downloaded executable  so I can figure out why the codeblocks.exe and dll's I built is crashing when I try to build a simple C++ test file.

Background:
I have cloned https://github.com/obfuscated/codeblocks_sf and downloaded wxWidget 3.1.5 source (https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.5/wxWidgets-3.1.5.zip).
I have build wxwidget with NO patches. If this is wrong please let me know where I can grab the patches or correct wxwidget sources.
I have built codeblocks using the CodeBlocks_wx31_64.cbp project file and then run the update31_64.bat.
The codeblocks source does NOT have any of my changes in it.
The nightly 12458 calls the GCC exe and therefore builds the simple C++ test file.


Build Status:
The built codeblocks.exe starts and loads projects, but when I build I get an exception thrown in ntdll.dll that looks like a corrupted filespec in the call to findfirst() from the call stack in the attached codeblocks.RPT file.

Call stack Snippet:
codeblocks.exe caused an Access Violation at location 00007FFDB40FFAAD in module ntdll.dll Writing to location 00000000489E40B0.

AddrPC           Params
00007FFDB40FFAAD 00000068651FA7C0 00000068651F9C80 00000068651F9C50  ntdll.dll!RtlEnterCriticalSection
00007FFDB19E94B5 6968637200000001 0000000000000000 00000000489E4080  KERNELBASE.dll!FindNextFileW
00007FFDB19E9358 00007FFD4BB78F44 00007FFD4BB78F43 0000000000000000  KERNELBASE.dll!FindNextFileA
00007FFDB2F66DAA 0000000000000000 0000000000000000 00000068651FA790  msvcrt.dll!_findnext64
00007FFD4BB4B546 0000000000000000 00007FFD4BB4A700 0000000000000000  compiler.dll!file_dirscan
00007FFD4BB4AA3D 0000000000000000 0000000000000000 0000000000000000  compiler.dll!timestamp
00007FFD4BB46E47 0000000000000010 00007FFD4BB60990 0000000000000001  compiler.dll!depsTimeStamp
00007FFD4BB3D495 00000068651FBD20 000001E848C3BB28 0000000000000000  compiler.dll!DirectCommands::IsObjectOutdated


Windows Version:
I am running Windows 10 21H1 with MS patches up until Monday night.
I have MSYS2 using mingw64 with latest updates as of yesterday morning (24 hrs ago).


Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Re: Help with debugging codeblocks build from sources
« Reply #1 on: June 17, 2021, 06:01:13 am »
I have figured out how to debug the codeblocks.exe built from source within the nightly codeblocks exe, but I cannot get breakpoints I set in code that is in the compiler.dll plugin to break in the nightly codeblokcs.exe. Looks like more google and forum searching.

Any pointers with debugging a plugin dll?

Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Re: Help with debugging codeblocks build from sources
« Reply #2 on: June 17, 2021, 06:18:31 am »
Worked it out  project did not have debug compiler option "-g" enabled.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Help with debugging codeblocks build from sources
« Reply #3 on: June 17, 2021, 10:41:09 am »
There is a global variable cb_release_type. Set it to something like "-O0 -g"
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline gd_on

  • Lives here!
  • ****
  • Posts: 665
Re: Help with debugging codeblocks build from sources
« Reply #4 on: June 17, 2021, 11:52:56 am »
I had a similar problem described in https://forums.codeblocks.org/index.php/topic,24363.msg166172.html#msg166172 : RPT file looks very similar.
I published a patch (ticket #1086: https://sourceforge.net/p/codeblocks/tickets/1086/) which solved the problem for me, but has not been still integrated in official distribution. May be you can try it.
And if you use gcc from msys2 last version (with gcc 10.3 64 bits), you'll probably will have an other problem described in https://forums.codeblocks.org/index.php/topic,24486.0.html but I have no solutions for that, except to use an "old" compiler version, before the last update of binutils to 2.36!
« Last Edit: June 17, 2021, 12:10:45 pm by gd_on »
Windows 10 64 bits (21H1), svn C::B (last version or almost!), wxWidgets 3.1.5, Msys2 Compilers 10.3.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (sjlj, posix in C:\msys64\mingw32).

Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Re: Help with debugging codeblocks build from sources
« Reply #5 on: June 17, 2021, 12:31:36 pm »
Thanks gd_on. Looks like you have come across the problems I am encounting and the post will help a HUGE amount as the links make sense and appear to be related to the issues I have come accross. I created the post below before your post and was updating it based on the -Ox changes and then hit the post button and the web site coded poped up info that there was another post.

I am going to call it a night (Sydney OZ) and will pickup in the morning.

I will apply the patch and read the MSYS2 thread in the morning. Have you posted anything on the MSYS2 github issues list or a GNU bug list? Is there anything I can do to help out after applying the patch and reading the thread?


Original post below before sd_on response was seen:

I have been debugging the code and the problem is in code that has not changed in 8+ years, so I have discounted a bug in CB.

My debugging has traced the issue to src\plugins\compilergcc\depslib\src\fileent.c file on line 107:
Code
sprintf( filespec, "%s/*", dir );

When I step to this line the dir variable becomes out of scope and therefor the filespec is "undefined" as in whet ever the underlying memory is......

The failing code above was built with "-g -O2" using gcc.exe (Rev2, Built by MSYS2 project) 10.3.0.
If I build with "-g -Og" then line 107 works, but there is still an exception thrown.
If I build with "-g -O0" then I get the following error when GDB tries to run the exe:
The procedure entry point _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev could not be located in the dynamic link library F:\Andrew_Development\codeblocks_sf\src\devel31_64\codeblocks.dll.


Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Re: Help with debugging codeblocks build from sources
« Reply #6 on: June 18, 2021, 02:36:22 am »
I am now able to build codeblocks from source and it runs correctly now with the fileent.c changed and using "-g -Og" compile options.

Offline AndrewCot

  • Almost regular
  • **
  • Posts: 175
Re: Help with debugging codeblocks build from sources
« Reply #7 on: June 18, 2021, 02:52:38 am »
Any updates / eta when the  fileent.c changes will be completed (ticket #1086: https://sourceforge.net/p/codeblocks/tickets/1086/).

BTW my 2c on the change is that in the \src\plugins\compilergcc\depslib\src\hash.c  file there is a __LP64__ macro used that may be a better fit if the first patch is going to be used in addition to the _WIN64 as __LP64__ is applicable for GCC and looks like it is supported on Windows (Cygwin & MSYS2) and Linux and MacOS. I personally do not have a preference for which patch is applied, but it probably needs to be done sooner so devs like I have do not fall into the hole like I did going forward.