[Lldb-commits] [PATCH] D128034: [lldb] [test] Disable gmodules testing on FreeBSD

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: emaste, krytarowski, labath.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

The -gmodule tests currently fail on FreeBSD due to include bugs:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264730

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128034

Files:
  lldb/packages/Python/lldbsuite/test/test_categories.py


Index: lldb/packages/Python/lldbsuite/test/test_categories.py
===
--- lldb/packages/Python/lldbsuite/test/test_categories.py
+++ lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -64,7 +64,7 @@
 return platform in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]
 elif category == "gmodules":
 # First, check to see if the platform can even support gmodules.
-if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", 
"tvos", "bridgeos"]:
+if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", 
"bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
 return True


Index: lldb/packages/Python/lldbsuite/test/test_categories.py
===
--- lldb/packages/Python/lldbsuite/test/test_categories.py
+++ lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -64,7 +64,7 @@
 return platform in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]
 elif category == "gmodules":
 # First, check to see if the platform can even support gmodules.
-if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
+if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
 return True
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3fd9aeb - [LLDB] XFAIL TestLoadUnload fails on Arm/Ubuntu Jammy

2022-06-17 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2022-06-17T12:06:35+04:00
New Revision: 3fd9aebbb75ab0966bd767e15ba6a69cad17f160

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

LOG: [LLDB] XFAIL TestLoadUnload fails on Arm/Ubuntu Jammy

This patch marks following tests as XFAIL for Arm/Ubuntu Jammy 22.04:
test_lldb_process_load_and_unload_commands
test_load_unload

Added: 


Modified: 
lldb/test/API/functionalities/load_unload/TestLoadUnload.py

Removed: 




diff  --git a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py 
b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
index f3b715c4c35ed..15e602cc784db 100644
--- a/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
+++ b/lldb/test/API/functionalities/load_unload/TestLoadUnload.py
@@ -203,6 +203,7 @@ def test_dyld_library_path(self):
 hostoslist=["windows"],
 triple='.*-android')
 @expectedFailureAll(oslist=["windows"]) # process load not implemented
+@expectedFailureAll(oslist=["linux"], archs=["arm"]) # Fails on ubuntu 
jammy
 def test_lldb_process_load_and_unload_commands(self):
 self.setSvr4Support(False)
 self.run_lldb_process_load_and_unload_commands()
@@ -296,6 +297,7 @@ def run_lldb_process_load_and_unload_commands(self):
 self.runCmd("process continue")
 
 @expectedFailureAll(oslist=["windows"]) # breakpoint not hit
+@expectedFailureAll(oslist=["linux"], archs=["arm"]) # Fails on ubuntu 
jammy
 def test_load_unload(self):
 self.setSvr4Support(False)
 self.run_load_unload()



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


[Lldb-commits] [PATCH] D128041: [lldb] [test] Make AVX/MPX register tests more robust and fix on BSD

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: emaste, labath, DavidSpickett, krytarowski.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Make the AVX/MPX register tests more robust by checking for the presence
of actual registers rather than register sets.  Account for the option
that the respective registers are defined but not available, as is
the case on FreeBSD and NetBSD.  This fixes test regression on these
platforms.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128041

Files:
  lldb/test/API/commands/register/register/register_command/TestRegisters.py


Index: 
lldb/test/API/commands/register/register/register_command/TestRegisters.py
===
--- lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -395,31 +395,25 @@
 st0regname +
 ' = 0'])
 
-has_avx = False
-has_mpx = False
-# Returns an SBValueList.
+# Check if AVX/MPX registers are defined at all.
 registerSets = currentFrame.GetRegisters()
-for registerSet in registerSets:
-set_name = registerSet.GetName().lower()
-if 'advanced vector extensions' in set_name:
-has_avx = True
-# Darwin reports AVX registers as part of "Floating Point 
Registers"
-elif self.platformIsDarwin() and 'floating point registers' in 
set_name:
-has_avx = 
registerSet.GetChildMemberWithName('ymm0').IsValid()
-
-# FreeBSD/NetBSD reports missing register sets differently
-# at the moment and triggers false positive here.
-# TODO: remove FreeBSD/NetBSD exception when we make 
unsupported
-# register groups correctly disappear.
-if ('memory protection extension' in 
registerSet.GetName().lower()
-and self.getPlatform() not in ["freebsd", "netbsd"]):
-has_mpx = True
+registers = frozenset(reg.GetName() for registerSet in registerSets
+  for reg in registerSet)
+has_avx_regs = "ymm0" in registers
+has_mpx_regs = "bnd0" in registers
+# Check if they are actually present.
+self.runCmd("register read -a")
+output = self.res.GetOutput()
+has_avx = "ymm0 =" in output
+has_mpx = "bnd0 =" in output
 
 if has_avx:
 new_value = "{0x01 0x02 0x03 0x00 0x00 0x00 0x00 0x00 0x09 
0x0a 0x2f 0x2f 0x2f 0x2f 0x0e 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x0c 0x0d 0x0e 0x0f}"
 self.write_and_read(currentFrame, "ymm0", new_value)
 self.write_and_read(currentFrame, "ymm7", new_value)
 self.expect("expr $ymm0", substrs=['vector_type'])
+elif has_avx_regs:
+self.expect("register read ymm0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read ymm0", substrs=["Invalid register 
name 'ymm0'"],
 error=True)
@@ -436,6 +430,8 @@
 new_value = "{0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08}"
 self.write_and_read(currentFrame, "bndstatus", new_value)
 self.expect("expr $bndstatus", substrs = ['vector_type'])
+elif has_mpx_regs:
+self.expect("register read bnd0", substrs=["error: 
unavailable"])
 else:
 self.expect("register read bnd0", substrs=["Invalid register 
name 'bnd0'"],
 error=True)


Index: lldb/test/API/commands/register/register/register_command/TestRegisters.py
===
--- lldb/test/API/commands/register/register/register_command/TestRegisters.py
+++ lldb/test/API/commands/register/register/register_command/TestRegisters.py
@@ -395,31 +395,25 @@
 st0regname +
 ' = 0'])
 
-has_avx = False
-has_mpx = False
-# Returns an SBValueList.
+# Check if AVX/MPX registers are defined at all.
 registerSets = currentFrame.GetRegisters()
-for registerSet in registerSets:
-set_name = registerSet.GetName().lower()
-if 'advanced vector extensions' in set_name:
-has_avx = True
-# Darwin reports AVX registers as part of "Floating Point Registers"
-elif self.platformIsDarwin() and 'floating point registers' in set_name:
-has_avx = registerSet.GetChildMemberWithName('ymm0').IsValid()
-
-# FreeBSD/N

[Lldb-commits] [PATCH] D128042: [lldb] [test] Fix test_platform_file_fstat to account for negative ints

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: arichardson.
Herald added a project: All.
mgorny requested review of this revision.

Fix test_platform_file_fstat to correctly truncate/max out the expected
value when GDB Remote Serial Protocol specifies a value as an unsigned
integer but the underlying platform type uses a signed integer.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D128042

Files:
  lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py


Index: lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -32,11 +32,11 @@
 
 
 def uint32_or_zero(x):
-return x if x < 2**32 else 0
+return x if x < 2**32 and x >= 0 else 0
 
 
 def uint32_or_max(x):
-return x if x < 2**32 else 2**32 - 1
+return x if x < 2**32 and x >= 0 else 2**32 - 1
 
 
 def uint32_trunc(x):


Index: lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
===
--- lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -32,11 +32,11 @@
 
 
 def uint32_or_zero(x):
-return x if x < 2**32 else 0
+return x if x < 2**32 and x >= 0 else 0
 
 
 def uint32_or_max(x):
-return x if x < 2**32 else 2**32 - 1
+return x if x < 2**32 and x >= 0 else 2**32 - 1
 
 
 def uint32_trunc(x):
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 13dfe0f - [lldb] [test] Update baseline test status for FreeBSD

2022-06-17 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-06-17T14:35:18+02:00
New Revision: 13dfe0f0fc267f3f747a5e0802c0a8b01240d0af

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

LOG: [lldb] [test] Update baseline test status for FreeBSD

Fixes #19721
Fixes #18440
Partially fixes bug #47660
Fixes #47761
Fixes #47763

Sponsored by: The FreeBSD Foundation

Added: 


Modified: 

lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
lldb/test/API/commands/target/basic/TestTargetCommand.py
lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py

lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
lldb/test/API/lang/c/calling-conventions/TestCCallingConventions.py
lldb/test/API/python_api/event/TestEvents.py
lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
lldb/test/API/tools/lldb-server/vCont-threads/TestGdbRemote_vContThreads.py
lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
 
b/lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
index 938934f1d3fa4..1026de6e491ce 100644
--- 
a/lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ 
b/lldb/test/API/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -74,7 +74,6 @@ def test_nav_arrow_down(self):
 
 @skipIfAsan
 @skipIfEditlineSupportMissing
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr48316')
 @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) # Randomly fails on 
buildbot
 def test_nav_arrow_up_empty(self):
 """

diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 9904eb02394a9..0f153fcdbfed8 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -470,6 +470,8 @@ def test_target_modules_search_paths_query(self):
 substrs=["query requires one argument"])
 
 @no_debug_info_test
+@expectedFailureAll(oslist=["freebsd"],
+bugnumber="github.com/llvm/llvm-project/issues/56079")
 def test_target_modules_type(self):
 self.buildB()
 self.runCmd("file " + self.getBuildArtifact("b.out"),

diff  --git 
a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py 
b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py
index da5ea215bc236..b1a1c4fb007a2 100644
--- a/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py
+++ b/lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py
@@ -95,9 +95,6 @@ def check_two_threads(self, result_str, thread_id_1, name_1, 
thread_id_2, name_2
 # the comments whether it was getting two threads to the same breakpoint 
that was
 # problematic, or the step-out part.  This test stops at the rendevous 
point so I'm
 # removing the skipIfLinux to see if we see any flakiness in just this 
part of the test.
-@expectedFailureAll(
-oslist=["freebsd"],
-bugnumber="llvm.org/pr18066 inferior does not exit")
 @skipIfWindows # This test will hang on windows llvm.org/pr21753
 @expectedFailureAll(oslist=["windows"])
 @expectedFailureNetBSD
@@ -157,7 +154,3 @@ def test_thread_backtrace_two_threads(self):
 self.assertTrue(result.Succeeded(), "repeat command succeeded for two 
threads")
 result_str = result.GetOutput()
 self.check_two_threads(result_str, thread_id_1, name_1, thread_id_2, 
name_2, 13, 22)
-
-
-
-

diff  --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
index 40a20a04b76b1..aafa43fc5bb69 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
@@ -13,6 +13,8 @@ class BreakpointSetRestart(TestBase):
 BREAKPOINT_TEXT = 'Set a breakpoint here'
 
 @skipIfNetBSD
+@skipIf(oslist=["freebsd"],
+bugnumber="github.com/llvm/llvm-project/issues/56082")
 def test_breakpoint_set_restart(self):
 self.build()
 

diff  --git 
a/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py 
b/lldb/test/API/functionalities/thread/step_out/TestThreadStepOut.py
index 71a7e6033

[Lldb-commits] [PATCH] D128063: [LLDB][ExpressionParser] Fix indexing into LLDB_LOG calls

2022-06-17 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a subscriber: arphaman.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

`llvm::formatv` expects the parameter indexes to start with 0.
Unfortunately it doesn't detect out-of-bounds accesses in the format
string, of which we had several inside `ClangExpressionDeclMap`.

This patch fixes these out-of-index format accesses.

*Example output*

- Before

  ClangExpressionDeclMap::FindExternalVisibleDecls for '$__lldb_class' in a
  'TranslationUnit'
CEDM::FEVD Searching the root namespace
CEDM::FEVD Adding type for $__lldb_class: 1



- After

  ClangExpressionDeclMap::FindExternalVisibleDecls for '$__lldb_class' in
  a 'TranslationUnit'
CEDM::FEVD Searching the root namespace
CEDM::FEVD Adding type for $__lldb_class: class (lambda)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128063

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -806,7 +806,7 @@
 TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
  function_decl_ctx.GetTypeSystem());
 
-LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {0}",
  class_qual_type.getAsString());
 
 AddContextClassType(context, class_user_type);
@@ -848,7 +848,7 @@
 TypeFromUser pointee_type =
 this_type->GetForwardCompilerType().GetPointeeType();
 
-LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {0}",
  ClangUtil::GetQualType(pointee_type).getAsString());
 
 AddContextClassType(context, pointee_type);
@@ -1037,7 +1037,7 @@
 
   LLDB_LOG(log,
"  CAS::FEVD Matching decl found for "
-   "\"{1}\" in the modules",
+   "\"{0}\" in the modules",
name);
 
   clang::Decl *copied_decl = CopyDecl(decl_from_modules);
@@ -1595,7 +1595,7 @@
   if (is_reference)
 entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2} (original 
{3})",
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1} (original 
{2})",
decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
 }
 
@@ -1626,7 +1626,7 @@
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value.Clear();
 
-  LLDB_LOG(log, "  CEDM::FEVD Added pvar {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added pvar {0}, returned\n{1}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1678,7 +1678,7 @@
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_sym = &symbol;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1717,7 +1717,7 @@
   parser_vars->m_lldb_value.Clear();
   entity->m_flags |= ClangExpressionVariable::EVBareRegister;
 
-  LLDB_LOG(log, "  CEDM::FEVD Added register {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added register {0}, returned\n{1}",
context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1767,7 +1767,7 @@
 
   LLDB_LOG(log,
"  CEDM::FEVD Imported decl for function template"
-   " {1} (description {2}), returned\n{3}",
+   " {0} (description {1}), returned\n{2}",
copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(copied_function_template));
@@ -1785,8 +1785,8 @@
   function->DumpSymbolContext(&ss);
 
   LLDB_LOG(log,
-   "  CEDM::FEVD Imported decl for function {1} "
-   "(description {2}), returned\n{3}",
+   "  CEDM::FEVD Imported decl for function {0} "
+   "(description {1}), returned\n{2}",
copied_function_decl->getNameAsString(), ss.GetData(),
ClangUtil::DumpDecl(copied_function_decl));
 }
@@ -1885,8 +1885,8 @@
  Address::DumpStyleResolvedDescription);
 
 LLDB_LOG(log,
- "  CEDM::FEVD Found {1} function {2} (description {3}), "
- "returned\n{4}",
+ "  CEDM::FEVD Found {0} function {1} (description {2}), "
+ "returned\n{3}",
  (f

[Lldb-commits] [PATCH] D127999: [lldb] fix stepping through POSIX trampolines

2022-06-17 Thread Michael Daniels via Phabricator via lldb-commits
mdaniels added a comment.

@JDevlieghere could you confirm my understanding of the issue here is correct?

It looks like https://github.com/llvm/llvm-project/issues/54250 is the same 
issue, and should be fix with this as well.




Comment at: 
lldb/test/API/lang/cpp/step-into-namespace/TestStepIntoNamespace.py:8
+
+def test(self):
+self.build()

clayborg wrote:
> Do we want to limit this to linux? I am not sure this will pass the windows 
> buildbots if we don't restrict it
Looking at other tests that load a shared library, it seems I should have at 
least

```
@skipIfRemote
@skipIfWindows
```
But I can also just restrict it to the platforms I am able to test on locally, 
linux and darwin, if there is still concern that other platforms might fail.


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

https://reviews.llvm.org/D127999

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


[Lldb-commits] [PATCH] D128063: [LLDB][ExpressionParser] Fix indices inside format-strings passed to LLDB_LOG

2022-06-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128063

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


[Lldb-commits] [lldb] f000de8 - [LLDB][ExpressionParser] Fix indices inside format-strings passed to LLDB_LOG

2022-06-17 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2022-06-17T09:26:01-07:00
New Revision: f000de8760c112ead0487a020c3849c6280f2a57

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

LOG: [LLDB][ExpressionParser] Fix indices inside format-strings passed to 
LLDB_LOG

llvm::formatv expects the parameter indexes to start with 0.
Unfortunately it doesn't detect out-of-bounds accesses in the format
string at compile-time, of which we had several inside ClangExpressionDeclMap.

This patch fixes these out-of-bounds format accesses.

Example output

Before

ClangExpressionDeclMap::FindExternalVisibleDecls for '$__lldb_class' in a
'TranslationUnit'
  CEDM::FEVD Searching the root namespace
  CEDM::FEVD Adding type for $__lldb_class: 1

After

ClangExpressionDeclMap::FindExternalVisibleDecls for '$__lldb_class' in
a 'TranslationUnit'
  CEDM::FEVD Searching the root namespace
  CEDM::FEVD Adding type for $__lldb_class: class (lambda)

Patch by Michael Buch!

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

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 06a7e175cb617..cc45871bcd71a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -806,7 +806,7 @@ void 
ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
 TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
  function_decl_ctx.GetTypeSystem());
 
-LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {0}",
  class_qual_type.getAsString());
 
 AddContextClassType(context, class_user_type);
@@ -848,7 +848,7 @@ void 
ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
 TypeFromUser pointee_type =
 this_type->GetForwardCompilerType().GetPointeeType();
 
-LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {0}",
  ClangUtil::GetQualType(pointee_type).getAsString());
 
 AddContextClassType(context, pointee_type);
@@ -1037,7 +1037,7 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
 
   LLDB_LOG(log,
"  CAS::FEVD Matching decl found for "
-   "\"{1}\" in the modules",
+   "\"{0}\" in the modules",
name);
 
   clang::Decl *copied_decl = CopyDecl(decl_from_modules);
@@ -1595,7 +1595,7 @@ void 
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
   if (is_reference)
 entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2} (original 
{3})",
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1} (original 
{2})",
decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
 }
 
@@ -1626,7 +1626,7 @@ void 
ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value.Clear();
 
-  LLDB_LOG(log, "  CEDM::FEVD Added pvar {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added pvar {0}, returned\n{1}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1678,7 +1678,7 @@ void 
ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_sym = &symbol;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1717,7 +1717,7 @@ void 
ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
   parser_vars->m_lldb_value.Clear();
   entity->m_flags |= ClangExpressionVariable::EVBareRegister;
 
-  LLDB_LOG(log, "  CEDM::FEVD Added register {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added register {0}, returned\n{1}",
context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1767,7 +1767,7 @@ void 
ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
 
   LLDB_LOG(log,
"  CEDM::FEVD Imported decl for function template"
-   " {1} (description {2}), returned\n{3}",
+   " {0} (description {1}), returned\n{2}",
copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(

[Lldb-commits] [PATCH] D128063: [LLDB][ExpressionParser] Fix indices inside format-strings passed to LLDB_LOG

2022-06-17 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf000de8760c1: [LLDB][ExpressionParser] Fix indices inside 
format-strings passed to LLDB_LOG (authored by aprantl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128063

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -806,7 +806,7 @@
 TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
  function_decl_ctx.GetTypeSystem());
 
-LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {0}",
  class_qual_type.getAsString());
 
 AddContextClassType(context, class_user_type);
@@ -848,7 +848,7 @@
 TypeFromUser pointee_type =
 this_type->GetForwardCompilerType().GetPointeeType();
 
-LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, "  FEVD Adding type for $__lldb_class: {0}",
  ClangUtil::GetQualType(pointee_type).getAsString());
 
 AddContextClassType(context, pointee_type);
@@ -1037,7 +1037,7 @@
 
   LLDB_LOG(log,
"  CAS::FEVD Matching decl found for "
-   "\"{1}\" in the modules",
+   "\"{0}\" in the modules",
name);
 
   clang::Decl *copied_decl = CopyDecl(decl_from_modules);
@@ -1595,7 +1595,7 @@
   if (is_reference)
 entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2} (original 
{3})",
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1} (original 
{2})",
decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
 }
 
@@ -1626,7 +1626,7 @@
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_value.Clear();
 
-  LLDB_LOG(log, "  CEDM::FEVD Added pvar {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added pvar {0}, returned\n{1}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1678,7 +1678,7 @@
   parser_vars->m_llvm_value = nullptr;
   parser_vars->m_lldb_sym = &symbol;
 
-  LLDB_LOG(log, "  CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+  LLDB_LOG(log, "  CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1717,7 +1717,7 @@
   parser_vars->m_lldb_value.Clear();
   entity->m_flags |= ClangExpressionVariable::EVBareRegister;
 
-  LLDB_LOG(log, "  CEDM::FEVD Added register {1}, returned\n{2}",
+  LLDB_LOG(log, "  CEDM::FEVD Added register {0}, returned\n{1}",
context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
 }
 
@@ -1767,7 +1767,7 @@
 
   LLDB_LOG(log,
"  CEDM::FEVD Imported decl for function template"
-   " {1} (description {2}), returned\n{3}",
+   " {0} (description {1}), returned\n{2}",
copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(copied_function_template));
@@ -1785,8 +1785,8 @@
   function->DumpSymbolContext(&ss);
 
   LLDB_LOG(log,
-   "  CEDM::FEVD Imported decl for function {1} "
-   "(description {2}), returned\n{3}",
+   "  CEDM::FEVD Imported decl for function {0} "
+   "(description {1}), returned\n{2}",
copied_function_decl->getNameAsString(), ss.GetData(),
ClangUtil::DumpDecl(copied_function_decl));
 }
@@ -1885,8 +1885,8 @@
  Address::DumpStyleResolvedDescription);
 
 LLDB_LOG(log,
- "  CEDM::FEVD Found {1} function {2} (description {3}), "
- "returned\n{4}",
+ "  CEDM::FEVD Found {0} function {1} (description {2}), "
+ "returned\n{3}",
  (function ? "specific" : "generic"), decl_name, ss.GetData(),
  ClangUtil::DumpDecl(function_decl));
   }


Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -806,7 +806,7 @@
 TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
  function_decl_ctx.GetTypeSystem());
 
-LLDB_LOG(log, "  CEDM::FEVD Adding type for $__lldb_class: {1}",
+LLDB_LOG(log, " 

[Lldb-commits] [PATCH] D125575: [lldb] [llgs] Implement non-stop style stop notification packets

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In D125575#3586534 , @labath wrote:

> I think this is a pretty good start. The main thing bugging me is the two 
> bool flags on the stop reply packet functions. I wonder if it would be more 
> readable to split this into two functions. Something like:
>
>   SendStopReplyForThread(bool force_synchronous /*seems better than 
> allow_async, but that could just be me*/, bool enqueue /*enqueues just this 
> thread*/);
>   EnqueueStopReplyPackets(NativeThreadProtocol &thread_to_skip);
>
> perhaps?

`force_synchronous` makes sense. I guess moving the loop into another function 
does as well. However, I think the `bool enqueue` change is going to be more 
confusing than helpful (note that the notification is always enqueued through 
`SendNotificationPacketNoLock()` unless `force_synchronous`, so `bool enqueue` 
only applies for that case), and I don't really see how to avoid `bool 
queue_all_threads` other than repeating the calls to 
`EnqueueStopReplyPackets()` all over the place — which ofc is possible but 
seems like a lot of duplication.

The thing is, we generally have three cases to handle:

1. A function that uses asynchronous replies in non-stop mode — i.e. we always 
enqueue, and send async notification if one wasn't sent already.
2. A function that always uses synchronous replies — i.e. we send plain old 
reply and don't queue anything.
3. `?` — which in non-stop mode enqueues for all threads but sends the first 
one synchronous rather than asynchronous.

Perhaps the best approach would be to eliminate `bool enqueue` entirely and 
call `PrepareStopReplyPacketForThread()` from `?` handler directly. I need to 
think about it more.




Comment at: lldb/test/API/tools/lldb-server/TestLldbGdbServer.py:1414
+
+def test_QNonStop(self):
+self.build()

labath wrote:
> Could you put these into a new file? TestLldbGdbServer is already one of the 
> longest running tests...
Yes, I agree. `TestNonStop.py` coming once!


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

https://reviews.llvm.org/D125575

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


[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-06-17 Thread David M. Lary via Phabricator via lldb-commits
dmlary created this revision.
dmlary added a reviewer: clayborg.
dmlary added a project: LLDB.
Herald added subscribers: Michael137, JDevlieghere.
Herald added a project: All.
dmlary requested review of this revision.

This commit adds SBSection.GetAlignment(), and SBSection.alignment as a python 
property to lldb.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128069

Files:
  lldb/bindings/interface/SBSection.i
  lldb/include/lldb/API/SBSection.h
  lldb/source/API/SBSection.cpp


Index: lldb/source/API/SBSection.cpp
===
--- lldb/source/API/SBSection.cpp
+++ lldb/source/API/SBSection.cpp
@@ -242,6 +242,15 @@
   return 0;
 }
 
+uint32_t SBSection::GetAlignment() {
+  LLDB_INSTRUMENT_VA(this);
+
+  SectionSP section_sp(GetSP());
+  if (section_sp.get())
+return (1 << section_sp->GetLog2Align());
+  return 0;
+}
+
 bool SBSection::operator==(const SBSection &rhs) {
   LLDB_INSTRUMENT_VA(this, rhs);
 
Index: lldb/include/lldb/API/SBSection.h
===
--- lldb/include/lldb/API/SBSection.h
+++ lldb/include/lldb/API/SBSection.h
@@ -76,6 +76,12 @@
   /// The number of host (8-bit) bytes needed to hold a target byte
   uint32_t GetTargetByteSize();
 
+  /// Return the alignment of the section in bytes
+  ///
+  /// \return
+  /// The alignment of the section in bytes
+  uint32_t GetAlignment();
+
   bool operator==(const lldb::SBSection &rhs);
 
   bool operator!=(const lldb::SBSection &rhs);
Index: lldb/bindings/interface/SBSection.i
===
--- lldb/bindings/interface/SBSection.i
+++ lldb/bindings/interface/SBSection.i
@@ -105,6 +105,9 @@
 uint32_t
 GetTargetByteSize ();
 
+uint32_t
+GetAlignment ();
+
 bool
 GetDescription (lldb::SBStream &description);
 
@@ -138,6 +141,7 @@
 data = property(GetSectionData, None, doc='''A read only property that 
returns an lldb object that represents the bytes for this section (lldb.SBData) 
for this section.''')
 type = property(GetSectionType, None, doc='''A read only property that 
returns an lldb enumeration value (see enumerations that start with 
"lldb.eSectionType") that represents the type of this section (code, data, 
etc.).''')
 target_byte_size = property(GetTargetByteSize, None, doc='''A read 
only property that returns the size of a target byte represented by this 
section as a number of host bytes.''')
+alignment = property(GetAlignment, None, doc='''A read only property 
that returns the alignment of this section as a number of host bytes.''')
 %}
 #endif
 


Index: lldb/source/API/SBSection.cpp
===
--- lldb/source/API/SBSection.cpp
+++ lldb/source/API/SBSection.cpp
@@ -242,6 +242,15 @@
   return 0;
 }
 
+uint32_t SBSection::GetAlignment() {
+  LLDB_INSTRUMENT_VA(this);
+
+  SectionSP section_sp(GetSP());
+  if (section_sp.get())
+return (1 << section_sp->GetLog2Align());
+  return 0;
+}
+
 bool SBSection::operator==(const SBSection &rhs) {
   LLDB_INSTRUMENT_VA(this, rhs);
 
Index: lldb/include/lldb/API/SBSection.h
===
--- lldb/include/lldb/API/SBSection.h
+++ lldb/include/lldb/API/SBSection.h
@@ -76,6 +76,12 @@
   /// The number of host (8-bit) bytes needed to hold a target byte
   uint32_t GetTargetByteSize();
 
+  /// Return the alignment of the section in bytes
+  ///
+  /// \return
+  /// The alignment of the section in bytes
+  uint32_t GetAlignment();
+
   bool operator==(const lldb::SBSection &rhs);
 
   bool operator!=(const lldb::SBSection &rhs);
Index: lldb/bindings/interface/SBSection.i
===
--- lldb/bindings/interface/SBSection.i
+++ lldb/bindings/interface/SBSection.i
@@ -105,6 +105,9 @@
 uint32_t
 GetTargetByteSize ();
 
+uint32_t
+GetAlignment ();
+
 bool
 GetDescription (lldb::SBStream &description);
 
@@ -138,6 +141,7 @@
 data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''')
 type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''')
 target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''')
+alignment = property(GetAlignment, None, doc='''A read only property that returns the alignment of this section as a number of host bytes.''')
 %}
 #endif
 
___
lldb-commits mailing lis

[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-06-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Is this something we could add a test for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [PATCH] D125575: [lldb] [llgs] Implement non-stop style stop notification packets

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added a comment.

Thinking about it more, `?` needs to be special-cased anyway to handle 
multiprocess, so that's probably the best way forward.


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

https://reviews.llvm.org/D125575

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


[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-06-17 Thread David M. Lary via Phabricator via lldb-commits
dmlary added a comment.

I went through the existing tests for SBSection, and there is only one test 
case for all the getters & props, and that is for `target_byte_size`.  Based on 
that lack, and the simplicity of the getter, I didn't think a test case was 
warranted here.

If the reviewers feel a test is necessary here, I can definitely add one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [PATCH] D128077: [lldb][tests] Automatically call compute_mydir (NFC)

2022-06-17 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

Great! LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128077

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


[Lldb-commits] [PATCH] D50304: [lldb] Fix thread step until to not set breakpoint(s) on incorrect line numbers

2022-06-17 Thread Venkata Ramanaiah Nalamothu via Phabricator via lldb-commits
RamNalamothu added a comment.

In D50304#3586710 , @jingham wrote:

> For some reason I'm not getting mail notifications for review changes, sorry 
> about that.
>
> This is certainly better than the original implementation.  Among other 
> things, if we find an exact match, we really shouldn't be doing any more 
> inexact matches, so after the first exact hit it should have switched exact 
> to true.
>
> But if you had line tables laid out like (this is in increasing order of 
> address:
>
> 10
> 20
> 30
> 10
> 16
>
> and you did "thread until 15", this would find the inexact match at 20, 
> switch to an exact match for line 20 and find no other matches.  But the gap 
> between 10 & 16 in the line table is maybe an even more plausible place to 
> put the line 15 until breakpoint, so maybe we did want to throw a breakpoint 
> there as well?

@jingham 
Nope, with the current patch, we would find the inexact match at 16.

> Regular breakpoint setting has to move inexact breakpoints in much the same 
> way.  The code in the BreakpointResolverFileLine::SearchCallback ends up 
> calling CompileUnit::ResolveSymbolContext to get the "best" inexact match.  
> Maybe it would be better to not do this by hand here in the Until command, 
> but reuse the code that we use to move break points more generally?

Be it CompileUnit::ResolveSymbolContext or CompileUnit::FindLineEntry, we end 
up calling LineTable::FindLineEntryIndexByFileIndex which finds "Exact match 
always wins.  Otherwise try to find the closest line > the desired line." when 
we pass `exact = false` to it.
Given that and we anyway have to extract address list, from what we get out of 
CompileUnit::ResolveSymbolContext, for the thread until thread plan to work 
with, probably the additional overhead to use CompileUnit::ResolveSymbolContext 
here does not make sense. Or am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50304

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


[Lldb-commits] [PATCH] D128077: [lldb][tests] Automatically call compute_mydir (NFC)

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

Neat :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128077

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


[Lldb-commits] [PATCH] D125575: [lldb] [llgs] Implement non-stop style stop notification packets

2022-06-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 438007.
mgorny added a comment.

Move tests to a separate file. Rename and reverse `allow_async` into 
`force_synchronous`. Remove `queue_all_threads` — we now always queue all in 
async mode. Rework `Handle_stop_reason` not to rely on 
`SendStopReasonForState()`, and fix reporting exiting processes via `?` when 
not acked by client yet. Add tests for correct exit reporting.


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

https://reviews.llvm.org/D125575

Files:
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/tools/lldb-server/TestNonStop.py

Index: lldb/test/API/tools/lldb-server/TestNonStop.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-server/TestNonStop.py
@@ -0,0 +1,165 @@
+from lldbsuite.test.lldbtest import *
+
+import gdbremote_testcase
+
+
+class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def test_run(self):
+self.build()
+self.set_inferior_startup_launch()
+thread_num = 3
+procs = self.prep_debug_monitor_and_inferior(
+inferior_args=["thread:segfault"] + thread_num * ["thread:new"])
+self.test_sequence.add_log_lines(
+["read packet: $QNonStop:1#00",
+ "send packet: $OK#00",
+ "read packet: $c#63",
+ "send packet: $OK#00",
+ ], True)
+self.expect_gdbremote_sequence()
+
+segv_signo = lldbutil.get_signal_number('SIGSEGV')
+all_threads = set()
+all_segv_threads = []
+
+# we should get segfaults from all the threads
+for segv_no in range(thread_num):
+# first wait for the notification event
+self.reset_test_sequence()
+self.test_sequence.add_log_lines(
+[{"direction": "send",
+  "regex": r"^%Stop:(T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)",
+  "capture": {1: "packet", 2: "signo", 3: "thread_id"},
+  },
+ ], True)
+m = self.expect_gdbremote_sequence()
+del m["O_content"]
+threads = [m]
+
+# then we may get events for the remaining threads
+# (but note that not all threads may have been started yet)
+while True:
+self.reset_test_sequence()
+self.test_sequence.add_log_lines(
+["read packet: $vStopped#00",
+ {"direction": "send",
+  "regex": r"^\$(OK|T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)",
+  "capture": {1: "packet", 2: "signo", 3: "thread_id"},
+  },
+ ], True)
+m = self.expect_gdbremote_sequence()
+if m["packet"] == "OK":
+break
+del m["O_content"]
+threads.append(m)
+
+segv_threads = []
+other_threads = []
+for t in threads:
+signo = int(t["signo"], 16)
+if signo == segv_signo:
+segv_threads.append(t["thread_id"])
+else:
+self.assertEqual(signo, 0)
+other_threads.append(t["thread_id"])
+
+# verify that exactly one thread segfaulted
+self.assertEqual(len(segv_threads), 1)
+# we should get only one segv from every thread
+self.assertNotIn(segv_threads[0], all_segv_threads)
+all_segv_threads.extend(segv_threads)
+# segv_threads + other_threads should always be a superset
+# of all_threads, i.e. we should get states for all threads
+# already started
+self.assertFalse(
+all_threads.difference(other_threads + segv_threads))
+all_threads.update(other_threads + segv_threads)
+
+# verify that `?` returns the same result
+self.reset_test_sequence()
+self.test_sequence.add_log_lines(
+["read packet: $?#00",
+ ], True)
+threads_verify = []
+while True:
+self.test_sequence.add_log_lines(
+[{"direction": "send",
+  "regex": r"^\$(OK|T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+);)",
+  "capture"

[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

2022-06-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D128069#3592733 , @dmlary wrote:

> I went through the existing tests for SBSection, and there is only one test 
> case for all the getters & props, and that is for `target_byte_size`.  Based 
> on that lack, and the simplicity of the getter, I didn't think a test case 
> was warranted here.

I'm less concerned about the getter and the property and more about the 
underlying functionality. It doesn't look like it's being tested, and adding it 
to the SB API allows to change that.

> If the reviewers feel a test is necessary here, I can definitely add one.

Yes, unless there's a good reason not too, every change should be accompanied 
by a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128069

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


[Lldb-commits] [lldb] 9916633 - [lldb] Fix modernize-use-override warnings (NFC)

2022-06-17 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-06-17T15:08:02-07:00
New Revision: 991663399792d4cc03da6b6c7131a6c213655318

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

LOG: [lldb] Fix modernize-use-override warnings (NFC)

Fix modernize-use-override warnings. Because this check is listed in
LLDB's top level .clang-tidy configuration, the check is enabled by
default and the resulting warnings show up in my editor.

I've audited the modified lines. This is not a blind change.

Added: 


Modified: 
lldb/include/lldb/Core/DebuggerEvents.h
lldb/include/lldb/Core/ValueObjectDynamicValue.h
lldb/include/lldb/Host/File.h
lldb/include/lldb/Symbol/SymbolFileOnDemand.h
lldb/include/lldb/Target/LanguageRuntime.h
lldb/include/lldb/Target/SystemRuntime.h
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Utility/DataBuffer.h
lldb/source/Host/macosx/cfcpp/CFCBundle.h
lldb/source/Host/macosx/cfcpp/CFCData.h
lldb/source/Host/macosx/cfcpp/CFCMutableArray.h
lldb/source/Host/macosx/cfcpp/CFCMutableDictionary.h
lldb/source/Host/macosx/cfcpp/CFCMutableSet.h
lldb/source/Host/macosx/cfcpp/CFCString.h
lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h
lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h
lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h
lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h
lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.h
lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h
lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h
lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

Removed: 




diff  --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index b1ddb1fc47e2d..df64798db2316 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -57,7 +57,7 @@ class DiagnosticEventData : public EventData {
   DiagnosticEventData(Type type, std::string message, bool debugger_specific)
   : m_message(std::move(message)), m_type(type),
 m_debugger_specific(debugger_specific) {}
-  ~DiagnosticEventData() {}
+  ~DiagnosticEventData() override {}
 
   const std::string &GetMessage() const { return m_message; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }

diff  --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h 
b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
index 09dcd0f968be4..a36db44f449ac 100644
--- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
@@ -32,7 +32,7 @@ class Status;
 /// set lldb type.
 class ValueObjectDynamicValue : public ValueObject {
 public:
-  ~ValueObjectDynamicValue() = default;
+  ~ValueObjectDynamicValue() override = default;
 
   llvm::Optional GetByteSize() override;
 

diff  --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index d10ec1fe282a1..85e8185ebc966 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -410,7 +410,7 @@ class NativeFile : public File {
   llvm::Expected GetOptions() const override;
 
   static char ID;
-  virtual bool isA(const void *classID) const override {
+  bool isA(const void *classID) const override {
 return classID == &ID || File::isA(classID);
   }
   static bool classof(const File *file) { return file->isA(&ID); }
@@ -458,7 +458,7 @@ class SerialPort : public NativeFile {
   Status Close() override;
 
   static char ID;
-  virtual bool isA(const void *classID) const override {
+  bool isA(const void *classID) const override {
 return classID == &ID || File::isA(classID);
   }
   static bool classof(const File *file) { return file->isA(&ID); }

diff  --git a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h 
b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
index ad2a999080864..e47872c9761c6 100644
--- a/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
+++ b/lldb/include/lldb/Symbol/SymbolFileOnDemand.h
@@ -43,7 +43,7 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
   /// \}
 
   SymbolFileOnDemand(std::unique_ptr 

[Lldb-commits] [lldb] 9168871 - [lldb] Fix modernize-use-equals-default warnings (NFC)

2022-06-17 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-06-17T15:08:02-07:00
New Revision: 91688716ba49942051dccdf7b9c4f81a7ec8feaf

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

LOG: [lldb] Fix modernize-use-equals-default warnings (NFC)

Fix modernize-use-equals-default warnings. Because this check is listed
in LLDB's top level .clang-tidy configuration, the check is enabled by
default and the resulting warnings show up in my editor.

I've audited the modified lines. This is not a blind change.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/BreakpointOptions.h
lldb/include/lldb/Breakpoint/WatchpointOptions.h
lldb/include/lldb/Core/Address.h
lldb/include/lldb/Core/DebuggerEvents.h
lldb/include/lldb/Core/Declaration.h
lldb/include/lldb/Core/Disassembler.h
lldb/include/lldb/Core/LoadedModuleInfoList.h
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Core/ModuleSpec.h
lldb/include/lldb/Core/StructuredDataImpl.h
lldb/include/lldb/Core/ValueObject.h
lldb/include/lldb/DataFormatters/FormatClasses.h
lldb/include/lldb/Host/Debug.h
lldb/include/lldb/Symbol/CompactUnwindInfo.h
lldb/include/lldb/Symbol/Type.h
lldb/include/lldb/Target/MemoryTagManager.h
lldb/include/lldb/Target/Platform.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/SectionLoadHistory.h
lldb/include/lldb/Target/SectionLoadList.h
lldb/include/lldb/Target/StackID.h
lldb/include/lldb/Target/UnwindLLDB.h
lldb/include/lldb/Utility/GDBRemote.h
lldb/include/lldb/Utility/ProcessInfo.h
lldb/include/lldb/Utility/StringExtractorGDBRemote.h
lldb/source/Commands/CommandObjectHelp.h
lldb/source/Commands/CommandObjectScript.h
lldb/source/Core/Section.cpp
lldb/source/Symbol/SymbolFileOnDemand.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h 
b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index c2456024d9194..7bf545717422f 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -43,7 +43,7 @@ friend class Breakpoint;
  | eCondition | eAutoContinue)
   };
   struct CommandData {
-CommandData() {}
+CommandData() = default;
 
 CommandData(const StringList &user_source, lldb::ScriptLanguage interp)
 : user_source(user_source), interpreter(interp), stop_on_error(true) {}

diff  --git a/lldb/include/lldb/Breakpoint/WatchpointOptions.h 
b/lldb/include/lldb/Breakpoint/WatchpointOptions.h
index c5ad90c334c48..369120e985342 100644
--- a/lldb/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/WatchpointOptions.h
@@ -166,7 +166,7 @@ class WatchpointOptions {
lldb::user_id_t watch_id);
 
   struct CommandData {
-CommandData() {}
+CommandData() = default;
 
 ~CommandData() = default;
 

diff  --git a/lldb/include/lldb/Core/Address.h 
b/lldb/include/lldb/Core/Address.h
index 4121f6c07ae2b..b19e694427546 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -116,7 +116,7 @@ class Address {
   ///
   /// Initialize with a invalid section (NULL) and an invalid offset
   /// (LLDB_INVALID_ADDRESS).
-  Address() {}
+  Address() = default;
 
   /// Copy constructor
   ///

diff  --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index df64798db2316..b584b6285af80 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -57,7 +57,7 @@ class DiagnosticEventData : public EventData {
   DiagnosticEventData(Type type, std::string message, bool debugger_specific)
   : m_message(std::move(message)), m_type(type),
 m_debugger_specific(debugger_specific) {}
-  ~DiagnosticEventData() override {}
+  ~DiagnosticEventData() override = default;
 
   const std::string &GetMessage() const { return m_message; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }

diff  --git a/lldb/include/lldb/Core/Declaration.h 
b/lldb/include/lldb/Core/Declaration.h
index 6ae21eb65eb36..4a0e9047b5469 100644
--- a/lldb/include/lldb/Core/Declaration.h
+++ b/lldb/include/lldb/Core/Declaration.h
@@ -24,7 +24,7 @@ namespace lldb_private {
 class Declaration {
 public:
   /// Default constructor.
-  Declaration() {}
+  Declaration() = default;
 
   /// Construct with file specification, and optional line and column.
   ///

diff  --git a/lldb/include/lldb/Core/Disassembler.h 
b/lldb/include/lldb/Core/Disassembler.h
index 87979fd925846..2dd1153031a6a 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -465,7 +465,7 @@ class Disassembler : public 
std::enable_shared_from_this,
 uint32_t

[Lldb-commits] [PATCH] D128107: Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-17 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 created this revision.
jj10306 added a reviewer: wallace.
Herald added a project: All.
jj10306 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add trace load functionality to SBDebugger via the `LoadTraceFromFile` method.
Update intelpt test case class to have `testTraceLoad` method so we can take 
advantage of
the testApiAndSB decorator to test both the CLI and SB without duplicating code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128107

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBTrace.h
  lldb/include/lldb/Target/Trace.h
  lldb/packages/Python/lldbsuite/test/tools/intelpt/intelpt_testcase.py
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBTrace.cpp
  lldb/source/Commands/CommandObjectTrace.cpp
  lldb/source/Target/Trace.cpp
  lldb/test/API/commands/trace/TestTraceLoad.py

Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -9,10 +9,11 @@
 mydir = TestBase.compute_mydir(__file__)
 NO_DEBUG_INFO_TESTCASE = True
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTrace(self):
 src_dir = self.getSourceDir()
 trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+self.traceLoad(traceSessionFilePath=trace_definition_file, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -21,10 +22,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTraceWithStringNumbers(self):
 src_dir = self.getSourceDir()
 trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_with_string_numbers.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+self.traceLoad(traceSessionFilePath=trace_definition_file, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -33,10 +35,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadMultiCoreTraceWithMissingThreads(self):
 src_dir = self.getSourceDir()
 trace_definition_file = os.path.join(src_dir, "intelpt-multi-core-trace", "trace_missing_threads.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+self.traceLoad(traceSessionFilePath=trace_definition_file, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 3 -t",
   substrs=["19521: [tsc=0x008fb5211c143fd8] error: expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
@@ -45,10 +48,11 @@
   substrs=["67910: [tsc=0x008fb5211bfdf270] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
+@testSBAPIAndCommands
 def testLoadTrace(self):
 src_dir = self.getSourceDir()
 trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace.json")
-self.expect("trace load -v " + trace_definition_file, substrs=["intel-pt"])
+self.traceLoad(traceSessionFilePath=trace_definition_file, substrs=["intel-pt"])
 
 target = self.dbg.GetSelectedTarget()
 process = target.GetProcess()
@@ -90,11 +94,12 @@
   Errors:
 Number of TSC decoding errors: 0'''])
 
+@testSBAPIAndCommands
 def testLoadInvalidTraces(self):
 src_dir = self.getSourceDir()
+trace_definition_file = os.path.join(src_dir, "intelpt-trace", "trace_bad.json")
 # We test first an invalid type
-self.expect("trace load -v " + os.path.join(src_dir, "intelpt-trace", "trace_bad.json"), error=True,
-  substrs=['''error: expected object at traceSession.processes[0]
+self.traceLoad(traceSessionFilePath=trace_definition_file, error=True, substrs=['''error: expected object at traceSession.processes[0]
 
 Context:
 {
Index: lldb/source/Target/Trace.cpp
===
--- lldb/source/Target/Trace.cpp
+++ lldb/source/Target/Trace.cpp
@@ -89,6 +89,30 @@
   plugin

[Lldb-commits] [PATCH] D128107: [trace] Add LoadTraceFromFile to SBDebugger and SBTrace

2022-06-17 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/API/SBDebugger.h:403
+  /// trace session.
+  SBTrace LoadTraceFromFile(SBError &error, const char *trace_file_path);
+

Can this take a filespec? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128107

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