Author Topic: Compiling codeblocks original source code to develop my own customized codeblock  (Read 2306 times)

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
Please Enable full debug logging: Settings->Debugger->Common->Full (Debug) log. There you see exactly what is going on, and why the debugger fails.


Quote
Plugin question:
So do I need to copy my complete source code and put it inside plugin section in codeblocks_svn_code?
No. Simply open both projects in one workspace (by opening simply both projects). But the settings of the projects have to be ok, and i think there is your problem...

As Tim suggested you should try to build and debug a contrib plugin first.
1) For this open a contrib plugin project from /PATHTOCODEBLOCKS/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cbp .
2) Then open /PATHTOCODEBLOCKS/src/CodeBlocks.cbp .
3) Activate again the ProjectOptionsManipulator.cbp by double click int the Management pane. This project should now be marked as active (The name is bold).
4) Check if the correct "default" target is selected in the toolbar near the build button
5) In the Management panel browse to Codeblocks/Source/src/app.cpp  (BUT DON'T ACTIVATE THE PROJECT) and go to line 610. Set a breakpoint there
6) Set a breakpoint of interest in the ProjectOptionsManipulator source
7) Now hit the debugger button
8) It should now halt first at src/app.cpp:610
9) Hit continue if the debugger stops until you hit the desired breakpoint

If this works you can look into the project settings, how the project is set up and compare it wit your settings. Then you should find the error why your plugin is not debugging correctly. If you have found the error can you please post it here?

[EDIT:] I am not sure but probably you have to build codeblocks with debugging symbols enabled. You do this by Settings->Global Variables->cb_release_type and add "-g" in the "base" field. Then you have to rebuild Codeblocks by hitting Build->Rebuild
« Last Edit: February 21, 2017, 10:41:14 am by BlueHazzard »

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
Ok , i think i have found your problem. The wizard script for plugins is not really created for targets to be able to debug. I have created a updated script:
0) Close Codeblocks
1) Download the attached archive
1.1) Extract the archive
2) copy the extracted script to YOUR_CODEBLOCKS_INSTALLATION_DIRECTORY\share\CodeBlocks\templates\wizard\plugins\wizard.script
3) Open codeblocks by clicking on YOUR_CODEBLOCKS_INSTALLATION_DIRECTORY\codeblocks.exe
4) Create a new project: Codeblocks plugin
5) Go trough the wizard pages
6) This should create a project with two targets: "default" and "to_codeblocks"
   * "default"               will create the normal PLUGIN_NAME.cbplugin file for installation
   * "to_codeblocks"   will build and install the plugin in one step to your development version of codeblocks. With this target debugging should work out of the box

If this works i will try to talk to the devs to update the script

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86

Hi @BlueHazzard

Thanks for the detailed explanation.
Quote
No. Simply open both projects in one workspace (by opening simply both projects). But the settings of the projects have to be ok, and i think there is your problem...

As Tim suggested you should try to build and debug a contrib plugin first.
1) For this open a contrib plugin project from /PATHTOCODEBLOCKS/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cbp .
2) Then open /PATHTOCODEBLOCKS/src/CodeBlocks.cbp .
3) Activate again the ProjectOptionsManipulator.cbp by double click int the Management pane. This project should now be marked as active (The name is bold).
4) Check if the correct "default" target is selected in the toolbar near the build button
5) In the Management panel browse to Codeblocks/Source/src/app.cpp  (BUT DON'T ACTIVATE THE PROJECT) and go to line 610. Set a breakpoint there
6) Set a breakpoint of interest in the ProjectOptionsManipulator source
7) Now hit the debugger button
8) It should now halt first at src/app.cpp:610
9) Hit continue if the debugger stops until you hit the desired breakpoint
I follow the steps and it works fine.Thanks

After it, I go to ProjectOptionsManipulator.cbp and then go into it build options (right click->buildOptions) but it has no any relevant settings inside. I mean Other directories tab doesn't contain any path and same with linker and compiler settings. Even pre/post build steps tab also doesn't contain any info. Then I go into the ProjectOptionsManipulator project Properties, There also I compared the settings it was fine.
I checked into the files inside projectOptionsManipulator contrib plug, Th only additional file is makefile, which is not available in my menuplugin project.

Quote
If this works you can look into the project settings, how the project is set up and compare it wit your settings
By this, did you mean to compare the settings present in makefile?

After matching the properties, I am getting the error while debugging
My debuggerlog after matching project properties:
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
default
Adding source dir: C:\zbcqcm\codeblocks_svn_code\code\src\plugins\contrib\MenuPlugin\
Adding source dir: C:\zbcqcm\codeblocks_svn_code\code\src\plugins\contrib\MenuPlugin\
Adding file: C:\zbcqcm\codeblocks_svn_code\code\src\devel\codeblocks.exe
Changing directory to: C:/zbcqcm/codeblocks_svn_code/code/src/devel
Set variable: PATH=.;C:\zbcqcm\codeblocks_svn_code\code\src\devel;C:\wxMSW-2.8.12\wxMSW-2.8.12\lib\gcc_dll;C:\MinGW\bin;C:\MinGW;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\doxygen\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\SEGGER\JLink_V610l;C:\GNU_Tools_ARM_Embedded\6.2_2016q4\bin;C:\arm-none-eabi-gcc-4.8.2_nl-1.19.0_bu-2.23.2-mingw32-netx.0\arm-none-eabi-gcc-4.8.2\arm-none-eabi\bin;C:\arm-none-eabi-gcc-4.8.2_nl-1.19.0_bu-2.23.2-mingw32-netx.0\arm-none-eabi-gcc-4.8.2\bin;C:\gcc-arm-none-eabi-6_2-2016q4-20161216-win32\arm-none-eabi\bin;C:\gcc-arm-none-eabi-6_2-2016q4-20161216-win32\bin;C:\SysGCC\arm-elf\bin;C:\SysGCC\arm-eabi\bin;C:\Program Files (x86)\AXSEM\AXSDB\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\TDM-GCC-32\bin;C:\Program Files (x86)\WinRAR;C:\Program Files (x86)\GNU Tools ARM Embedded\6.2 2016q4\bin;C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.5\arm\bin;\\ C\CB_20161120_rev10922_win32\zip300xn-x64\zip300xn-x64;\\ C\boost\boost-jam-3.1.18-1-ntx86\boost-jam-3.1.18-1-ntx86;C:\Program Files\Git\bin;C:\cygwin64\bin;C:\codeblocks zip\zip300xn-x64\zip300xn-x64

[debug]Command-line: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet  -args C:/zbcqcm/codeblocks_svn_code/code/src/devel/codeblocks.exe
[debug]Working dir : C:\zbcqcm\codeblocks_svn_code\code\src\devel

Starting debugger: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet  -args C:/zbcqcm/codeblocks_svn_code/code/src/devel/codeblocks.exe
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:/zbcqcm/codeblocks_svn_code/code/src/devel/codeblocks.exe...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.9.1
[debug]Copyright (C) 2015 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.9.1

[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 200
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\zbcqcm\codeblocks_svn_code\code\src\devel\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/MenuPlugin/
[debug]Source directories searched: C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/MenuPlugin;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/zbcqcm/codeblocks_svn_code/code/src/src/app.cpp:610"
[debug]Breakpoint 2 at 0x402d12: file C:\zbcqcm\codeblocks_svn_code\code\src\src\app.cpp, line 610.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:181"
[debug]No source file named C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp.
[debug]Breakpoint 3 ("C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:181") pending.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:161"
[debug]No source file named C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp.
[debug]Breakpoint 4 ("C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:161") pending.
[debug]>>>>>>cb_gdb:
[debug]> break "C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:85"
[debug]No source file named C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp.
[debug]Breakpoint 5 ("C:/zbcqcm/codeblocks_svn_code/code/src/plugins/contrib/ProjectOptionsManipulator/ProjectOptionsManipulator.cpp:85") pending.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\zbcqcm\codeblocks_svn_code\code\src\devel\codeblocks.exe

Child process PID: 4488

[debug][New Thread 4488.0xfcc]
[debug]Breakpoint 2, CodeBlocksApp::OnInit (this=0x5d707f0) at C:\zbcqcm\codeblocks_svn_code\code\src\src\app.cpp:610
[debug]C:\zbcqcm\codeblocks_svn_code\code\src\src\app.cpp:610:21787:beg:0x402d12
[debug]>>>>>>cb_gdb:

At C:\zbcqcm\codeblocks_svn_code\code\src\src\app.cpp:610
Continuing...

[debug]> cont
[debug]Continuing.
[debug]Starting Code::Blocks svn build  rev 0 Feb  7 2017, 17:16:55 - wx2.8.12 (Windows, unicode) - 32 bit
[debug][Inferior 1 (process 4488) exited with code 037777777777]
[debug]>>>>>>cb_gdb:

[Inferior 1 (process 4488) exited with code 037777777777]

[debug]> quit

Debugger finished with status 0

Quote
I am not sure but probably you have to build codeblocks with debugging symbols enabled. You do this by Settings->Global Variables->cb_release_type and add "-g" in the "base" field. Then you have to rebuild Codeblocks by hitting Build->Rebuild
I did the build, using "-g" symbol inside cb_release_type.

I will check your wizard, once I understand the makefile present in projectOptionsManipulator plugin.
[/quote]
« Last Edit: February 22, 2017, 07:57:07 am by anandamu16 »

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86
Quote
Ok , i think i have found your problem. The wizard script for plugins is not really created for targets to be able to debug. I have created a updated script:
0) Close Codeblocks
1) Download the attached archive
1.1) Extract the archive
2) copy the extracted script to YOUR_CODEBLOCKS_INSTALLATION_DIRECTORY\share\CodeBlocks\templates\wizard\plugins\wizard.script
3) Open codeblocks by clicking on YOUR_CODEBLOCKS_INSTALLATION_DIRECTORY\codeblocks.exe
4) Create a new project: Codeblocks plugin
5) Go trough the wizard pages
6) This should create a project with two targets: "default" and "to_codeblocks"
   * "default"               will create the normal PLUGIN_NAME.cbplugin file for installation
   * "to_codeblocks"   will build and install the plugin in one step to your development version of codeblocks. With this target debugging should work out of the box
It gives the same error, as in previous case

Quote
* "to_codeblocks"   will build and install the plugin in one step to your development version of codeblocks
Does it mean that, on building our project on "to_codeblock" target, it will build up as well as plugin gets automatically installed in codeblocks.? If its so, I checked my plugins sections inside codeblocks IDE. Plugin-> Manage Plugins-> Look into the list.
But there was no plugin installed in the list.
I also try to debug the plugin, but the error was same.

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
Quote
Does it mean that, on building our project on "to_codeblock" target, it will build up as well as plugin gets automatically installed in codeblocks.? If its so, I checked my plugins sections inside codeblocks IDE. Plugin-> Manage Plugins-> Look into the list.
But there was no plugin installed in the list.
I also try to debug the plugin, but the error was same.
Yes, it gets installed in the development output of Codeblocks (the subfolder devel, hopefully not the codeblocks folder with what you work).
Just to make things clear: There should be 3 folders with codeblocks.exe
1) CODEBLOCKS_INSTALLATION <-- Something like C:\Program Files\Codeblocks  - This is your installation of codeblocks. If you use Codeblocks in your daily work this executable should be used
2) CODEBLOCKS_DEVEL  <-- Something like C:\User\MYUSER\Documents\Programming\Codeblocks\src\codeblocks_sf\src\devel   - This is the output directory if you build codeblocks. This gets overwritten every time you build codeblocks
3) CODEBLOCKS_OUTPUT  <-- This folder gets created/updated if you run the update.bat script from the src folder. You can copy the content from this folder over CODEBLOCKS_INSTALLATION to update your installation

Now if you run my script and build the "to_codeblock" target the output gets copied and installed to CODEBLOCKS_DEVEL. Now if you want to run your plugin you have to run CODEBLOCKS_DEVEL\codeblocks.exe.

I made a mistake in the script: the run parameter for codeblocks are missing. For the target to_codeblocks you should add
Code: [Select]
--debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose -p debugTo Project->Set programs argument->Program arguments    You have to select the correct target from the list.
i have attached a updated version of the script




Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
Code: [Select]
[debug]> cont
[debug]Continuing.
[debug]Starting Code::Blocks svn build  rev 0 Feb  7 2017, 17:16:55 - wx2.8.12 (Windows, unicode) - 32 bit
[debug][Inferior 1 (process 4488) exited with code 037777777777]
[debug]>>>>>>cb_gdb:

Your application still crashes and at the moment i have no idea how i can help you with this...

[EDIT:] Can you post the code of your plugin?

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86
Quote
Now if you run my script and build the "to_codeblock" target
You want me to run your script through CODEBLOCKS_INSTALLATION or CODEBLOCKS_DEVEL?
FYI: I am developing everything through CODEBLOCKS_DEVEL and checking on CODEBLOCKS_DEVEL only.
Note: I used CODEBLOCKS_INSTALLATION to create CODEBLOCKS_DEVEL and from then I am using only CODEBLOCKS_DEVEL. Let me know, if i am doing something wrong.?
I will make a plugin project separately through CODEBLOCKS_DEVEL based on "your" wizard. I will add the project here itself.
Bdw I don't think, It is something related to plugin code.

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86
ok, let me update it.
I will use the same terminology like below.
Quote
1) CODEBLOCKS_INSTALLATION <-- Something like C:\Program Files\Codeblocks  - This is your installation of codeblocks. If you use Codeblocks in your daily work this executable should be used
2) CODEBLOCKS_DEVEL  <-- Something like C:\User\MYUSER\Documents\Programming\Codeblocks\src\codeblocks_sf\src\devel   - This is the output directory if you build codeblocks. This gets overwritten every time you build codeblocks
3) CODEBLOCKS_OUTPUT  <-- This folder gets created/updated if you run the update.bat script from the src folder. You can copy the content from this folder over CODEBLOCKS_INSTALLATION to update your installation

Firstly: I create a plugin through CODEBLOCKS_DEVEL  and try to execute it. It gave me the execution error.
Next: I create a plugin through CODEBLOCKS_INSTALLATION (with updated wizard.script for plugin that you shared)and try to execute it. It works fine i.e; after execution it opens the CODEBLOCKS_DEVEL  IDE window to check the plugin.
Next:  I create a plugin through CODEBLOCKS_INSTALLATION (with default wizard.script for plugin that comes by default)and try to execute it, it gave me the same error that I was receiving from beginnin.
So, I doubt my plugin is executing fine because of the changes you have made in wizard.script file. Can you help me to understand the changes?

So my question is:
- Why it didn't work in the First case?
- So for now, I should remember that.... I need to develop everything through CODEBLOCKS_INSTALLATION, check it on CODEBLOCKS_DEVEL and for distribution, I should use CODEBLOCKS_OUTPUT?
- I tried to build wxwidget application through CODEBLOCKS_DEVEL  and try to execute it using CODEBLOCKS_DEVEL only and that works fine, why was it so. I mean likewise plugin, wxwidget application should also fail to execute but that worked fine?

« Last Edit: February 22, 2017, 12:36:30 pm by anandamu16 »

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
You copy the script to CODEBLOCKS_INSTALLATION or CODEBLOCKS_OUTPUT. Then you run the appropriate codeblocks.exe. With this instance you create and develop your plugin. If you run the plugin it will run trough CODEBLOCKS_DEVEL with a separate profile so you won't kill your working environment if something goes wrong.

Generally you should not run CODEBLOCKS_DEVEL while you are developing on codeblocks/plugins but always  CODEBLOCKS_INSTALLATION or minimal CODEBLOCKS_OUTPUT.
Things are like this
not stable                     < a bit stable                    < stable
CODEBLOCKS_DEVEL   < CODEBLOCKS_OUTPUT  < CODEBLOCKS_INSTALLATION

Also CODEBLOCKS_DEVEL will get overwritten every time you build codeblocks.

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
What i changed in the script:
1) Add the target to_codeblocks
1.1) Set the output directory to CODEBLOCKS_DEVEL
1.2) Copy all needed resources to  CODEBLOCKS_DEVEL
1.3) Add the call parameters so CODEBLOCKS_DEVEL will get called with a grade of isolation

Now this makes it possible to debug the plugin. It should not influence your plugin, but only how you debug it. So if you say it "executes" right do you mean "debugging" or also executing?
One possibility would be that you are missing some DLL and if you call it with CODEBLOCKS_DEVEL all dlls are in place, but it is hard to tell...

Q: Why are this steps needed for debugging the plugin?
GDB needs a executable to debug dlls (a plugin is a dll) and in our case this is CODEBLOCKS_DEVEL. My script copies all to CODEBLOCKS_DEVEL and runs CODEBLOCKS_DEVEL trought the debugger. CODEBLOCKS_DEVEL will then load your plugin and you can debug it.


Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86
Quote
What i changed in the script:
1) Add the target to_codeblocks
1.1) Set the output directory to CODEBLOCKS_DEVEL
1.2) Copy all needed resources to  CODEBLOCKS_DEVEL
1.3) Add the call parameters so CODEBLOCKS_DEVEL will get called with a grade of isolation
If the changes are required in the script, how it was working before for other users? Everyone should have the problem, not only me? :(

Quote
So if you say it "executes" right do you mean "debugging" or also executing?
I mean 'executing'. i.e; build and run command.

Quote
One possibility would be that you are missing some DLL and if you call it with CODEBLOCKS_DEVEL all dlls are in place, but it is hard to tell...
You mean to say that.....So this could be the possible reason to not work with CODEBLOCKS_DEVEL?



Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1273
Quote
If the changes are required in the script, how it was working before for other users? Everyone should have the problem, not only me? :(
Probably it never worked, and all developer fixed the project by them self (and also there are not that many plugin developer out there)...

Quote
You mean to say that.....So this could be the possible reason to not work with CODEBLOCKS_DEVEL?
I have no idea... this was a shot in the dark

Offline anandamu16

  • Multiple posting newcomer
  • *
  • Posts: 86
Thanks for the help. Creating and executing a plugin otherwise will be a great challenge for any new plugin developer.
I will post here in case I faced any additional error.

Moreover, may be your modified wizard script for plugins can be linked to codeblocks default plugin wizard by codeblocks official developers.