symbolize.h
Go to the documentation of this file.
00001 // Copyright 2018 The Abseil Authors.
00002 //
00003 // Licensed under the Apache License, Version 2.0 (the "License");
00004 // you may not use this file except in compliance with the License.
00005 // You may obtain a copy of the License at
00006 //
00007 //      https://www.apache.org/licenses/LICENSE-2.0
00008 //
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00014 //
00015 // -----------------------------------------------------------------------------
00016 // File: symbolize.h
00017 // -----------------------------------------------------------------------------
00018 //
00019 // This file configures the Abseil symbolizer for use in converting instruction
00020 // pointer addresses (program counters) into human-readable names (function
00021 // calls, etc.) within Abseil code.
00022 //
00023 // The symbolizer may be invoked from several sources:
00024 //
00025 //   * Implicitly, through the installation of an Abseil failure signal handler.
00026 //     (See failure_signal_handler.h for more information.)
00027 //   * By calling `Symbolize()` directly on a program counter you obtain through
00028 //     `absl::GetStackTrace()` or `absl::GetStackFrames()`. (See stacktrace.h
00029 //     for more information.
00030 //   * By calling `Symbolize()` directly on a program counter you obtain through
00031 //     other means (which would be platform-dependent).
00032 //
00033 // In all of the above cases, the symbolizer must first be initialized before
00034 // any program counter values can be symbolized. If you are installing a failure
00035 // signal handler, initialize the symbolizer before you do so.
00036 //
00037 // Example:
00038 //
00039 //   int main(int argc, char** argv) {
00040 //     // Initialize the Symbolizer before installing the failure signal handler
00041 //     absl::InitializeSymbolizer(argv[0]);
00042 //
00043 //     // Now you may install the failure signal handler
00044 //     absl::FailureSignalHandlerOptions options;
00045 //     absl::InstallFailureSignalHandler(options);
00046 //
00047 //     // Start running your main program
00048 //     ...
00049 //     return 0;
00050 //  }
00051 //
00052 #ifndef ABSL_DEBUGGING_SYMBOLIZE_H_
00053 #define ABSL_DEBUGGING_SYMBOLIZE_H_
00054 
00055 #include "absl/debugging/internal/symbolize.h"
00056 
00057 namespace absl {
00058 
00059 // InitializeSymbolizer()
00060 //
00061 // Initializes the program counter symbolizer, given the path of the program
00062 // (typically obtained through `main()`s `argv[0]`). The Abseil symbolizer
00063 // allows you to read program counters (instruction pointer values) using their
00064 // human-readable names within output such as stack traces.
00065 //
00066 // Example:
00067 //
00068 // int main(int argc, char *argv[]) {
00069 //   absl::InitializeSymbolizer(argv[0]);
00070 //   // Now you can use the symbolizer
00071 // }
00072 void InitializeSymbolizer(const char* argv0);
00073 
00074 // Symbolize()
00075 //
00076 // Symbolizes a program counter (instruction pointer value) `pc` and, on
00077 // success, writes the name to `out`. The symbol name is demangled, if possible.
00078 // Note that the symbolized name may be truncated and will be NUL-terminated.
00079 // Demangling is supported for symbols generated by GCC 3.x or newer). Returns
00080 // `false` on failure.
00081 //
00082 // Example:
00083 //
00084 //   // Print a program counter and its symbol name.
00085 //   static void DumpPCAndSymbol(void *pc) {
00086 //     char tmp[1024];
00087 //     const char *symbol = "(unknown)";
00088 //     if (absl::Symbolize(pc, tmp, sizeof(tmp))) {
00089 //       symbol = tmp;
00090 //     }
00091 //     absl::PrintF("%*p  %s\n", pc, symbol);
00092 //  }
00093 bool Symbolize(const void *pc, char *out, int out_size);
00094 
00095 }  // namespace absl
00096 
00097 #endif  // ABSL_DEBUGGING_SYMBOLIZE_H_


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:15