Skip to main content

5 posts tagged with "Qtcreator"

View All Tags

· One min read
Hreniuc Cristian-Alexandru

Source: https://doc.qt.io/qtcreator/creator-debugging-helpers.html#adding-custom-debugging-helpers

find ~ -name personaltypes.py

/home/cristi/Qt/Tools/QtCreator/share/qtcreator/debugger/personaltypes.py

Add there the following contents:

def qdump__ClassType1(d, value):
m_member1 = value["m_member1"].integer()
m_member2 = value["m_member2"].integer()
miliseconds = int(m_member1 * 1000 / m_member2)
d.putNumChild(0)
d.putValue(str(miliseconds) + str("ms (")+ str(m_member1) + str("m1, ") + str(m_member2) + str("m2)"))

def qdump__ClassType2(d, value):
position = value["m_position"]
d.putNumChild(0)
qdump__FramesDuration(d, position)

The ClassType2 will be displayed like this: 3642331ms (160626834m1, 44100m2).

For more examples, check: /home/cristi/Qt/Tools/QtCreator/share/qtcreator/debugger/stdtypes.py.

· 2 min read
Hreniuc Cristian-Alexandru

Tools

# Make sure pip is using python3
pip install conan

# Cmake
sudo apt-get install cmake

# gcc + make
sudo apt-get install build-essential

Install clang for automatic formatting:

#!/bin/bash

# Use this script to install the clang formatter and all its utilities.
# Install Clang(Used for clang-format)
# ============================================================================ #
mkdir -p ~/programs/clang && cd ~/programs/clang &&
# http://releases.llvm.org/download.html
clang_version="9.0.0" &&
archive_name="clang+llvm-${clang_version}-x86_64-linux-gnu-ubuntu-18.04" &&
wget http://releases.llvm.org/${clang_version}/${archive_name}.tar.xz &&
tar xf ${archive_name}.tar.xz &&
rm -Rf ${archive_name}.tar.xz &&
unlink clang_latest # Just in case there was another sym link
ln -sf ${archive_name} clang_latest &&
(
echo "CLANG_INSTALL_PATH=\"/mnt/programs/clang/clang_latest\"" &&
echo "export PATH=\"\${CLANG_INSTALL_PATH}/bin:\$PATH\"" &&
echo -n "export LD_LIBRARY_PATH=\"\${CLANG_INSTALL_PATH}/lib" &&
echo ":\$LD_LIBRARY_PATH\""
) >> ~/.bashrc
# ============================================================================ #

IDE

Use QtCreator.

Activate these plugins:

Go to Help -> About plugins:
- C++
- Check ClangCodeModel
- Check ClangFormat
- Beautifier
- Code Analyzer
- Check ClangTools
- Utilities
- Check Todo

Set these settings:

Go to Tools -> Options:
- Text Editor
- Behavior:
- Tab policy: Spaces Only
- Tab size: 2
- Indend size: 2
- Align continuation lines: With Spaces
- Clean whitespace (upon saving)
- Display:
- Display right margin at column: 80
- Display line numbers
- Display folding markers
- Visualize whitespace
- Highlight search results on the scrollbar
- Highlight current line
- Highlight blocks
- Animate matching parentheses
- Highlight matching parentheses
- Completion:
- Enable Doxygen blocks
- Generate brief description
- Add leading asterisks
- Beautifier
- Enable auto format on file save
- Clang Format
- Use predefined style: `File`
- Debugger
- General:
- Set breakpoints using full absolute path

· One min read
Hreniuc Cristian-Alexandru

Source: https://stackoverflow.com/a/19537899

My server(started from qtcreator in Debug) was sending data to a client and the client crashed ungracefully(CTRL+C), this resulted in two things:

  • SIGPIPE signal was generated(which was handled in my code, but before getting to my code GDB was handleling it, and crashed my server)
  • The server crashed with SEGFAULT when I was running it in terminal with no GDB attached.

So, to investigate the SEGFAULT easier, inside QtCreator, I had to force GDB to ignore the first signal SIGPIPE, I did this by doing thse two steps:

  • uncheck the box "Show a message box when receiving a signal" in Tools -> Options... -> Debugger -> GDB.
  • If you want gdb not to catch a signal but pass it to your program, you need to give gdb a command like the following:handle SIGPIPE pass nostop noprint(see Window -> Views -> Debugger Log or Tools -> Options... -> Debugger -> GDB -> GDB startup script Debugging Helper Customization or Tools -> Options... -> Debugger -> GDB -> Locals & Expressions (like the image below for the SIGPIPE signal)).

· One min read
Hreniuc Cristian-Alexandru

We encountered a problem when using the debugger from qtcreater with the gcc 9.1.0. The values of the std::string were not printed, they were marked as : <not accessible>. We found the fix on stackoverflow.

The fix is simple, you need to change the file: /usr/share/qtcreator/debugger/stdtypes.py as shown in the diff:

640c640
< (size, alloc, refcount) = d.split("ppp", value.address() + d.ptrSize())
---
> (size, alloc, refcount) = d.split("ppp", data - 3 * d.ptrSize())
643,644c643
< if size > 1000:
< size = 1000
---
> d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)

· One min read
Hreniuc Cristian-Alexandru

Create a build folder for each project called project_name, which will contain multiple subfolders for each build_type.

Go to Tools -> Options -> Build & Run -> Default build directory:

/path/to/builds/%{JS: Util.asciify("%{CurrentProject:Name}/build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}")}

This will result in a a tree of folders:

  • builds
    • project_name
      • build-project_name-Kit_name-Build_type
    • project_name2
    • build-project_name2-Kit_name-Build_type

Or we can set it to :

/path/to/builds/%{JS: Util.asciify("%{CurrentProject:Name}/%{CurrentBuild:Name}")}

This will result in a a tree of folders:

  • builds
    • project_name
      • Release
      • Debug
    • project_name2
    • build_type