mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 01:26:31 +01:00
Allow to skip top stacktrace frames
This is useful to hide the call of `PBD::stacktrace` itself.
This commit is contained in:
parent
9e2c5f4ffc
commit
7d39205350
2 changed files with 5 additions and 5 deletions
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
namespace PBD {
|
namespace PBD {
|
||||||
|
|
||||||
LIBPBD_API void stacktrace (std::ostream& out, int levels = 0);
|
LIBPBD_API void stacktrace (std::ostream& out, int levels = 0, int start_level = 0);
|
||||||
LIBPBD_API void trace_twb();
|
LIBPBD_API void trace_twb();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ PBD::trace_twb ()
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
PBD::stacktrace (std::ostream& out, int levels)
|
PBD::stacktrace (std::ostream& out, int levels, int start)
|
||||||
{
|
{
|
||||||
void *array[200];
|
void *array[200];
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
@ -63,7 +63,7 @@ PBD::stacktrace (std::ostream& out, int levels)
|
||||||
|
|
||||||
if (strings) {
|
if (strings) {
|
||||||
|
|
||||||
for (i = 0; i < size && (levels == 0 || i < size_t(levels)); i++) {
|
for (i = start; i < size && (levels == 0 || i < size_t(levels)); i++) {
|
||||||
out << " " << demangle (strings[i]) << std::endl;
|
out << " " << demangle (strings[i]) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
PBD::stacktrace (std::ostream& out, int)
|
PBD::stacktrace (std::ostream& out, int levels, int start)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
const size_t levels = 62; // does not support more then 62 levels of stacktrace
|
const size_t levels = 62; // does not support more then 62 levels of stacktrace
|
||||||
|
|
@ -112,7 +112,7 @@ PBD::stacktrace (std::ostream& out, int)
|
||||||
symbol->MaxNameLen = 255;
|
symbol->MaxNameLen = 255;
|
||||||
symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
|
symbol->SizeOfStruct = sizeof (SYMBOL_INFO);
|
||||||
|
|
||||||
for (i = 0; i < frames; ++i) {
|
for (i = start; i < frames && (levels == 0 || i < levels); ++i) {
|
||||||
SymFromAddr (process, (DWORD64)(stack[i]), 0, symbol);
|
SymFromAddr (process, (DWORD64)(stack[i]), 0, symbol);
|
||||||
out << string_compose ("%1: %2 - %3\n", frames - i - 1, symbol->Name, symbol->Address);
|
out << string_compose ("%1: %2 - %3\n", frames - i - 1, symbol->Name, symbol->Address);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue