1 //===-- TraceIntelPTGDBRemotePackets.cpp ------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
12 using namespace llvm::json
;
14 namespace lldb_private
{
16 bool fromJSON(const json::Value
&value
, TraceIntelPTStartRequest
&packet
,
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
))
25 if (packet
.tids
&& packet
.processBufferSizeLimit
) {
26 path
.report("processBufferSizeLimit must be provided");
29 if (!packet
.tids
&& !packet
.processBufferSizeLimit
) {
30 path
.report("processBufferSizeLimit must not be provided");
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
);
46 } // namespace lldb_private