How to get a backtrace from qDebug()
-
wrote on 8 Jun 2023, 16:32 last edited by Perdrix 6 Aug 2023, 16:35
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."
wrote on 8 Jun 2023, 17:43 last edited by Perdrix 6 Aug 2023, 17:44@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.
wrote on 9 Jun 2023, 14:14 last edited by Perdrix 6 Sept 2023, 14:16@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.
wrote on 12 Jun 2023, 07:09 last edited byC++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.
wrote on 12 Jun 2023, 08:28 last edited by@SimonSchroeder Good news ...
2/8