How to get a backtrace from qDebug()
-
Trying to get a backtrace from qDebug()
In my startup code I wrote:
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}%{backtrace}");
thinking that would get me a backtrace.
Unfortunately I didn't get a backtrace.
qDebug() << __FUNCTION__;
just got me e.g.:
DSS::ProgressLive::Start2
What did I do wrong?
Thanks
David -
Trying to get a backtrace from qDebug()
In my startup code I wrote:
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}%{backtrace}");
thinking that would get me a backtrace.
Unfortunately I didn't get a backtrace.
qDebug() << __FUNCTION__;
just got me e.g.:
DSS::ProgressLive::Start2
What did I do wrong?
Thanks
David@Perdrix said in How to get a backtrace from qDebug():
Unfortunately I didn't get a backtrace.
Did you read the docs?
"A backtrace with the number of frames specified by the optional depth parameter (defaults to 5), and separated by the optional separator parameter (defaults to "|"). This expansion is available only on some platforms (currently only platfoms using glibc). Names are only known for exported functions. If you want to see the name of every function in your application, use QMAKE_LFLAGS += -rdynamic."
-
@Perdrix said in How to get a backtrace from qDebug():
Unfortunately I didn't get a backtrace.
Did you read the docs?
"A backtrace with the number of frames specified by the optional depth parameter (defaults to 5), and separated by the optional separator parameter (defaults to "|"). This expansion is available only on some platforms (currently only platfoms using glibc). Names are only known for exported functions. If you want to see the name of every function in your application, use QMAKE_LFLAGS += -rdynamic."
@Christian-Ehrlicher Oh! I missed the bit about glibc - so no backtrace on Windows :(
Sorry
-
@Christian-Ehrlicher Oh! I missed the bit about glibc - so no backtrace on Windows :(
Sorry
-
@ChrisW67 said in How to get a backtrace from qDebug():
Unless you are using the MingW toolchain I expect.
No - as stated in the documentation you need glibc.
-
@ChrisW67 said in How to get a backtrace from qDebug():
Unless you are using the MingW toolchain I expect.
No - as stated in the documentation you need glibc.
@Christian-Ehrlicher I used StackWalker https://github.com/JochenKalmbach/StackWalker to get the back trace I needed.
StackWalker sw; sw.ShowCallstack();
It's a shame this isn't part of Qt!
D.
-
@Christian-Ehrlicher I used StackWalker https://github.com/JochenKalmbach/StackWalker to get the back trace I needed.
StackWalker sw; sw.ShowCallstack();
It's a shame this isn't part of Qt!
D.
C++23 includes std::stacktrace. So, we'll have a standardized solution in the future when C++23 is widely adopted.
-
C++23 includes std::stacktrace. So, we'll have a standardized solution in the future when C++23 is widely adopted.
@SimonSchroeder Good news ...