add:添加crash模块(-DGRAB_CRASH=ON)。
This commit is contained in:
parent
a81cc54025
commit
9839fa79ea
135
.clang-tidy
135
.clang-tidy
@ -1,135 +0,0 @@
|
|||||||
Checks: "-*,
|
|
||||||
|
|
||||||
clang-*,
|
|
||||||
|
|
||||||
google-build-explicit-make-pair,
|
|
||||||
google-build-namespaces,
|
|
||||||
google-default-arguments,
|
|
||||||
google-explicit-constructor,
|
|
||||||
google-readability-avoid-underscore-in-googletest-name,
|
|
||||||
google-runtime-int,
|
|
||||||
google-runtime-operator,
|
|
||||||
|
|
||||||
|
|
||||||
-readability-non-const-parameter,
|
|
||||||
readability-avoid-const-params-in-decls,
|
|
||||||
readability-const-return-type,
|
|
||||||
readability-container-size-empty,
|
|
||||||
-readability-convert-member-functions-to-static,
|
|
||||||
readability-delete-null-pointer,
|
|
||||||
readability-deleted-default,
|
|
||||||
readability-make-member-function-const,
|
|
||||||
readability-misplaced-array-index,
|
|
||||||
readability-qualified-auto,
|
|
||||||
readability-redundant-control-flow,
|
|
||||||
readability-redundant-function-ptr-dereference,
|
|
||||||
readability-redundant-smartptr-get,
|
|
||||||
readability-redundant-string-cstr,
|
|
||||||
readability-static-definition-in-anonymous-namespace,
|
|
||||||
readability-string-compare,
|
|
||||||
readability-uniqueptr-delete-release,
|
|
||||||
readability-redundant-member-init,
|
|
||||||
readability-simplify-subscript-expr,
|
|
||||||
readability-simplify-boolean-expr,
|
|
||||||
readability-inconsistent-declaration-parameter-name,
|
|
||||||
|
|
||||||
cert-dcl21-cpp,
|
|
||||||
cert-dcl50-cpp,
|
|
||||||
# 不要使用 system()
|
|
||||||
-cert-env33-c,
|
|
||||||
cert-err34-c,
|
|
||||||
cert-err52-cpp,
|
|
||||||
cert-flp30-c,
|
|
||||||
cert-mem57-cpp,
|
|
||||||
cert-msc50-cpp,
|
|
||||||
cert-oop58-cpp,
|
|
||||||
|
|
||||||
modernize-avoid-bind,
|
|
||||||
modernize-deprecated-headers,
|
|
||||||
modernize-loop-convert,
|
|
||||||
modernize-make-shared,
|
|
||||||
modernize-make-unique,
|
|
||||||
-modernize-pass-by-value,
|
|
||||||
modernize-raw-string-literal,
|
|
||||||
modernize-redundant-void-arg,
|
|
||||||
modernize-replace-auto-ptr,
|
|
||||||
modernize-shrink-to-fit,
|
|
||||||
modernize-use-bool-literals,
|
|
||||||
modernize-use-emplace,
|
|
||||||
modernize-use-equals-delete,
|
|
||||||
modernize-use-nullptr,
|
|
||||||
modernize-use-override,
|
|
||||||
|
|
||||||
cppcoreguidelines-pro-type-reinterpret-cast,
|
|
||||||
-cppcoreguidelines-narrowing-conversions,
|
|
||||||
cppcoreguidelines-pro-type-member-init,
|
|
||||||
|
|
||||||
misc-unconventional-assign-operator,
|
|
||||||
-misc-unused-parameters,
|
|
||||||
misc-throw-by-value-catch-by-reference,
|
|
||||||
misc-misplaced-const,
|
|
||||||
misc-redundant-expression,
|
|
||||||
misc-static-assert,
|
|
||||||
misc-uniqueptr-reset-release,
|
|
||||||
-misc-unused-alias-decls,
|
|
||||||
-misc-unused-using-decls,
|
|
||||||
|
|
||||||
bugprone-undelegated-constructor,
|
|
||||||
bugprone-macro-parentheses,
|
|
||||||
bugprone-macro-repeated-side-effects,
|
|
||||||
bugprone-forward-declaration-namespace,
|
|
||||||
bugprone-bool-pointer-implicit-conversion,
|
|
||||||
bugprone-misplaced-widening-cast,
|
|
||||||
bugprone-argument-comment,
|
|
||||||
bugprone-bad-signal-to-kill-thread,
|
|
||||||
bugprone-copy-constructor-init,
|
|
||||||
bugprone-dangling-handle,
|
|
||||||
bugprone-fold-init-type,
|
|
||||||
bugprone-inaccurate-erase,
|
|
||||||
bugprone-incorrect-roundings,
|
|
||||||
bugprone-integer-division,
|
|
||||||
bugprone-misplaced-operator-in-strlen-in-alloc,
|
|
||||||
bugprone-misplaced-pointer-arithmetic-in-alloc,
|
|
||||||
bugprone-move-forwarding-reference,
|
|
||||||
bugprone-multiple-statement-macro,
|
|
||||||
bugprone-parent-virtual-call,
|
|
||||||
bugprone-posix-return,
|
|
||||||
bugprone-reserved-identifier,
|
|
||||||
bugprone-signed-char-misuse,
|
|
||||||
bugprone-sizeof-container,
|
|
||||||
bugprone-sizeof-expression,
|
|
||||||
bugprone-string-constructor,
|
|
||||||
bugprone-string-integer-assignment,
|
|
||||||
bugprone-string-literal-with-embedded-nul,
|
|
||||||
bugprone-suspicious-enum-usage,
|
|
||||||
bugprone-suspicious-include,
|
|
||||||
bugprone-suspicious-memset-usage,
|
|
||||||
bugprone-suspicious-missing-comma,
|
|
||||||
bugprone-suspicious-string-compare,
|
|
||||||
bugprone-swapped-arguments,
|
|
||||||
bugprone-terminating-continue,
|
|
||||||
bugprone-throw-keyword-missing,
|
|
||||||
bugprone-too-small-loop-variable,
|
|
||||||
bugprone-undefined-memory-manipulation,
|
|
||||||
bugprone-unhandled-self-assignment,
|
|
||||||
bugprone-unused-raii,
|
|
||||||
bugprone-unused-return-value,
|
|
||||||
bugprone-use-after-move,
|
|
||||||
bugprone-virtual-near-miss,
|
|
||||||
|
|
||||||
hicpp-exception-baseclass,
|
|
||||||
hicpp-ignored-remove-result,
|
|
||||||
hicpp-no-assembler,
|
|
||||||
-hicpp-signed-bitwise,
|
|
||||||
|
|
||||||
performance-faster-string-find,
|
|
||||||
performance-for-range-copy,
|
|
||||||
performance-implicit-conversion-in-loop,
|
|
||||||
performance-inefficient-algorithm,
|
|
||||||
performance-inefficient-vector-operation,
|
|
||||||
performance-move-constructor-init,
|
|
||||||
performance-no-automatic-move,
|
|
||||||
-performance-trivially-destructible,
|
|
||||||
performance-unnecessary-copy-initialization'
|
|
||||||
|
|
||||||
WarningsAsErrors: "*"
|
|
9
.clangd
9
.clangd
@ -1,9 +0,0 @@
|
|||||||
Hover:
|
|
||||||
ShowAKA: true
|
|
||||||
Diagnostics:
|
|
||||||
UnusedIncludes: None # 禁用未使用头文件提示
|
|
||||||
Suppress:
|
|
||||||
- anon_type_definition # 禁用匿名的typedef提示
|
|
||||||
- unused-variable # 禁用未使用变量提示
|
|
||||||
- unused-function # 禁用未使用函数提示
|
|
||||||
- unused-includes # 禁用未使用的头文件提示
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -6,3 +6,6 @@
|
|||||||
path = filecomplete
|
path = filecomplete
|
||||||
url = https://www.sinxmiao.cn/taynpg/filecomplete
|
url = https://www.sinxmiao.cn/taynpg/filecomplete
|
||||||
branch = main
|
branch = main
|
||||||
|
[submodule "crashelper"]
|
||||||
|
path = crashelper
|
||||||
|
url = https://www.sinxmiao.cn/taynpg/crashelper
|
||||||
|
26
.vscode/settings.json
vendored
26
.vscode/settings.json
vendored
@ -1,6 +1,8 @@
|
|||||||
{
|
{
|
||||||
"files.autoSave": "onFocusChange",
|
"files.autoSave": "onFocusChange",
|
||||||
"editor.fontSize": 14,
|
"editor.fontSize": 13,
|
||||||
|
"editor.fontFamily": "'Monaspace Krypton Light', 'Monaspace Krypton Light', 'Monaspace Krypton Light'",
|
||||||
|
"terminal.integrated.fontFamily": "Monaspace Krypton Light",
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.configureOnOpen": true,
|
||||||
"cmake.debugConfig": {
|
"cmake.debugConfig": {
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
@ -19,6 +21,10 @@
|
|||||||
"9999"
|
"9999"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"cmake.configureArgs": [
|
||||||
|
"-Wno-dev",
|
||||||
|
"-DGRAB_CRASH=ON"
|
||||||
|
],
|
||||||
"cmake.configureSettings": {
|
"cmake.configureSettings": {
|
||||||
//"CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
//"CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
},
|
},
|
||||||
@ -31,17 +37,9 @@
|
|||||||
"zh-hant": true,
|
"zh-hant": true,
|
||||||
"zh-hans": true
|
"zh-hans": true
|
||||||
},
|
},
|
||||||
"C_Cpp.intelliSenseEngine": "disabled",
|
"files.associations": {
|
||||||
"clangd.arguments": [
|
".clang-tidy": "yaml",
|
||||||
"--header-insertion=never",
|
"filesystem": "cpp",
|
||||||
"--all-scopes-completion",
|
"regex": "cpp"
|
||||||
"--completion-style=detailed",
|
}
|
||||||
"-j=4",
|
|
||||||
"--clang-tidy",
|
|
||||||
"--pch-storage=memory",
|
|
||||||
"--compile-commands-dir=build",
|
|
||||||
"--background-index",
|
|
||||||
"--ranking-model=heuristics",
|
|
||||||
"--function-arg-placeholders=false"
|
|
||||||
],
|
|
||||||
}
|
}
|
@ -46,6 +46,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
|||||||
${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/
|
${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (DEFINED GRAB_CRASH)
|
||||||
|
message(STATUS "GRAB_CRASH ${GRAB_CRASH}")
|
||||||
|
add_subdirectory(crashelper/crashelper)
|
||||||
|
add_definitions(-DGRAB_CRASH)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_definitions(-DFMT_HEADER_ONLY)
|
add_definitions(-DFMT_HEADER_ONLY)
|
||||||
include_directories(3rd)
|
include_directories(3rd)
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
|
@ -24,6 +24,10 @@ if(DEFINED USE_BOOST)
|
|||||||
target_link_directories(tsc PRIVATE ${MBOOST_LIB_DIR})
|
target_link_directories(tsc PRIVATE ${MBOOST_LIB_DIR})
|
||||||
target_link_libraries(tsc PRIVATE ${MBOOST_LIBS})
|
target_link_libraries(tsc PRIVATE ${MBOOST_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
if (DEFINED GRAB_CRASH)
|
||||||
|
message(STATUS "tsc link crashelper")
|
||||||
|
target_link_libraries(tsc PRIVATE crashelper)
|
||||||
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND uname -a
|
COMMAND uname -a
|
||||||
|
@ -16,11 +16,21 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GRAB_CRASH)
|
||||||
|
#ifdef USE_BOOST
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
namespace fs = boost::filesystem;
|
||||||
|
#else
|
||||||
|
#include <filesystem>
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
#endif
|
||||||
|
#include <crashelper.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<ClientConfig> g_Config = nullptr;
|
std::shared_ptr<ClientConfig> g_Config = nullptr;
|
||||||
int parse_cmd(int argc, char** argv, CmdParam& param)
|
int parse_cmd(int argc, char** argv, CmdParam& param)
|
||||||
{
|
{
|
||||||
std::string intro(
|
std::string intro(fmt::format("tsc cmd introduce, version: {}\nopensource: {}", VERSION_NUM, VERSION_URL));
|
||||||
fmt::format("tsc cmd introduce, version: {}\nopensource: {}", VERSION_NUM, VERSION_URL));
|
|
||||||
CLI::App app(intro);
|
CLI::App app(intro);
|
||||||
|
|
||||||
app.add_option("-u, --use", param.use_config, "使用服务器地址组(值为使用--show中显示的序号)");
|
app.add_option("-u, --use", param.use_config, "使用服务器地址组(值为使用--show中显示的序号)");
|
||||||
@ -156,6 +166,13 @@ bool exec_cmd(CmdParam& param, bool& run)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
#if defined(GRAB_CRASH)
|
||||||
|
auto config_dir = COfPath::get_config_dir("transm", true);
|
||||||
|
auto err = fs::path(config_dir).append("errs").string();
|
||||||
|
backward::SetDumpFileSavePath(err);
|
||||||
|
backward::SetDumpLogSavePath(err);
|
||||||
|
CRASHELPER_MARK_ENTRY();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
1
crashelper
Submodule
1
crashelper
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit eed787c1bfc1ed1585843923673e27354be7c0bd
|
@ -23,6 +23,9 @@ endif()
|
|||||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||||
target_link_libraries(tss PRIVATE ws2_32 wsock32)
|
target_link_libraries(tss PRIVATE ws2_32 wsock32)
|
||||||
endif()
|
endif()
|
||||||
|
if (DEFINED GRAB_CRASH)
|
||||||
|
target_link_libraries(tss PRIVATE crashelper)
|
||||||
|
endif()
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND uname -a
|
COMMAND uname -a
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include <of_path.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -13,17 +14,26 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void signal_handler(int signal)
|
#if defined(GRAB_CRASH)
|
||||||
{
|
#ifdef USE_BOOST
|
||||||
if (signal == SIGINT) {
|
#include <boost/filesystem.hpp>
|
||||||
fc_recovery_color();
|
namespace fs = boost::filesystem;
|
||||||
exit(signal);
|
#else
|
||||||
}
|
#include <filesystem>
|
||||||
}
|
namespace fs = std::filesystem;
|
||||||
|
#endif
|
||||||
|
#include <crashelper.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
std::signal(SIGINT, signal_handler);
|
#if defined(GRAB_CRASH)
|
||||||
|
auto config_dir = COfPath::get_config_dir("transm", true);
|
||||||
|
auto err = fs::path(config_dir).append("errs").string();
|
||||||
|
backward::SetDumpFileSavePath(err);
|
||||||
|
backward::SetDumpLogSavePath(err);
|
||||||
|
CRASHELPER_MARK_ENTRY();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user