================
@@ -394,6 +394,103 @@ bool ProcessGDBRemote::ParsePythonTargetDefinition(
   return false;
 }
 
+static bool ParseMemoryRegionInfoJSON(StructuredData::Object *json,
+                                      MemoryRegionInfo &ri,
+                                      uint32_t page_size) {
+  ri.Clear();
+  if (!json || !json->GetAsArray())
+    return false;
+  bool returnval = true;
+  json->GetAsArray()->ForEach(
+      [&ri, page_size, &returnval](StructuredData::Object *obj) -> bool {
+        StructuredData::Dictionary *dict = obj->GetAsDictionary();
+        if (!dict)
+          returnval = false;
+
+        if (!dict->HasKey("start") || !dict->HasKey("size") ||
+            !dict->HasKey("permissions"))
+          returnval = false;
+
+        ri.GetRange().SetRangeBase(
+            dict->GetValueForKey("start")->GetUnsignedIntegerValue());
+        ri.GetRange().SetByteSize(
+            dict->GetValueForKey("size")->GetUnsignedIntegerValue());
+        llvm::StringRef permissions =
+            dict->GetValueForKey("permissions")->GetStringValue();
+        if (permissions.contains('r'))
+          ri.SetReadable(eLazyBoolYes);
+        else
+          ri.SetReadable(eLazyBoolNo);
+
+        if (permissions.contains('w'))
+          ri.SetWritable(eLazyBoolYes);
+        else
+          ri.SetWritable(eLazyBoolNo);
+
+        if (permissions.contains('x'))
+          ri.SetExecutable(eLazyBoolYes);
+        else
+          ri.SetExecutable(eLazyBoolNo);
+
+        if (!permissions.empty())
+          ri.SetMapped(eLazyBoolYes);
+        else
+          ri.SetMapped(eLazyBoolNo);
+
+        if (dict->HasKey("flags")) {
+          dict->GetValueForKey("flags")->GetAsArray()->ForEach(
+              [&ri](StructuredData::Object *obj) -> bool {
+                if (!obj->GetAsString())
+                  return true;
+                if (obj->GetAsString()->GetValue() == "mt")
+                  ri.SetMemoryTagged(eLazyBoolYes);
+                if (obj->GetAsString()->GetValue() == "ss")
+                  ri.SetIsShadowStack(eLazyBoolYes);
+                return true;
+              });
+        }
+
+        if (dict->HasKey("name") && 
dict->GetValueForKey("name")->GetAsString())
+          ri.SetName(dict->GetValueForKey("name")
+                         ->GetAsString()
+                         ->GetValue()
+                         .str()
+                         .c_str());
+
+        if (dict->HasKey("dirty_pages") &&
+            dict->GetValueForKey("dirty_pages")->GetAsArray()) {
+          std::vector<addr_t> dirty_pages;
+          dict->GetValueForKey("dirty_pages")
+              ->GetAsArray()
+              ->ForEach([&dirty_pages](StructuredData::Object *obj) -> bool {
+                if (!obj->GetAsUnsignedInteger())
+                  return true;
+                dirty_pages.push_back(
+                    obj->GetAsUnsignedInteger()->GetUnsignedIntegerValue());
+                return true;
+              });
+        }
+
+        if (dict->HasKey("types")) {
+          dict->GetValueForKey("types")->GetAsArray()->ForEach(
+              [&ri](StructuredData::Object *obj) -> bool {
+                if (!obj->GetAsString())
+                  return true;
+                if (obj->GetAsString()->GetValue() == "stack")
----------------
jasonmolenda wrote:

I don't think that changes anything here.  But I can create a 
`StructuredData::String*` and use it in both conditional expressions.

https://github.com/llvm/llvm-project/pull/202509
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to