|
10 | 10 | #include "SBReproducerPrivate.h" |
11 | 11 |
|
12 | 12 | #include "lldb/API/SBEnvironment.h" |
| 13 | +#include "lldb/API/SBError.h" |
13 | 14 | #include "lldb/API/SBFileSpec.h" |
14 | 15 | #include "lldb/API/SBListener.h" |
| 16 | +#include "lldb/API/SBStream.h" |
| 17 | +#include "lldb/API/SBStructuredData.h" |
| 18 | +#include "lldb/Core/StructuredDataImpl.h" |
15 | 19 | #include "lldb/Host/ProcessLaunchInfo.h" |
16 | 20 |
|
17 | 21 | using namespace lldb; |
@@ -343,6 +347,53 @@ bool SBLaunchInfo::GetDetachOnError() const { |
343 | 347 | return m_opaque_sp->GetDetachOnError(); |
344 | 348 | } |
345 | 349 |
|
| 350 | +const char *SBLaunchInfo::GetScriptedProcessClassName() const { |
| 351 | + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, |
| 352 | + GetScriptedProcessClassName); |
| 353 | + |
| 354 | + // Constify this string so that it is saved in the string pool. Otherwise it |
| 355 | + // would be freed when this function goes out of scope. |
| 356 | + ConstString class_name(m_opaque_sp->GetScriptedProcessClassName().c_str()); |
| 357 | + return class_name.AsCString(); |
| 358 | +} |
| 359 | + |
| 360 | +void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) { |
| 361 | + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, |
| 362 | + (const char *), class_name); |
| 363 | + |
| 364 | + m_opaque_sp->SetScriptedProcessClassName(class_name); |
| 365 | +} |
| 366 | + |
| 367 | +lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { |
| 368 | + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo, |
| 369 | + GetScriptedProcessDictionary); |
| 370 | + |
| 371 | + lldb_private::StructuredData::DictionarySP dict_sp = |
| 372 | + m_opaque_sp->GetScriptedProcessDictionarySP(); |
| 373 | + |
| 374 | + SBStructuredData data; |
| 375 | + data.m_impl_up->SetObjectSP(dict_sp); |
| 376 | + |
| 377 | + return LLDB_RECORD_RESULT(data); |
| 378 | +} |
| 379 | + |
| 380 | +void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) { |
| 381 | + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, |
| 382 | + (lldb::SBStructuredData), dict); |
| 383 | + |
| 384 | + SBStream stream; |
| 385 | + SBError error = dict.GetAsJSON(stream); |
| 386 | + |
| 387 | + if (error.Fail()) |
| 388 | + return; |
| 389 | + |
| 390 | + StructuredData::DictionarySP dict_sp; |
| 391 | + llvm::json::OStream s(stream.ref().AsRawOstream()); |
| 392 | + dict_sp->Serialize(s); |
| 393 | + |
| 394 | + m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); |
| 395 | +} |
| 396 | + |
346 | 397 | namespace lldb_private { |
347 | 398 | namespace repro { |
348 | 399 |
|
@@ -403,6 +454,14 @@ void RegisterMethods<SBLaunchInfo>(Registry &R) { |
403 | 454 | ()); |
404 | 455 | LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool)); |
405 | 456 | LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ()); |
| 457 | + LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, |
| 458 | + GetScriptedProcessClassName, ()); |
| 459 | + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, |
| 460 | + (const char *)); |
| 461 | + LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBLaunchInfo, |
| 462 | + GetScriptedProcessDictionary, ()); |
| 463 | + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, |
| 464 | + (lldb::SBStructuredData)); |
406 | 465 | LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironment, |
407 | 466 | (const lldb::SBEnvironment &, bool)); |
408 | 467 | LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment, ()); |
|
0 commit comments