This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspector.cc
More file actions
47 lines (39 loc) · 1.43 KB
/
inspector.cc
File metadata and controls
47 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "core/include/common.h"
#include "core/include/command.h"
#include "snapshot/snapshot_inspector.h"
static inline void
InitializeLogging(char *arg0){
using namespace token;
google::LogToStderr();
google::InitGoogleLogging(arg0);
}
DEFINE_string(inspector_tool, "", "The inspector tool to use");
int
main(int argc, char **argv){
using namespace token;
SignalHandlers::Initialize();
gflags::ParseCommandLineFlags(&argc, &argv, true);
InitializeLogging(argv[0]);
std::string inspector_path;
if(FLAGS_inspector_tool == "snapshot"){
LOG(INFO) << "Please enter a snapshot to inspect (type .exit to quit):";
std::cin >> inspector_path;
if(inspector_path == ".exit") return EXIT_SUCCESS;
if(!FileExists(inspector_path)){
LOG(WARNING) << "Snapshot " << inspector_path << " doesn't exist, please enter a IsValid snapshot path";
return EXIT_FAILURE;
}
SnapshotInspector inspector;
SnapshotPtr snapshot = Snapshot::ReadSnapshot(inspector_path);
inspector.Inspect(snapshot.get());
} else if(FLAGS_inspector_tool == "heap-dump"){
LOG(INFO) << "Please enter a heap dump to inspect (type .exit to quit):";
std::cin >> inspector_path;
if(inspector_path == ".exit") return EXIT_SUCCESS;
if(!FileExists(inspector_path)){
LOG(ERROR) << "Heap Dump " << inspector_path << " doesn't exist, please enter a IsValid path";
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}