Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115496
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
View Options
diff --git a/src/util/exception.cpp b/src/util/exception.cpp
index fea920849..5e8942dfb 100644
--- a/src/util/exception.cpp
+++ b/src/util/exception.cpp
@@ -1,42 +1,43 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/exception.h>
#include <logging.h>
#include <tinyformat.h>
#include <exception>
#include <iostream>
#include <string>
#include <typeinfo>
#ifdef WIN32
#include <windows.h>
#endif // WIN32
static std::string FormatException(const std::exception *pex,
- const char *pszThread) {
+ std::string_view thread_name) {
#ifdef WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(nullptr, pszModule, sizeof(pszModule));
#else
const char *pszModule = "bitcoin";
#endif
if (pex) {
return strprintf("EXCEPTION: %s \n%s \n%s in %s \n",
typeid(*pex).name(), pex->what(), pszModule,
- pszThread);
+ thread_name);
} else {
return strprintf("UNKNOWN EXCEPTION \n%s in %s \n",
- pszModule, pszThread);
+ pszModule, thread_name);
}
}
-void PrintExceptionContinue(const std::exception *pex, const char *pszThread) {
- std::string message = FormatException(pex, pszThread);
+void PrintExceptionContinue(const std::exception *pex,
+ std::string_view thread_name) {
+ std::string message = FormatException(pex, thread_name);
LogPrintf("\n\n************************\n%s\n", message);
tfm::format(std::cerr, "\n\n************************\n%s\n", message);
}
diff --git a/src/util/exception.h b/src/util/exception.h
index 90d59408a..45fc1317c 100644
--- a/src/util/exception.h
+++ b/src/util/exception.h
@@ -1,14 +1,15 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UTIL_EXCEPTION_H
#define BITCOIN_UTIL_EXCEPTION_H
#include <exception>
#include <string_view>
-void PrintExceptionContinue(const std::exception *pex, const char *pszThread);
+void PrintExceptionContinue(const std::exception *pex,
+ std::string_view thread_name);
#endif // BITCOIN_UTIL_EXCEPTION_H
diff --git a/src/util/thread.cpp b/src/util/thread.cpp
index 7b6d35abf..a305a5984 100644
--- a/src/util/thread.cpp
+++ b/src/util/thread.cpp
@@ -1,27 +1,28 @@
// Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <util/thread.h>
#include <logging.h>
#include <util/exception.h>
#include <util/threadnames.h>
#include <exception>
+#include <string>
-void util::TraceThread(const char *thread_name,
+void util::TraceThread(std::string_view thread_name,
std::function<void()> thread_func) {
- util::ThreadRename(thread_name);
+ util::ThreadRename(std::string{thread_name});
try {
LogPrintf("%s thread start\n", thread_name);
thread_func();
LogPrintf("%s thread exit\n", thread_name);
} catch (const std::exception &e) {
PrintExceptionContinue(&e, thread_name);
throw;
} catch (...) {
PrintExceptionContinue(nullptr, thread_name);
throw;
}
}
diff --git a/src/util/thread.h b/src/util/thread.h
index 3186426e1..d80ae5451 100644
--- a/src/util/thread.h
+++ b/src/util/thread.h
@@ -1,18 +1,20 @@
// Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UTIL_THREAD_H
#define BITCOIN_UTIL_THREAD_H
#include <functional>
+#include <string>
namespace util {
/**
* A wrapper for do-something-once thread functions.
*/
-void TraceThread(const char *thread_name, std::function<void()> thread_func);
+void TraceThread(std::string_view thread_name,
+ std::function<void()> thread_func);
} // namespace util
#endif // BITCOIN_UTIL_THREAD_H
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Mar 2, 11:13 (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5181022
Default Alt Text
(4 KB)
Attached To
rABC Bitcoin ABC
Event Timeline
Log In to Comment