Author Topic: Change the Debugger Toolbar on the fly  (Read 18866 times)

Offline e.p

  • Multiple posting newcomer
  • *
  • Posts: 12
Change the Debugger Toolbar on the fly
« on: May 26, 2011, 12:24:40 pm »
Hello, I am bothering you again ;-)

I am adding a second debugger on the framework created by obfuscated.
Problem: the functions of my debugger are different from the functions of gdb, so I need a different toolbar with different tools.

I managed to change on the fly the Debug menu (I call in DebuggerMenuHandler::SetActiveDebugger a slightly modified version of DebuggerManager::GetMenu).
I am now trying to do the same with the toolbar, but without success.

I modified DebuggerToolbarHandler::GetToolbar and it does what I want. But calling it does not replace the toolbar.
Making MainFrame::CreateToolbars public and calling it adds the right toolbar, but after it I have everything twice. A solution would be to delete all the toolbars (how?) and then call MainFrame::CreateToolbars.

Is there a better way? Hints? Am I missing something?

Regards
e.p

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #1 on: May 26, 2011, 12:31:53 pm »
Hm, tell us what you want to have in the toolbar and we(I) will see if they could be added/implemented.
What kind of debugger?
Is your plugin going to be open sourced?

Can you show me the changes you've made?
(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 e.p

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Change the Debugger Toolbar on the fly
« Reply #2 on: May 26, 2011, 01:33:41 pm »
Hm, tell us what you want to have in the toolbar and we(I) will see if they could be added/implemented.

I don't think it would make sense. The functions are very specific and would be of no use for normal debuggers (it is a hardware debugger).

Quote
What kind of debugger?

A debugger for a microcontroller unit.

Quote
Is your plugin going to be open sourced?

It will be distributed freely to the developers using the microcontroller.
In order to make it work, I had to make changes to the code of CB, so it will not be available as plugin, but only as packet together with the "special" version of CB.

Quote
Can you show me the changes you've made?

We run two different networks: the development network (without internet access) and the external network. So I can not show you the code directly.
I'll explain you what I did and if you want more details, ask. I can copy small snippets of code if needed.



  • copy debuggergdb folder and paste it as debuggerA
  • renamed everything until I had a properly compiling project with two debuggers (which did exactly the same)
  • adapted debuggerA (executable name, prompt, options, ParseOutput,...)
  • since the debugging windows are very different and I need to call functions of their classes from ParseOutput, I created other classes for them (e.g. A_cbCPURegistersDlg instead of cbCPURegistersDlg)
  • added in the .xrc files objects like "debugger_A_menu" (the same for the toolbar)
  • added to DebuggerMenuHandler::SetActiveDebugger the following line: Manager::Get()->GetDebuggerManager()->GetMenu();
  • edited GetMenu so that the menu gets deleted each time and then rebuilt using either "debugger_A_menu" or "debugger_menu" according to the active debugger
  • added in debuggermenu.cpp the IDs, the event table entries and the event handlers for the A-menu

This works like a gem. The problem I am facing is how to adapt the toolbar, too.

Thank you for your help
e.p

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #3 on: May 26, 2011, 02:04:56 pm »
It will be distributed freely to the developers using the microcontroller.
In order to make it work, I had to make changes to the code of CB, so it will not be available as plugin, but only as packet together with the "special" version of CB.
Keep in mind that most of the sources of C::B are licensed under the GPL v3 license, some are LGPL v3. Look at the top of the files you modify for the correct license.
(some files in the SDK have wrong licenses btw). So if you modify a GPL file you can't redistribute binaries without redistributing the changes to that code.
LGPL is relatively similar.



  • copy debuggergdb folder and paste it as debuggerA
  • renamed everything until I had a properly compiling project with two debuggers (which did exactly the same)
  • adapted debuggerA (executable name, prompt, options, ParseOutput,...)
  • since the debugging windows are very different and I need to call functions of their classes from ParseOutput, I created other classes for them (e.g. A_cbCPURegistersDlg instead of cbCPURegistersDlg)
  • added in the .xrc files objects like "debugger_A_menu" (the same for the toolbar)
  • added to DebuggerMenuHandler::SetActiveDebugger the following line: Manager::Get()->GetDebuggerManager()->GetMenu();
  • edited GetMenu so that the menu gets deleted each time and then rebuilt using either "debugger_A_menu" or "debugger_menu" according to the active debugger
  • added in debuggermenu.cpp the IDs, the event table entries and the event handlers for the A-menu

This works like a gem. The problem I am facing is how to adapt the toolbar, too.

Thank you for your help
e.p
Hm, sounds like a big hack. And why have you copied the debuggergdb directory?
Why haven't you started a new plugin, there is a wizard which does almost perfect job?

My advice would be to not use the Debugger menu and Debugger toolbar, but use your separate version.
Every plugin can have a menu and a toolbar, see the other plugins how to do it.

And I'm asking again, what do you want to have in the toolbar, how could it be so different to the normal debugger?
(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 e.p

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Change the Debugger Toolbar on the fly
« Reply #4 on: May 26, 2011, 02:22:56 pm »
Keep in mind that most of the sources of C::B are licensed under the GPL v3 license, some are LGPL v3. Look at the top of the files you modify for the correct license.
(some files in the SDK have wrong licenses btw). So if you modify a GPL file you can't redistribute binaries without redistributing the changes to that code.
LGPL is relatively similar.

This is no problem. What I am saying is that you cannot use it as single plugin in a "normal" version of CB. You need the rest of the modified code too.


Quote
Hm, sounds like a big hack. And why have you copied the debuggergdb directory?
Why haven't you started a new plugin, there is a wizard which does almost perfect job?

Because I can recycle a lot of your code ;-)

Quote
And I'm asking again, what do you want to have in the toolbar, how could it be so different to the normal debugger?

We have no "Run to cursor" and no "Information windows".
No "Call stack" and no "Threads". In return we have a "Pin Emulation" and a "Debugger Link" window. And a "reset" button.

e.p

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Change the Debugger Toolbar on the fly
« Reply #5 on: May 26, 2011, 03:58:29 pm »
Sry for hijacking the topic but a 'reset' button on the debugger toolbar should be implemented somehow for microcontroller work.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #6 on: May 26, 2011, 04:21:08 pm »
We have no "Run to cursor" and no "Information windows".
I've plans to make most of the features optional, so in the future a plugin could make the "Run to cursor" menu item disabled or any other such item could be disabled, too.
If you state your requirements I can design the API in a way that it can be fulfilled.

No "Call stack" and no "Threads".
"Call stack" and "Threads" windows could be made optional, too, so if plugin doesn't support them, they could be disabled.

In return we have a "Pin Emulation" and a "Debugger Link" window. And a "reset" button.
You can add your windows in the debugger plugin, there is no point to modify the core of C::B. The core/sdk should have only the common GUI/features.
If a plugin has something specific it should be implemented inside the plugin.
Also we can rename the "Information windows" to "Auxiliary windows", "Other windows" or something similar.
These are windows created inside the plugin and they could have anything in them.
It looks like these two ("Pin Emulation" and "Debugger Link") are suitable to be implemented as such.

Sry for hijacking the topic but a 'reset' button on the debugger toolbar should be implemented somehow for microcontroller work.
What is the purpose of this button?

Probably it won't be that hard to add API for adding toolbar buttons from inside the debugger plugins. (I should check if this is supported by wxWidgets).
Another option is to make another toolbar, with the buttons you need.
(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 Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: Change the Debugger Toolbar on the fly
« Reply #7 on: May 26, 2011, 08:47:28 pm »
Hm, tell us what you want to have in the toolbar and we(I) will see if they could be added/implemented.

I don't think it would make sense. The functions are very specific and would be of no use for normal debuggers (it is a hardware debugger).

There is many embedder programmers using C::B, so I think it would be useful to have such flexible debugger infrastructure that can support both desktop and UC debugger in same instance of IDE. Same I can say about compiler and project manager frameworks. For example now when I want to add non-standart compiler I must inherit my plugin from cbCompilerPlugin because CompilerGCC developed for traditional compilers, but in this case I can`t reuse many compiler-related code (for example output parser). It would be great to make C::B yet more customizable.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #8 on: May 27, 2011, 01:16:50 am »
It would be great to make C::B yet more customizable.
Patches welcomed :)
(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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Change the Debugger Toolbar on the fly
« Reply #9 on: May 27, 2011, 03:07:25 pm »
Sry for hijacking the topic but a 'reset' button on the debugger toolbar should be implemented somehow for microcontroller work.
What is the purpose of this button?

It's basically the same as restarting ur PC. For microcontroller work without a tiny kind of OS running in ur uc it's probable that ur code may crash while running so u need to reset ur hardware. U may do it by hand by switching the power on and off etc... then u have to restart the debugger software (i.e. GDB). Specific debuggers have the option to reset the hardware by software like MPLAB, AVRStudio etc... and they begin debugging from the top of the code. Some 'gdb servers' have certain commands to send a reset signal to the target hardware so this property can be used with gdb. There was a certain command the gdb uses to run a command specific to the 'gdb server' but I can't remember it right now.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #10 on: May 27, 2011, 03:48:21 pm »
scarphin:
Hm, pretty random answer, it looks like this feature is not a generic one, so I need particular examples :)
This sounds like a feature request for "custom command buttons/menu items", I'm adding it to the TODO list :)
But I guess to implement the reset button functionality I'll need a resetable board and setup. Which won't happen any time soon... (patches welcome)
(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 e.p

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Change the Debugger Toolbar on the fly
« Reply #11 on: May 27, 2011, 04:14:52 pm »
I am solving my problem creating two toolbars and switching between them. Not really elegant, but it seems to work.

I am glad, my post started such a discussion  8)

While we are at it... I had to modify all dialogs (Registers, Watches, ...). I think it would be useful to make the debugging windows customisable too.
I do not really know a lot of debuggers, but I doubt, that all are providing the same interface and the same functionalities as gdb.

Just a suggestion... I would not know, wehre to put the line between debugger-specific interface and stiff framework.

The reset button: imagine we are controlling a traffic light with a microcontroller.
Three colors --> 2 bits of memory to store the state.
00=red, 01=green, 10=yellow/orange
The program would be something like
Code
while (true)
   if (state == 00)
      wait t
      state = 01
   if (state == 01)
      wait t
      state = 10
   if (state == 10)
      wait t
      state = 00
end while
If something goes wrong, we could have state = 11 in the memory. Now you need the reset button. It's like the Ctrl+C under linux  :lol:
Edit: of course you can avoid this situation by intelligent programming, but if everything would be perfectly coded, there would be no need for debuggers...

e.p
« Last Edit: May 27, 2011, 04:22:58 pm by e.p »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Change the Debugger Toolbar on the fly
« Reply #12 on: May 27, 2011, 04:38:49 pm »
I am solving my problem creating two toolbars and switching between them. Not really elegant, but it seems to work.
Why are you switching? Show them both...

While we are at it... I had to modify all dialogs (Registers, Watches, ...). I think it would be useful to make the debugging windows customisable too.
I do not really know a lot of debuggers, but I doubt, that all are providing the same interface and the same functionalities as gdb.
What changes? Esspicially for the watches? What customisation?
Keep in mind that the debuggers could be switched between debugging sessions and the GUI should be able to respond to the change!

Just a suggestion... I would not know, wehre to put the line between debugger-specific interface and stiff framework.
Yes, I know, with experience we all learn where to put it. I'm still learning :)

The reset button: imagine we are controlling a traffic light with a microcontroller...
OK, I guess this is on the controller, I'm interested what you're doing on the PC's side :)
(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 Alatar

  • Multiple posting newcomer
  • *
  • Posts: 60
Re: Change the Debugger Toolbar on the fly
« Reply #13 on: May 27, 2011, 09:37:13 pm »
OK, I guess this is on the controller, I'm interested what you're doing on the PC's side :)
On PC side you are send Reset command to hardware debugger =) Then debugger resets program counter, special registers and etc. on MCU.

Offline e.p

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Change the Debugger Toolbar on the fly
« Reply #14 on: June 29, 2011, 02:22:33 pm »
Hello and sorry for the very late answer

Why are you switching? Show them both...

Good idea. I did it this way.

Quote
What changes? Esspicially for the watches? What customisation?

Our watches window is just a table with seven columns: label, value (dec), value (hex), symbol (if watched variable is char), type, address space, base address.
There is no menu.

Quote
OK, I guess this is on the controller, I'm interested what you're doing on the PC's side :)

Alatar already ansered this question. Our hardware debugger has a command "reset" which triggers the reset. So, the only thing I do is to issue this command.

Bye
e.p