HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stackTrace.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_TF_STACK_TRACE_H
8 #define PXR_BASE_TF_STACK_TRACE_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/tf/api.h"
12 
13 #include <cstdio>
14 #include <ctime>
15 #include <iosfwd>
16 #include <string>
17 
19 
20 class TfCallContext;
21 
22 /// Gets both the C++ and the python stack and returns it as a string.
23 TF_API std::string TfGetStackTrace();
24 
25 /// Prints both the C++ and the python stack to the \c file provided
26 TF_API
27 void TfPrintStackTrace(FILE *file, const std::string &reason);
28 
29 /// Prints both the C++ and the python stack to the \a stream provided
30 TF_API
31 void TfPrintStackTrace(std::ostream &out, std::string const &reason);
32 
33 /// Logs both the C++ and the python stack to a file in /var/tmp
34 /// A message is printed to stderr reporting that a stack trace
35 /// has been taken and what file it has been written to. If \c
36 /// logtodb is true, then the stack trace will be added to the
37 /// stack_trace database table.
38 TF_API
39 void TfLogStackTrace(const std::string &reason, bool logtodb=false);
40 
41 /// Creates a nicely formatted message describing a crash and writes it to a
42 /// temporary file.
43 ///
44 /// \p reason is a very short descriptive title for the error (ie, FATAL_ERROR)
45 /// \p message further describes the crash (ie, Dereferenced an invalid MfHandle)
46 /// \p additionalInfo is secondary, possibly multi-line, information that should
47 /// be included in the report.
48 /// \p callContext describes the location of the crash
49 /// \p logToDB controls whether the stack will be added to the stack_trace db table.
50 TF_API
51 void TfLogCrash(const std::string &reason,
52  const std::string &message, const std::string &additionalInfo,
53  TfCallContext const &context, bool logToDB);
54 
55 /// Returns the application's launch time.
56 TF_API
57 time_t TfGetAppLaunchTime();
58 
60 
61 #endif
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2543
#define TF_API
Definition: api.h:23
TF_API void TfPrintStackTrace(FILE *file, const std::string &reason)
Prints both the C++ and the python stack to the file provided.
TF_API void TfLogCrash(const std::string &reason, const std::string &message, const std::string &additionalInfo, TfCallContext const &context, bool logToDB)
TF_API void TfLogStackTrace(const std::string &reason, bool logtodb=false)
TF_API std::string TfGetStackTrace()
Gets both the C++ and the python stack and returns it as a string.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
TF_API time_t TfGetAppLaunchTime()
Returns the application's launch time.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74