1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Various changes in TVM, github builds and tests (#793)

* Bugfixes in TVM and node

* Upgrade to C++17

* Improve GitHub builds

* Fix existing tests and partially integrate them into builds

---------

Co-authored-by: neodiX42 <namlem@gmail.com>
Co-authored-by: EmelyanenkoK <emelyanenko.kirill@gmail.com>
This commit is contained in:
SpyCheese 2023-11-03 14:43:34 +03:00 committed by GitHub
parent 89700cb2aa
commit 5847897b37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 2889 additions and 4100 deletions

View file

@ -20,9 +20,13 @@
#include "td/utils/port/signals.h"
#if __GLIBC__
#if TD_WINDOWS
#include <DbgHelp.h>
#else
#if TD_DARWIN || __GLIBC__
#include <execinfo.h>
#endif
#endif
#if TD_LINUX || TD_FREEBSD
#include <sys/types.h>
@ -39,13 +43,48 @@ namespace td {
namespace {
void print_backtrace(void) {
#if __GLIBC__
#if TD_WINDOWS
void *stack[100];
HANDLE process = GetCurrentProcess();
SymInitialize(process, nullptr, 1);
unsigned frames = CaptureStackBackTrace(0, 100, stack, nullptr);
signal_safe_write("------- Stack Backtrace -------\n", false);
for (unsigned i = 0; i < frames; i++) {
td::uint8 symbol_buf[sizeof(SYMBOL_INFO) + 256];
auto symbol = (SYMBOL_INFO *)symbol_buf;
memset(symbol_buf, 0, sizeof(symbol_buf));
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
SymFromAddr(process, (DWORD64)(stack[i]), nullptr, symbol);
// Don't use sprintf here because it is not signal-safe
char buf[256 + 32];
char* buf_ptr = buf;
if (frames - i - 1 < 10) {
strcpy(buf_ptr, " ");
buf_ptr += strlen(buf_ptr);
}
_itoa(frames - i - 1, buf_ptr, 10);
buf_ptr += strlen(buf_ptr);
strcpy(buf_ptr, ": [");
buf_ptr += strlen(buf_ptr);
_ui64toa(td::uint64(symbol->Address), buf_ptr, 16);
buf_ptr += strlen(buf_ptr);
strcpy(buf_ptr, "] ");
buf_ptr += strlen(buf_ptr);
strcpy(buf_ptr, symbol->Name);
buf_ptr += strlen(buf_ptr);
strcpy(buf_ptr, "\n");
signal_safe_write(td::Slice{buf, strlen(buf)}, false);
}
#else
#if TD_DARWIN || __GLIBC__
void *buffer[128];
int nptrs = backtrace(buffer, 128);
signal_safe_write("------- Stack Backtrace -------\n", false);
backtrace_symbols_fd(buffer, nptrs, 2);
signal_safe_write("-------------------------------\n", false);
#endif
#endif
}
void print_backtrace_gdb(void) {
@ -129,7 +168,7 @@ void Stacktrace::print_to_stderr(const PrintOptions &options) {
}
void Stacktrace::init() {
#if __GLIBC__
#if TD_DARWIN || __GLIBC__
// backtrace needs to be called once to ensure that next calls are async-signal-safe
void *buffer[1];
backtrace(buffer, 1);