[Lldb-commits] [PATCH] D131693: [lldb][Breakpoint] Prevent crash when resolving regex breakpoint on functions with asm declaration

2022-08-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 452098.
Michael137 added a comment.

- Skip Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131693

Files:
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
  
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(void) asm("NonStandardMangling");
+
+int func_with_asm(void) { return 10; }
+
+int main() {
+  func_with_asm();
+  return 0;
+}
Index: 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
@@ -0,0 +1,51 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestSourceRegexBreakpointsWithAsm(TestBase):
+
+@skipIfWindows
+def test_restrictions(self):
+self.build()
+self.source_regex_restrictions()
+
+def source_regex_restrictions(self):
+""" Test restricting source expressions to to functions with 
non-standard mangling."""
+# Create a target by the debugger.
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+asm_tag = "NonStandardMangling"
+
+# Sanity check that we can set breakpoint on non-standard mangled name
+main_break = target.BreakpointCreateByName(asm_tag)
+
+expected_num_locations = 1
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
+
+# Check regex on asm tag restricted to function names
+func_names = lldb.SBStringList()
+func_names.AppendString('main')
+func_names.AppendString('func')
+func_names.AppendString('')
+func_names.AppendString('NonStandardMangling')
+
+main_break = target.BreakpointCreateBySourceRegex(
+asm_tag, lldb.SBFileSpecList(), lldb.SBFileSpecList(), func_names)
+
+expected_num_locations = 0
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -122,8 +122,9 @@
 sc_ctx
 .GetFunctionName(
 Mangled::NamePreference::ePreferDemangledWithoutArguments)
-.AsCString());
-if (!m_function_names.count(name)) {
+.AsCString(""));
+
+if (name.empty() || !m_function_names.count(name)) {
   sc_to_remove.push_back(i);
 }
   }


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(void) asm("NonStandardMangling");
+
+int func_with_asm(void) { return 10; }
+
+int main() {
+  func_with_asm();
+  return 0;
+}
Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
@@ -0,0 +1,51 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import

[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-08-12 Thread Ilya Biryukov via Phabricator via lldb-commits
ilya-biryukov added a comment.

In D112374#3716982 , @mizvekov wrote:

> We even match GCC now: https://gcc.godbolt.org/z/WT93WdE7e
>
> Ie we are printing the function type as-written correctly now.

We don't match GCC in other cases. GCC seems to always print the type name 
without qualifiers, clang used to always print with qualifiers, but will now 
print what was typed in the code, see https://gcc.godbolt.org/z/jznncGboM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [lldb] 9ba71d0 - [lldb] [gdb-remote] Remove unimplemented ProcessIDIsValid() (NFC)

2022-08-12 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2022-08-12T11:17:15+02:00
New Revision: 9ba71d03b0f0ec82b7f74ec52818236237680348

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

LOG: [lldb] [gdb-remote] Remove unimplemented ProcessIDIsValid() (NFC)

This method is not implemented and not referenced anywhere in the code.

Sponsored by: The FreeBSD Foundation

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 6ad9b3effe7b0..8e2a462f61212 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -308,8 +308,6 @@ class ProcessGDBRemote : public Process,
 
   bool HasExited(lldb::StateType state) { return state == lldb::eStateExited; }
 
-  bool ProcessIDIsValid() const;
-
   void Clear();
 
   bool DoUpdateThreadList(ThreadList &old_thread_list,



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


[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-08-12 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov added a comment.

In D112374#3718417 , @ilya-biryukov 
wrote:

> We don't match GCC in other cases. GCC seems to always print the type name 
> without qualifiers, clang used to always print with qualifiers, but will now 
> print what was typed in the code, see https://gcc.godbolt.org/z/jznncGboM

Well, Clang always tried printing them as typed in the code, except for this 
bug that we fixed here.

It would fail to represent a name written without both qualifiers and 
elaboration. If it had either or both, it would print the name as-written.
Example: https://gcc.godbolt.org/z/3xv4xxYf1

So, consider that relying on `__PRETTY_FUNCTION__` output was pretty unreliable 
from the get go, as you already had different results across compilers.

Also, consider these other points:

- This patch had a lot of test churn, but no test churn on 
`__PRETTY_FUNCTION__` tests, so I think this means that this was pretty much 
untested on Clang's part.
- The implementation relies on reconstructing the function signature as-written 
from the AST. So any improvement in that area would cause changes, or extra 
complexity to keep the old limitations around behind switches.
- There seems to be no attempt to enforce the stability of this result at the 
architectural level in Clang. It relies directly on the type printer, which is 
used all around in many different scenarios, and you can see that folks here 
just make changes to the type printer for cosmetic reasons, with little vetting 
and no concern for stability.

Otherwise, the type printer is customizable with Policies, so you could think 
of adding a new one to customize this behavior. But even then, I think the old 
Clang behavior was too weird to make an option for it.
What would we even call such a policy, something like 
`InventFullNameQualifierIfNeitherQualifiedOrElaborated`?

We could make a separate type printer system for such a macro, stripping the 
function signature of any decoration and using a stable policy, and create all 
the test cases for it so that we don't regress accidentally.
We could leave the current macro as is, printing the signature as written, and 
add this new one behind a new macro, so that the user gets to choose between 
`__PRETTY_FUNCTION__` and `__NAKED_FUNCTION__`? 🤔


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D131758: [lldb] [gdb-remote] Include PID in vCont packets if multiprocess

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

Try to always send vCont packets and include the PID in them if running
multiprocess.  This is necessary to ensure that with the upcoming full
multiprocess support always resumes the correct process without having
to resort to the legacy Hc packets.

Sponsored by: The FreeBSD Foundation


https://reviews.llvm.org/D131758

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestContinue.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestContinue.py
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/TestContinue.py
@@ -0,0 +1,87 @@
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+
+class TestContinue(GDBRemoteTestBase):
+class BaseResponder(MockGDBServerResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+;multiprocess+"
+
+def qfThreadInfo(self):
+return "mp400.401"
+
+def haltReason(self):
+return "S13"
+
+def cont(self):
+return "W01"
+
+def other(self, packet):
+if packet == "vCont?":
+return "vCont;c;C;s;S"
+if packet.startswith("vCont;"):
+return "W00"
+return ""
+
+def test_continue_no_multiprocess(self):
+class MyResponder(self.BaseResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+"
+
+def qfThreadInfo(self):
+return "m401"
+
+self.server.responder = MyResponder()
+self.runCmd("platform select remote-linux")
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+self.assertPacketLogContains(["vCont;C13:401"])
+
+def test_continue_no_vCont(self):
+class MyResponder(self.BaseResponder):
+def qSupported(self, client_supported):
+return "PacketSize=3fff;QStartNoAckMode+"
+
+def qfThreadInfo(self):
+return "m401"
+
+def other(self, packet):
+return ""
+
+self.server.responder = MyResponder()
+self.runCmd("platform select remote-linux")
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+self.assertPacketLogContains(["Hc401", "C13"])
+
+def test_continue_multiprocess(self):
+class MyResponder(self.BaseResponder):
+pass
+
+self.server.responder = MyResponder()
+self.runCmd("platform select remote-linux")
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+self.assertPacketLogContains(["vCont;C13:p400.401"])
+
+def test_step_multiprocess(self):
+class MyResponder(self.BaseResponder):
+def other(self, packet):
+if packet == "vCont?":
+return "vCont;c;C;s;S"
+if packet.startswith("vCont;C"):
+return "S13"
+if packet.startswith("vCont;s"):
+return "W00"
+return ""
+
+self.server.responder = MyResponder()
+self.runCmd("platform select remote-linux")
+target = self.createTarget("a.yaml")
+process = self.connect(target)
+thread = process.GetSelectedThread()
+thread.StepInstruction(False)
+self.assertPacketLogContains(["vCont;s:p400.401"])
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1186,11 +1186,16 @@
 StreamString continue_packet;
 bool continue_packet_error = false;
 if (m_gdb_comm.HasAnyVContSupport()) {
+  std::string pid_prefix;
+  if (GetID() != LLDB_INVALID_PROCESS_ID &&
+  m_gdb_comm.GetMultiprocessSupported())
+pid_prefix = llvm::formatv("p{0:x-}.", GetID());
+
   if (m_continue_c_tids.size() == num_threads ||
   (m_continue_c_tids.empty() && m_continue_C_tids.empty() &&
m_continue_s_tids.empty() && m_continue_S_tids.empty())) {
-// All threads are continuing, just send a "c" packet
-continue_packet.PutCString("c");
+// All threads are continuing
+co

[Lldb-commits] [PATCH] D131761: [LLDB] Remove __future__ imports from tests

2022-08-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: wenlei.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Not needed now that we require python 3.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131761

Files:
  lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
  lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py
  lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
  lldb/test/API/api/multiple-targets/TestMultipleTargets.py
  lldb/test/API/api/multithreaded/TestMultithreaded.py
  lldb/test/API/arm/emulation/TestEmulations.py
  lldb/test/API/benchmarks/continue/TestBenchmarkContinue.py
  lldb/test/API/benchmarks/expression/TestExpressionCmd.py
  lldb/test/API/benchmarks/expression/TestRepeatedExprs.py
  lldb/test/API/benchmarks/frame_variable/TestFrameVariableResponse.py
  lldb/test/API/benchmarks/libcxxlist/TestBenchmarkLibcxxList.py
  lldb/test/API/benchmarks/libcxxmap/TestBenchmarkLibcxxMap.py
  lldb/test/API/benchmarks/startup/TestStartupDelays.py
  lldb/test/API/benchmarks/stepping/TestSteppingSpeed.py
  lldb/test/API/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py
  lldb/test/API/commands/command/container/welcome.py
  lldb/test/API/commands/command/script/decorated.py
  lldb/test/API/commands/command/script/import/bar/bar.py
  lldb/test/API/commands/command/script/import/foo/bar/foobar.py
  lldb/test/API/commands/command/script/import/foo/foo.py
  lldb/test/API/commands/command/script/import/foo/foo2.py
  lldb/test/API/commands/command/script/import/thepackage/__init__.py
  lldb/test/API/commands/command/script/mysto.py
  lldb/test/API/commands/command/script/welcome.py
  lldb/test/API/commands/command/script_alias/tcsacmd.py
  lldb/test/API/commands/command/source/my.py
  lldb/test/API/commands/expression/no-deadlock/TestExprDoesntBlock.py
  lldb/test/API/commands/process/launch/TestProcessLaunch.py
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  
lldb/test/API/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
  lldb/test/API/commands/watchpoints/watchpoint_events/TestWatchpointEvents.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py
  lldb/test/API/functionalities/breakpoint/breakpoint_command/bktptcmd.py
  
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
  lldb/test/API/functionalities/breakpoint/cpp/TestCPPBreakpointLocations.py
  lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py
  lldb/test/API/functionalities/conditional_break/TestConditionalBreak.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSNumber.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py
  lldb/test/API/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
  
lldb/test/API/functionalities/data-formatter/vector-types/TestVectorTypesFormatting.py
  lldb/test/API/functionalities/exec/TestExec.py
  lldb/test/API/functionalities/gdb_remote_client/TestAArch64XMLRegOffsets.py
  lldb/test/API/functionalities/gdb_remote_client/TestArmRegisterDefinition.py
  lldb/test/API/functionalities/gdb_remote_client/TestFork.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerNoTargetXML.py
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
  
lldb/test/API/functionalities/gdb_remote_client/TestJLink6Armv7RegisterDefinition.py
  lldb/test/API/functionalities/gdb_remote_client/TestMultiprocess.py
  lldb/test/API/functionalities/gdb_remote_client/TestNestedRegDefinitions.py
  lldb/test/API/functionalities/gdb_remote_client/TestNoGPacketSupported.py
  lldb/test/API/functionalities/gdb_remote_client/TestNoWatchpointSupportInfo.py
  lldb/test/API/functionalities/gdb_remote_client/TestPartialGPacket.py
  lldb/test/API/functionalities/gdb_remote_client/TestRegDefinitionInParts.py
  lldb/test/API/functionalities/gdb_remote_client/TestRemoteRegNums.py
  lldb/test/API/functionalities/gdb_remote_client/TestRestartBug.py
  lldb/test/API/functionalities/gdb_remote_client/TestTargetXMLArch.py
  lldb/test/API/functionalities/inferior-assert/TestInferiorAssert.py
  lldb/test/API/functionalities/load_unload/TestLoadUnload.py
  
lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
  lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
  
lldb/test/API/functionalities/plugins/python_os_plugin/stepping_plugin_threads/TestOSPluginStepping.py
  lldb/test/API/functionalities/postmortem/elf-core/TestLinuxC

[Lldb-commits] [PATCH] D131335: WIP: [lldb] abi_tag support 3/3 - Use mangle tree API to determine approximate mangled matches

2022-08-12 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

So one of the problems with constructing a more accurate AST is that we don't 
have enough information in DWARF to construct a unspecialised 
FunctionProtoType, i.e., `FunctionProtoType 0x1282fe870 'bool (T)'` as opposed 
to the current `FunctionProtoType 0x1282fe870 '_Bool (struct A::B)' cdecl`.

This was also noted in https://reviews.llvm.org/D61044

> creating the correct templated signature is just impossible. DWARF contains 
> the template parameter, but not their mapping to the actual function 
> signature. In the above example I know that foo has been parametrized by the 
> type ‘int’ (and that T was the template argument name), but I don’t know 
> whether the return type or the first argument were templated or plain ints…

E.g., here is an example DWARF entry for a template function:

  0x01f8: DW_TAG_subprogram
DW_AT_low_pc  (0x00013f00)
DW_AT_high_pc (0x00013f18)
DW_AT_APPLE_omit_frame_ptr(true)
DW_AT_frame_base  (DW_OP_reg31 WSP)
DW_AT_linkage_name
("_ZN1A10multiParamINS_1BEiEEbT_T0_S1_")
DW_AT_name("multiParam")
DW_AT_decl_file   ("adl.cpp")
DW_AT_decl_line   (34)
DW_AT_type(0x007d "bool")
DW_AT_external(true)
  
  0x0215:   DW_TAG_formal_parameter
  DW_AT_location  (DW_OP_fbreg +15)
  DW_AT_name  ("p1")
  DW_AT_decl_file ("adl.cpp")
  DW_AT_decl_line (34)
  DW_AT_type  (0x0089 "A::B")
  
  0x0223:   DW_TAG_formal_parameter
  DW_AT_location  (DW_OP_fbreg +8)
  DW_AT_name  ("p2")
  DW_AT_decl_file ("adl.cpp")
  DW_AT_decl_line (34)
  DW_AT_type  (0x0317 "int")
  
  0x0231:   DW_TAG_formal_parameter
  DW_AT_location  (DW_OP_fbreg +14)
  DW_AT_name  ("p3")
  DW_AT_decl_file ("adl.cpp")
  DW_AT_decl_line (34)
  DW_AT_type  (0x0089 "A::B")
  
  0x023f:   DW_TAG_template_type_parameter
  DW_AT_type  (0x0089 "A::B")
  DW_AT_name  ("First")
  
  0x0248:   DW_TAG_template_type_parameter
  DW_AT_type  (0x0317 "int")
  DW_AT_name  ("Second")

Just from this we wouldn't be able to reconstruct the function prototype (which 
we need to create a more accurate `FunctionTemplateDecl`). Mainly we don't know 
whether the formal parameters are of a template parameter type or a concrete 
type. Maybe someone has an idea of how to get the function prototype through 
other means at the point where we need to create the `FunctionTemplateDecl`, 
but I didn't manage to yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131335

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


[Lldb-commits] [PATCH] D131772: [LLDB] Remove __future__ imports from examples

2022-08-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Not needed now that we require python 3.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131772

Files:
  lldb/examples/customization/bin-utils/binutils.py
  lldb/examples/customization/import-python/importcmd.py
  lldb/examples/customization/pwd-cd-and-system/utils.py
  lldb/examples/darwin/heap_find/heap.py
  lldb/examples/python/bsd.py
  lldb/examples/python/cmdtemplate.py
  lldb/examples/python/delta.py
  lldb/examples/python/diagnose_nsstring.py
  lldb/examples/python/diagnose_unwind.py
  lldb/examples/python/gdbremote.py
  lldb/examples/python/globals.py
  lldb/examples/python/jump.py
  lldb/examples/python/lldb_module_utils.py
  lldb/examples/python/lldbtk.py
  lldb/examples/python/mach_o.py
  lldb/examples/python/memory.py
  lldb/examples/python/performance.py
  lldb/examples/python/process_events.py
  lldb/examples/python/pytracer.py
  lldb/examples/python/scripted_step.py
  lldb/examples/python/shadow.py
  lldb/examples/python/sources.py
  lldb/examples/python/stacks.py
  lldb/examples/python/symbolication.py
  lldb/examples/python/types.py
  lldb/examples/scripting/tree_utils.py
  lldb/examples/summaries/cocoa/CFBitVector.py
  lldb/examples/summaries/cocoa/Logger.py
  lldb/examples/summaries/cocoa/NSNumber.py
  lldb/examples/synthetic/gnu_libstdcpp.py

Index: lldb/examples/synthetic/gnu_libstdcpp.py
===
--- lldb/examples/synthetic/gnu_libstdcpp.py
+++ lldb/examples/synthetic/gnu_libstdcpp.py
@@ -1,4 +1,3 @@
-from __future__ import division
 import lldb.formatters.Logger
 
 # C++ STL formatters for LLDB
Index: lldb/examples/summaries/cocoa/NSNumber.py
===
--- lldb/examples/summaries/cocoa/NSNumber.py
+++ lldb/examples/summaries/cocoa/NSNumber.py
@@ -8,8 +8,6 @@
 # example summary provider for NSNumber
 # the real summary is now C++ code built into LLDB
 
-from __future__ import print_function
-
 import lldb
 import ctypes
 import lldb.runtime.objc.objc_runtime
Index: lldb/examples/summaries/cocoa/Logger.py
===
--- lldb/examples/summaries/cocoa/Logger.py
+++ lldb/examples/summaries/cocoa/Logger.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
 import sys
 import os.path
 import inspect
Index: lldb/examples/summaries/cocoa/CFBitVector.py
===
--- lldb/examples/summaries/cocoa/CFBitVector.py
+++ lldb/examples/summaries/cocoa/CFBitVector.py
@@ -5,7 +5,6 @@
 See https://llvm.org/LICENSE.txt for license information.
 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 """
-from __future__ import print_function
 
 # summary provider for CF(Mutable)BitVector
 import lldb
Index: lldb/examples/scripting/tree_utils.py
===
--- lldb/examples/scripting/tree_utils.py
+++ lldb/examples/scripting/tree_utils.py
@@ -18,8 +18,6 @@
 http://lldb.llvm.org/scripting.html
 """
 
-from __future__ import print_function
-
 
 def DFS(root, word, cur_path):
 """
Index: lldb/examples/python/types.py
===
--- lldb/examples/python/types.py
+++ lldb/examples/python/types.py
@@ -9,8 +9,6 @@
 #   (lldb) command script import /path/to/cmdtemplate.py
 #--
 
-from __future__ import print_function
-
 import platform
 import os
 import re
Index: lldb/examples/python/symbolication.py
===
--- lldb/examples/python/symbolication.py
+++ lldb/examples/python/symbolication.py
@@ -26,7 +26,6 @@
 #   PYTHONPATH=/path/to/LLDB.framework/Resources/Python ./crashlog.py ~/Library/Logs/DiagnosticReports/a.crash
 #--
 
-from __future__ import print_function
 import lldb
 import optparse
 import os
Index: lldb/examples/python/stacks.py
===
--- lldb/examples/python/stacks.py
+++ lldb/examples/python/stacks.py
@@ -1,5 +1,4 @@
 #!/usr/bin/env python
-from __future__ import print_function
 import lldb
 import optparse
 import shlex
Index: lldb/examples/python/sources.py
===
--- lldb/examples/python/sources.py
+++ lldb/examples/python/sources.py
@@ -1,5 +1,4 @@
 #!/usr/bin/env python
-from __future__ import print_function
 
 import lldb
 import shlex
Index: lldb/examples/python/shadow.py
===
--- lldb/examples/python/shadow.py
+++ lldb/examples/python/shadow.py
@@ -1,5 +1,4 @@
 #!

[Lldb-commits] [PATCH] D131664: [LLDB][ARM] Remove unused LoadPseudoRegistersFromFrame function

2022-08-12 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Thanks for the review folks. I'll just wait for Jonas to confirm (probably not 
used downstream but no rush to land this).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131664

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


[Lldb-commits] [PATCH] D131772: [LLDB] Remove __future__ imports from examples

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.
This revision is now accepted and ready to land.

thanks I had the same thought


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131772

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


[Lldb-commits] [PATCH] D131761: [LLDB] Remove __future__ imports from tests

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.
This revision is now accepted and ready to land.

👍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131761

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


[Lldb-commits] [PATCH] D131783: [LLDB][JIT] Set processor for ARM architecture

2022-08-12 Thread Pavel Kosov via Phabricator via lldb-commits
kpdev42 created this revision.
kpdev42 added reviewers: clayborg, davide, k8stone, DavidSpickett, 
granata.enrico.
kpdev42 added a project: LLDB.
Herald added subscribers: omjavaid, JDevlieghere, kristof.beyls.
Herald added a project: All.
kpdev42 requested review of this revision.
Herald added a subscriber: lldb-commits.

Patch sets ARM cpu, before compiling JIT code. This enables FastISel for armv6 
and higher CPUs and allows using hardware FPU

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131783

Files:
  lldb/source/Utility/ArchSpec.cpp
  lldb/test/API/lang/c/fpeval/TestFPEval.py


Index: lldb/test/API/lang/c/fpeval/TestFPEval.py
===
--- lldb/test/API/lang/c/fpeval/TestFPEval.py
+++ lldb/test/API/lang/c/fpeval/TestFPEval.py
@@ -19,7 +19,6 @@
 # Find the line number to break inside main().
 self.line = line_number('main.c', '// Set break point at this line.')
 
-@skipIf(archs=no_match(['amd64', 'x86_64', 'arm64'])) # lldb jitter 
incorrectly evals function with FP args on 32 bit arm
 def test(self):
 """Test floating point expressions while jitter is disabled."""
 self.build()
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -583,7 +583,6 @@
 
 std::string ArchSpec::GetClangTargetCPU() const {
   std::string cpu;
-
   if (IsMIPS()) {
 switch (m_core) {
 case ArchSpec::eCore_mips32:
@@ -630,6 +629,9 @@
   break;
 }
   }
+
+  if (GetTriple().isARM())
+cpu = GetTriple().getARMCPUForArch("").str();
   return cpu;
 }
 


Index: lldb/test/API/lang/c/fpeval/TestFPEval.py
===
--- lldb/test/API/lang/c/fpeval/TestFPEval.py
+++ lldb/test/API/lang/c/fpeval/TestFPEval.py
@@ -19,7 +19,6 @@
 # Find the line number to break inside main().
 self.line = line_number('main.c', '// Set break point at this line.')
 
-@skipIf(archs=no_match(['amd64', 'x86_64', 'arm64'])) # lldb jitter incorrectly evals function with FP args on 32 bit arm
 def test(self):
 """Test floating point expressions while jitter is disabled."""
 self.build()
Index: lldb/source/Utility/ArchSpec.cpp
===
--- lldb/source/Utility/ArchSpec.cpp
+++ lldb/source/Utility/ArchSpec.cpp
@@ -583,7 +583,6 @@
 
 std::string ArchSpec::GetClangTargetCPU() const {
   std::string cpu;
-
   if (IsMIPS()) {
 switch (m_core) {
 case ArchSpec::eCore_mips32:
@@ -630,6 +629,9 @@
   break;
 }
   }
+
+  if (GetTriple().isARM())
+cpu = GetTriple().getARMCPUForArch("").str();
   return cpu;
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131761: [LLDB] Remove __future__ imports from tests

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131761

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


[Lldb-commits] [PATCH] D131772: [LLDB] Remove __future__ imports from examples

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131772

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


[Lldb-commits] [PATCH] D131741: [lldb] Skip target variable tests on Darwin because of chained fixups

2022-08-12 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D131741

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


[Lldb-commits] [lldb] abe9599 - [lldb] Skip target variable tests on Darwin because of chained fixups

2022-08-12 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-08-12T10:23:15-07:00
New Revision: abe9599f04f07baae46f4123d4c43d330f34df52

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

LOG: [lldb] Skip target variable tests on Darwin because of chained fixups

When targeting macOS Ventura, ld64 will use authenticated fixups for
x86_64 as well as arm64 (where that has always been the case). This
results in test failures when using an Xcode 14 toolchain on an Intel
mac running macOS Ventura:

  Failed Tests (3):
lldb-api :: commands/target/basic/TestTargetCommand.py
lldb-api :: lang/c/global_variables/TestGlobalVariables.py
lldb-api :: lang/cpp/char8_t/TestCxxChar8_t.py

Rather than trying to come up with a sophisticated decorator based off
the deployment target, I marked them all as skipped with a comment
explaining why.

Differential revision: https://reviews.llvm.org/D131741

Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py
lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index efbde6acd957..f377bc0f43d2 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,7 @@ def test_target_command(self):
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +51,7 @@ def test_target_variable_command(self):
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}

diff  --git a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py 
b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
index f3668f905535..7f5c5295bf0e 100644
--- a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,8 @@ def setUp(self):
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+@skipIfDarwin # Chained Fixups
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""

diff  --git a/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py 
b/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
index ed9f60419870..0cf1b1a4e65f 100644
--- a/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ b/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,8 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+@skipIfDarwin # Chained Fixups
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()



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


[Lldb-commits] [PATCH] D131741: [lldb] Skip target variable tests on Darwin because of chained fixups

2022-08-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabe9599f04f0: [lldb] Skip target variable tests on Darwin 
because of chained fixups (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131741

Files:
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,8 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+@skipIfDarwin # Chained Fixups
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,8 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+@skipIfDarwin # Chained Fixups
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,7 @@
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +51,7 @@
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,8 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+@skipIfDarwin # Chained Fixups
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,8 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+@skipIfDarwin # Chained Fixups
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,7 @@
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@skipIfDarwin # Chained Fixups
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +51,7 @@
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@skipIfDarwin # Chained Fixups
 def test_target_variable_command_no_fail(self):
 """Test 'tar

[Lldb-commits] [PATCH] D131795: [LLDB] Fix the 'default' switch case in GetCompatibleArchs()

2022-08-12 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon created this revision.
fixathon added reviewers: clayborg, JDevlieghere.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
fixathon edited the summary of this revision.
fixathon published this revision for review.
fixathon added a comment.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This is an unfinished draft up for discussion.


Moving the discussion of this issue that started in 
https://reviews.llvm.org/D113155 to here for clarity.

1. The 'default' switch case falls through to ArchSpec::Core_arm_arm64 due to 
the missing 'break', which seems wrong..

2. The following test is failing after #1 is corrected. Additionally, @clayborg 
discovered mismatch in cputype between qHostInfo and qProcessInfo.

However, even then the test appears to be failing. GetCompatibleArchs() in 
PlatformDarwin.cpp receives ArchSpec::kCore_invalid
Tested on M1  hardware running MacOS 12.5

$ llvm-lit -sv  
llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
..
AssertionError: 'host' != 'remote-ios'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131795

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py


Index: lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
@@ -19,7 +19,7 @@
 return MockGDBServerResponder.respond(self, packet)
 
 def qHostInfo(self):
-return 
"cputype:16777223;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;"
 % self.host_ostype
+return 
"cputype:16777228;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;"
 % self.host_ostype
 
 def qProcessInfo(self):
 return 
"pid:a860;parent-pid:d2a0;real-uid:1f5;real-gid:14;effective-uid:1f5;effective-gid:14;cputype:10c;cpusubtype:2;ptrsize:8;ostype:ios;vendor:apple;endian:little;"
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -498,7 +498,7 @@
 static llvm::ArrayRef GetCompatibleArchs(ArchSpec::Core core) {
   switch (core) {
   default:
-[[fallthrough]];
+break;
   case ArchSpec::eCore_arm_arm64e: {
 static const char *g_arm64e_compatible_archs[] = {
 "arm64e","arm64","armv7","armv7f",   "armv7k",   "armv7s",


Index: lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py
@@ -19,7 +19,7 @@
 return MockGDBServerResponder.respond(self, packet)
 
 def qHostInfo(self):
-return "cputype:16777223;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;" % self.host_ostype
+return "cputype:16777228;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;" % self.host_ostype
 
 def qProcessInfo(self):
 return "pid:a860;parent-pid:d2a0;real-uid:1f5;real-gid:14;effective-uid:1f5;effective-gid:14;cputype:10c;cpusubtype:2;ptrsize:8;ostype:ios;vendor:apple;endian:little;"
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -498,7 +498,7 @@
 static llvm::ArrayRef GetCompatibleArchs(ArchSpec::Core core) {
   switch (core) {
   default:
-[[fallthrough]];
+break;
   case ArchSpec::eCore_arm_arm64e: {
 static const char *g_arm64e_compatible_archs[] = {
 "arm64e","arm64","armv7","armv7f",   "armv7k",   "armv7s",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:133
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), 3,
+ "Queue %s is not stopped at breakpoint %d" %

mib wrote:
> Could you replace that with the enum variable ?
Yes the enum variable would be better here



Comment at: lldb/test/API/macosx/queues/TestQueues.py:388
+# to be the name of the main thread
+queue_breakpoint = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)[3]
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())

mib wrote:
> Do you really need a `main_thread` variable since 
> `lldbutil.run_to_name_breakpoint` would return a tuple with `(target, 
> process, thread, bkpt)` ? Is the thread returned here different from the 
> `main_thread` you created above ?
The thread is the same actually, so it would probably be beneficial to just get 
the thread from `run_to_name_breakpoint` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova updated this revision to Diff 452267.
cassanova added a comment.

Use the enum name for the stop reason when asserting that the queues hit their 
breakpoints instead of just the raw number.

Also, get the main thread from `run_to_name_breakpoint` instead of getting it 
from `get_threads_stopped_at_breakpoint`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

Files:
  lldb/test/API/macosx/queues/TestQueues.py


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+ "Queue %s is not stopped at breakpoint %d" %
+ (queue1.GetName(), queue_breakpoint.GetID()))
+self.assertNotEqual(queue2_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+"Queue %s is stopped at breakpoint %d, but this 
breakpoint should only be hit for queue %s" %
+(queue2.GetName(), queue_breakpoint.GetID(), 
queue_breakpoint.GetQueueName()))
+
 def queues(self):
 """Test queues inspection SB APIs without libBacktraceRecording."""
 exe = self.getBuildArtifact("a.out")
@@ -183,6 +198,15 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+process_info = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)
+main_thread = process_info[2]
+queue_breakpoint = process_info[3]
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 # We have threads running with all the different dispatch QoS service
 # levels - find those threads and check that we can get the correct
 # QoS name for each of them.
@@ -291,6 +315,7 @@
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
 
+main_thread = threads[0]
 self.inferior_process = process
 
 libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib")
@@ -358,6 +383,15 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+process_info = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)
+main_thread = process_info[2]
+queue_breakpoint = process_info[3]
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 self.assertTrue(queue_performer_2.GetPendingItemAtIndex(
 0).IsValid(), "queue 2's pending item #0 is valid")
 
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol(


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), queue1.GetName()))
+self.assertTrue(

[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:204-206
+process_info = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)
+main_thread = process_info[2]
+queue_breakpoint = process_info[3]

Why not do it this way ? Takes less space and it's easier to read (for people 
who don't know what `process_info[2]` and `process_info[3]` refers to)



Comment at: lldb/test/API/macosx/queues/TestQueues.py:318
 
+main_thread = threads[0]
 self.inferior_process = process

Do you still need this ?



Comment at: lldb/test/API/macosx/queues/TestQueues.py:389-391
+process_info = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)
+main_thread = process_info[2]
+queue_breakpoint = process_info[3]

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131795: [LLDB] Fix the 'default' switch case in GetCompatibleArchs()

2022-08-12 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

> However, even if that is corrected the test appears to be failing. 
> GetCompatibleArchs() in PlatformDarwin.cpp receives ArchSpec::kCore_invalid

Can you set a breakpoint and see why an invalid core is being passed into this 
function? This shouldn't be happening IMHO




Comment at: 
lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py:22
 def qHostInfo(self):
-return 
"cputype:16777223;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;"
 % self.host_ostype
+return 
"cputype:16777228;cpusubtype:2;ostype:%s;vendor:apple;os_version:10.15.4;maccatalyst_version:13.4;endian:little;ptrsize:8;"
 % self.host_ostype
 

I believe that Jonas stated in the other diff that this was intentional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131795

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova updated this revision to Diff 452275.
cassanova added a comment.

All variables needed from `run_to_name_breakpoint` are obtained in one line 
rather than getting them by index.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

Files:
  lldb/test/API/macosx/queues/TestQueues.py


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+ "Queue %s is not stopped at breakpoint %d" %
+ (queue1.GetName(), queue_breakpoint.GetID()))
+self.assertNotEqual(queue2_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+"Queue %s is stopped at breakpoint %d, but this 
breakpoint should only be hit for queue %s" %
+(queue2.GetName(), queue_breakpoint.GetID(), 
queue_breakpoint.GetQueueName()))
+
 def queues(self):
 """Test queues inspection SB APIs without libBacktraceRecording."""
 exe = self.getBuildArtifact("a.out")
@@ -183,6 +198,13 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+target, process, main_thread, queue_breakpoint = 
lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 # We have threads running with all the different dispatch QoS service
 # levels - find those threads and check that we can get the correct
 # QoS name for each of them.
@@ -291,6 +313,7 @@
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
 
+main_thread = threads[0]
 self.inferior_process = process
 
 libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib")
@@ -358,6 +381,13 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+target, process, main_thread, queue_breakpoint = 
lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 self.assertTrue(queue_performer_2.GetPendingItemAtIndex(
 0).IsValid(), "queue 2's pending item #0 is valid")
 
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol(


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % (queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), lldb.eStopReasonBreakpoint,

[Lldb-commits] [PATCH] D131630: [trace][intel pt] Fix per-psb packet decoding

2022-08-12 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked 4 inline comments as done.
wallace added inline comments.



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:476-478
+  if (event.has_tsc) {
+tsc = event.tsc;
+break;

jj10306 wrote:
> so is this inner loop what's actually doing the work of getting to the next 
> PSB? is the assumption that if an event has a tsc then it's a PSB?
> Can you explain what the two different while loops are doing?
discussed offline. Every invocation to pt_qry_event will get a new PSB. the 
event loop is just for getting the first TSC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131630

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:204-206
+process_info = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)
+main_thread = process_info[2]
+queue_breakpoint = process_info[3]

mib wrote:
> Why not do it this way ? Takes less space and it's easier to read (for people 
> who don't know what `process_info[2]` and `process_info[3]` refers to)
This is a much cleaner way to write it :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:131
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))

missed assertEqual here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.

LGTM with @teemperor feedback !




Comment at: lldb/test/API/macosx/queues/TestQueues.py:131
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))

teemperor wrote:
> missed assertEqual here?
+1!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:131
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertTrue(queue_breakpoint.GetHitCount() == 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))

mib wrote:
> teemperor wrote:
> > missed assertEqual here?
> +1!
Yes, adding this in 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-12 Thread Chelsea Cassanova via Phabricator via lldb-commits
cassanova updated this revision to Diff 452302.
cassanova added a comment.

Changed an `assertTrue` to `assertEqual`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

Files:
  lldb/test/API/macosx/queues/TestQueues.py


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the 
breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), 
queue1.GetName()))
+self.assertEqual(queue_breakpoint.GetHitCount(), 1,
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+ "Queue %s is not stopped at breakpoint %d" %
+ (queue1.GetName(), queue_breakpoint.GetID()))
+self.assertNotEqual(queue2_thread.GetStopReason(), 
lldb.eStopReasonBreakpoint,
+"Queue %s is stopped at breakpoint %d, but this 
breakpoint should only be hit for queue %s" %
+(queue2.GetName(), queue_breakpoint.GetID(), 
queue_breakpoint.GetQueueName()))
+
 def queues(self):
 """Test queues inspection SB APIs without libBacktraceRecording."""
 exe = self.getBuildArtifact("a.out")
@@ -183,6 +198,13 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+target, process, main_thread, queue_breakpoint = 
lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 # We have threads running with all the different dispatch QoS service
 # levels - find those threads and check that we can get the correct
 # QoS name for each of them.
@@ -291,6 +313,7 @@
 if len(threads) != 1:
 self.fail("Failed to stop at breakpoint 1.")
 
+main_thread = threads[0]
 self.inferior_process = process
 
 libbtr_module_filespec = lldb.SBFileSpec("libBacktraceRecording.dylib")
@@ -358,6 +381,13 @@
 self.check_queues_threads_match_queue(queue_performer_2)
 self.check_queues_threads_match_queue(queue_performer_3)
 
+# Run the executable until the stopper function and get the breakpoint
+# that's created from that. Then set the queue name of the breakpoint
+# to be the name of the main thread
+target, process, main_thread, queue_breakpoint = 
lldbutil.run_to_name_breakpoint(self, "stopper", only_one_thread=False)
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())
+self.check_queue_breakpoints(main_thread.GetQueue(), 
queue_submittor_1, queue_breakpoint)
+
 self.assertTrue(queue_performer_2.GetPendingItemAtIndex(
 0).IsValid(), "queue 2's pending item #0 is valid")
 
self.assertTrue(queue_performer_2.GetPendingItemAtIndex(0).GetAddress().GetSymbol(


Index: lldb/test/API/macosx/queues/TestQueues.py
===
--- lldb/test/API/macosx/queues/TestQueues.py
+++ lldb/test/API/macosx/queues/TestQueues.py
@@ -122,6 +122,21 @@
  t.GetQueue().GetQueueID(),
 queue.GetQueueID()))
 
+def check_queue_breakpoints(self, queue1, queue2, queue_breakpoint):
+queue1_thread = queue1.GetThreadAtIndex(0)
+queue2_thread = queue2.GetThreadAtIndex(0)
+
+self.assertEqual(queue_breakpoint.GetQueueName(), queue1.GetName(),
+ "The breakpoint was set for queue %s, but the breakpoint's queue name is %s" % (queue_breakpoint.GetQueueName(), queue1.GetName()))
+self.assertEqual(queue_breakpoint.GetHitCount(), 1,
+"The breakpoint for queue %s has not been hit" % (queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), lldb.eStopReasonBreakpoint,
+ "Queue %s is not stopped at breakpoint %d" %
+

[Lldb-commits] [PATCH] D131630: [trace][intel pt] Fix per-psb packet decoding

2022-08-12 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 accepted this revision.
jj10306 added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:440
+Expected>
 lldb_private::trace_intel_pt::SplitTraceInContinuousExecutions(
+TraceIntelPT &trace_intel_pt, llvm::ArrayRef buffer,

consider renaming?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131630

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


[Lldb-commits] [PATCH] D131795: [LLDB] Fix the 'default' switch case in GetCompatibleArchs()

2022-08-12 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added a comment.
This revision now requires changes to proceed.

As mentioned in D113155  the difference in 
CPU type between `qHostInfo` and `qProcessInfo` is intentional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131795

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


[Lldb-commits] [PATCH] D131630: [trace][intel pt] Fix per-psb packet decoding

2022-08-12 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 452313.
wallace marked an inline comment as done.
wallace added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131630

Files:
  lldb/include/lldb/Target/TraceCursor.h
  lldb/include/lldb/Target/TraceDumper.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp
  lldb/source/Target/TraceCursor.cpp
  lldb/source/Target/TraceDumper.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/TestTraceEvents.py
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceStartStop.py

Index: lldb/test/API/commands/trace/TestTraceStartStop.py
===
--- lldb/test/API/commands/trace/TestTraceStartStop.py
+++ lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -168,29 +168,29 @@
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl'''])
+1: {ADDRESS_REGEX}movl'''])
 
 # We can reconstruct the instructions up to the second line
 self.expect("n")
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl .*
+1: {ADDRESS_REGEX}movl .*
   a.out`main \+ 11 at main.cpp:4
-2: {ADDRESS_REGEX}movl .*
-4: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
-6: {ADDRESS_REGEX}cmpl .*
-8: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5'''])
+3: {ADDRESS_REGEX}movl .*
+5: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
+7: {ADDRESS_REGEX}cmpl .*
+9: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5'''])
 
 self.expect("thread trace dump instructions",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 32 at main.cpp:4
-8: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5
-6: {ADDRESS_REGEX}cmpl .*
-4: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
-2: {ADDRESS_REGEX}movl .*
+9: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5
+7: {ADDRESS_REGEX}cmpl .*
+5: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
+3: {ADDRESS_REGEX}movl .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl .* '''])
+1: {ADDRESS_REGEX}movl .* '''])
 
 # We stop tracing
 self.expect("thread trace stop")
@@ -206,12 +206,12 @@
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
-0: {ADDRESS_REGEX}xorl'''])
+1: {ADDRESS_REGEX}xorl'''])
 
 self.expect("thread trace dump instructions",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
-0: {ADDRESS_REGEX}xorl'''])
+1: {ADDRESS_REGEX}xorl'''])
 
 self.expect("c")
 # Now the process has finished, so the commands should fail
Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -13,11 +13,11 @@
 trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
 self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
-  substrs=["19531: [20456511.000 ns] (error) expected tracing enabled event",
+  substrs=["19532: [20456513.000 ns] (error) expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
-   "19523: [19691630.216 ns] 0x00400ba7jg 0x400bb3"])
+   "9524: [19691630.226 ns] 0x00400ba7jg 0x400bb3"])
 self.expect("thread trace dump instructions 3 -t",
-  substrs=["67919: [19736130.084 ns] 0x00400bd7addl   $0x1, -0x4(%rbp)",
+  substrs=["61831: [19736134.073 ns] 0x00400bd7addl   $0x1, -0x4(%rbp)",
"m.out`bar() + 26 at multi_thread.cpp:20:6"])
 
 self.expect("thread trace dump info --json",
@@ -38,11 +38

[Lldb-commits] [lldb] e17cae0 - [trace][intel pt] Fix per-psb packet decoding

2022-08-12 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2022-08-12T15:13:48-07:00
New Revision: e17cae076c4727b99017927c3e8746db5bec6db7

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

LOG: [trace][intel pt] Fix per-psb packet decoding

The per-PSB packet decoding logic was wrong because it was assuming that 
pt_insn_get_sync_offset was being udpated after every PSB. Silly me, that is 
not true. It returns the offset of the PSB packet after invoking 
pt_insn_sync_forward regardless of how many PSBs are visited later. Instead, 
I'm now following the approach described in 
https://github.com/intel/libipt/blob/master/doc/howto_libipt.md#parallel-decode 
for parallel decoding, which is basically what we need.

A nasty error that happened because of this is that when we had two PSBs (A and 
B), the following was happening

1. PSB A was processed all the way up to the end of the trace, which includes 
PSB B.
2. PSB B was then processed until the end of the trace.

The instructions emitted by step 2. were also emitted as part of step 1. so our 
trace had duplicated chunks. This problem becomes worse when you many PSBs.

As part of making sure this diff is correct, I added some other features that 
are very useful.

- Added a "synchronization point" event to the TraceCursor, so we can inspect 
when PSBs are emitted.
- Removed the single-thread decoder. Now the per-cpu decoder and single-thread 
decoder use the same code paths.
- Use the query decoder to fetch PSBs and timestamps. It turns out that the 
pt_insn_sync_forward of the instruction decoder can move past several PSBs 
(this means that we could skip some TSCs). On the other hand, the 
pt_query_sync_forward method doesn't skip PSBs, so we can get more accurate 
sync events and timing information.
- Turned LibiptDecoder into PSBBlockDecoder, which decodes single PSB blocks. 
It is the fundamental processing unit for decoding.
- Added many comments, asserts and improved error handling for clarity.
- Improved DecodeSystemWideTraceForThread so that a TSC is emitted always 
before a cpu change event. This was a bug that was annoying me before.
- SplitTraceInContinuousExecutions and FindLowestTSCInTrace are now using the 
query decoder, which can identify precisely each PSB along with their TSCs.
- Added an "only-events" option to the trace dumper to inspect only events.

I did extensive testing and I think we should have an in-house testing CI. The 
LLVM buildbots are not capable of supporting testing post-mortem traces of 
hundreds of megabytes. I'll leave that for later, but at least for now the 
current tests were able to catch most of the issues I encountered when doing 
this task.

A sample output of a program that I was single stepping is the following. You 
can see that only one PSB is emitted even though stepping happened!

```
thread #1: tid = 3578223
0: (event) trace synchronization point [offset = 0x0xef0]
  a.out`main + 20 at main.cpp:29:20
1: 0x00402479leaq   -0x1210(%rbp), %rax
2: (event) software disabled tracing
3: 0x00402480movq   %rax, %rdi
4: (event) software disabled tracing
5: (event) software disabled tracing
6: 0x00402483callq  0x403bd4  ; 
std::vector>::vector at stl_vector.h:391:7
7: (event) software disabled tracing
  a.out`std::vector>::vector() at stl_vector.h:391:7
8: 0x00403bd4pushq  %rbp
9: (event) software disabled tracing
10: 0x00403bd5movq   %rsp, %rbp
11: (event) software disabled tracing
```

This is another trace of a long program with a few PSBs.
```
(lldb) thread trace dump instructions -E -f 
thread #1: 
tid = 3603082
0: (event) trace synchronization point [offset = 0x0x80]
47417: (event) software disabled tracing
129231: (event) trace synchronization point [offset = 0x0x800]
146747: (event) software disabled tracing
246076: (event) software disabled tracing
259068: (event) trace synchronization point [offset = 0x0xf78]
259276: (event) software disabled tracing
259278: (event) software disabled tracing
no more data
```

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

Added: 


Modified: 
lldb/include/lldb/Target/TraceCursor.h
lldb/include/lldb/Target/TraceDumper.h
lldb/include/lldb/lldb-enumerations.h
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h

[Lldb-commits] [PATCH] D131630: [trace][intel pt] Fix per-psb packet decoding

2022-08-12 Thread Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe17cae076c47: [trace][intel pt] Fix per-psb packet decoding 
(authored by Walter Erquinigo ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131630

Files:
  lldb/include/lldb/Target/TraceCursor.h
  lldb/include/lldb/Target/TraceDumper.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
  lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp
  lldb/source/Target/TraceCursor.cpp
  lldb/source/Target/TraceDumper.cpp
  lldb/test/API/commands/trace/TestTraceDumpInfo.py
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/TestTraceEvents.py
  lldb/test/API/commands/trace/TestTraceLoad.py
  lldb/test/API/commands/trace/TestTraceStartStop.py

Index: lldb/test/API/commands/trace/TestTraceStartStop.py
===
--- lldb/test/API/commands/trace/TestTraceStartStop.py
+++ lldb/test/API/commands/trace/TestTraceStartStop.py
@@ -168,29 +168,29 @@
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl'''])
+1: {ADDRESS_REGEX}movl'''])
 
 # We can reconstruct the instructions up to the second line
 self.expect("n")
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl .*
+1: {ADDRESS_REGEX}movl .*
   a.out`main \+ 11 at main.cpp:4
-2: {ADDRESS_REGEX}movl .*
-4: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
-6: {ADDRESS_REGEX}cmpl .*
-8: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5'''])
+3: {ADDRESS_REGEX}movl .*
+5: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
+7: {ADDRESS_REGEX}cmpl .*
+9: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5'''])
 
 self.expect("thread trace dump instructions",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 32 at main.cpp:4
-8: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5
-6: {ADDRESS_REGEX}cmpl .*
-4: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
-2: {ADDRESS_REGEX}movl .*
+9: {ADDRESS_REGEX}jle  .* ; <\+20> at main.cpp:5
+7: {ADDRESS_REGEX}cmpl .*
+5: {ADDRESS_REGEX}jmp  .* ; <\+28> at main.cpp:4
+3: {ADDRESS_REGEX}movl .*
   a.out`main \+ 4 at main.cpp:2
-0: {ADDRESS_REGEX}movl .* '''])
+1: {ADDRESS_REGEX}movl .* '''])
 
 # We stop tracing
 self.expect("thread trace stop")
@@ -206,12 +206,12 @@
 self.expect("thread trace dump instructions -f",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
-0: {ADDRESS_REGEX}xorl'''])
+1: {ADDRESS_REGEX}xorl'''])
 
 self.expect("thread trace dump instructions",
 patterns=[f'''thread #1: tid = .*
   a.out`main \+ 20 at main.cpp:5
-0: {ADDRESS_REGEX}xorl'''])
+1: {ADDRESS_REGEX}xorl'''])
 
 self.expect("c")
 # Now the process has finished, so the commands should fail
Index: lldb/test/API/commands/trace/TestTraceLoad.py
===
--- lldb/test/API/commands/trace/TestTraceLoad.py
+++ lldb/test/API/commands/trace/TestTraceLoad.py
@@ -13,11 +13,11 @@
 trace_description_file_path = os.path.join(src_dir, "intelpt-multi-core-trace", "trace.json")
 self.traceLoad(traceDescriptionFilePath=trace_description_file_path, substrs=["intel-pt"])
 self.expect("thread trace dump instructions 2 -t",
-  substrs=["19531: [20456511.000 ns] (error) expected tracing enabled event",
+  substrs=["19532: [20456513.000 ns] (error) expected tracing enabled event",
"m.out`foo() + 65 at multi_thread.cpp:12:21",
-   "19523: [19691630.216 ns] 0x00400ba7jg 0x400bb3"])
+   "9524: [19691630.226 ns] 0x00400ba7jg 0x400bb3"])
 self.expect("thread trace dump instructions 3 -t",
-  substrs=["67919: [19736130.084 ns] 0x00400bd7addl   $0x1, -0x4(%rbp)",
+  substrs=["61831: [19736134.073 ns] 0x00400bd7addl   $0x1, -0x4(%rbp)"

[Lldb-commits] [PATCH] D131821: Add test that shows the problem with aed965d5

2022-08-12 Thread Emre Kultursay via Phabricator via lldb-commits
emrekultursay created this revision.
Herald added a project: All.
emrekultursay requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The test is identical to API/lang/c/stepping/ except:

1. It uses C++ and thus needs demangling support
2. It uses dynamic library, and tries to step into a function that is defined 
in the library.

Test fails with:

File 
"...llvm-project/lldb/test/API/lang/cpp/stepping/TestStepAndBreakpointsCpp.py", 
line 252, in test_and_python_api
  self.assertEqual(thread.GetFrameAtIndex(0).GetFunctionName(), "b(int)")
  AssertionError: 'main' != 'b(int)'

...because it fails to step into the `b(int)` method and hits the next
breakpoint inside the `main` method.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131821

Files:
  lldb/test/API/lang/cpp/stepping/Makefile
  lldb/test/API/lang/cpp/stepping/TestStepAndBreakpointsCpp.py
  lldb/test/API/lang/cpp/stepping/helper.cpp
  lldb/test/API/lang/cpp/stepping/main.cpp

Index: lldb/test/API/lang/cpp/stepping/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/stepping/main.cpp
@@ -0,0 +1,24 @@
+int a(int);
+int b(int);
+int c(int);
+const char *print_string = "aa\n";
+int complex (int first, int second, int third);
+
+int main (int argc, char const *argv[])
+{
+int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
+
+int B2 = b(2); // assignment to B2
+
+int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
+
+int A4 = complex (a(1), b(2), c(3)); // Stop here to try step in targeting b.
+
+int A5 = complex (a(2), b(3), c(4)); // Stop here to try step in targeting complex.
+
+int A6 = complex (a(4), b(5), c(6)); // Stop here to step targeting b and hitting breakpoint.
+
+int A7 = complex (a(5), b(6), c(7)); // Stop here to make sure bogus target steps over.
+
+return A1 + B2 + A3 + A4 + A5 + A6 + A7 + *print_string;
+}
Index: lldb/test/API/lang/cpp/stepping/helper.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/stepping/helper.cpp
@@ -0,0 +1,35 @@
+int a(int);
+int b(int);
+int c(int);
+
+int a(int val)
+{
+int return_value = val;  // basic break at the start of b
+
+if (val <= 1)
+{
+return_value =  b(val); // break here to stop in a before calling b
+}
+else if (val >= 3)
+{
+return_value = c(val);
+}
+
+return return_value;
+}
+
+int b(int val)
+{
+int rc = c(val); // thread step-out while stopped at "c(2)"
+return rc;
+}
+
+int c(int val)
+{
+return val + 3; // Find the line number of function "c" here.
+}
+
+int complex (int first, int second, int third)
+{
+return first + second + third;  // Step in targeting complex should stop here
+}
Index: lldb/test/API/lang/cpp/stepping/TestStepAndBreakpointsCpp.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/stepping/TestStepAndBreakpointsCpp.py
@@ -0,0 +1,302 @@
+"""Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCppStepping(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+# Find the line numbers that we will step to in main:
+self.main_source = "main.cpp"
+self.helper_source = "helper.cpp"
+
+@add_test_categories(['pyapi', 'basic_process'])
+@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17932')
+@expectedFailureAll(oslist=["linux"], archs=no_match(["i386", "x86_64"]))
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24777")
+@expectedFailureNetBSD
+@skipIfWindows
+@skipIfDarwinEmbedded
+def test_and_python_api(self):
+"""Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+environment = self.registerSharedLibrariesWithTarget(target, ["helper"])
+
+self.main_source_spec = lldb.SBFileSpec(self.main_source)
+self.helper_source_spec = lldb.SBFileSpec(self.helper_source)
+
+breakpoints_to_disable = []
+
+break_1_in_main = target.BreakpointCreateBySourceRegex(
+'// frame select 2, thread step-out while stopped at .c.1..',
+self.main_source_spec)
+self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
+breakpoints_to_disable.append(break_1_in_main)
+
+break_in_a = target.BreakpointCreateBySourceRegex(
+'// break here to stop i

[Lldb-commits] [PATCH] D117383: [lldb] Expose std::pair children for unordered_map

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 452364.
kastiglione added a comment.

Use backend's type name to differentiate between unordered_{map,set}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+self.look_for_content_and_continue(
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -118,10 +118,24 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+// This synthetic provider is used for both unordered_map and
+// unordered_set. For unordered_map, the element type has an additional
+// type layer, an internal struct (`__hash_value_type`) that wraps a
+// std::pair. Peel away the internal wrapper type - whose structure is
+// of no value to users, to expose the std::pair. This matches the
+// structure returned by the std::map synthetic provider.
+if (m_backend.GetTypeName().GetStringRef().startswith(
+"unordered_map<")) {
+  std::string name;
+  auto key_value_type = m_element_type.GetFieldAtIndex(
+  0, name, nullptr, nullptr, nullptr);
+  if (name == "__cc") {
+// __cc is an internal typedef of std::pair.
+m_element_type = key_value_type.GetTypedefedType();
+  } else {
+assert(false && "Expected field name of '__cc'");
+  }
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +167,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }
 
 bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+

[Lldb-commits] [PATCH] D117383: [lldb] Expose std::pair children for unordered_map

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 452365.
kastiglione added a comment.

Ignore the internal field name and use type names for conditions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+self.look_for_content_and_continue(
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -118,10 +118,21 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+// This synthetic provider is used for both unordered_map and
+// unordered_set. For unordered_map, the element type has an additional
+// type layer, an internal struct (`__hash_value_type`) that wraps a
+// std::pair. Peel away the internal wrapper type - whose structure is
+// of no value to users, to expose the std::pair. This matches the
+// structure returned by the std::map synthetic provider.
+if (m_backend.GetTypeName().GetStringRef().startswith(
+"unordered_map<")) {
+  std::string name;
+  CompilerType field_type = m_element_type.GetFieldAtIndex(
+  0, name, nullptr, nullptr, nullptr);
+  CompilerType actual_type = field_type.GetTypedefedType();
+  if (actual_type.GetTypeName().GetStringRef().startswith("pair<"))
+m_element_type = actual_type;
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +164,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }
 
 bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::


Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+s

[Lldb-commits] [PATCH] D117383: [lldb] Expose std::pair children for unordered_map

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 452366.
kastiglione added a comment.

Handle GetTypeName() returning strings both with and without std:: namespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+self.look_for_content_and_continue(
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -13,10 +13,12 @@
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringRef.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -65,6 +67,21 @@
   return m_num_elements;
 }
 
+static bool isUnorderedMap(ConstString type_name) {
+  llvm::StringRef name = type_name.GetStringRef();
+  // Unlike for pair, GetTypeName() returns a name without a namespace.
+  return name.startswith("unordered_map<") ||
+ name.startswith("unordered_multimap<") ||
+ name.startswith("std::__1::unordered_map<") ||
+ name.startswith("std::__1::unordered_multimap<");
+}
+
+static bool isPair(ConstString type_name) {
+  llvm::StringRef name = type_name.GetStringRef();
+  // Unlike for unordered_map, GetTypeName() returns a name the namespace.
+  return name.startswith("std::__1::pair<") || name.startswith("pair<");
+}
+
 lldb::ValueObjectSP lldb_private::formatters::
 LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx >= CalculateNumChildren())
@@ -118,10 +135,20 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+// This synthetic provider is used for both unordered_(multi)map and
+// unordered_(multi)set. For unordered_map, the element type has an
+// additional type layer, an internal struct (`__hash_value_type`)
+// that wraps a std::pair. Peel away the internal wrapper type - whose
+// structure is of no value to users, to expose the std::pair. This
+// matches the structure returned by the std::map synthetic provider.
+if (isUnorderedMap(m_backend.GetTypeName())) {
+  std::string name;
+  CompilerType field_type = m_element_type.GetFieldAtIndex(
+  0, name, nullptr, nullptr, nullptr);
+  CompilerType actual_type = field_type.GetTypedefedType();
+  if (isPair(actual_type.GetTypeName()))
+m_element_type = actual_type;
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +180,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetC

[Lldb-commits] [PATCH] D117383: [lldb] Expose std::pair children for unordered_map

2022-08-12 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 452367.
kastiglione added a comment.

fix comment grammar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117383

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py


Index: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
===
--- 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
+++ 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered/TestDataFormatterGenericUnordered.py
@@ -47,12 +47,17 @@
 "corrupt_map", ['%s::unordered_map' %
 ns, 'size=0 {}'])
 
-self.look_for_content_and_continue(
-"map", ['%s::unordered_map' %
-ns, 'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+must_not_contain__cc = r'(?s)^(?!.*\b__cc = )'
 
 self.look_for_content_and_continue(
-"mmap", ['%s::unordered_multimap' % ns, 'size=6 {', 'first = 3', 
'second = "this"',
+"map", ['%s::unordered_map' % ns,
+must_not_contain__cc,
+'size=5 {', 'hello', 'world', 'this', 'is', 'me'])
+
+self.look_for_content_and_continue(
+"mmap", ['%s::unordered_multimap' % ns,
+ must_not_contain__cc,
+ 'size=6 {', 'first = 3', 'second = "this"',
  'first = 2', 'second = "hello"'])
 
 self.look_for_content_and_continue(
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -13,10 +13,12 @@
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
 #include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Endian.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringRef.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -65,6 +67,21 @@
   return m_num_elements;
 }
 
+static bool isUnorderedMap(ConstString type_name) {
+  llvm::StringRef name = type_name.GetStringRef();
+  // Unlike for pair, GetTypeName() excludes the namespace.
+  return name.startswith("unordered_map<") ||
+ name.startswith("unordered_multimap<") ||
+ name.startswith("std::__1::unordered_map<") ||
+ name.startswith("std::__1::unordered_multimap<");
+}
+
+static bool isPair(ConstString type_name) {
+  llvm::StringRef name = type_name.GetStringRef();
+  // Unlike for unordered_map, GetTypeName() includes the namespace.
+  return name.startswith("std::__1::pair<") || name.startswith("pair<");
+}
+
 lldb::ValueObjectSP lldb_private::formatters::
 LibcxxStdUnorderedMapSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
   if (idx >= CalculateNumChildren())
@@ -118,10 +135,20 @@
 m_element_type = m_element_type.GetPointeeType();
 m_node_type = m_element_type;
 m_element_type = m_element_type.GetTypeTemplateArgument(0);
-std::string name;
-m_element_type =
-m_element_type.GetFieldAtIndex(0, name, nullptr, nullptr, nullptr);
-m_element_type = m_element_type.GetTypedefedType();
+// This synthetic provider is used for both unordered_(multi)map and
+// unordered_(multi)set. For unordered_map, the element type has an
+// additional type layer, an internal struct (`__hash_value_type`)
+// that wraps a std::pair. Peel away the internal wrapper type - whose
+// structure is of no value to users, to expose the std::pair. This
+// matches the structure returned by the std::map synthetic provider.
+if (isUnorderedMap(m_backend.GetTypeName())) {
+  std::string name;
+  CompilerType field_type = m_element_type.GetFieldAtIndex(
+  0, name, nullptr, nullptr, nullptr);
+  CompilerType actual_type = field_type.GetTypedefedType();
+  if (isPair(actual_type.GetTypeName()))
+m_element_type = actual_type;
+}
   }
   if (!m_node_type)
 return nullptr;
@@ -153,7 +180,7 @@
   ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock(
   thread_and_frame_only_if_stopped);
   return CreateValueObjectFromData(stream.GetString(), data, exe_ctx,
-   val_hash.first->GetCompilerType());
+   m_element_type);
 }