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 ////////////////////////////////////////////////////////////////////////
|
// MAIN ////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
TraceMe();
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string> options =
|
std::unordered_map<std::string, std::string> options =
|
||||||
ParseOptions(argc, argv);
|
ParseOptions(argc, argv);
|
||||||
|
|
||||||
|
@ -47,4 +47,6 @@ std::vector<std::string> GetPlatformClangArguments();
|
|||||||
void FreeUnusedMemory();
|
void FreeUnusedMemory();
|
||||||
|
|
||||||
// If true objective-c index tests will be run.
|
// If true objective-c index tests will be run.
|
||||||
bool RunObjectiveCIndexTests();
|
bool RunObjectiveCIndexTests();
|
||||||
|
|
||||||
|
void TraceMe();
|
||||||
|
@ -37,8 +37,11 @@
|
|||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
#include <sys/param.h> // MAXPATHLEN
|
#include <sys/param.h> // MAXPATHLEN
|
||||||
#include <sys/sysctl.h> // sysctl
|
#include <sys/sysctl.h> // sysctl
|
||||||
|
#elif defined(__APPLE__) || defined(__BSD__)
|
||||||
|
#include <sys/ptrace.h>
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -272,4 +275,12 @@ bool RunObjectiveCIndexTests() {
|
|||||||
#endif
|
#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
|
#endif
|
||||||
|
@ -146,4 +146,8 @@ bool RunObjectiveCIndexTests() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Wait for debugger to attach
|
||||||
|
void TraceMe() {
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user