Author Topic: About cb's debugger  (Read 16361 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: About cb's debugger
« Reply #15 on: November 12, 2014, 02:17:15 pm »
@ollydbg: Thanks for the info, much appreciated. Out of curiosity what pretty-printers do you use for OpenCV? I didn't know there existed any!

There are many: renatoGarcia/gdb-imshow and his recent post: Visualizing OpenCV Images on GDB
I'm also implementing one(but not finished yet, once finished, I will released it under some free software license), see related discussion: GDB cv::Mat python object issue when debugging a c++ program and Non blocking pyplot GUI for GDB python pretty printer.

With python support, I think we can do everything when debugging under GDB.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: About cb's debugger
« Reply #16 on: November 12, 2014, 04:32:18 pm »
Wow, those links are extremely useful. I always use 'imshow' to see the images but it's quite hard to debug using 'imshow'. But with those python scripts I think debugging opencv will be much easier. Thanks again for the information. ;)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About cb's debugger
« Reply #17 on: November 15, 2014, 10:14:22 pm »
scarphin: Your patch is committed thanks for it...
(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: About cb's debugger
« Reply #18 on: November 16, 2014, 03:50:42 pm »
Glad it worked. ;)

Another issue: I can't dereference a function argument (pointer type) in the 'watch list->function arguments'. I can dereference the same function argument if I add it to the watch list manually though. Is this a limitation of automatic function arguments, intended or a bug?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About cb's debugger
« Reply #19 on: November 16, 2014, 04:49:09 pm »
Intended. Or missing feature actually.
If you want to add this feature I'll happily look at the resulting patch :)
(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: About cb's debugger
« Reply #20 on: November 16, 2014, 05:26:42 pm »
Ok, thanks for the info. I believe it will be very challenging for me regarding my skills but I'll give it a try.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About cb's debugger
« Reply #21 on: November 16, 2014, 05:37:45 pm »
I don't think so. It should be pretty easy to add. Almost all of the code should be there you just have to re-arrange it a bit. :)
(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: About cb's debugger
« Reply #22 on: November 22, 2014, 10:54:37 am »
Sorry for the late reply, I don't and won't have access to my computer for a couple of days. I think the problem with dereferencing the function arguments or locals is they are implemented as properties of 'function arguments' and 'local variables' special watches respectively. So when one tries to dereference them cb acts like the right click menu for a property is clicked. I'm not sure how to fix that in a proper way. What I can come up with is to implement them as normal watches not properties of 'function arguments' and 'locals' but I can't find for sure where they are implemented in the code. Maybe it will be easier for someone more skilled than me to fix that. Any help or a better solution?

I don't think so. It should be pretty easy to add. Almost all of the code should be there you just have to re-arrange it a bit. :)
'Easy for you' means at most 'possible' for me btw. ;)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: About cb's debugger
« Reply #23 on: November 29, 2014, 02:49:09 pm »
I can't find where in the source the locals and function arguments are inserted into the watch dialog, can anyone point me to the part of the code in question?

Offline Bat

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: About cb's debugger
« Reply #24 on: November 29, 2014, 04:53:42 pm »
Here few entry point for searching

Add of "Dereference" context menu
Code
plugins\debuggergdb\debuggergdb.cpp
void DebuggerGDB::OnWatchesContextMenu(wxMenu &menu, const cbWatch &watch, wxObject *property, int &disabledMenus)
Entry is registered with a standard item,
Code
idMenuWatchDereference
that is defined in EVT_MENU at top of file

"Locals" and "functions arguments" are inserted in DebuggerGDB::DoWatches as special entries


Handling of watches (standard to all debugger plugins)
Code
src\watchesdlg.cpp


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About cb's debugger
« Reply #25 on: November 29, 2014, 06:17:52 pm »
Hm, as I think about it more, I don't think it will be possible to implement it, because the info locals and info args commands don't print the types of the variables.
The type is used to decide if the variable is a pointer or not, and so controls if the dereference menu item should be shown or not.

You can always prove me wrong of course.  :P ::)
(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: About cb's debugger
« Reply #26 on: November 29, 2014, 07:07:50 pm »
@bat: Thnx for the help but that wasn't what I was looking for.

@obfuscated: What I was going to try was to add them as normal watches not properties of 'Locals'/'Function arguments' so the right click menu would contain (to my understanding) a 'dereference' option. If you say the type information won't be available when implemented that way, well that's out of my league. ;) It would be nice to have that feature implemented somehow though.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: About cb's debugger
« Reply #27 on: November 30, 2014, 02:20:07 am »
One thing that would be easy to implement it right click menu to add the selected local/arg variable as normal watch.
I don't think it will be easy to add the locals/args as separate watches. Also it will slow down stepping pretty significantly.
(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!]