[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-11 Thread Felipe de Azevedo Piovezan via Phabricator via lldb-commits
fdeazeve updated this revision to Diff 459348.
fdeazeve edited the summary of this revision.
fdeazeve added a comment.

Reworded commit message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133639/new/

https://reviews.llvm.org/D133639

Files:
  lldb/test/API/lit.cfg.py


Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -91,6 +91,13 @@
   This allows us to check if the attribute exists before trying to access 
it."""
   return getattr(config, attr, None)
 
+def is_configured_and_true(attr):
+  """Returns true if and only if the configuration attribute exists and it is
+  set to'1'.
+
+  This is useful when checking CMake variables that have been cannonicalized to
+  0/1."""
+  return getattr(config, attr, None) == '1'
 
 def delete_module_cache(path):
   """Clean the module caches in the test build directory.
@@ -171,7 +178,7 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
+if is_configured_and_true('has_libcxx') and platform.system() != 'Windows':
   if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
 dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
 dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]


Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -91,6 +91,13 @@
   This allows us to check if the attribute exists before trying to access it."""
   return getattr(config, attr, None)
 
+def is_configured_and_true(attr):
+  """Returns true if and only if the configuration attribute exists and it is
+  set to'1'.
+
+  This is useful when checking CMake variables that have been cannonicalized to
+  0/1."""
+  return getattr(config, attr, None) == '1'
 
 def delete_module_cache(path):
   """Clean the module caches in the test build directory.
@@ -171,7 +178,7 @@
   dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir]
 
 # If we have a just-built libcxx, prefer it over the system one.
-if is_configured('has_libcxx') and platform.system() != 'Windows':
+if is_configured_and_true('has_libcxx') and platform.system() != 'Windows':
   if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
 dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
 dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-09-11 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 459362.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111509/new/

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/complex-int.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/complex-conversion.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/In

[Lldb-commits] [PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-09-11 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov updated this revision to Diff 459369.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111509/new/

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/complex-int.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/complex-conversion.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/In

[Lldb-commits] [PATCH] D133639: [lldb] Fix detection of existing libcxx

2022-09-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/test/API/lit.cfg.py:94
 
+def is_configured_and_true(attr):
+  """Returns true if and only if the configuration attribute exists and it is

`is_enabled` maybe?



Comment at: lldb/test/API/lit.cfg.py:181-184
+if is_configured_and_true('has_libcxx') and platform.system() != 'Windows':
   if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
 dotest_cmd += ['--libcxx-include-dir', 
os.path.join(config.llvm_include_dir, 'c++', 'v1')]
 dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]

Are there other places where this helper would be useful? If not I think we can 
check the value directly. With the helper we lose a little bit of signal (if it 
returns false, was it not configured or set to false?). I don't think it's a 
big deal, but those two things combined make me favor inlining the check. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133639/new/

https://reviews.llvm.org/D133639

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D133038: Add SBDebugger::GetSetting() public API

2022-09-11 Thread jeffrey tan via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5f54751048b: Add SBDebugger::GetSetting() public APIs 
(authored by yinghuitan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133038/new/

https://reviews.llvm.org/D133038

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Core/UserSettingsController.h
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueArray.h
  lldb/include/lldb/Interpreter/OptionValueBoolean.h
  lldb/include/lldb/Interpreter/OptionValueChar.h
  lldb/include/lldb/Interpreter/OptionValueDictionary.h
  lldb/include/lldb/Interpreter/OptionValueFileSpec.h
  lldb/include/lldb/Interpreter/OptionValueFormat.h
  lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
  lldb/include/lldb/Interpreter/OptionValueLanguage.h
  lldb/include/lldb/Interpreter/OptionValuePathMappings.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/include/lldb/Interpreter/OptionValueRegex.h
  lldb/include/lldb/Interpreter/OptionValueSInt64.h
  lldb/include/lldb/Interpreter/OptionValueString.h
  lldb/include/lldb/Interpreter/OptionValueUInt64.h
  lldb/include/lldb/Interpreter/OptionValueUUID.h
  lldb/include/lldb/Target/PathMappingList.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/UserSettingsController.cpp
  lldb/source/Interpreter/OptionValueArray.cpp
  lldb/source/Interpreter/OptionValueDictionary.cpp
  lldb/source/Interpreter/OptionValueFormat.cpp
  lldb/source/Interpreter/OptionValueFormatEntity.cpp
  lldb/source/Interpreter/OptionValueLanguage.cpp
  lldb/source/Interpreter/OptionValuePathMappings.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Target/PathMappingList.cpp
  lldb/test/API/commands/settings/TestSettings.py
  lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Index: lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
===
--- lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
+++ lldb/test/API/functionalities/source-map/TestTargetSourceMap.py
@@ -1,11 +1,45 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test.decorators import *
+import json
 import os
 
 
 class TestTargetSourceMap(TestBase):
 
+@no_debug_info_test
+def test_source_map_via_setting_api(self):
+"""
+Test that ensures SBDebugger::GetSetting("target.source-map") API
+can correctly fetch source mapping entries.
+"""
+# Set the target soure map to map "./" to the current test directory
+src_dir = self.getSourceDir()
+
+source_map_setting_path = "target.source-map"
+initial_source_map = self.dbg.GetSetting(source_map_setting_path)
+self.assertEquals(initial_source_map.GetSize(), 0,
+"Initial source map should be empty")
+
+src_dir = self.getSourceDir()
+self.runCmd('settings set %s . "%s"' % (source_map_setting_path, src_dir))
+
+source_map = self.dbg.GetSetting(source_map_setting_path)
+self.assertEquals(source_map.GetSize(), 1,
+"source map should be have one appended entry")
+
+stream = lldb.SBStream()
+source_map.GetAsJSON(stream)
+serialized_source_map = json.loads(stream.GetData())
+
+self.assertEquals(len(serialized_source_map[0]), 2,
+"source map entry should have two parts")
+self.assertEquals(serialized_source_map[0][0], ".",
+"source map entry's first part does not match")
+self.assertEquals(serialized_source_map[0][1], src_dir,
+"source map entry's second part does not match")
+
+
 @no_debug_info_test
 def test_source_map(self):
 """Test target.source-map' functionality."""
Index: lldb/test/API/commands/settings/TestSettings.py
===
--- lldb/test/API/commands/settings/TestSettings.py
+++ lldb/test/API/commands/settings/TestSettings.py
@@ -3,7 +3,7 @@
 """
 
 
-
+import json
 import os
 import re
 import lldb
@@ -274,7 +274,7 @@
 self.assertEqual(launch_info.GetArgumentAtIndex(0), "A")
 self.assertEqual(launch_info.GetArgumentAtIndex(1), "B")
 self.assertEqual(launch_info.GetArgumentAtIndex(2), "C")
-
+
 self.expect(
 'target show-launch-environment',
 substrs=["MY_ENV_VAR=YES"])
@@ -787,3 +787,59 @@
 
 # A known option should fail if its argument is invalid.
 self.expect("settings set auto-confirm bogus", error=True)
+
+def get_setting_json(self, setting_path = None):
+settings_data = self.dbg.GetSetting(setting_path)
+stream = lldb.SBStream()
+settings_data.GetAsJSON(stream)
+return json.loads(stream.GetData())
+
+def verify_setting_value_json(self, setting_path, s

[Lldb-commits] [lldb] d5f5475 - Add SBDebugger::GetSetting() public APIs

2022-09-11 Thread Jeffrey Tan via lldb-commits

Author: Jeffrey Tan
Date: 2022-09-11T20:50:03-07:00
New Revision: d5f54751048b59cc101125e03dabc57536fc1d2d

URL: 
https://github.com/llvm/llvm-project/commit/d5f54751048b59cc101125e03dabc57536fc1d2d
DIFF: 
https://github.com/llvm/llvm-project/commit/d5f54751048b59cc101125e03dabc57536fc1d2d.diff

LOG: Add SBDebugger::GetSetting() public APIs

This patch adds new SBDebugger::GetSetting() API which
enables client to access settings as SBStructedData.

Implementation wise, a new ToJSON() virtual function is added to OptionValue
class so that each concrete child class can override and provides its
own JSON representation. This patch aims to define the APIs and implement
a common set of OptionValue child classes, leaving the remaining for
future patches.

This patch is used later by auto deduce source map from source line breakpoint
feature for testing generated source map entries.

Differential Revision: https://reviews.llvm.org/D133038

Added: 


Modified: 
lldb/bindings/interface/SBDebugger.i
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/Core/UserSettingsController.h
lldb/include/lldb/Interpreter/OptionValue.h
lldb/include/lldb/Interpreter/OptionValueArray.h
lldb/include/lldb/Interpreter/OptionValueBoolean.h
lldb/include/lldb/Interpreter/OptionValueChar.h
lldb/include/lldb/Interpreter/OptionValueDictionary.h
lldb/include/lldb/Interpreter/OptionValueFileSpec.h
lldb/include/lldb/Interpreter/OptionValueFormat.h
lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
lldb/include/lldb/Interpreter/OptionValueLanguage.h
lldb/include/lldb/Interpreter/OptionValuePathMappings.h
lldb/include/lldb/Interpreter/OptionValueProperties.h
lldb/include/lldb/Interpreter/OptionValueRegex.h
lldb/include/lldb/Interpreter/OptionValueSInt64.h
lldb/include/lldb/Interpreter/OptionValueString.h
lldb/include/lldb/Interpreter/OptionValueUInt64.h
lldb/include/lldb/Interpreter/OptionValueUUID.h
lldb/include/lldb/Target/PathMappingList.h
lldb/source/API/SBDebugger.cpp
lldb/source/Core/UserSettingsController.cpp
lldb/source/Interpreter/OptionValueArray.cpp
lldb/source/Interpreter/OptionValueDictionary.cpp
lldb/source/Interpreter/OptionValueFormat.cpp
lldb/source/Interpreter/OptionValueFormatEntity.cpp
lldb/source/Interpreter/OptionValueLanguage.cpp
lldb/source/Interpreter/OptionValuePathMappings.cpp
lldb/source/Interpreter/OptionValueProperties.cpp
lldb/source/Target/PathMappingList.cpp
lldb/test/API/commands/settings/TestSettings.py
lldb/test/API/functionalities/source-map/TestTargetSourceMap.py

Removed: 




diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index 5d51a6ac20d2f..e82ce2aa8e7c7 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -225,6 +225,8 @@ public:
 }
 }
 
+lldb::SBStructuredData GetSetting(const char *setting = nullptr);
+
 SBError
 SetInputString (const char* data);
 

diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index b9a9b593d0ad4..d3de61caeb811 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -115,6 +115,21 @@ class LLDB_API SBDebugger {
 
   void Clear();
 
+  /// Getting a specific setting value into SBStructuredData format.
+  /// Client can specify empty string or null to get all settings.
+  ///
+  /// Example usages:
+  /// lldb::SBStructuredData settings = debugger.GetSetting();
+  /// lldb::SBStructuredData settings = debugger.GetSetting(nullptr);
+  /// lldb::SBStructuredData settings = debugger.GetSetting("");
+  /// lldb::SBStructuredData settings = debugger.GetSetting("target.arg0");
+  /// lldb::SBStructuredData settings = debugger.GetSetting("target");
+  ///
+  /// \param[out] setting
+  ///   Property setting path to retrieve values. e.g "target.source-map"
+  ///
+  lldb::SBStructuredData GetSetting(const char *setting = nullptr);
+
   void SetAsync(bool b);
 
   bool GetAsync();

diff  --git a/lldb/include/lldb/Core/UserSettingsController.h 
b/lldb/include/lldb/Core/UserSettingsController.h
index 3f08c351d..8afef06359738 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -57,10 +57,11 @@ class Properties {
 
   virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx,
Stream &strm, llvm::StringRef property_path,
-   uint32_t dump_mask);
+   uint32_t dump_mask, bool is_json = false);
 
   virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx,
- Stream &strm, uint32_t dump_mask);
+ Stream &strm, uint32_t dump_mask,
+  

[Lldb-commits] [PATCH] D133680: Add support for mach-o corefile loading of a platform binary

2022-09-11 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added reviewers: JDevlieghere, jingham.
jasonmolenda added a project: LLDB.
Herald added a reviewer: ributzka.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

This builds on the work in https://reviews.llvm.org/D133534 where support for a 
platform binary in live process debugging was added, and adds it to the Mach-O 
corefile loading as well.  It has five changes:

1. Add a name field to `DynamicLoader::LoadBinaryWithUUIDAndAddress` when we 
have a name, but may end up reading the binary out of memory, so we can use the 
name instead of a generic placeholder.

2. In `ObjectFileMachO::LoadCoreFileImages`, check if the image address is a 
platform binary, load it and set the Platform/DynamicLoader as appropriate.

3. Clean up the different cases in `LoadCoreFileImages` that handle corefile 
binary loading so it is clearer to read.

4. Separate `ProcessMachCore::DoLoadCore` into half a dozen smaller helper 
methods.  This method had grown quite large and it was difficult to trace the 
code flow through the different parts, and the complexity was unnecessary.

5. In the new `ProcessMachCore::LoadBinariesViaMetadata` method which handles 
LC_NOTE type hints about binaries, when we have a `main bin spec` LC_NOTE that 
is explicitly a kernel, don't load the binary here -- just save the address and 
note that this will be a `DynamicLoaderDarwinKernel` dynamic loader, and leave 
the loading up to DynamicLoaderDarwinKernel to do correctly.

The minor cleanups in `ObjectFileMachO::LoadCoreFileImages` are easy to read in 
the phabracator if you only read the new version of the code.  The (seriously 
needed) separation of `ObjectFileMachO::LoadCoreFileImages` into separate 
methods has made the diff very difficult to read.  In my own reviewing of the 
patch, I've settled on simply reading through the new version of the file.  
Most of it is simple code movement, but I did make some cleanups to how 
sections of code were working -- for instance in the exhaustive search for a 
dyld or kernel binary, when multiple images that appear to be a kernel are 
found, I handle this better now by allowing DynamicLoaderDarwinKernel to pick 
the kernel image.  It's common that we get fragments in a corefile that look 
similar to a kernel and can confuse the exhaustive search algorithm.

Similar to the problem of testing this with a live process, to test this I'd 
need to construct a corefile with a Mach-O fileset with a kernel image in it.  
It would not be easy to construct a test case without a corefile writer that 
synthesized all of this together, a not small bit of code, and it would also 
need to modify a test binary's mach header to look enough like a kernel that 
lldb would be tricked into using it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133680

Files:
  lldb/include/lldb/Target/DynamicLoader.h
  lldb/source/Core/DynamicLoader.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h

Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -85,7 +85,14 @@
 lldb_private::MemoryRegionInfo ®ion_info) override;
 
 private:
-  bool GetDynamicLoaderAddress(lldb::addr_t addr);
+  void CreateMemoryRegions();
+  void LoadBinariesViaMetadata();
+  void LoadBinariesViaExhaustiveSearch();
+  void LoadBinariesAndSetDYLD();
+  void CleanupMemoryRegionPermissions();
+
+  bool CheckAddressForDyldOrKernel(lldb::addr_t addr, lldb::addr_t &dyld,
+   lldb::addr_t &kernel);
 
   enum CorefilePreference { eUserProcessCorefile, eKernelCorefile };
 
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -40,6 +40,7 @@
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
 
 #include 
 #include 
@@ -124,10 +125,13 @@
   Finalize();
 }
 
-bool ProcessMachCore::GetDynamicLoaderAddress(lldb::addr_t addr) {
+bool ProcessMachCore::CheckAddressForDyldOrKernel(lldb::addr_t addr,
+  addr_t &dyld,
+  addr_t &kernel) {
   Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
   llvm::Mach

[Lldb-commits] [PATCH] D133680: Add support for mach-o corefile loading of a platform binary

2022-09-11 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 459400.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133680/new/

https://reviews.llvm.org/D133680

Files:
  lldb/include/lldb/Target/DynamicLoader.h
  lldb/source/Core/DynamicLoader.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.h

Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -85,7 +85,14 @@
 lldb_private::MemoryRegionInfo ®ion_info) override;
 
 private:
-  bool GetDynamicLoaderAddress(lldb::addr_t addr);
+  void CreateMemoryRegions();
+  void LoadBinariesViaMetadata();
+  void LoadBinariesViaExhaustiveSearch();
+  void LoadBinariesAndSetDYLD();
+  void CleanupMemoryRegionPermissions();
+
+  bool CheckAddressForDyldOrKernel(lldb::addr_t addr, lldb::addr_t &dyld,
+   lldb::addr_t &kernel);
 
   enum CorefilePreference { eUserProcessCorefile, eKernelCorefile };
 
Index: lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -40,6 +40,7 @@
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
 #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
 
 #include 
 #include 
@@ -124,10 +125,13 @@
   Finalize();
 }
 
-bool ProcessMachCore::GetDynamicLoaderAddress(lldb::addr_t addr) {
+bool ProcessMachCore::CheckAddressForDyldOrKernel(lldb::addr_t addr,
+  addr_t &dyld,
+  addr_t &kernel) {
   Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
   llvm::MachO::mach_header header;
   Status error;
+  dyld = kernel = LLDB_INVALID_ADDRESS;
   if (DoReadMemory(addr, &header, sizeof(header), error) != sizeof(header))
 return false;
   if (header.magic == llvm::MachO::MH_CIGAM ||
@@ -141,9 +145,6 @@
 header.flags = llvm::ByteSwap_32(header.flags);
   }
 
-  // TODO: swap header if needed...
-  // printf("0x%16.16" PRIx64 ": magic = 0x%8.8x, file_type= %u\n", vaddr,
-  // header.magic, header.filetype);
   if (header.magic == llvm::MachO::MH_MAGIC ||
   header.magic == llvm::MachO::MH_MAGIC_64) {
 // Check MH_EXECUTABLE to see if we can find the mach image that contains
@@ -152,26 +153,23 @@
 // has the list of kexts to load
 switch (header.filetype) {
 case llvm::MachO::MH_DYLINKER:
-  // printf("0x%16.16" PRIx64 ": file_type = MH_DYLINKER\n", vaddr);
-  // Address of dyld "struct mach_header" in the core file
   LLDB_LOGF(log,
-"ProcessMachCore::GetDynamicLoaderAddress found a user "
+"ProcessMachCore::CheckAddressForDyldOrKernel found a user "
 "process dyld binary image at 0x%" PRIx64,
 addr);
-  m_dyld_addr = addr;
+  dyld = addr;
   return true;
 
 case llvm::MachO::MH_EXECUTE:
-  // printf("0x%16.16" PRIx64 ": file_type = MH_EXECUTE\n", vaddr);
   // Check MH_EXECUTABLE file types to see if the dynamic link object flag
   // is NOT set. If it isn't, then we have a mach_kernel.
   if ((header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
 LLDB_LOGF(log,
-  "ProcessMachCore::GetDynamicLoaderAddress found a mach "
+  "ProcessMachCore::CheckAddressForDyldOrKernel found a mach "
   "kernel binary image at 0x%" PRIx64,
   addr);
 // Address of the mach kernel "struct mach_header" in the core file.
-m_mach_kernel_addr = addr;
+kernel = addr;
 return true;
   }
   break;
@@ -180,46 +178,10 @@
   return false;
 }
 
-// Process Control
-Status ProcessMachCore::DoLoadCore() {
-  Log *log(GetLog(LLDBLog::DynamicLoader | LLDBLog::Process));
-  Status error;
-  if (!m_core_module_sp) {
-error.SetErrorString("invalid core module");
-return error;
-  }
-
+void ProcessMachCore::CreateMemoryRegions() {
   ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
-  if (core_objfile == nullptr) {
-error.SetErrorString("invalid core object file");
-return error;
-  }
-
-  if (core_objfile->GetNumThreadContexts() == 0) {
-error.SetErrorString("core file doesn't contain any LC_THREAD load "
- "commands, or the LC_THREAD architecture is not "
- "supp