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 9 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h" 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("threadBufferSize", packet.threadBufferSize) || 21 !o.map("processBufferSizeLimit", packet.processBufferSizeLimit)) 22 return false; 23 if (packet.tids && packet.processBufferSizeLimit) { 24 path.report("processBufferSizeLimit must be provided"); 25 return false; 26 } 27 if (!packet.tids && !packet.processBufferSizeLimit) { 28 path.report("processBufferSizeLimit must not be provided"); 29 return false; 30 } 31 return true; 32 } 33 34 json::Value toJSON(const TraceIntelPTStartRequest &packet) { 35 json::Value base = toJSON((const TraceStartRequest &)packet); 36 base.getAsObject()->try_emplace("threadBufferSize", packet.threadBufferSize); 37 base.getAsObject()->try_emplace("processBufferSizeLimit", 38 packet.processBufferSizeLimit); 39 return base; 40 } 41 42 } // namespace lldb_private 43