Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Better stack tracing #33

Open
dmerkushov opened this issue Aug 15, 2020 · 1 comment
Open

FEATURE: Better stack tracing #33

dmerkushov opened this issue Aug 15, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@dmerkushov
Copy link
Owner

Problem solved by the feature

The current stack trace in exceptions is not as clear as it can be

Description of the proposed solution

https://github.com/bombela/backward-cpp

Impact on nanoservice development

Better stack traces will enhance developer experience

Feature optionality

This is a mandatory feature

@dmerkushov dmerkushov added the enhancement New feature or request label Aug 15, 2020
@Ffeanor Ffeanor self-assigned this Sep 17, 2020
@dmerkushov
Copy link
Owner Author

dmerkushov commented Sep 17, 2020

By now, stacktraces are filled up in NsException::init():

void NsException::init(const string &rootExStack, const string &rootExShort, const string &rootExFull) {
void **addressArr = new void *[NSE_STACKTRACE_SIZE_MAX];
size_t stacktraceSize = backtrace(addressArr, NSE_STACKTRACE_SIZE_MAX);
char **stacktraceArr = backtrace_symbols(addressArr, stacktraceSize);
std::stringstream ss;
ss << _stacktrace << " - ";
if (stacktraceSize >= 3) {
for (unsigned int i = 2; i < stacktraceSize; i++) {
ss << stacktraceArr[i] << endl;
}
}
_stacktrace = ss.str();
free(stacktraceArr);
delete[] addressArr;
stringstream wss;
try {
wss << typeid(*this).name();
} catch (std::bad_typeid &bti) {
wss << "(Unknown exception class)";
}
wss << " : " << _shortDescription << endl;
wss << _stacktrace;
if (rootExFull != "") {
wss << endl << endl;
wss << "\tCaused by:" << endl;
wss << rootExFull;
}
_fullDescription = wss.str();
_rootExceptionFullDescription = rootExFull;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants