LLDB  mainline
TraceIntelPTGDBRemotePackets.cpp
Go to the documentation of this file.
1 //===-- TraceIntelPTGDBRemotePackets.cpp ------------------------*- 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 
10 
11 using namespace llvm;
12 using namespace llvm::json;
13 
14 namespace lldb_private {
15 
16 bool fromJSON(const json::Value &value, TraceIntelPTStartRequest &packet,
17  Path path) {
18  ObjectMapper o(value, path);
19  if (!o || !fromJSON(value, (TraceStartRequest &)packet, path) ||
20  !o.map("enableTsc", packet.enableTsc) ||
21  !o.map("psbPeriod", packet.psbPeriod) ||
22  !o.map("threadBufferSize", packet.threadBufferSize) ||
23  !o.map("processBufferSizeLimit", packet.processBufferSizeLimit))
24  return false;
25  if (packet.tids && packet.processBufferSizeLimit) {
26  path.report("processBufferSizeLimit must be provided");
27  return false;
28  }
29  if (!packet.tids && !packet.processBufferSizeLimit) {
30  path.report("processBufferSizeLimit must not be provided");
31  return false;
32  }
33  return true;
34 }
35 
36 json::Value toJSON(const TraceIntelPTStartRequest &packet) {
37  json::Value base = toJSON((const TraceStartRequest &)packet);
38  base.getAsObject()->try_emplace("threadBufferSize", packet.threadBufferSize);
39  base.getAsObject()->try_emplace("processBufferSizeLimit",
40  packet.processBufferSizeLimit);
41  base.getAsObject()->try_emplace("psbPeriod", packet.psbPeriod);
42  base.getAsObject()->try_emplace("enableTsc", packet.enableTsc);
43  return base;
44 }
45 
46 } // namespace lldb_private
llvm
Definition: Debugger.h:49
llvm::json
Definition: TraceJSONStructs.cpp:19
TraceIntelPTGDBRemotePackets.h
lldb_private::TraceIntelPTStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceIntelPTGDBRemotePackets.h:19
lldb_private::TraceStartRequest
jLLDBTraceStart gdb-remote packet
Definition: TraceGDBRemotePackets.h:41
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::TraceStartRequest::tids
llvm::Optional< std::vector< int64_t > > tids
If llvm::None, then this starts tracing the whole process.
Definition: TraceGDBRemotePackets.h:47
llvm::json::toJSON
llvm::json::Value toJSON(const JSONModule &module)
Definition: TraceJSONStructs.cpp:21