Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: scarphin on May 13, 2015, 04:11:14 pm

Title: Debugger Predefined User Commands
Post by: scarphin on May 13, 2015, 04:11:14 pm
After hours of struggle I finally managed to make ollydbg's opencv pretty printer here (https://sourceware.org/ml/gdb/2013-04/msg00104.html) 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/ (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.
Title: Re: Debugger Predefined User Commands
Post by: oBFusCATed 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.
Title: Re: Debugger Predefined User Commands
Post by: ollydbg on May 13, 2015, 11:34:01 pm
After hours of struggle I finally managed to make ollydbg's opencv pretty printer here (https://sourceware.org/ml/gdb/2013-04/msg00104.html) 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.
Title: Re: Debugger Predefined User Commands
Post by: scarphin 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.
Title: Re: Debugger Predefined User Commands
Post by: ollydbg 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.
Title: Re: Debugger Predefined User Commands
Post by: scarphin 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.
Title: Re: Debugger Predefined User Commands
Post by: ollydbg 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)
Title: Re: Debugger Predefined User Commands
Post by: scarphin 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.