Skip to content

Commit fbe04c1

Browse files
committed
Feedback from Jonas, and cleanup dev logging
1 parent e150907 commit fbe04c1

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include <thread>
5656
#include <vector>
5757

58-
#include <iostream>
5958
#if defined(_WIN32)
6059
// We need to #define NOMINMAX in order to skip `min()` and `max()` macro
6160
// definitions that conflict with other system headers.
@@ -419,21 +418,18 @@ static std::string GetStringFromStructuredData(lldb::SBStructuredData &data,
419418
if (!keyValue)
420419
return std::string();
421420

422-
size_t size = keyValue.GetStringValue(nullptr, 0);
423-
std::cout << "Size for " << key << " " << size << std::endl;
424-
std::string stringValue;
425-
stringValue.resize(size);
426-
keyValue.GetStringValue(&stringValue[0], size + 1);
427-
std::cout << "String value after: " << stringValue << std::endl;
428-
return stringValue;
421+
const size_t length = keyValue.GetStringValue(nullptr, 0);
422+
std::string str(length + 1, 0);
423+
value.GetStringValue(&str[0], length);
424+
return str;
429425
}
430426

431427
static uint64_t GetUintFromStructuredData(lldb::SBStructuredData &data,
432428
const char *key) {
433429
lldb::SBStructuredData keyValue = data.GetValueForKey(key);
434430

435431
if (!keyValue.IsValid())
436-
return -1;
432+
return 0;
437433
return keyValue.GetUnsignedIntegerValue();
438434
}
439435

@@ -456,23 +452,24 @@ void ProgressEventThreadFunction(DAP &dap) {
456452
lldb::SBStructuredData data =
457453
lldb::SBDebugger::GetProgressDataFromEvent(event);
458454

459-
uint64_t progress_id = GetUintFromStructuredData(data, "progress_id");
460-
uint64_t completed = GetUintFromStructuredData(data, "completed");
461-
uint64_t total = GetUintFromStructuredData(data, "total");
455+
const uint64_t progress_id =
456+
GetUintFromStructuredData(data, "progress_id");
457+
const uint64_t completed = GetUintFromStructuredData(data, "completed");
458+
const uint64_t total = GetUintFromStructuredData(data, "total");
459+
const std::string details =
460+
GetStringFromStructuredData(data, "details");
462461
std::string message;
463462
// Include the title on the first event.
464463
if (completed == 0) {
465-
std::string title = GetStringFromStructuredData(data, "title");
464+
const std::string title = GetStringFromStructuredData(data, "title");
466465
message += title;
467466
message += ": ";
468467
}
469468

470-
std::string details = GetStringFromStructuredData(data, "details");
471469
message += details;
472470
// Verbose check, but we get -1 for the uint64 on failure to read
473471
// so we check everything before broadcasting an event.
474-
if (message.length() > 0 && progress_id > 0 && total >= 0 &&
475-
completed >= 0)
472+
if (message.length() > 0)
476473
dap.SendProgressEvent(progress_id, message.c_str(), completed, total);
477474
}
478475
}

0 commit comments

Comments
 (0)