LLDB debugger never finishes in QtCreator - macos

I am trying to use Qt Creator 3.5.1 to debug a piece of software I wrote. I noticed that whilst debugging my program would just halt at random points and I mistook these issues for threading problems. However, eventually I found out that even when I ran the simplest of programs the debugger would keep running for all eternity without finishing.
I am running on a Mac (El Capitan), with Qt 5.5.1 and Xcode 7.3.
This is my very simple test program:
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Howdy, this is a simple test program." << std::endl;
return 0;
}
When I run this in debugging mode in Qt Creator without setting any breakpoints it just never finishes:
Debugging starts
Howdy, this is a simple test program.
It is only when I press the stop button several times that the debugger comes back at me with Debugging has finished
When I look at the "Debugger log view" it shows me a Python exception of something crashing. I have no idea how to troubleshoot this though.
ERROR: Lldb stderr: Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/Users/Stan/Qt5.5.1/Qt Creator.app/Contents/Resources/debugger/lldbbridge.py", line 765, in loop
self.handleEvent(event)
File "/Users/Stan/Qt5.5.1/Qt Creator.app/Contents/Resources/debugger/lldbbridge.py", line 1383, in handleEvent
% self.hexencode(msg))
File "/Users/Stan/Qt5.5.1/Qt Creator.app/Contents/Resources/debugger/dumper.py", line 478, in hex encode
return s.encode("hex") eAttributeError: 'NoneType' object has no attribute 'encode'
It might be nothing, but I have quite a challenge on my hands right now and I'd rather not work with a debugger I can't trust.
Thanks.

Apparently, you can fix the problem directly by applying this patch in your Qt Creator's sources: https://codereview.qt-project.org/#/c/154748/
It worked for me.

Related

How to fix permanent EXC_BAD_ACCESS exception in Xcode using SystemC?

I want to write SystemC code using the Xcode IDE. I have set it all up and the code I use for testing my Installation builds just fine, but it runs always into Thread 1: EXC_BAD_ACCESS exception, no matter what I do.
I tried to comment everything out, until only the systemc header include and the sc_main was left. When I tried normal c++ code in a different project, to see if it was a general Xcode problem, it work fine and ran into no exception.
I use this generic Hello World-code to test my Installation:
#include <systemc>
//Hello_world is module name
SC_MODULE (hello_world) {
SC_CTOR (hello_world) {
// Nothing in constructor
}
void say_hello() {
//Print "Hello World" to the console.
std::cout << "Hello World.\n";
}
};
// sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
hello_world hello("HELLO");
//Print the hello world
hello.say_hello();
return(0);
}
After the code ran for a few seconds, it always crashes with: Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffeef3ffff8).
EDIT:
My Config:
- SystemC: v2.3.3
- Xcode: v10.2.1 (10E1001)
- Compiler: (I ran gcc --version)
- LLV: v10.0.1 (clang-1001.0.46.4)
- c++: v4.2.1
Im using std=gnu++98 (Compiler Default) as c++language Dialect, everything else ran into build errors.
EXC_BAD_ACCESS happens when system can not return from an execution block, such as infinite loop or recursion.
you should take a look at stack trace in the Debugger navigator and see which function is getting called and never returns OR which function(s) are calling over and over.
Don't forget to run project in DEBUG mode. (NOT release)
If you're using SystemC 2.3.2, you might be running into the following issue (on macOS 10.13 or later): http://forums.accellera.org/topic/6079-make-check-return-fail/. This issue is assumed to be fixed in SystemC 2.3.3.
You can avoid it by compiling SystemC 2.3.2 with ../configure --disable-async-updates ... or by moving to SystemC 2.3.3 and enabling C++11 (might be the default on a recent Xcode version, you can check the value of the SC_CPLUSPLUS macro in your model).
I did it! I built SystemC with Cmake following the steps provided in this answer: Setting up a SystemC project with CMake: undefined reference to sc_core
. In the CMakeLists.txt I set CMAKE_CXX_STANDARD explicitly to 11 and built the project via the command line and cmake.
Thanks for the help:)

Displaying debug outputs into MacOS terminal

On Mac OS X the debug outputs go to the system logger that can be read with the Console Application. But when you are developing outside of Xcode (using QtCreator or just the terminal for example), it's not very practical to check the system logs for debugging.
Is there any way to force MacOS to print the backtrace to the terminal (similar to Linux behavior) without any trick on the application side ??
I'm developing a new feature for Clang so it's a C++ program. And I'm using MacOS 10.13.3.
If you are using qt, then include QDebug and then use qDebug() as follows:
qDebug() << debug_qstring;
And if you are using XCode and ObjC, look for NSLog.
void NSLog(NSString *format, ...);
Also printf in case of C and std::out in case of cpp are always your friends!

Debug error: &"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device\n"

I've recently updated my system to Ubuntu 14.04 LTE. I've also updated the version of my QtCreator to 3.3.
When I run in Release mode, no problem. However, when I tried to debug, something strange happens: The system throws a Segmentation Fault, and the application give me this message:
&"warning: GDB: Failed to set controlling terminal: Inappropriate ioctl for device\n"
I saw other comments that propose to downgrade the GDB version from 7.8 to 7.7 and other saying the opposite thing. I tried both but nothing works.
I saw some posts saying that it's a bug, but I'm not being able to find any solution in these messages.
Have anyone some suggestions?
Thank you very much!
EDIT:
I tried to use gdb via command line, and it works a little bit different: The segmentation fault remains, but the error is different:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff1da2a70 in boost::math::lanczos::lanczos_initializer<boost::math::lanczos::lanczos17m64, long double>::init::init() ()
from /usr/lib/libpcl_sample_consensus.so.1.7
I removed the flag -std=c++0x from my makefile in order to not use c++11. Then, using command line gdb, the debugging works. However, using QtCreator it still not working.
Any idea? Thaaanks!
I get this message every time I debug, but the debugging works fine. I'm sure I found a comment on the QT forums that says just ignore it.
Have you tried debugging a trivial "hello world" program?

Process terminated with status 255

I run Ubuntu to dual boot with Windows 7, I used to work on a C++ project on Windows in VS2013, I imported it to code:: blocks (the original project is in my other partition with Windows on, and I assume I don't have root privileges on it, but I don't really know what I'm talking about). When I try to run my project (which runs fine on Windows) I get the following messages in the "Build log":
-------------- Run: Release Win32 in Huffman (compiler: GNU GCC Compiler)---------------
Checking for existence: /media/shoham/BC5461BE54617C50/Users/Administrator.Shoham-PC/workspace/Huffman/Huffman/Huffman
Executing: /media/shoham/BC5461BE54617C50/Users/Administrator.Shoham-PC/workspace/Huffman/Huffman/Huffman (in /media/shoham/BC5461BE54617C50/Users/Administrator.Shoham-PC/workspace/Huffman/Huffman/.)
Process terminated with status 255 (0 minute(s), 0 second(s))
Most people on the Internet say to install xterm or change the terminal in Settings->Environment..., but it doesn't work for me, even though I have xterm.
What's weird is that it works on a new project I create on my system to test this. By that I mean this:
int main()
{
return 0;
}
In a new project works.
Do I not have privilleges to my project on my other partition?
Do I have to make a new project copying the files? Or can I link them to be the same one?
What do I have to do to fix this?
I got a similar message too when I compile my C++ code in Code::Blocks IDE. To correct the problem, I changed the default console program to "konsole-e".
Settings->Environment-> Terminal to launch console programs: konsole -e
This error occurs as Code::Blocks is trying to start its default application to run console programs. And since this is an app you've not installed on your local machine it stops and outputs the error
Process terminated with status 255 (0 minute(s), 0 second(s)).
Installing xterm could solve this problem if this really is the default app Code::Block is searching for, but there is no need to do so. It is more helpful to look up the current settings and to pick an app that you've already installed.
Go to Settings > Environment and you'll find a dropdown saying Terminal to launch console programs. Here you can select a different default app to launch console programs in.
In Linux Mint this should be: gnome-terminal. In other Linux OS this can be a good choice: konsole-e. If none of them work just set up a very simple C++ program such as:
#include <iostream>
int main(){
std::cout << "Hello world! << std::endl;
return 0;
}
and try out different options Code::Blocks successfully opens up a Terminal and displays Hello world!.

file in/out error with CUDA 5.0

After downloading the latest toolkit and compiling/running the code that I currently have, I get a debug assertion error with any sort of file IO functions. Even the code below will exit with an assertion error when fprintf is called.
//main.cu
#include <stdio.h>
#include <stdlib.h>
int main ( void ) {
FILE* foo;
foo=fopen("C:\\asdfsa.txt","w");
fprintf(foo,"wtf\n");
fclose(foo);
return 0;
}
I am using CUDA toolkit 5.0, and Visual studio.
Any idea on what is going on? My code worked fine on my older computer with an old version cuda toolkit.
Check the fopen return value. Looks like you are running the code on the entirely new environmnent - maybe you can't create the file in the C:\ (e.g. this may require admin permissions)

Resources