1
votes

I'm working on an IDE for debugging scripts and codes in Qt my duty is to implement GUI and there is a very good example of Code Editor in Qt Documentation in this url: http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html

all of the introduced features (like line number and highlighting and syntaxes) are good explained but there are some words about implementing break point as an extension to the Code Editor documentation says:

In addition to line numbers, you can add more to the extra area, for instance, break points.

I just wondered since the document explicitly stated that a break point implementation would be the next step of developing a code editor component but as I googled and searched web sites I didn't find any relevant article or project with the related implementation or an example of implementing breakpoints into an IDE. I just wanted to ask if you know any example or guide about this matter I would be very glad if you can help me through this or otherwise I would sub-class and implement it by myself and ask much more detailed questions here.

thanks in advance for reading :)

UPDATE

I end up implementing such a features like : breakpoint and breakpoint area, current line that is running, step over, step in, continue and other debugger features and I used PythonQt as the API for communicating with Python/C API to debug my scripts from. I used QTextBlockUserData to implement the breakpoint data and it's aspects so it'll be managed by the block's data itself. that was all the things I was searching for in the first place. if anyone had any question I'd be happy to help.

1
Just add some kind of marker. It can be highlighted line (read editor widget docs about "extra selections", or implement some marker drawn on line number, or what ever). Then how to communicate this with debugger, there's no built-in support for any of this. - hyde

1 Answers

2
votes

My best guess would be to check out the QtCreator breakpoint support.

The UI part is contained in this class and others:

https://github.com/qt-creator/qt-creator/blob/master/src/plugins/debugger/breakhandler.cpp

... while the real logic depends on the engine. There are different debugger engines like gdb, cdb for Windows, QML debugger etc.).

Looking at the gdb engine, there is a gdb process running in MI mode. This mode makes it easy for programs to parse gdb output; try e.g. gdb -i=mi programToDebug. Also, the documentation might help: ftp://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_211.html.

Qt Creator is then reading the gdb process' output to display information like call stacks; see e.g. https://github.com/qt-creator/qt-creator/blob/master/src/plugins/debugger/gdb/gdbengine.cpp#L244

So what I would do is this:

  1. implement UI to set breakpoints, start debugger etc.
  2. run debugger in an own process and machine mode (if available)
  3. connect input / output of that process to set breakpoints, display call stack etc.