mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Add TraceMe() to main()
On POSIX systems, you may set CQUERY_TRACEME=1 before running your editor. cquery will inherit that environment variable and stop itself at the start of main().
This commit is contained in:
parent
32d37ede49
commit
0a7b9209df
@ -383,6 +383,8 @@ void LanguageServerMain(const std::string& bin_name,
|
||||
// MAIN ////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main(int argc, char** argv) {
|
||||
TraceMe();
|
||||
|
||||
std::unordered_map<std::string, std::string> options =
|
||||
ParseOptions(argc, argv);
|
||||
|
||||
|
@ -48,3 +48,5 @@ void FreeUnusedMemory();
|
||||
|
||||
// If true objective-c index tests will be run.
|
||||
bool RunObjectiveCIndexTests();
|
||||
|
||||
void TraceMe();
|
||||
|
@ -37,8 +37,11 @@
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h> // MAXPATHLEN
|
||||
#include <sys/sysctl.h> // sysctl
|
||||
#elif defined(__APPLE__) || defined(__BSD__)
|
||||
#include <sys/ptrace.h>
|
||||
#elif defined(__linux__)
|
||||
#include <malloc.h>
|
||||
#include <sys/ptrace.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
@ -272,4 +275,12 @@ bool RunObjectiveCIndexTests() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void TraceMe() {
|
||||
// If the environment variable is defined, wait for a debugger.
|
||||
// In gdb, you need to invoke `signal SIGCONT` if you want cquery to continue
|
||||
// after detaching.
|
||||
if (getenv("CQUERY_TRACEME"))
|
||||
raise(SIGTSTP);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -146,4 +146,8 @@ bool RunObjectiveCIndexTests() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Wait for debugger to attach
|
||||
void TraceMe() {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user