LLDB  mainline
TraceJSONStructs.h
Go to the documentation of this file.
1 //===-- TraceJSONStruct.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_TARGET_TRACEJSONSTRUCTS_H
10 #define LLDB_TARGET_TRACEJSONSTRUCTS_H
11 
12 #include "lldb/lldb-types.h"
13 #include "llvm/Support/JSON.h"
14 
15 namespace lldb_private {
16 
17 struct JSONAddress {
19 };
20 
21 struct JSONModule {
23  llvm::Optional<std::string> file;
25  llvm::Optional<std::string> uuid;
26 };
27 
28 struct JSONThread {
29  int64_t tid;
31 };
32 
33 struct JSONProcess {
34  int64_t pid;
36  std::vector<JSONThread> threads;
37  std::vector<JSONModule> modules;
38 };
39 
42 };
43 
45  std::vector<JSONProcess> processes;
46 };
47 
48 /// The trace plug-in implementation should provide its own TPluginSettings,
49 /// which corresponds to the "trace" section of the schema.
50 template <class TPluginSettings>
52  TPluginSettings trace;
53 };
54 
55 } // namespace lldb_private
56 
57 namespace llvm {
58 namespace json {
59 
60 llvm::json::Value toJSON(const lldb_private::JSONModule &module);
61 
62 llvm::json::Value toJSON(const lldb_private::JSONThread &thread);
63 
64 llvm::json::Value toJSON(const lldb_private::JSONProcess &process);
65 
66 llvm::json::Value
67 toJSON(const lldb_private::JSONTraceSessionBase &session_base);
68 
69 bool fromJSON(const Value &value, lldb_private::JSONAddress &address,
70  Path path);
71 
72 bool fromJSON(const Value &value, lldb_private::JSONModule &module, Path path);
73 
74 bool fromJSON(const Value &value, lldb_private::JSONThread &thread, Path path);
75 
76 bool fromJSON(const Value &value, lldb_private::JSONProcess &process,
77  Path path);
78 
79 bool fromJSON(const Value &value,
81  Path path);
82 
83 bool fromJSON(const Value &value, lldb_private::JSONTraceSessionBase &session,
84  Path path);
85 
86 template <class TPluginSettings>
87 bool fromJSON(const Value &value,
89  Path path) {
90  ObjectMapper o(value, path);
91  return o && o.map("trace", session.trace) &&
92  fromJSON(value, (lldb_private::JSONTraceSessionBase &)session, path);
93 }
94 
95 } // namespace json
96 } // namespace llvm
97 
98 #endif // LLDB_TARGET_TRACEJSONSTRUCTS_H
llvm
Definition: Debugger.h:49
lldb_private::JSONModule::file
llvm::Optional< std::string > file
Definition: TraceJSONStructs.h:23
lldb_private::JSONThread
Definition: TraceJSONStructs.h:28
lldb_private::JSONModule::load_address
JSONAddress load_address
Definition: TraceJSONStructs.h:24
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::JSONTracePluginSettings
Definition: TraceJSONStructs.h:40
lldb_private::JSONTracePluginSettings::type
std::string type
Definition: TraceJSONStructs.h:41
lldb_private::JSONThread::trace_file
std::string trace_file
Definition: TraceJSONStructs.h:30
lldb_private::JSONTraceSession
The trace plug-in implementation should provide its own TPluginSettings, which corresponds to the "tr...
Definition: TraceJSONStructs.h:51
lldb_private::JSONProcess::pid
int64_t pid
Definition: TraceJSONStructs.h:34
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::JSONTraceSessionBase
Definition: TraceJSONStructs.h:44
lldb_private::JSONTraceSessionBase::processes
std::vector< JSONProcess > processes
Definition: TraceJSONStructs.h:45
lldb-types.h
lldb_private::JSONAddress
Definition: TraceJSONStructs.h:17
lldb_private::JSONProcess::modules
std::vector< JSONModule > modules
Definition: TraceJSONStructs.h:37
lldb_private::JSONAddress::value
lldb::addr_t value
Definition: TraceJSONStructs.h:18
lldb_private::JSONProcess::triple
std::string triple
Definition: TraceJSONStructs.h:35
llvm::json::fromJSON
bool fromJSON(const Value &value, JSONAddress &address, Path path)
Definition: TraceJSONStructs.cpp:66
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::JSONModule
Definition: TraceJSONStructs.h:21
lldb_private::JSONTraceSession::trace
TPluginSettings trace
Definition: TraceJSONStructs.h:52
lldb_private::JSONThread::tid
int64_t tid
Definition: TraceJSONStructs.h:29
lldb_private::JSONProcess::threads
std::vector< JSONThread > threads
Definition: TraceJSONStructs.h:36
lldb_private::JSONModule::uuid
llvm::Optional< std::string > uuid
Definition: TraceJSONStructs.h:25
lldb_private::JSONProcess
Definition: TraceJSONStructs.h:33
lldb_private::JSONModule::system_path
std::string system_path
Definition: TraceJSONStructs.h:22
llvm::json::toJSON
llvm::json::Value toJSON(const JSONModule &module)
Definition: TraceJSONStructs.cpp:21