================
@@ -44,12 +44,16 @@ class ProgressEventData : public EventData {
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   std::string GetMessage() const {
-    std::string message = m_title;
-    if (!m_details.empty()) {
-      message.append(": ");
-      message.append(m_details);
-    }
-    return message;
+    // Only put the title in the message of the progress create event.
+    if (m_completed == 0) {
+      std::string message = m_title;
+      if (!m_details.empty()) {
+        message.append(": ");
+        message.append(m_details);
+      }
+      return message;
+    } else
+      return !m_details.empty() ? m_details : std::string();
----------------
clayborg wrote:

The current API for `const char * SBDebugger::GetProgressFromEvent(...)` is 
causing some memory bloat for any users as each return value, which is the 
`<title> + ":" + <detail>` is being constified via `ConstString` so that we can 
return a `const char *`. Currently I am not sure of how many `Progress` objects 
update the detail and return millions of updates, but if they did, that will 
cause use to constify all of the `<title> + ":" + <detail>` strings, which is 
bad. So maybe a new API should be something like:
```
bool SBDebugger::GetProgressFromEvent(
  const lldb::SBEvent &event,
  uint64_t &progress_id,
  uint64_t &completed,
  uint64_t &total,
  bool &is_debugger_specific,
  char *title, size_t max_title_length,
  char *detail, size_t max_detail_length);
```
Then we can call `strncpy` on the `Progress::m_title` and `Progress::m_detail` 
as needed and avoid constifying the progress strings and bloating up the const 
string pool.




https://github.com/llvm/llvm-project/pull/124648
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to