Author Topic: Debugger Predefined User Commands  (Read 5371 times)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Debugger Predefined User Commands
« on: May 13, 2015, 04:11:14 pm »
After hours of struggle I finally managed to make ollydbg's opencv pretty printer here work with everything 64-bit (cb, gcc, python, opencv etc...). After some practice, I found it annoying to type 'plot something' every time I need to inspect an image so I implemented 'predefined user commands' for the debugger plugin with 2 extra macros to aid in execution of the commands:
1- $symbol_mouse extracts the symbol under the mouse pointer,
2- $symbol_cursor extracts the symbol under the cursor.

As an example, user commands can be defined as:
command 1:
Code
plot $symbol_mouse
command 2:
Code
plot $symbol_cursor
When the debugger is stopped at some breakpoint, executing command 1 and command 2 will show the image under the mouse and cursor respectively.

I failed to implement a dedicated dialog for the definition of user commands so I limited them with 2 because of space considerations in the settings dialog.
Patch is here->https://sourceforge.net/p/codeblocks/tickets/169/
in case people or developers may find it useful. Please discard otherwise.

@ollydbg: Is there some place that you maintain your pretty printer code? I made some simple modifications and found a possible bug that I want to discuss. Please let me know if I can at least pm you about this.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugger Predefined User Commands
« Reply #1 on: May 13, 2015, 07:58:42 pm »
About the patch:
For sure this feature should not be implemented in the sdk part. It should be done somewhere in the gdb's code.
Some time in the future I'll take a look and probably apply it with modifications.
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger Predefined User Commands
« Reply #2 on: May 13, 2015, 11:34:01 pm »
After hours of struggle I finally managed to make ollydbg's opencv pretty printer here work with everything 64-bit (cb, gcc, python, opencv etc...).
Thanks for the time and help.
The encoding error is annoying when debugging such python pretty printer. (I don't know a good method to debug the python pretty printer, I can just print(log out) something, I can't (don't have a way to) step the pretty printer line by line.
Quote
@ollydbg: Is there some place that you maintain your pretty printer code? I made some simple modifications and found a possible bug that I want to discuss. Please let me know if I can at least pm you about this.
Currently, I don't have a place to hold my public pretty printer code for OpenCV, but I do have a local git which use some GUI (matplotlib) to print the OpenCV image in an GUI Window from python pretty printer, but it still has a lot of issues I can't fixed yet.

I think we can discuss by PM or by email(you can see my email in from gdb maillist). Thanks.
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: Debugger Predefined User Commands
« Reply #3 on: May 14, 2015, 12:19:42 am »
The encoding error is annoying when debugging such python pretty printer. (I don't know a good method to debug the python pretty printer, I can just print(log out) something, I can't (don't have a way to) step the pretty printer line by line.
I think you misunderstood me. Your code works like a charm, it was numpy, cv bindings, openblas etc... that gave me the headache. ;) Anyway I'll send you a pm to discuss further.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger Predefined User Commands
« Reply #4 on: May 16, 2015, 03:51:48 pm »
The encoding error is annoying when debugging such python pretty printer. (I don't know a good method to debug the python pretty printer, I can just print(log out) something, I can't (don't have a way to) step the pretty printer line by line.
I think you misunderstood me. Your code works like a charm, it was numpy, cv bindings, openblas etc... that gave me the headache. ;) Anyway I'll send you a pm to discuss further.
Indeed, I misunderstood you, you did not fix the encoding issue. :)

Ideally, those kind of improvement could be: create an GUI window in the GDB debugger plugin, and send a command to GDB(it could be GDB MI command), and GDB return the buffer of the image, then we should the image in the GUI window of C::B. But there are some issues: 1, GDB MI plugin is not matured currently, 2, if the image is quite big, then GDB need to send a large bytes through the pipe(we use the text pipe to communicate with GDB, right?), I believe it is really slow.
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: Debugger Predefined User Commands
« Reply #5 on: May 16, 2015, 05:19:40 pm »
I think you're talking about a dedicated CB plugin, like the one for Visual Studio. If the image should be transferred byte by byte to manage that, I don't think it would be anything useful. From what I understand from the python code, gdb supplies a pointer to the image object which python code uses to render the image. If it would involve transferring the image byte by byte, I can't think how much time it will take to transfer an HD frame. Maybe I'm wrong though.

Btw although I haven't tested the pretty printer much, I didn't encounter any encoding error. What 'encoding error' are you talking about? I think I found why Garcia's printer displays the ROIs correctly. I'll send you an email about it soon.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Debugger Predefined User Commands
« Reply #6 on: August 11, 2015, 04:48:10 pm »
@scarphin, FYI
My updated "opencv image visual debugger" python script can be seen from https://sourceforge.net/projects/visualdebugger/.
You can see the screen shots which show the usages within C::B (either Windows Or Linux)
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: Debugger Predefined User Commands
« Reply #7 on: August 11, 2015, 05:06:03 pm »
Look great, thanks for making this available! I'll see how it goes along with a Qt enabled CV as soon as I find some free time.