Debugging Kate with Qt Creator

Let’s have a quick look at how to debug Kate and KWrite with Qt Creator. First, make sure you meet the requirements:

  1. build Kate according to this tutorial
  2. install Qt-Creator (in my case this is version 2.0.0)

Setup the Kate project Qt-Creator once like this

  1. start Qt-Creator like this (important to get all environment variables right):
    ~/kde/ qtcreator
  2. invoke File > Open File or Project and choose ~/kde/kate/CMakeLists.txt
  3. Build Location: choose ~/kde/build
  4. Run CMake arguments: type
    ../kate -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=~/kde/usr
  5. click the button “Run CMake” and then “Finish”

Start debugging like this

  1. click the (C) “hammer” icon button on the very bottom left to compile Kate
  2. click the (B) “computer” icon button and choose “kate” (or “kwrite”) in the Run combo box
  3. choose the (A) “Debug” icon in the left pane
  4. invoke “Debug > Start Debugging (F5)”, now Kate starts
  5. open part/document/katedocument.cpp in the file tree view on the left
  6. go to the line “KateDocument::insertText” and click “Debug > Toggle Breakpoint (F9)”
  7. now if you type a character in Kate, Qt-Crator will halt in KateDocument::insertText
  8. chose “Debug > Step Opver (F10)” (and “Debug > Stip Into (F11)”) to step through the code
  9. click on “Locals and Watchers” in the debugging pane on the bottom and you see the values of local variables

Happy debugging! :)

4 thoughts on “Debugging Kate with Qt Creator

  1. with qtcreator 1.3.1 and an a system installed kate it's a bit more complex than this.

    you need to tell qtcreator the right paths for it not to use /usr/lib64/

    I've just no idea how to do that though :p

    git compiled kate is started from command line the with the following bash script:

    export KATE_DIR=~/usr
    export PATH=$KATE_DIR/bin:$PATH
    export KDEDIR=$KATE_DIR
    export KDEDIRS=$KDEDIR
    # update KDE's system configuration cache
    # start app
    kate $@

  2. but you can start kate as an aeternal application and then attach to it later from Debug->Start Debugging->Attach to running exernal application

  3. @vivo: if i undestand correctly, that's why you simply should start qt-crator already with the script:

    ~/kde/ /path/to/qtcreator/bin/qtcreator

    Now, qt-creator has automatically all paths set correctly out of the box.

Comments are closed.

Scroll to top