Browsing and debugging code with Qt Creator:
Download and installation
The current version can be downloaded from:
http://qt.nokia.com/downloads
Scroll down to the bottom of the page and look at the left. There you
find binaries for different platforms. The part of Qt needed by Qt
Creator is included in the binary. The current version runs fine under
SLC5, under SLC4 there may be problems. Download the correct version,
make it executable (chmod +r) and run the program, a dialog will come
up (so you need to run an X11 session, either via a direct connection
or via VNC) asking
whether you agree with the license and where you want to store the
program. To run the program: it has the name qtcreator and is stored in
the bin directory of the directory in which everything is stored. Once
the program is running: under the "Help" button at the left you will
find a manual for the program.
Browsing code
With Qt Creator up and running a new project file (.pro) file can be
produced. One can start with an empty file and add source files to it
if needed while studying code one is interested in. This is an example
of a .pro file used for browsing relevant code for the
ReadoutApplication:
INCLUDEPATH += tdaq/installed/include \
tdaq-common/installed/include \
dqm-common/installed/include \
boost \
tdaq/installed/i686-slc4-gcc34-opt/include
SOURCES += tdaq/ROSApplication/src/ROSApplication.cpp \
tdaq/ROSCore/src/IOManager.cpp \
tdaq/ROSIO/src/DcTriggerIn.cpp \
tdaq/ROSModules/src/RobinReadoutModule.cpp \
tdaq/msg/src/Port.cxx \
tdaq/ROSIO/src/ReleaseRequest.cpp \
tdaq/ROSIO/src/GarbageCollectionRequest.cpp \
tdaq/ROSModules/src/RobinDataChannel.cpp \
tdaq/ROSCore/src/FragmentRequest.cpp \
tdaq/ROSCore/src/RequestHandler.cpp \
tdaq/ROSCore/src/Request.cpp \
tdaq/ROSIO/src/ROSFragmentBuilder.cpp \
tdaq/ROSEventFragment/src/FullFragment.cpp \
tdaq/ROSEventFragment/src/ROBFragment.cpp \
tdaq/ROSBufferManagement/src/Buffer.cpp \
tdaq/ROSMemoryPool/src/MemoryPool_malloc.cpp \
tdaq/ROSMemoryPool/src/MemoryPool_CMEM.cpp \
tdaq/ROSMemoryPool/src/MemoryPool.cpp \
tdaq/ROSRobin/src/lib/Rol.cpp \
tdaq/ROSRobin/src/lib/Robin.cpp \
tdaq/ROSMemoryPool/src/WrapperMemoryPool.cpp \
tdaq/ROSIO/src/DcDataOut.cpp \
tdaq/ROSModules/src/EthSequentialReadoutModule.cpp \
tdaq/ROSModules/src/EthSequentialDataChannel.cpp \
tdaq/ROSCore/src/SequentialDataChannel.cpp \
tdaq/ROSIO/src/DataDrivenTriggerIn.cpp \
tdaq/ROSIO/src/RODFragmentBuilder.cpp \
tdaq/ROSIO/src/EmulatedTriggerIn.cpp \
tdaq/ROSIO/src/DataDrivenTriggerIn.cpp
So one sees that the contents of the file is simple: it is a
specification of the include paths and of the sources. There is one
trick and that is that tdaq is a symbolic link to the tdaq software
installation (in the same directory as the .pro file).
tdaq-common, dqm-common, and boost are also symbolic links to the
tdaq-common, dqm-common and Boost installations (for Boost the link
points to the directory with the includes for Boost). For afs the links
are as follows:
boost -> /afs/cern.ch/atlas/project/tdaq/inst/sw/lcg/external/Boost/1.39.0_python2.5/slc4_ia32_gcc34/include/boost-1_39/boost
dqm-common -> /afs/cern.ch/atlas/project/tdaq/inst/dqm-common/dqm-common-00-10-00<>
tdaq -> /afs/cern.ch/atlas/project/tdaq/inst/tdaq/tdaq-02-00-03/
tdaq-common -> /afs/cern.ch/atlas/project/tdaq/inst/tdaq-common/tdaq-common-01-14-00
Once the .pro file and the links are in place the .pro file can be
opened by Qt Creator (first press the "Edit" button at the left).
Without compilation all include files are known to the IDE,
definitions are found by right clicking on the item of which the
definition has to be found. For opening a source file, double click it
in the list of files at the left. For finding a method in the file
clicking <Select Symbol> at the right of the file name at the top
of the windowand results in a list of methods. The cursor will jump to
the one that is selected from the list.
An example .pro file and the links for afs can be found in:
/afs/cern.ch/user/v/vermeule/public/ReadoutApplication
One may have to experiment somewhat for getting familiar with how to
useQt Creator. One thing that may not be obvious is how one adds a
source file to the .pro file: click right on the name of the project
and then select "Add Existing files". The appearance of text files can
be improved by choosing
another font: select from the "Tools" menu the last item:
"Options.."
and then "Text Editor" at the left side of the dialog box.
"LucidaTypewrite", Size 9 is a good choice
Debugging
It is possible to connect to a running application for debugging.
Select "Debug" at the left of the window. This results at the bottom of
the window in two subwindows. One is used for displaying the call stack
(at the left) and the other for variables ot breakpoints or threads. It
is possible to set breakpoints in the source code by clicking in the
left margin of the source code subwindow. A red dot appears, the
breakpoint can again be removed by clicking on the red dot. Connecting
gdb to a running application is done by Debug->Start Debugging ->
Attach to Running External Application. This results in a list of
processes, from which the process can be selected associated with the
.pro file. Once the process hits a breakpoint it will stop execution,
variables can be inspected and one can continue with stepping through
the code. If the process crashes before hitting a breakpoint a
post-mortem analysis of the call stack and of values of variables is
possible. It may occur that the process stops execution after attaching
to it, click the green arrow at the top left of the left debugger
subwindow if execution should continue.
Tip
The source window can be split in subwindows, in which the content of
different source files can be displayed, by means of "Split" or "Split
Side by Side" in the "Window" menu.