[Lldb-commits] [lldb] 9f0b5f9 - [lldb/test] Added lldbutil function to test a breakpoint

2021-11-17 Thread SYNOPSYSgeorgiev via lldb-commits

Author: SYNOPSYS\georgiev
Date: 2021-11-17T08:37:30Z
New Revision: 9f0b5f9a39ea6e70c98c69a720d7e4f5d3800bf6

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

LOG: [lldb/test] Added lldbutil function to test a breakpoint

Testing the breakpoint itself rather than the lldb string.

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
lldb/test/API/commands/command/nested_alias/TestNestedAlias.py

lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py

lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py

lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
lldb/test/API/functionalities/load_unload/TestLoadUnload.py
lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
lldb/test/API/functionalities/memory/find/TestMemoryFind.py
lldb/test/API/functionalities/memory/read/TestMemoryRead.py
lldb/test/API/lang/c/anonymous/TestAnonymous.py
lldb/test/API/lang/c/array_types/TestArrayTypes.py
lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
lldb/test/API/lang/c/const_variables/TestConstVariables.py
lldb/test/API/lang/c/enum_types/TestEnumTypes.py
lldb/test/API/lang/c/forward/TestForwardDeclaration.py
lldb/test/API/lang/c/function_types/TestFunctionTypes.py
lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
lldb/test/API/lang/c/local_variables/TestLocalVariables.py
lldb/test/API/lang/c/modules/TestCModules.py
lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
lldb/test/API/lang/c/set_values/TestSetValues.py
lldb/test/API/lang/c/shared_lib/TestSharedLib.py

lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
lldb/test/API/lang/cpp/class_types/TestClassTypes.py
lldb/test/API/lang/cpp/inlines/TestInlines.py
lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
lldb/test/API/lang/objc/modules/TestObjCModules.py
lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
lldb/test/API/lang/objc/real-definition/TestRealDefinition.py

lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 2ab372d82b72d..c92626f5baed9 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -730,6 +730,57 @@ def check_breakpoint_result(
 (out_module_name,
  module_name))
 
+def check_breakpoint(
+test,
+bpno,
+expected_locations = None,
+expected_resolved_count = None,
+expected_hit_count = None,
+location_id = None,
+expected_location_resolved = True,
+expected_location_hit_count = None):
+"""
+Test breakpoint or breakpoint location.
+Breakpoint resolved count is always checked. If not specified the 
assumption is that all locations 
+should be resolved. 
+To test a breakpoint location, breakpoint number (bpno) and location_id 
must be set. In this case
+the resolved count for a breakpoint is not tested by default. The location 
is expected to be resolved,
+unless expected_location_resolved is set to False.
+test - test context
+bpno - breakpoint number to test
+expected_locations - expected number of locations for this breakpoint. If 
'None' this parameter is not tested.
+expected_resolved_count - expected resolved locations number for the 
breakpoint.  If 'None' - all locations should be resolved.
+expected_hit_count - expected hit count for this breakpoint. If 'None' 
this parameter is not tested.
+location_id - If not 'None' sets the location ID for the breakpoint to 
test.
+expected_location_resolved - Extected resolved status for the location_id 
(True/False). Default - True.
+expected_location_hit_count - Expected hit count for the breakpoint at 
location_id. Must be set if the location_id parameter

[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-11-17 Thread Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f0b5f9a39ea: [lldb/test] Added lldbutil function to test a 
breakpoint (authored by SYNOPSYS\georgiev ).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111899

Files:
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/test/API/commands/apropos/with-process/TestAproposWithProcess.py
  lldb/test/API/commands/command/nested_alias/TestNestedAlias.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_locations/TestBreakpointLocations.py
  lldb/test/API/functionalities/dead-strip/TestDeadStrip.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  lldb/test/API/functionalities/memory/cache/TestMemoryCache.py
  lldb/test/API/functionalities/memory/find/TestMemoryFind.py
  lldb/test/API/functionalities/memory/read/TestMemoryRead.py
  lldb/test/API/lang/c/anonymous/TestAnonymous.py
  lldb/test/API/lang/c/array_types/TestArrayTypes.py
  lldb/test/API/lang/c/conflicting-symbol/TestConflictingSymbol.py
  lldb/test/API/lang/c/const_variables/TestConstVariables.py
  lldb/test/API/lang/c/enum_types/TestEnumTypes.py
  lldb/test/API/lang/c/forward/TestForwardDeclaration.py
  lldb/test/API/lang/c/function_types/TestFunctionTypes.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/c/local_variables/TestLocalVariables.py
  lldb/test/API/lang/c/modules/TestCModules.py
  lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
  lldb/test/API/lang/c/set_values/TestSetValues.py
  lldb/test/API/lang/c/shared_lib/TestSharedLib.py
  
lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
  lldb/test/API/lang/cpp/class_types/TestClassTypes.py
  lldb/test/API/lang/cpp/inlines/TestInlines.py
  lldb/test/API/lang/cpp/namespace_definitions/TestNamespaceDefinitions.py
  lldb/test/API/lang/cpp/signed_types/TestSignedTypes.py
  lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py
  lldb/test/API/lang/objc/forward-decl/TestForwardDecl.py
  lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
  lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py
  lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py
  lldb/test/API/lang/objc/modules/TestObjCModules.py
  lldb/test/API/lang/objc/objc-new-syntax/ObjCNewSyntaxTest.py
  lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
  
lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py

Index: lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
===
--- lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
+++ lldb/test/API/lang/objc/single-entry-dictionary/TestObjCSingleEntryDictionary.py
@@ -57,8 +57,7 @@
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 d1 = self.frame().FindVariable("d1")
 d1.SetPreferSyntheticValue(True)
Index: lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
===
--- lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -32,14 +32,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 # This should display correctly.
 self.expect(
@@ -69,14 +67,12 @@
  'stop reason = breakpoint'])
 
 # Run and stop at Foo
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' resolved, hit count = 1'])
+lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
 
 self.runCmd("continue", RUN_SUCCEEDED)
 
 # Run at stop at main
-self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-substrs=[' reso

[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added a comment.

Btw, this crash in `llvm::DataLayout::getIndexedOffsetInType` was discovered by 
lldb-eval fuzzer a while ago -- 
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36738


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [lldb] 9574da8 - [lldb/test] TestRegisterVariables test fix

2021-11-17 Thread SYNOPSYSgeorgiev via lldb-commits

Author: SYNOPSYS\georgiev
Date: 2021-11-17T10:58:48Z
New Revision: 9574da8f51c82aa437c3b968251225932cc970a5

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

LOG: [lldb/test] TestRegisterVariables test fix

Added: 


Modified: 
lldb/test/API/lang/c/register_variables/TestRegisterVariables.py

Removed: 




diff  --git a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py 
b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
index ef6b0425525ca..c255056352c25 100644
--- a/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
+++ b/lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
@@ -50,7 +50,7 @@ def test_and_run_command(self):
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
+lldbutil.check_breakpoint(self, bpno = 1, location_id = 1, 
expected_location_hit_count = 1)
 
 # Try some variables that should be visible
 frame = self.dbg.GetSelectedTarget().GetProcess(
@@ -76,7 +76,7 @@ def test_and_run_command(self):
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
+lldbutil.check_breakpoint(self, bpno = 1, location_id = 2, 
expected_location_hit_count = 1)
 
 # Try some variables that should be visible
 frame = self.dbg.GetSelectedTarget().GetProcess(
@@ -102,7 +102,7 @@ def test_and_run_command(self):
  'stop reason = breakpoint'])
 
 # The breakpoint should have a hit count of 1.
-lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
+lldbutil.check_breakpoint(self, bpno = 1, location_id = 3, 
expected_location_hit_count = 1)
 
 # Try some variables that should be visible
 frame = self.dbg.GetSelectedTarget().GetProcess(



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


[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D113498#3131336 , @werat wrote:

> In D113498#3124525 , @teemperor 
> wrote:
>
>> I really like the solution, but I think by fixing the `CanInterpret` you 
>> also made the test case no longer reach the actual changed interpreting 
>> logic?
>>
>> So, `CanInterpret` says "we can't interpret this" (which is correct), but 
>> then the interpreter won't run it and your change to `ResolveConstantValue` 
>> isn't actually tested. There is no other test that touches that logic from 
>> what I can see. You could try throwing in some other expression at this that 
>> tests that new code? Maybe some kind of pointer arithmetic on a variable 
>> defined in your expression itself (so it can be constant evaluated).
>
> I think you're right, the interpreter now doesn't get to evaluating the 
> operands of `GetElementPtr`. However, I've failed to construct an expression 
> that would have a constant expression with `getelementptr` instruction. So 
> far I've only been able to reproduce it with the example from the test case 
> (which is being rejected during `CanInterpret`). I've tried expressions like 
> `const int x = 1; (int*)100 + (long long)(&x)` and similar (also with `x` 
> being a global variable), but they're are being compiled in a way that 
> `getelementptr` is not a constant expression anymore.

Not sure how flexible your fuzzer setup is regarding downstream patches, but 
did you try putting some kind of `assert("coverage" && false);` in that new 
code and try fuzzing until you reach it?

> In D113498#3124525 , @teemperor 
> wrote:
>
>> We could also split out the interpreting change and then this is good to go.
>
> I think the `Interpret` and `CanInterpret` should really be in-sync with each 
> other, otherwise more bugs can follow. Given that we can't get an expression 
> for the logic I've implemented, I can make the check more strict -- just 
> verify that all indexes are `ConstantInt`. What do you think?

Sure, that would also work for me.

FWIW, I'm OOO for an undefined amount of time so I am not sure when I can take 
a look at this again. Feel free to ping in case you don't find another reviewer.




Comment at: lldb/source/Expression/IRInterpreter.cpp:490
+ constant_expr->op_end());
+for (Value *op : operands) {
+  Constant *constant_op = dyn_cast(op);

werat wrote:
> teemperor wrote:
> > `for (Value *op : constant_expr->ops())` ?
> `ConstantExpr` doesn't have `ops()` accessor, only `op_begin/op_end`. Am I 
> missing something?
My bad, the function name was `operands()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Andy Yankovsky via Phabricator via lldb-commits
werat updated this revision to Diff 387911.
werat added a comment.

Make the check more strict, only verify that the indexes are ConstantInt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

Files:
  lldb/source/Expression/IRInterpreter.cpp
  lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py


Index: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
===
--- lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
+++ lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
@@ -41,3 +41,31 @@
 self.createTestTarget()
 self.expect("expression s_c", error=True,
 startstr="error: use of undeclared identifier 's_d'")
+
+def test_no_crash_in_IR_arithmetic(self):
+"""
+Test that LLDB doesn't crash on evaluating specific expression 
involving
+pointer arithmetic and taking the address of a static class member.
+See https://bugs.llvm.org/show_bug.cgi?id=52449
+"""
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// stop in main", 
lldb.SBFileSpec("main.cpp"))
+
+# This expression contains the following IR code:
+# ... i64 ptrtoint (i32* @_ZN1A3s_cE to i64)) ...
+expr = "(int*)100 + (long long)(&A::s_c)"
+
+# The IR interpreter doesn't support non-const operands to the
+# `GetElementPtr` IR instruction, so verify that it correctly fails to
+# evaluate expression.
+opts = lldb.SBExpressionOptions()
+opts.SetAllowJIT(False)
+value = self.target().EvaluateExpression(expr, opts)
+self.assertTrue(value.GetError().Fail())
+self.assertIn(
+"Can't evaluate the expression without a running target",
+value.GetError().GetCString())
+
+# Evaluating the expression via JIT should work fine.
+value = self.target().EvaluateExpression(expr)
+self.assertSuccess(value.GetError())
Index: lldb/source/Expression/IRInterpreter.cpp
===
--- lldb/source/Expression/IRInterpreter.cpp
+++ lldb/source/Expression/IRInterpreter.cpp
@@ -283,9 +283,11 @@
 return true; // no offset to apply!
 
   SmallVector indices(op_cursor, op_end);
-
   Type *src_elem_ty =
   cast(constant_expr)->getSourceElementType();
+
+  // DataLayout::getIndexedOffsetInType assumes the indices are
+  // instances of ConstantInt.
   uint64_t offset =
   m_target_data.getIndexedOffsetInType(src_elem_ty, indices);
 
@@ -465,12 +467,20 @@
   case Instruction::BitCast:
 return CanResolveConstant(constant_expr->getOperand(0));
   case Instruction::GetElementPtr: {
+// Check that the base can be constant-resolved.
 ConstantExpr::const_op_iterator op_cursor = constant_expr->op_begin();
 Constant *base = dyn_cast(*op_cursor);
-if (!base)
+if (!base || !CanResolveConstant(base))
   return false;
 
-return CanResolveConstant(base);
+// Check that all other operands are just ConstantInt.
+for (Value *op : make_range(constant_expr->op_begin() + 1,
+constant_expr->op_end())) {
+  ConstantInt *constant_int = dyn_cast(op);
+  if (!constant_int)
+return false;
+}
+return true;
   }
   }
 } else {


Index: lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
===
--- lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
+++ lldb/test/API/lang/cpp/static_members/TestCPPStaticMembers.py
@@ -41,3 +41,31 @@
 self.createTestTarget()
 self.expect("expression s_c", error=True,
 startstr="error: use of undeclared identifier 's_d'")
+
+def test_no_crash_in_IR_arithmetic(self):
+"""
+Test that LLDB doesn't crash on evaluating specific expression involving
+pointer arithmetic and taking the address of a static class member.
+See https://bugs.llvm.org/show_bug.cgi?id=52449
+"""
+self.build()
+lldbutil.run_to_source_breakpoint(self, "// stop in main", lldb.SBFileSpec("main.cpp"))
+
+# This expression contains the following IR code:
+# ... i64 ptrtoint (i32* @_ZN1A3s_cE to i64)) ...
+expr = "(int*)100 + (long long)(&A::s_c)"
+
+# The IR interpreter doesn't support non-const operands to the
+# `GetElementPtr` IR instruction, so verify that it correctly fails to
+# evaluate expression.
+opts = lldb.SBExpressionOptions()
+opts.SetAllowJIT(False)
+value = self.target().EvaluateExpression(expr, opts)
+self.assertTrue(value.G

[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Andy Yankovsky via Phabricator via lldb-commits
werat marked 2 inline comments as done.
werat added a comment.

In D113498#3137196 , @teemperor wrote:

> Not sure how flexible your fuzzer setup is regarding downstream patches, but 
> did you try putting some kind of `assert("coverage" && false);` in that new 
> code and try fuzzing until you reach it?

It's not that flexible, it runs against the prebuilt version of LLVM 12 at the 
moment -- https://github.com/google/lldb-eval/releases/tag/oss-fuzz-ubuntu-20.04

> FWIW, I'm OOO for an undefined amount of time so I am not sure when I can 
> take a look at this again. Feel free to ping in case you don't find another 
> reviewer.

Sure, I'll try to find someone else for now. Will ping if nobody comes along :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset

2021-11-17 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

just some minor changes.
Could you unify these tests with libcxx?




Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:10
 # before relying on these formatters to do the right thing for your setup
+class StdUnorderedMapSynthProvider:
+def __init__(self, valobj, dict):

add a few empty lines before this to avoid confusing that comment with this 
specific formatter. Besides that, rename this to 
StdUnorderedMapLikeSynthProvider and add a comment similar to 

"""
 This formatter can be applied to all
 unordered map-like structures (unordered_map, unordered_multimap, 
unordered_set, unordered_multiset)
"""





Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:25
+  return kind
+return Exception
+

an exception is too much. Normally we just fail silently, as it obvious to the 
user when the formatter fails and investigation is needed. Just return "map" if 
"set" is not present in the type name.



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:29
+type = self.valobj.GetType()
+template_arg_num = 4 if self.kind == "map" else 3
+allocator_type = type.GetTemplateArgumentType(template_arg_num)

this comment

# type of std::pair is the first template
# argument type of the 4th template argument to std::map and 
# 3rd template argument for std::set. That's why 
# we need to know kind of the object

should be here



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:32
+data_type = allocator_type.GetTemplateArgumentType(0)
+return data_type
+

if we used something that is not a map or set, this data type will be a dummy 
object that won't fail but won't do anything useful



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:46
+except:
+pass
+return False

you see? we fail silently by default



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:83
+count = 
self.head.GetChildMemberWithName('_M_element_count').GetValueAsUnsigned(0)
+logger >> "I have " + str(count) + " children available"
+return count

remove this comment, as this information is easily available to the user



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:86
+except:
+logger >> "Could not determine the size"
+return 0

this one is fine



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp:5
+
+using std::string;
+

also remove this, you barely save a few characters by not typing std::string



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp:7-13
+#define intstr_map std::unordered_map
+#define intstr_mmap std::unordered_multimap
+
+#define int_set std::unordered_set
+#define str_set std::unordered_set
+#define int_mset std::unordered_multiset
+#define str_mset std::unordered_multiset

avoid using these defines, they just obscure the code when reading


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113760

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


[Lldb-commits] [PATCH] D114008: Draft PR for the deque, stack, queue lldb data formatters

2021-11-17 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

discussed offline how to traverse each individual subarray. This might make it 
impossible to reuse it for queue and stack




Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:13
+def __init__(self, valobj, dict):
+print("Init called")
+self.valobj = valobj

remove



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:22
+try:
+print("Update called")
+self.impl = self.valobj.GetChildMemberWithName('_M_impl')

remove



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:31
+except:
+pass
+

don't forget to always return False



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:60
+
+def num_children_impl(self):
+# logger = lldb.formatters.Logger.Logger()

danilashtefan wrote:
> This method does not currently work. I simply tried to calculate the size 
> from start and finish pointers. When it did not, I investigated further and 
> this was my founding:
> 
> This is when we get the iterator value this comes out:
> 
> `_Deque_iterator(const _Deque_iterator& __x) noexcept
>169   : _M_cur(__x._M_cur), _M_first(__x._M_first),
>170 _M_last(__x._M_last), _M_node(__x._M_node) { }`
> 
> And when it++ is done this is what happens behind:
> 
> operator++()
>189   {
>190++_M_cur;
>191if (_M_cur == _M_last)
>192  {
>193_M_set_node(_M_node + 1);
>194_M_cur = _M_first;
>195  }
>196return *this;
>197}
> 
> 
discussed offline how to handle this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114008

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


[Lldb-commits] [lldb] f07ddbc - [lldb] build failure for LLDB_PYTHON_EXE_RELATIVE_PATH on greendragon

2021-11-17 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'Anna
Date: 2021-11-17T09:26:24-08:00
New Revision: f07ddbc620a0466ebbb41ccbc78f20a8591bed5a

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

LOG: [lldb] build failure for LLDB_PYTHON_EXE_RELATIVE_PATH on greendragon

see: https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38387/console

```
Could not find a relative path to sys.executable under sys.prefix
tried: /usr/local/opt/python/bin/python3.7
tried: 
/usr/local/opt/python/bin/../Frameworks/Python.framework/Versions/3.7/bin/python3.7
sys.prefix: 
/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7
```

It was unable to find LLDB_PYTHON_EXE_RELATIVE_PATH because it was not resolving
the real path of sys.prefix.

caused by: https://reviews.llvm.org/D113650

Added: 


Modified: 
lldb/bindings/python/get-python-config.py

Removed: 




diff  --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 507a8aa072076..978dc07b3e4c0 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -24,19 +24,21 @@ def main():
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
+prefix = os.path.realpath(sys.prefix)
 while True:
 try:
-print(relpath_nodots(exe, sys.prefix))
+print(relpath_nodots(exe, prefix))
 break
 except ValueError:
 tried.append(exe)
 if os.path.islink(exe):
-exe = os.path.join(os.path.dirname(exe), os.readlink(exe))
+exe = os.path.join(os.path.realpath(os.path.dirname(exe)), 
os.readlink(exe))
 continue
 else:
 print("Could not find a relative path to sys.executable 
under sys.prefix", file=sys.stderr)
 for e in tried:
 print("tried:", e, file=sys.stderr)
+print("realpath(sys.prefix):", prefix, file=sys.stderr)
 print("sys.prefix:", sys.prefix, file=sys.stderr)
 sys.exit(1)
 elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":



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


[Lldb-commits] [PATCH] D113650: [lldb] fix -print-script-interpreter-info on windows

2021-11-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D113650#3136407 , @aprantl wrote:

> This seems to have broken the green dragon incremental bot: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38387/

looks like its fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113650

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


[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-17 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

Friendly ping, maybe you forgot this, can you check it now @teemperor ? :)


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

https://reviews.llvm.org/D113604

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


[Lldb-commits] [PATCH] D113604: [lldb] Format lldb/include/lldb/Symbol/Type.h

2021-11-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.

LGTM modulo the inline comment.




Comment at: lldb/include/lldb/Symbol/Type.h:204
   // the remaining type scope (namespaces/classes).
-  static bool GetTypeScopeAndBasename(const llvm::StringRef& name,
+  static bool GetTypeScopeAndBasename(const llvm::StringRef &name,
   llvm::StringRef &scope,

Since you're touching this line... The coding standards say that StringRefs 
should always be passed by-value:

> StringRef is small and pervasive enough in LLVM that it should always be 
> passed by value.

https://llvm.org/docs/ProgrammersManual.html#the-stringref-class


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

https://reviews.llvm.org/D113604

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


[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: labath, jingham, JDevlieghere.
Herald added a subscriber: mgorny.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.

distutils is deprecated and will be removed, so we shouldn't be
using it.

We were using it to compute LLDB_PYTHON_RELATIVE_PATH.

Discussing a similar issue
at python.org , Filipe Laíns said:

  If you are relying on the value of distutils.sysconfig.get_python_lib()
  as you shown in your system, you probably don't want to. That
  directory (dist-packages) should be for Debian provided packages
  only, so moving to sysconfig.get_path() would be a good thing,
  as it has the correct value for user installed packages on your
  system.

So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.

On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.

On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.

This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114106

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to 
find it.
+# If not, you'll have to use lldb -P or lldb 
-print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to find it.
+# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.tx

[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I guess the correct path might depend on the precise value of "us". The ubuntu 
packagers might still want to put the files at that location, but they can just 
use the cmake variable to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114106

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


[Lldb-commits] [PATCH] D114111: Remove a useless temporary of a base class type.

2021-11-17 Thread Alexander Kornienko via Phabricator via lldb-commits
alexfh created this revision.
alexfh added a reviewer: clayborg.
alexfh requested review of this revision.
Herald added a project: LLDB.

This was found by clang-tidy bugprone-undelegated-constructor check.
Was there since the very first commit back in 2016.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114111

Files:
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp


Index: 
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
===
--- 
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ 
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -175,7 +175,6 @@
 namespace lldb_renderscript {
 
 RSIRPasses::RSIRPasses(Process *process) {
-  IRPasses();
   assert(process);
 
   EarlyPasses = std::make_shared();


Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -175,7 +175,6 @@
 namespace lldb_renderscript {
 
 RSIRPasses::RSIRPasses(Process *process) {
-  IRPasses();
   assert(process);
 
   EarlyPasses = std::make_shared();
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1b468f1 - [lldb] Port PlatformWindows, PlatformOpenBSD and PlatformRemoteGDBServer to GetSupportedArchitectures

2021-11-17 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-11-17T20:09:31+01:00
New Revision: 1b468f1c1b46734f64f15c22cfbd403bada9fed8

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

LOG: [lldb] Port PlatformWindows, PlatformOpenBSD and PlatformRemoteGDBServer 
to GetSupportedArchitectures

Added: 


Modified: 
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h

Removed: 




diff  --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp 
b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
index 7fcc30b92d295..84d9ff799f474 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
@@ -106,53 +106,21 @@ void PlatformOpenBSD::Terminate() {
 /// Default Constructor
 PlatformOpenBSD::PlatformOpenBSD(bool is_host)
 : PlatformPOSIX(is_host) // This is the local host platform
-{}
-
-bool PlatformOpenBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
-  ArchSpec &arch) {
-  if (IsHost()) {
-ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
-if (hostArch.GetTriple().isOSOpenBSD()) {
-  if (idx == 0) {
-arch = hostArch;
-return arch.IsValid();
-  }
-}
+{
+  if (is_host) {
+m_supported_architectures.push_back(HostInfo::GetArchitecture());
   } else {
-if (m_remote_platform_sp)
-  return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
-
-llvm::Triple triple;
-// Set the OS to OpenBSD
-triple.setOS(llvm::Triple::OpenBSD);
-// Set the architecture
-switch (idx) {
-case 0:
-  triple.setArchName("x86_64");
-  break;
-case 1:
-  triple.setArchName("i386");
-  break;
-case 2:
-  triple.setArchName("aarch64");
-  break;
-case 3:
-  triple.setArchName("arm");
-  break;
-default:
-  return false;
-}
-// Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
-// vendor by calling triple.SetVendorName("unknown") so that it is a
-// "unspecified unknown". This means when someone calls
-// triple.GetVendorName() it will return an empty string which indicates
-// that the vendor can be set when two architectures are merged
-
-// Now set the triple into "arch" and return true
-arch.SetTriple(triple);
-return true;
+m_supported_architectures =
+CreateArchList({llvm::Triple::x86_64, llvm::Triple::x86,
+llvm::Triple::aarch64, llvm::Triple::arm},
+   llvm::Triple::OpenBSD);
   }
-  return false;
+}
+
+std::vector PlatformOpenBSD::GetSupportedArchitectures() {
+  if (m_remote_platform_sp)
+return m_remote_platform_sp->GetSupportedArchitectures();
+  return m_supported_architectures;
 }
 
 void PlatformOpenBSD::GetStatus(Stream &strm) {

diff  --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h 
b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
index 81680fe81e6f5..fd03988590cad 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
@@ -42,7 +42,7 @@ class PlatformOpenBSD : public PlatformPOSIX {
 
   void GetStatus(Stream &strm) override;
 
-  bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+  std::vector GetSupportedArchitectures() override;
 
   bool CanDebugProcess() override;
 
@@ -52,6 +52,8 @@ class PlatformOpenBSD : public PlatformPOSIX {
   lldb::addr_t length, unsigned prot,
   unsigned flags, lldb::addr_t fd,
   lldb::addr_t offset) override;
+
+  std::vector m_supported_architectures;
 };
 
 } // namespace platform_openbsd

diff  --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index f991e127d0e22..8714953a9cdb8 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -30,35 +30,6 @@ LLDB_PLUGIN_DEFINE(PlatformWindows)
 
 static uint32_t g_initialize_count = 0;
 
-namespace {
-class SupportedArchList {
-public:
-  SupportedArchList() {
-AddArch(ArchSpec("i686-pc-windows"));
-AddArch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
-AddArch(HostInfo::GetArchitecture(HostInfo::eArchKind32));
-AddArch

[Lldb-commits] [PATCH] D114111: Remove a useless temporary of a base class type.

2021-11-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

@labath Do you know what the status is of removing RenderScript altogether?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114111

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


[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset

2021-11-17 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 388012.
danilashtefan marked 9 inline comments as done.
danilashtefan added a comment.

All the above-mentioned is changed. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113760

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include 
-#include 
-#include 
-
-using std::string;
-
-#define intstr_map std::unordered_map 
-#define intstr_mmap std::unordered_multimap 
-
-#define int_set std::unordered_set 
-#define str_set std::unordered_set 
-#define int_mset std::unordered_multiset 
-#define str_mset std::unordered_multiset 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-int main()
-{
-	intstr_map map;
-	map.emplace(1,"hello");
-	map.emplace(2,"world");
-	map.emplace(3,"this");
-	map.emplace(4,"is");
-	map.emplace(5,"me");
-	thefoo_rw();  // Set break point at this line.
-	
-	intstr_mmap mmap;
-	mmap.emplace(1,"hello");
-	mmap.emplace(2,"hello");
-	mmap.emplace(2,"world");
-	mmap.emplace(3,"this");
-	mmap.emplace(3,"this");
-	mmap.emplace(3,"this");
-	thefoo_rw();  // Set break point at this line.
-	
-	int_set iset;
-	iset.emplace(1);
-	iset.emplace(2);
-	iset.emplace(3);
-	iset.emplace(4);
-	iset.emplace(5);
-	thefoo_rw();  // Set break point at this line.
-	
-	str_set sset;
-	sset.emplace("hello");
-	sset.emplace("world");
-	sset.emplace("this");
-	sset.emplace("is");
-	sset.emplace("me");
-	thefoo_rw();  // Set break point at this line.
-	
-	int_mset imset;
-	imset.emplace(1);
-	imset.emplace(2);
-	imset.emplace(2);
-	imset.emplace(3);
-	imset.emplace(3);
-	imset.emplace(3);
-	thefoo_rw();  // Set break point at this line.
-	
-	str_mset smset;
-	smset.emplace("hello");
-	smset.emplace("world");
-	smset.emplace("world");
-	smset.emplace("is");
-	smset.emplace("is");
-	thefoo_rw();  // Set break point at this line.
-	
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-CXX_SOURCES := main.cpp
-
-# Work around "exception specification in declaration does not match previous
-# declaration" errors present in older libc++ releases. This error was fixed in
-# the 3.8 release.
-CFLAGS_EXTRAS := -fno-exceptions
-
-USE_LIBCPP := 1
-include Makefile.rules
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
@@ -0,0 +1,68 @@
+#include 
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+int main() {
+  std::unordered_map map;
+  map.emplace(1, "hello");
+  map.emplace(2, "world");
+  map.emplace(3, "this");
+  map.emplace(4, "is");
+  map.emplace(5, "me");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_multimap mmap;
+  mmap.emplace(1, "hello");
+  mmap.emplace(2, "hello");
+  mmap.emplace(2, "world");
+  mmap.emplace(3, "this");
+  mmap.emplace(3, "this");
+  mmap.emplace(3, "this");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_set iset;
+  iset.emplace(1);
+  iset.emplace(2);
+  iset.emplace(3);
+  iset.emplace(4);
+  iset.emplace(5);
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_set sset;
+  sset.emplace("hello");
+  sset.emplace("world");
+  sset.emplace("this");
+  sset.emplace("is");
+  sset.emplace("me");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_multiset imset;
+  imset.emplace(1);
+  imset.emplace(2);
+  imset.emplace(2);
+  i

[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset

2021-11-17 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/examples/synthetic/gnu_libstdcpp.py:22-27
+def get_object_kind(self, valobj):
+type_name = valobj.GetTypeName()
+for kind in ["set", "map"]:
+   if kind in type_name:
+  return kind
+pass




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113760

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


[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset

2021-11-17 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 388016.
danilashtefan added a comment.

Done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113760

Files:
  lldb/examples/synthetic/gnu_libstdcpp.py
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/TestDataFormatterUnordered.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/main.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include 
-#include 
-#include 
-
-using std::string;
-
-#define intstr_map std::unordered_map 
-#define intstr_mmap std::unordered_multimap 
-
-#define int_set std::unordered_set 
-#define str_set std::unordered_set 
-#define int_mset std::unordered_multiset 
-#define str_mset std::unordered_multiset 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-int main()
-{
-	intstr_map map;
-	map.emplace(1,"hello");
-	map.emplace(2,"world");
-	map.emplace(3,"this");
-	map.emplace(4,"is");
-	map.emplace(5,"me");
-	thefoo_rw();  // Set break point at this line.
-	
-	intstr_mmap mmap;
-	mmap.emplace(1,"hello");
-	mmap.emplace(2,"hello");
-	mmap.emplace(2,"world");
-	mmap.emplace(3,"this");
-	mmap.emplace(3,"this");
-	mmap.emplace(3,"this");
-	thefoo_rw();  // Set break point at this line.
-	
-	int_set iset;
-	iset.emplace(1);
-	iset.emplace(2);
-	iset.emplace(3);
-	iset.emplace(4);
-	iset.emplace(5);
-	thefoo_rw();  // Set break point at this line.
-	
-	str_set sset;
-	sset.emplace("hello");
-	sset.emplace("world");
-	sset.emplace("this");
-	sset.emplace("is");
-	sset.emplace("me");
-	thefoo_rw();  // Set break point at this line.
-	
-	int_mset imset;
-	imset.emplace(1);
-	imset.emplace(2);
-	imset.emplace(2);
-	imset.emplace(3);
-	imset.emplace(3);
-	imset.emplace(3);
-	thefoo_rw();  // Set break point at this line.
-	
-	str_mset smset;
-	smset.emplace("hello");
-	smset.emplace("world");
-	smset.emplace("world");
-	smset.emplace("is");
-	smset.emplace("is");
-	thefoo_rw();  // Set break point at this line.
-	
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-CXX_SOURCES := main.cpp
-
-# Work around "exception specification in declaration does not match previous
-# declaration" errors present in older libc++ releases. This error was fixed in
-# the 3.8 release.
-CFLAGS_EXTRAS := -fno-exceptions
-
-USE_LIBCPP := 1
-include Makefile.rules
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/main.cpp
@@ -0,0 +1,68 @@
+#include 
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+int main() {
+  std::unordered_map map;
+  map.emplace(1, "hello");
+  map.emplace(2, "world");
+  map.emplace(3, "this");
+  map.emplace(4, "is");
+  map.emplace(5, "me");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_multimap mmap;
+  mmap.emplace(1, "hello");
+  mmap.emplace(2, "hello");
+  mmap.emplace(2, "world");
+  mmap.emplace(3, "this");
+  mmap.emplace(3, "this");
+  mmap.emplace(3, "this");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_set iset;
+  iset.emplace(1);
+  iset.emplace(2);
+  iset.emplace(3);
+  iset.emplace(4);
+  iset.emplace(5);
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_set sset;
+  sset.emplace("hello");
+  sset.emplace("world");
+  sset.emplace("this");
+  sset.emplace("is");
+  sset.emplace("me");
+  thefoo_rw(); // Set break point at this line.
+
+  std::unordered_multiset imset;
+  imset.emplace(1);
+  imset.emplace(2);
+  imset.emplace(2);
+  imset.emplace(3);
+  imset.emplace(3);
+  imset.emplace(3);
+  thefoo_rw(); // Set break p

[Lldb-commits] [PATCH] D113760: [formatters] Add a libstdcpp formatter for for unordered_map, unordered_set, unordered_multimap, unordered_multiset

2021-11-17 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.
This revision is now accepted and ready to land.

good job!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113760

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


[Lldb-commits] [lldb] 6327071 - [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Lawrence D'Anna via lldb-commits

Author: Lawrence D'Anna
Date: 2021-11-17T13:14:30-08:00
New Revision: 63270710f13af10808aac980795128db127153f5

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

LOG: [lldb] remove usage of distutils, fix python path on debian/ubuntu

distutils is deprecated and will be removed, so we shouldn't be
using it.

We were using it to compute LLDB_PYTHON_RELATIVE_PATH.

Discussing a similar issue
[at python.org](https://bugs.python.org/issue41282), Filipe Laíns said:

If you are relying on the value of distutils.sysconfig.get_python_lib()
as you shown in your system, you probably don't want to. That
directory (dist-packages) should be for Debian provided packages
only, so moving to sysconfig.get_path() would be a good thing,
as it has the correct value for user installed packages on your
system.

So I propose using a relative path from `sys.prefix` to
`sysconfig.get_path("platlib")` instead.

On Mac and windows, this results in the same paths as we had before,
which are `lib/python3.9/site-packages` and `Lib\site-packages`,
respectively.

On ubuntu however, this will change the path from
`lib/python3/dist-packages` to `lib/python3.9/site-packages`.

This change seems to be correct, as Filipe said above, `dist-packages`
belongs to the distribution, not us.

Reviewed By: labath

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

Added: 


Modified: 
lldb/CMakeLists.txt
lldb/bindings/python/get-python-config.py

Removed: 




diff  --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index c45064d9bef23..5c2dac3f51f6d 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -32,9 +32,9 @@ endif()
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 

diff  --git a/lldb/bindings/python/get-python-config.py 
b/lldb/bindings/python/get-python-config.py
index 978dc07b3e4c0..5b670d77451a3 100755
--- a/lldb/bindings/python/get-python-config.py
+++ b/lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@ def main():
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to 
find it.
+# If not, you'll have to use lldb -P or lldb 
-print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable



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


[Lldb-commits] [PATCH] D114106: [lldb] remove usage of distutils, fix python path on debian/ubuntu

2021-11-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG63270710f13a: [lldb] remove usage of distutils, fix python 
path on debian/ubuntu (authored by lawrence_danna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114106

Files:
  lldb/CMakeLists.txt
  lldb/bindings/python/get-python-config.py


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to 
find it.
+# If not, you'll have to use lldb -P or lldb 
-print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install 
prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 


Index: lldb/bindings/python/get-python-config.py
===
--- lldb/bindings/python/get-python-config.py
+++ lldb/bindings/python/get-python-config.py
@@ -4,7 +4,6 @@
 import sys
 import argparse
 import sysconfig
-import distutils.sysconfig
 
 
 def relpath_nodots(path, base):
@@ -20,7 +19,18 @@
 parser.add_argument("variable_name")
 args = parser.parse_args()
 if args.variable_name == "LLDB_PYTHON_RELATIVE_PATH":
-print(distutils.sysconfig.get_python_lib(True, False, ''))
+# LLDB_PYTHON_RELATIVE_PATH is the relative path from lldb's prefix
+# to where lldb's python libraries will be installed.
+#
+# The way we're going to compute this is to take the relative path from
+# PYTHON'S prefix to where python libraries are supposed to be
+# installed.
+#
+# The result is if LLDB and python are give the same prefix, then
+# lldb's python lib will be put in the correct place for python to find it.
+# If not, you'll have to use lldb -P or lldb -print-script-interpreter-info
+# to figure out where it is.
+print(relpath_nodots(sysconfig.get_path("platlib"), sys.prefix))
 elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
 tried = list()
 exe = sys.executable
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -32,9 +32,9 @@
 
 if (LLDB_ENABLE_PYTHON)
   set(cachestring_LLDB_PYTHON_RELATIVE_PATH
-"Path where Python modules are installed, relative to install prefix")
+"Path where Python modules are installed, relative to LLDB's install prefix")
   set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
-"Path to python interpreter exectuable, relative to install prefix")
+"Path to python interpreter exectuable, relative to python's install prefix")
   set(cachestring_LLDB_PYTHON_EXT_SUFFIX
 "Filename extension for native code python modules")
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D114123: [NFC][lldb] Inclusive language: remove instances of master from comments in lldb

2021-11-17 Thread Quinn Pham via Phabricator via lldb-commits
quinnp created this revision.
quinnp requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

[NFC] As part of using inclusive language within the llvm project, this patch
removes master in these comments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114123

Files:
  lldb/source/Core/Debugger.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2585,7 +2585,7 @@
 
   type_sp = ParseType(sc, die, nullptr);
 } else if (type_ptr != DIE_IS_BEING_PARSED) {
-  // Grab the existing type from the master types lists
+  // Grab the existing type from the type list
   type_sp = type_ptr->shared_from_this();
 }
   }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -488,7 +488,7 @@
  "Debugger::Terminate called without a matching 
Debugger::Initialize!");
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
-// Clear our master list of debugger objects
+// Clear our list of debugger objects
 {
   std::lock_guard guard(*g_debugger_list_mutex_ptr);
   for (const auto &debugger : *g_debugger_list_ptr)


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2585,7 +2585,7 @@
 
   type_sp = ParseType(sc, die, nullptr);
 } else if (type_ptr != DIE_IS_BEING_PARSED) {
-  // Grab the existing type from the master types lists
+  // Grab the existing type from the type list
   type_sp = type_ptr->shared_from_this();
 }
   }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -488,7 +488,7 @@
  "Debugger::Terminate called without a matching Debugger::Initialize!");
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
-// Clear our master list of debugger objects
+// Clear our list of debugger objects
 {
   std::lock_guard guard(*g_debugger_list_mutex_ptr);
   for (const auto &debugger : *g_debugger_list_ptr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

FYI: I am not familiar enough with the expression parser and IR interpreter 
logic to be able to be able to give the ok here. I hope other expression parser 
experts will continue to give good feedback on this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [PATCH] D114123: [NFC][lldb] Inclusive language: remove instances of master from comments in lldb

2021-11-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Suggested different replacement strings for the comments.




Comment at: lldb/source/Core/Debugger.cpp:491
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
-// Clear our master list of debugger objects
+// Clear our list of debugger objects
 {





Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2588
 } else if (type_ptr != DIE_IS_BEING_PARSED) {
-  // Grab the existing type from the master types lists
+  // Grab the existing type from the type list
   type_sp = type_ptr->shared_from_this();




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114123

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


[Lldb-commits] [PATCH] D113965: [NFC] Refactor symbol table parsing.

2021-11-17 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG951b107eedab: [NFC] Refactor symbol table parsing. (authored 
by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113965

Files:
  lldb/include/lldb/Symbol/ObjectFile.h
  lldb/include/lldb/Symbol/Symtab.h
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
  lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -997,10 +997,15 @@
   }
 }
 
-void Symtab::CalculateSymbolSizes() {
+void Symtab::Finalize() {
   std::lock_guard guard(m_mutex);
-  // Size computation happens inside InitAddressIndexes.
+  // Calculate the size of symbols inside InitAddressIndexes.
   InitAddressIndexes();
+  // Shrink to fit the symbols so we don't waste memory
+  if (m_symbols.capacity() > m_symbols.size()) {
+collection new_symbols(m_symbols.begin(), m_symbols.end());
+m_symbols.swap(new_symbols);
+  }
 }
 
 Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {
Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -715,3 +715,20 @@
 break;
   }
 }
+
+
+Symtab *ObjectFile::GetSymtab() {
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+if (!m_symtab_up) {
+  ElapsedTime elapsed(module_sp->GetSymtabParseTime());
+  m_symtab_up = std::make_unique(this);
+  std::lock_guard symtab_guard(
+  m_symtab_up->GetMutex());
+  ParseSymtab(*m_symtab_up);
+  m_symtab_up->Finalize();
+}
+  }
+  return m_symtab_up.get();
+}
Index: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
===
--- lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1421,7 +1421,6 @@
));
   }
 
-  symtab.CalculateSymbolSizes();
   symtab.Finalize();
 }
 
Index: lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
===
--- lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -500,7 +500,7 @@
 
   for (Symbol &symbol : symbols)
 symtab.AddSymbol(std::move(symbol));
-  symtab.CalculateSymbolSizes();
+  symtab.Finalize();
 }
 
 llvm::Expected
@@ -927,4 +927,3 @@
   // Breakpad files are all debug info.
   return m_objfile_sp->GetByteSize();
 }
-
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -73,7 +73,7 @@
   bool IsExecutable() const override { return false; }
   ArchSpec GetArchitecture() override { return m_arch; }
   UUID GetUUID() override { return m_uuid; }
-  Symtab *GetSymtab() override { return m_symtab_up.get(); }
+  void ParseSymtab(lldb_private::Symtab &symtab) override {}
   bool IsStripped() override { return true; }
   ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); }
 
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
===
--- lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
+++ lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -78,7 +78,7 @@
 return AddressClass::eInvalid;
   }
 
-  Symtab *GetSymtab() override;
+  void ParseSymtab(lldb_private::Symtab &symtab) override;
 
   bool IsStripped() override { return !!GetExternalDebugInfoFileSpec(); }
 
Index: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
===
--- 

[Lldb-commits] [lldb] 951b107 - [NFC] Refactor symbol table parsing.

2021-11-17 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-11-17T15:14:01-08:00
New Revision: 951b107eedab1829f18049443f03339dbb0db165

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

LOG: [NFC] Refactor symbol table parsing.

Symbol table parsing has evolved over the years and many plug-ins contained 
duplicate code in the ObjectFile::GetSymtab() that used to be pure virtual. 
With this change, the "Symbtab *ObjectFile::GetSymtab()" is no longer virtual 
and will end up calling a new "void ObjectFile::ParseSymtab(Symtab &symtab)" 
pure virtual function to actually do the parsing. This helps centralize the 
code for parsing the symbol table and allows the ObjectFile base class to do 
all of the common work, like taking the necessary locks and creating the symbol 
table object itself. Plug-ins now just need to parse when they are asked to 
parse as the ParseSymtab function will only get called once.

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

Added: 


Modified: 
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Symbol/Symtab.h
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index 4ccd7f92064d5..f1b9d4699319b 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -322,12 +322,26 @@ class ObjectFile : public 
std::enable_shared_from_this,
   /// Gets the symbol table for the currently selected architecture (and
   /// object for archives).
   ///
-  /// Symbol table parsing can be deferred by ObjectFile instances until this
-  /// accessor is called the first time.
+  /// This function will manage when ParseSymtab(...) is called to actually do
+  /// the symbol table parsing in each plug-in. This function will take care of
+  /// taking all the necessary locks and finalizing the symbol table when the
+  /// symbol table does get parsed.
   ///
   /// \return
   /// The symbol table for this object file.
-  virtual Symtab *GetSymtab() = 0;
+  Symtab *GetSymtab();
+
+  /// Parse the symbol table into the provides symbol table object.
+  ///
+  /// Symbol table parsing will be done once when this function is called by
+  /// each object file plugin. All of the necessary locks will already be
+  /// acquired before this function is called and the symbol table object to
+  /// populate is supplied as an argument and doesn't need to be created by
+  /// each plug-in.
+  ///
+  /// \param
+  /// The symbol table to populate.
+  virtual void ParseSymtab(Symtab &symtab) = 0;
 
   /// Perform relocations on the section if necessary.
   ///

diff  --git a/lldb/include/lldb/Symbol/Symtab.h 
b/lldb/include/lldb/Symbol/Symtab.h
index e1ad0dfd2eb8d..e5d21c1bf4b38 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -119,20 +119,13 @@ class Symtab {
   lldb::addr_t file_addr, std::function const &callback);
   void FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list);
-  void CalculateSymbolSizes();
 
   void SortSymbolIndexesByValue(std::vector &indexes,
 bool remove_duplicates) const;
 
   static void DumpSymbolHeader(Stream *s);
 
-  void Finalize() {
-// Shrink to fit the symbols so we don't waste memory
-if (m_symbols.capacity() > m_symbols.size()) {
-  collection new_symbols(m_symbols.begin(), m_symbols.end());
-  m_symbols.swap(new_symbols);
-}
-  }
+  void Finalize();
 
   void AppendSymbolNamesToMap(const IndexCollection &indexes,
   bool add_demangled, bool add_mangled,

diff  --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp 
b/lldb/source/Plugins/ObjectFile/Break

[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Jim Ingham via Phabricator via lldb-commits
jingham resigned from this revision.
jingham added a comment.

I have also never looked at the IR Interpreter code, and am not particularly 
familiar with llvm IR, sorry.  Maybe Shafik Yaghmour?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [lldb] 92eaad2 - Revert "Revert "Make it possible for lldb to launch a remote binary with no local file.""

2021-11-17 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2021-11-17T17:59:47-08:00
New Revision: 92eaad2dd7adb5ee92f397cef85ab11f2612294e

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

LOG: Revert "Revert "Make it possible for lldb to launch a remote binary with 
no local file.""

This reverts commit dd5505a8f2c75a903ec944b6e46aed2042610673.

I picked the wrong class for the test, should have been GDBRemoteTestBase.

Added: 
lldb/test/API/functionalities/gdb_remote_client/TestNoLocalFile.py

Modified: 
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 8ce14f2a96d5e..5fd1718e84840 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -159,7 +159,12 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 // If our listener is nullptr, users aren't allows to launch
 ModuleSP exe_module_sp = target->GetExecutableModule();
 
-if (exe_module_sp == nullptr) {
+// If the target already has an executable module, then use that.  If it
+// doesn't then someone must be trying to launch using a path that will
+// make sense to the remote stub, but doesn't exist on the local host.
+// In that case use the ExecutableFile that was set in the target's
+// ProcessLaunchInfo.
+if (exe_module_sp == nullptr && 
!target->GetProcessLaunchInfo().GetExecutableFile()) {
   result.AppendError("no file in target, create a debug target using the "
  "'target create' command");
   return false;
@@ -219,11 +224,17 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 if (!target_settings_argv0.empty()) {
   m_options.launch_info.GetArguments().AppendArgument(
   target_settings_argv0);
-  m_options.launch_info.SetExecutableFile(
-  exe_module_sp->GetPlatformFileSpec(), false);
+  if (exe_module_sp)
+m_options.launch_info.SetExecutableFile(
+exe_module_sp->GetPlatformFileSpec(), false);
+  else
+
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 false);
 } else {
-  m_options.launch_info.SetExecutableFile(
-  exe_module_sp->GetPlatformFileSpec(), true);
+  if (exe_module_sp)
+m_options.launch_info.SetExecutableFile(
+exe_module_sp->GetPlatformFileSpec(), true);
+  else
+
m_options.launch_info.SetExecutableFile(target->GetProcessLaunchInfo().GetExecutableFile(),
 true);
 }
 
 if (launch_args.GetArgumentCount() == 0) {
@@ -250,11 +261,20 @@ class CommandObjectProcessLaunch : public 
CommandObjectProcessLaunchOrAttach {
 llvm::StringRef data = stream.GetString();
 if (!data.empty())
   result.AppendMessage(data);
-const char *archname =
-exe_module_sp->GetArchitecture().GetArchitectureName();
-result.AppendMessageWithFormat(
-"Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
-exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
+// If we didn't have a local executable, then we wouldn't have had an
+// executable module before launch.
+if (!exe_module_sp)
+  exe_module_sp = target->GetExecutableModule();
+if (!exe_module_sp) {
+  result.AppendWarning("Could not get executable module after 
launch.");
+} else {
+
+  const char *archname =
+  exe_module_sp->GetArchitecture().GetArchitectureName();
+  result.AppendMessageWithFormat(
+  "Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
+  exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
+}
 result.SetStatus(eReturnStatusSuccessFinishResult);
 result.SetDidChangeProcessState(true);
   } else {

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a666aeb8bb3f6..2233bf6758190 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -677,143 +677,133 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module 
*exe_module,
   //  LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD);
   //  ::LogSetLogFile ("/dev/stdout");
 
-  ObjectFile *object_file = exe_module->GetObjectFile();
-  if (object_file) {
-error = EstablishConnectionIfNeeded(launch_info);
-if (error.Success()) {
-  PseudoTerminal pty;
-  c

[Lldb-commits] [lldb] a68ccda - Revert "[NFC] Refactor symbol table parsing."

2021-11-17 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-11-17T18:07:28-08:00
New Revision: a68ccda203aad2cc4fd386d5e893237f09fa1ffb

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

LOG: Revert "[NFC] Refactor symbol table parsing."

This reverts commit 951b107eedab1829f18049443f03339dbb0db165.

Buildbots were failing, there is a deadlock in 
/Users/gclayton/Documents/src/llvm/clean/llvm-project/lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
 when ELF files try to relocate things.

Added: 


Modified: 
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Symbol/Symtab.h
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/source/Symbol/Symtab.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ObjectFile.h 
b/lldb/include/lldb/Symbol/ObjectFile.h
index f1b9d4699319b..4ccd7f92064d5 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -322,26 +322,12 @@ class ObjectFile : public 
std::enable_shared_from_this,
   /// Gets the symbol table for the currently selected architecture (and
   /// object for archives).
   ///
-  /// This function will manage when ParseSymtab(...) is called to actually do
-  /// the symbol table parsing in each plug-in. This function will take care of
-  /// taking all the necessary locks and finalizing the symbol table when the
-  /// symbol table does get parsed.
+  /// Symbol table parsing can be deferred by ObjectFile instances until this
+  /// accessor is called the first time.
   ///
   /// \return
   /// The symbol table for this object file.
-  Symtab *GetSymtab();
-
-  /// Parse the symbol table into the provides symbol table object.
-  ///
-  /// Symbol table parsing will be done once when this function is called by
-  /// each object file plugin. All of the necessary locks will already be
-  /// acquired before this function is called and the symbol table object to
-  /// populate is supplied as an argument and doesn't need to be created by
-  /// each plug-in.
-  ///
-  /// \param
-  /// The symbol table to populate.
-  virtual void ParseSymtab(Symtab &symtab) = 0;
+  virtual Symtab *GetSymtab() = 0;
 
   /// Perform relocations on the section if necessary.
   ///

diff  --git a/lldb/include/lldb/Symbol/Symtab.h 
b/lldb/include/lldb/Symbol/Symtab.h
index e5d21c1bf4b38..e1ad0dfd2eb8d 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -119,13 +119,20 @@ class Symtab {
   lldb::addr_t file_addr, std::function const &callback);
   void FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list);
+  void CalculateSymbolSizes();
 
   void SortSymbolIndexesByValue(std::vector &indexes,
 bool remove_duplicates) const;
 
   static void DumpSymbolHeader(Stream *s);
 
-  void Finalize();
+  void Finalize() {
+// Shrink to fit the symbols so we don't waste memory
+if (m_symbols.capacity() > m_symbols.size()) {
+  collection new_symbols(m_symbols.begin(), m_symbols.end());
+  m_symbols.swap(new_symbols);
+}
+  }
 
   void AppendSymbolNamesToMap(const IndexCollection &indexes,
   bool add_demangled, bool add_mangled,

diff  --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp 
b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
index ce701fd823fdf..bad730512ff49 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -116,10 +116,9 @@ bool ObjectFileBreakpad::ParseHeader() {
   return true;
 }
 
-void ObjectFileBreakpad::ParseSymtab(Symtab &symtab) {
-  // Nothing to do for breakpad files, all information is parsed as debug info
-  // which means "lldb_private::Fun

[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

So `(int*)100` can't be a constant expression b/c it is basically a 
`reinterpret_cast` and that is forbidden in a constant expression e.g.:

  constexpr const int* ip2 = (int*)100;

is ill-formed.

On the other hand this is a well-formed constant expression:

  static const int x =0;
  constexpr const int* ip1 = &x + 1;

Does that get you the test case you need?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [PATCH] D113498: [lldb] Constant-resolve operands to `getelementptr`

2021-11-17 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

I am OOO for a bit but this makes sense and LGTM, let me think about it a bit 
more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113498

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


[Lldb-commits] [PATCH] D114123: [NFC][lldb] Inclusive language: remove instances of master from comments in lldb

2021-11-17 Thread Quinn Pham via Phabricator via lldb-commits
quinnp updated this revision to Diff 388084.
quinnp marked 2 inline comments as done.
quinnp added a comment.

Addressing review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114123

Files:
  lldb/source/Core/Debugger.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2585,7 +2585,7 @@
 
   type_sp = ParseType(sc, die, nullptr);
 } else if (type_ptr != DIE_IS_BEING_PARSED) {
-  // Grab the existing type from the master types lists
+  // Get the original shared pointer for this type
   type_sp = type_ptr->shared_from_this();
 }
   }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -488,7 +488,7 @@
  "Debugger::Terminate called without a matching 
Debugger::Initialize!");
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
-// Clear our master list of debugger objects
+// Clear our global list of debugger objects
 {
   std::lock_guard guard(*g_debugger_list_mutex_ptr);
   for (const auto &debugger : *g_debugger_list_ptr)


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2585,7 +2585,7 @@
 
   type_sp = ParseType(sc, die, nullptr);
 } else if (type_ptr != DIE_IS_BEING_PARSED) {
-  // Grab the existing type from the master types lists
+  // Get the original shared pointer for this type
   type_sp = type_ptr->shared_from_this();
 }
   }
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -488,7 +488,7 @@
  "Debugger::Terminate called without a matching Debugger::Initialize!");
 
   if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
-// Clear our master list of debugger objects
+// Clear our global list of debugger objects
 {
   std::lock_guard guard(*g_debugger_list_mutex_ptr);
   for (const auto &debugger : *g_debugger_list_ptr)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D114123: [NFC][lldb] Inclusive language: remove instances of master from comments in lldb

2021-11-17 Thread Quinn Pham via Phabricator via lldb-commits
quinnp added a comment.

Thanks @clayborg! I've updated the patch based on your suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114123

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


[Lldb-commits] [PATCH] D113965: [NFC] Refactor symbol table parsing.

2021-11-17 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I had to revert this. There is a deadlock in:

  void Module::PreloadSymbols() {
std::lock_guard guard(m_mutex);
SymbolFile *sym_file = GetSymbolFile();
if (!sym_file)
  return;
  
// Prime the symbol file first, since it adds symbols to the symbol table.
sym_file->PreloadSymbols();
  
// Now we can prime the symbol table.
if (Symtab *symtab = sym_file->GetSymtab())
  symtab->PreloadSymbols();
  }

That happens only when we are using ELF files since they need to be manually 
indexed. What happens is:

- Thread #1 calls "sym_file->PreloadSymbols();"
- Thread #2 starts manually indexing the DWARF and tries to load section data 
for a DWARF section which has relocations and since Module::PreloadSymbols() 
from thread #1 has the lock.

The backtrace can be seen when debugging:

  $ /Users/gclayton/Documents/src/llvm/clean/Debug/bin/lldb --no-lldbinit -S 
/Users/gclayton/Documents/src/llvm/clean/Debug/tools/lldb/test/Shell/lit-lldb-init
 debug_rnglists-dwo.o -o image lookup -v -s lookup_rnglists -o exit

This deadlocks with:

  (lldb) bt all
  * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x0001850f4548 libsystem_kernel.dylib`__psynch_cvwait + 8
  frame #1: 0x00018512bdac libsystem_pthread.dylib`_pthread_cond_wait + 
1248
  frame #2: 0x000185085efc 
libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock&)
 + 28
  frame #3: 0x000104ee97a8 LLDB`void 
std::__1::condition_variable::wait(this=0x00016d3b03f0,
 __lk=0x00016d3aff58, __pred=(anonymous class) @ 0x00016d3aff28)::$_1) 
at __mutex_base:409:9
  frame #4: 0x000104ee9728 
LLDB`llvm::ThreadPool::wait(this=0x00016d3b0338) at ThreadPool.cpp:72:23
  frame #5: 0x000104b97d54 
LLDB`lldb_private::ManualDWARFIndex::Index(this=0x0001302129b0) at 
ManualDWARFIndex.cpp:109:8
  frame #6: 0x000104b0ef98 
LLDB`lldb_private::ManualDWARFIndex::Preload(this=0x0001302129b0) at 
ManualDWARFIndex.h:27:29
  frame #7: 0x000104bb5f1c 
LLDB`SymbolFileDWARF::PreloadSymbols(this=0x000130815400) at 
SymbolFileDWARF.cpp:2071:12
  frame #8: 0x000103c60dcc 
LLDB`lldb_private::Module::PreloadSymbols(this=0x00013020d238) at 
Module.cpp:1383:13
  frame #9: 0x000104266f44 
LLDB`lldb_private::TargetList::CreateTargetInternal(debugger=0x00013302d200,
 user_exe_path=(Data = "debug_rnglists-dwo.o", Length = 20), 
specified_arch=0x00016d3b1478, load_dependent_files=eLoadDependentsDefault, 
platform_sp=std::__1::shared_ptr::element_type @ 
0x000130705b70 strong=7 weak=1, 
target_sp=std::__1::shared_ptr::element_type @ 
0x000130811600 strong=1 weak=2) at TargetList.cpp:371:24
  frame #10: 0x000104266648 
LLDB`lldb_private::TargetList::CreateTargetInternal(debugger=0x00013302d200,
 user_exe_path=(Data = "debug_rnglists-dwo.o", Length = 20), triple_str=(Data = 
"", Length = 0), load_dependent_files=eLoadDependentsDefault, 
platform_options=0x000133044dc0, 
target_sp=std::__1::shared_ptr::element_type @ 
0x000130811600 strong=1 weak=2) at TargetList.cpp:280:10
  frame #11: 0x000104265ae0 
LLDB`lldb_private::TargetList::CreateTarget(this=0x00013302d2d0, 
debugger=0x00013302d200, user_exe_path=(Data = "debug_rnglists-dwo.o", 
Length = 20), triple_str=(Data = "", Length = 0), 
load_dependent_files=eLoadDependentsDefault, 
platform_options=0x000133044dc0, 
target_sp=std::__1::shared_ptr::element_type @ 
0x000130811600 strong=1 weak=2) at TargetList.cpp:52:17
  frame #12: 0x000107d2d2a8 
LLDB`CommandObjectTargetCreate::DoExecute(this=0x000133044c00, 
command=0x00016d3b22a0, result=0x00016d3b28c0) at 
CommandObjectTarget.cpp:314:45
  frame #13: 0x000103efc228 
LLDB`lldb_private::CommandObjectParsed::Execute(this=0x000133044c00, 
args_string="\"debug_rnglists-dwo.o\"", result=0x00016d3b28c0) at 
CommandObject.cpp:995:19
  frame #14: 0x000103ebd234 
LLDB`lldb_private::CommandInterpreter::HandleCommand(this=0x000132834c90, 
command_line="target create \"debug_rnglists-dwo.o\"", 
lazy_add_to_history=eLazyBoolCalculate, result=0x00016d3b28c0) at 
CommandInterpreter.cpp:1971:14
  frame #15: 0x000103ec17fc 
LLDB`lldb_private::CommandInterpreter::IOHandlerInputComplete(this=0x000132834c90,
 io_handler=0x000130508c18, line="target create \"debug_rnglists-dwo.o\"") 
at CommandInterpreter.cpp:3021:3
  frame #16: 0x000103bffcd8 
LLDB`lldb_private::IOHandlerEditline::Run(this=0x000130508c18) at 
IOHandler.cpp:576:22
  frame #17: 0x000103b8fbb8 
LLDB`lldb_private::Debugger::RunIOHandlers(this=0x00013302d200) at 
Debugger.cpp:877:16
  frame #18: 0x000103ec2eac 
LLDB`lldb_private::CommandInterpreter::RunCommandInterpreter(this=0x000132834c90,
 options=0x0001305085a0) at CommandInterpreter.cpp:3267:16
  frame #19: 0x00010349

[Lldb-commits] [PATCH] D114111: Remove a useless temporary of a base class type.

2021-11-17 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added subscribers: danalbert, srhines.
labath added a comment.
This revision is now accepted and ready to land.

In D114111#3138390 , @JDevlieghere 
wrote:

> @labath Do you know what the status is of removing RenderScript altogether?

Not really, but let me tag some people who might (@danalbert, @srhines).

In either case, this change is obviously correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114111

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