summaryrefslogtreecommitdiff
path: root/thread.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2017-06-03 12:43:22 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2017-06-03 12:43:22 +0200
commit2c74a31afed1a3552fb22b522039e67a3d40b188 (patch)
treeaab959a20ff7bb52ef16095812799160570fe577 /thread.h
parentbae02358a3a0f697bb10fe67bfc6ea183e36679b (diff)
downloadvdr-2c74a31afed1a3552fb22b522039e67a3d40b188.tar.gz
vdr-2c74a31afed1a3552fb22b522039e67a3d40b188.tar.bz2
Added backtrace functions for debugging
Diffstat (limited to 'thread.h')
-rw-r--r--thread.h33
1 files changed, 32 insertions, 1 deletions
diff --git a/thread.h b/thread.h
index 9df677d3..fe8535b7 100644
--- a/thread.h
+++ b/thread.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.h 4.2 2016/12/08 10:18:32 kls Exp $
+ * $Id: thread.h 4.3 2017/06/03 12:43:22 kls Exp $
*/
#ifndef __THREAD_H
@@ -291,6 +291,37 @@ public:
int Close(void);
};
+// cBackTrace can be used for debugging.
+
+class cStringList;
+class cString;
+
+class cBackTrace {
+public:
+ static cString Demangle(char *s);
+ ///< Demangles the function name in the given string and returns the converted
+ ///< version of s. s must be one of the strings returned by a call to
+ ///< BackTrace() or GetCaller().
+ ///< Note that this function works on the given string by inserting '\0'
+ ///< characters to separate the individual parts. Therefore the string
+ ///< will be modified upon return.
+ static void BackTrace(cStringList &StringList, int Level = 0, bool Mangled = false);
+ ///< Produces a backtrace and stores it in the given StringList.
+ ///< If Level is given, only calls up to the given value are listed.
+ ///< If Mangled is true, the raw backtrace will be returned and you can use
+ ///< Demangle() to make the function names readable.
+ static void BackTrace(FILE *f = NULL, int Level = 0, bool Mangled = false);
+ ///< Produces a backtrace beginning at the given Level, and
+ ///< writes it to the given file. If no file is given, the backtrace is
+ ///< written to the logfile. If Mangled is true, the raw backtrace will
+ ///< be printed/logged.
+ static cString GetCaller(int Level = 0, bool Mangled = false);
+ ///< Returns the caller at the given Level (or the immediate caller,
+ ///< if Level is 0).
+ ///< If Mangled is true, the raw backtrace will be returned and you can use
+ ///< Demangle() to make the function name readable.
+ };
+
// SystemExec() implements a 'system()' call that closes all unnecessary file
// descriptors in the child process.
// With Detached=true, calls command in background and in a separate session,