[Lldb-commits] [lldb] 0dfafa4 - [lldb] Correct hex digit regex in some tests

2022-05-06 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-05-06T09:28:21Z
New Revision: 0dfafa489230061cdde39d9e7294bb61d23f1064

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

LOG: [lldb] Correct hex digit regex in some tests

"A-f" -> "A-F"

Added: 


Modified: 
lldb/test/API/commands/memory/read/TestMemoryRead.py

lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py

Removed: 




diff  --git a/lldb/test/API/commands/memory/read/TestMemoryRead.py 
b/lldb/test/API/commands/memory/read/TestMemoryRead.py
index 1312dd4181a89..a1b88393c8cf1 100644
--- a/lldb/test/API/commands/memory/read/TestMemoryRead.py
+++ b/lldb/test/API/commands/memory/read/TestMemoryRead.py
@@ -37,7 +37,7 @@ def test_memory_read_c_string(self):
 # the third isn't 0 as expected.
 self.expect(cmd.format(3), substrs=['\"ab\"'])
 self.assertRegex(self.res.GetError(),
-"unable to find a NULL terminated string at 0x[0-9A-fa-f]+."
+"unable to find a NULL terminated string at 0x[0-9A-Fa-f]+."
 " Consider increasing the maximum read length.")
 
 def test_memory_read(self):

diff  --git 
a/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
 
b/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
index c95c2ae327533..1423307b47311 100644
--- 
a/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ 
b/lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -111,11 +111,11 @@ def test_mte_tag_read(self):
 
 # Ranges with any part outside the region will error
 self.expect("memory tag read mte_buf_2+page_size-16 
mte_buf_2+page_size+32",
-patterns=["error: Address range 
0x[0-9A-fa-f]+f0:0x[0-9A-Fa-f]+20 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+f0:0x[0-9A-Fa-f]+20 "
   "is not in a memory tagged region"],
 error=True)
 self.expect("memory tag read mte_buf_2+page_size",
-patterns=["error: Address range 
0x[0-9A-fa-f]+00:0x[0-9A-Fa-f]+10 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+00:0x[0-9A-Fa-f]+10 "
   "is not in a memory tagged region"],
 error=True)
 
@@ -197,15 +197,15 @@ def test_mte_tag_write(self):
 
 # Ranges with any part outside the region will error
 self.expect("memory tag write mte_buf_2+page_size-16 6 7",
-patterns=["error: Address range 
0x[0-9A-fa-f]+f0:0x[0-9A-Fa-f]+10 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+f0:0x[0-9A-Fa-f]+10 "
   "is not in a memory tagged region"],
 error=True)
 self.expect("memory tag write mte_buf_2+page_size 6",
-patterns=["error: Address range 
0x[0-9A-fa-f]+00:0x[0-9A-Fa-f]+10 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+00:0x[0-9A-Fa-f]+10 "
   "is not in a memory tagged region"],
 error=True)
 self.expect("memory tag write mte_buf_2+page_size 6 7 8",
-patterns=["error: Address range 
0x[0-9A-fa-f]+00:0x[0-9A-Fa-f]+30 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+00:0x[0-9A-Fa-f]+30 "
   "is not in a memory tagged region"],
 error=True)
 
@@ -248,7 +248,7 @@ def test_mte_tag_write(self):
   "greater than the start address \(0x[A-Fa-f0-9]+\)"],
 error=True)
 self.expect("memory tag write mte_buf_2 9 --end-addr 
mte_buf_2+page_size+16",
-patterns=["error: Address range 
0x[0-9A-fa-f]+00:0x[0-9A-Fa-f]+10 "
+patterns=["error: Address range 
0x[0-9A-Fa-f]+00:0x[0-9A-Fa-f]+10 "
   "is not in a memory tagged region"],
 error=True)
 
@@ -304,31 +304,31 @@ def test_mte_memory_read_tag_display(self):
 # Reading 16 bytes per line means 1 granule and so 1 tag per line
 self.expect("memory read mte_buf mte_buf+32 -f \"x\" -l 1 -s 16 
--show-tags",
 patterns=[
-"0x[0-9A-fa-f]+00: 0x0+ \(tag: 0x0\)\n"
-"0x[0-9A-fa-f]+10: 0x0+ \(tag: 0x1\)"
+"0x[0-9A-Fa-f]+00: 0x0+ \(tag: 0x0\)\n"
+"0x[0-9A-Fa-f]+10: 0x0+ \(tag: 0x1\)"
 ])
 
 # If bytes per line is > granule size then you get multiple tags
 # per line.
 self.expect("memory read mte_buf mte_buf+32 -f \"x\" -l 1 -s 32 
--show-tags",
 patterns=[
-"0x[0-9A-fa-f]+00: 0x0+ \(tags: 0x0 0x1\)\n"
+

[Lldb-commits] [PATCH] D125012: [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC

2022-05-06 Thread Kadir Cetinkaya via Phabricator via lldb-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125012

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


[Lldb-commits] [PATCH] D125089: [lldb] Change implementation of memory read --show-tags option

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

This does 2 things:

- Moves it after the short options. Which makes sense given it's a niche, 
default off option. (if 2 files for one option seems a bit much, I am going to 
reuse them for "memory find" later)
- Fixes the use of repeated commands. For example: memory read buf --show-tags 
 memory read 

Added tests for the repetition and updated existing help tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125089

Files:
  lldb/include/lldb/Interpreter/OptionGroupMemoryTag.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/CMakeLists.txt
  lldb/source/Interpreter/OptionGroupMemoryTag.cpp
  lldb/test/API/commands/help/TestHelp.py
  
lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py

Index: lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
===
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -411,3 +411,33 @@
 self.expect("memory read mte_buf mte_buf+32 -f \"uint8_t[]\" -s 16 -l 1 --show-tags",
 patterns=["0x[0-9A-Fa-f]+00: \{(0x00 ){15}0x00\} \(tag: 0x0\)\n"
   "0x[0-9A-Fa-f]+10: \{(0x00 ){15}0x00\} \(tag: 0x1\)"])
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+@skipUnlessAArch64MTELinuxCompiler
+def test_mte_memory_read_tag_display_repeated(self):
+"""Test that the --show-tags option is kept when repeating the memory read command."""
+self.setup_mte_test()
+
+self.expect("memory read mte_buf mte_buf+16 -f \"x\" --show-tags",
+patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x0\)"])
+# Equivalent to just pressing enter on the command line.
+self.expect("memory read",
+patterns=["0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+ \(tag: 0x1\)"])
+
+# You can add the argument to an existing repetition without resetting
+# the whole command. Though all other optional arguments will reset to
+# their default values when you do this.
+self.expect("memory read mte_buf mte_buf+16 -f \"x\"",
+patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+"])
+self.expect("memory read",
+patterns=["0x[0-9A-fa-f]+10: 0x0+ 0x0+ 0x0+ 0x0+"])
+# Note that the formatting returns to default here.
+self.expect("memory read --show-tags",
+patterns=["0x[0-9A-fa-f]+20: (00 )+ \.+ \(tag: 0x2\)"])
+self.expect("memory read",
+patterns=["0x[0-9A-fa-f]+30: (00 )+ \.+ \(tag: 0x3\)"])
+
+# A fresh command reverts to the default of tags being off.
+self.expect("memory read mte_buf mte_buf+16 -f \"x\"",
+patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+"])
Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -262,9 +262,9 @@
 """Test that we put a break between the usage and the options help lines,
and between the options themselves."""
 self.expect("help memory read", substrs=[
-"[]\n\n   --show-tags",
-# Starts with the end of the show-tags line
-"output).\n\n   -A"])
+"[]\n\n   -A ( --show-all-children )",
+# Starts with the end of the show-all-children line
+"to show.\n\n   -D"])
 
 @no_debug_info_test
 def test_help_detailed_information_ordering(self):
Index: lldb/source/Interpreter/OptionGroupMemoryTag.cpp
===
--- /dev/null
+++ lldb/source/Interpreter/OptionGroupMemoryTag.cpp
@@ -0,0 +1,59 @@
+//===-- OptionGroupMemoryTag.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "lldb/Interpreter/OptionGroupMemoryTag.h"
+
+#include "lldb/Host/OptionParser.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+OptionGroupMemoryTag::OptionGroupMemoryTag() : m_show_tags(false, false) {}
+
+static const uint32_t SHORT_OPTION_SHOW_TAGS = 0x54414753; // 'tags'
+
+static constexpr OptionDefini

[Lldb-commits] [PATCH] D125090: [lldb] Add --show-tags option to "memory find"

2022-05-06 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.

This is off by default. If you get a result and that
memory has memory tags, when --show-tags is given you'll
see the tags inline with the memory content.

(lldb) memory read mte_buf mte_buf+64 --show-tags
<...>
0xf7ff8020: 00 00 00 00 00 00 00 00 0d f0 fe ca 00 00 00 00 
 (tag: 0x2)
<...>
(lldb) memory find -e 0xcafef00d mte_buf mte_buf+64 --show-tags
data found at location: 0xf7ff8028
0xf7ff8028: 0d f0 fe ca 00 00 00 00 00 00 00 00 00 00 00 00 
 (tags: 0x2 0x3)
0xf7ff8038: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 (tags: 0x3 0x4)

The logic for handling alignments is the same as for memory read
so in the above example because the line starts misaligned to the
granule it covers 2 granules.

Depends on D125089 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125090

Files:
  lldb/include/lldb/Interpreter/OptionGroupMemoryTag.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Interpreter/OptionGroupMemoryTag.cpp
  lldb/test/API/commands/help/TestHelp.py
  
lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
  lldb/test/API/linux/aarch64/mte_tag_access/main.c

Index: lldb/test/API/linux/aarch64/mte_tag_access/main.c
===
--- lldb/test/API/linux/aarch64/mte_tag_access/main.c
+++ lldb/test/API/linux/aarch64/mte_tag_access/main.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,6 +54,9 @@
   char *non_mte_buf = checked_mmap(page_size, PROT_READ);
   char *mte_read_only = checked_mmap(page_size, mte_prot);
 
+  // Target value for "memory find" testing.
+  strncpy(mte_buf+128, "LLDB", 4);
+
   // Set incrementing tags until end of the first page
   char *tagged_ptr = mte_buf;
   // This ignores tag bits when subtracting the addresses
Index: lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
===
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -441,3 +441,30 @@
 # A fresh command reverts to the default of tags being off.
 self.expect("memory read mte_buf mte_buf+16 -f \"x\"",
 patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+"])
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+@skipUnlessAArch64MTELinuxCompiler
+def test_mte_memory_find(self):
+"""Test the --show-tags option with memory find."""
+self.setup_mte_test()
+
+cmd = "memory find -s \"LLDB\" mte_buf+64 mte_buf+512"
+found_pattern = "data found at location: 0x[0-9A-Fa-f]+80"
+results_patterns = [
+"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
+"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+"
+]
+
+# Default is not to show tags
+self.expect(cmd, patterns=[found_pattern, *results_patterns])
+self.expect(cmd + " --show-tags", patterns=[found_pattern,
+results_patterns[0] + " \(tag: 0x8\)",
+results_patterns[1] + " \(tag: 0x9\)"])
+
+# Uses the same logic as memory read to handle misalignment.
+self.expect("memory find -s \"DB\" mte_buf+64 mte_buf+512 --show-tags",
+patterns=[
+"data found at location: 0x[0-9A-Fa-f]+82\n"
+"0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\.+ \(tags: 0x8 0x9\)\n",
+"0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\.+ \(tags: 0x9 0xa\)"])
Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -303,3 +303,13 @@
 
 self.assertEqual(sorted(short_options), short_options,
  "Short option help displayed in an incorrect order!")
+
+@no_debug_info_test
+def test_help_show_tags(self):
+""" Check that memory find and memory read have the --show-tags option
+but only memory read mentions binary output. """
+self.expect("help memory read", patterns=[
+"--show-tags\n\s+Include memory tags in output "
+"\(does not apply to binary output\)."])
+self.expect("help memory find", patterns=[
+"--show-tags\n\s+Include memory tags in output."])
Index: lldb/source/Interpreter/OptionGroupMemoryTag.cpp
===
--- lldb/source/Interpreter/OptionGroupMemoryTag.cpp
+++ lldb/source/Interpreter/OptionGroup

[Lldb-commits] [PATCH] D125089: [lldb] Change implementation of memory read --show-tags option

2022-05-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: omjavaid.
DavidSpickett added a comment.

I did try to add the option via Options.td but adding a multi character short 
option there doesn't seem to work. I could enable that but it seems like just 
as much work to make an option group for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125089

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


[Lldb-commits] [PATCH] D125090: [lldb] Add --show-tags option to "memory find"

2022-05-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 427609.
DavidSpickett added a comment.

Test that show-tags without finding anything doesn't do anything strange.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125090

Files:
  lldb/include/lldb/Interpreter/OptionGroupMemoryTag.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Interpreter/OptionGroupMemoryTag.cpp
  lldb/test/API/commands/help/TestHelp.py
  
lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
  lldb/test/API/linux/aarch64/mte_tag_access/main.c

Index: lldb/test/API/linux/aarch64/mte_tag_access/main.c
===
--- lldb/test/API/linux/aarch64/mte_tag_access/main.c
+++ lldb/test/API/linux/aarch64/mte_tag_access/main.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,6 +54,9 @@
   char *non_mte_buf = checked_mmap(page_size, PROT_READ);
   char *mte_read_only = checked_mmap(page_size, mte_prot);
 
+  // Target value for "memory find" testing.
+  strncpy(mte_buf+128, "LLDB", 4);
+
   // Set incrementing tags until end of the first page
   char *tagged_ptr = mte_buf;
   // This ignores tag bits when subtracting the addresses
Index: lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
===
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -441,3 +441,34 @@
 # A fresh command reverts to the default of tags being off.
 self.expect("memory read mte_buf mte_buf+16 -f \"x\"",
 patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+"])
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+@skipUnlessAArch64MTELinuxCompiler
+def test_mte_memory_find(self):
+"""Test the --show-tags option with memory find."""
+self.setup_mte_test()
+
+# No result, nothing changes.
+self.expect("memory find -s \"foo\" mte_buf mte_buf+32 --show-tags",
+substrs=["data not found within the range."])
+
+cmd = "memory find -s \"LLDB\" mte_buf+64 mte_buf+512"
+found_pattern = "data found at location: 0x[0-9A-Fa-f]+80"
+results_patterns = [
+"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
+"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+"
+]
+
+# Default is not to show tags
+self.expect(cmd, patterns=[found_pattern, *results_patterns])
+self.expect(cmd + " --show-tags", patterns=[found_pattern,
+results_patterns[0] + " \(tag: 0x8\)",
+results_patterns[1] + " \(tag: 0x9\)"])
+
+# Uses the same logic as memory read to handle misalignment.
+self.expect("memory find -s \"DB\" mte_buf+64 mte_buf+512 --show-tags",
+patterns=[
+"data found at location: 0x[0-9A-Fa-f]+82\n"
+"0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\.+ \(tags: 0x8 0x9\)\n",
+"0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\.+ \(tags: 0x9 0xa\)"])
Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -303,3 +303,13 @@
 
 self.assertEqual(sorted(short_options), short_options,
  "Short option help displayed in an incorrect order!")
+
+@no_debug_info_test
+def test_help_show_tags(self):
+""" Check that memory find and memory read have the --show-tags option
+but only memory read mentions binary output. """
+self.expect("help memory read", patterns=[
+"--show-tags\n\s+Include memory tags in output "
+"\(does not apply to binary output\)."])
+self.expect("help memory find", patterns=[
+"--show-tags\n\s+Include memory tags in output."])
Index: lldb/source/Interpreter/OptionGroupMemoryTag.cpp
===
--- lldb/source/Interpreter/OptionGroupMemoryTag.cpp
+++ lldb/source/Interpreter/OptionGroupMemoryTag.cpp
@@ -13,25 +13,26 @@
 using namespace lldb;
 using namespace lldb_private;
 
-OptionGroupMemoryTag::OptionGroupMemoryTag() : m_show_tags(false, false) {}
-
 static const uint32_t SHORT_OPTION_SHOW_TAGS = 0x54414753; // 'tags'
 
-static constexpr OptionDefinition g_option_table[] = {
-{LLDB_OPT_SET_1,
- false,
- "show-tags",
- SHORT_OPTION_SHOW_TAGS,
- OptionParser::eNoArgument,
- nullptr,
- {},
- 0,
- eArgTypeNone,
- "Include memory tags in output (does not apply to binary output)."},
-};
+OptionGroupMemoryTag::OptionGroupMemoryTag(bool note_binary /*=

[Lldb-commits] [PATCH] D125090: [lldb] Add --show-tags option to "memory find"

2022-05-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

The logic for handling misalignment is all done in DumpDataExtractor so that is 
covered by the "memory read --show-tags" tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125090

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


[Lldb-commits] [PATCH] D125090: [lldb] Add --show-tags option to "memory find"

2022-05-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 427612.
DavidSpickett added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125090

Files:
  lldb/include/lldb/Interpreter/OptionGroupMemoryTag.h
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Interpreter/OptionGroupMemoryTag.cpp
  lldb/test/API/commands/help/TestHelp.py
  
lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
  lldb/test/API/linux/aarch64/mte_tag_access/main.c
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -170,6 +170,10 @@
 Changes to LLDB
 -
 
+* Added "--show-tags" option to the "memory find" command. This is off by default.
+  When enabled, if the target value is found in tagged memory, the tags for that
+  memory will be shown inline with the memory contents.
+
 Changes to Sanitizers
 -
 
Index: lldb/test/API/linux/aarch64/mte_tag_access/main.c
===
--- lldb/test/API/linux/aarch64/mte_tag_access/main.c
+++ lldb/test/API/linux/aarch64/mte_tag_access/main.c
@@ -2,6 +2,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -53,6 +54,9 @@
   char *non_mte_buf = checked_mmap(page_size, PROT_READ);
   char *mte_read_only = checked_mmap(page_size, mte_prot);
 
+  // Target value for "memory find" testing.
+  strncpy(mte_buf+128, "LLDB", 4);
+
   // Set incrementing tags until end of the first page
   char *tagged_ptr = mte_buf;
   // This ignores tag bits when subtracting the addresses
Index: lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
===
--- lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
+++ lldb/test/API/linux/aarch64/mte_tag_access/TestAArch64LinuxMTEMemoryTagAccess.py
@@ -441,3 +441,34 @@
 # A fresh command reverts to the default of tags being off.
 self.expect("memory read mte_buf mte_buf+16 -f \"x\"",
 patterns=["0x[0-9A-fa-f]+00: 0x0+ 0x0+ 0x0+ 0x0+"])
+
+@skipUnlessArch("aarch64")
+@skipUnlessPlatform(["linux"])
+@skipUnlessAArch64MTELinuxCompiler
+def test_mte_memory_find(self):
+"""Test the --show-tags option with memory find."""
+self.setup_mte_test()
+
+# No result, nothing changes.
+self.expect("memory find -s \"foo\" mte_buf mte_buf+32 --show-tags",
+substrs=["data not found within the range."])
+
+cmd = "memory find -s \"LLDB\" mte_buf+64 mte_buf+512"
+found_pattern = "data found at location: 0x[0-9A-Fa-f]+80"
+results_patterns = [
+"0x[0-9A-Fa-f]+80: 4c 4c 44 42 (00 )+ LLDB\.+",
+"0x[0-9A-Fa-f]+90: 00 00 00 00 (00 )+ \.+"
+]
+
+# Default is not to show tags
+self.expect(cmd, patterns=[found_pattern, *results_patterns])
+self.expect(cmd + " --show-tags", patterns=[found_pattern,
+results_patterns[0] + " \(tag: 0x8\)",
+results_patterns[1] + " \(tag: 0x9\)"])
+
+# Uses the same logic as memory read to handle misalignment.
+self.expect("memory find -s \"DB\" mte_buf+64 mte_buf+512 --show-tags",
+patterns=[
+"data found at location: 0x[0-9A-Fa-f]+82\n"
+"0x[0-9A-Fa-f]+82: 44 42 (00 )+ DB\.+ \(tags: 0x8 0x9\)\n",
+"0x[0-9A-Fa-f]+92: 00 00 (00 )+ ..\.+ \(tags: 0x9 0xa\)"])
Index: lldb/test/API/commands/help/TestHelp.py
===
--- lldb/test/API/commands/help/TestHelp.py
+++ lldb/test/API/commands/help/TestHelp.py
@@ -303,3 +303,13 @@
 
 self.assertEqual(sorted(short_options), short_options,
  "Short option help displayed in an incorrect order!")
+
+@no_debug_info_test
+def test_help_show_tags(self):
+""" Check that memory find and memory read have the --show-tags option
+but only memory read mentions binary output. """
+self.expect("help memory read", patterns=[
+"--show-tags\n\s+Include memory tags in output "
+"\(does not apply to binary output\)."])
+self.expect("help memory find", patterns=[
+"--show-tags\n\s+Include memory tags in output."])
Index: lldb/source/Interpreter/OptionGroupMemoryTag.cpp
===
--- lldb/source/Interpreter/OptionGroupMemoryTag.cpp
+++ lldb/source/Interpreter/OptionGroupMemoryTag.cpp
@@ -13,25 +13,26 @@
 using namespace ll

[Lldb-commits] [lldb] 499d0b9 - [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC

2022-05-06 Thread Sam McCall via lldb-commits

Author: Sam McCall
Date: 2022-05-06T16:21:48+02:00
New Revision: 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5

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

LOG: [clang] createInvocationFromCommandLine -> createInvocation, delete 
former. NFC

(Followup from 40c13720a4b977d4347bbde53c52a4d0703823c2)

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

Added: 


Modified: 
clang/include/clang/Frontend/Utils.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
clang/tools/c-index-test/core_main.cpp
clang/tools/diagtool/ShowEnabledWarnings.cpp
clang/tools/libclang/Indexing.cpp
clang/unittests/Frontend/ASTUnitTest.cpp
clang/unittests/Frontend/CompilerInstanceTest.cpp
clang/unittests/Serialization/ModuleCacheTest.cpp
clang/unittests/Tooling/Syntax/TokensTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 47f795b388f7..1e8841429ffa 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -234,15 +234,6 @@ std::unique_ptr
 createInvocation(ArrayRef Args,
  CreateInvocationOptions Opts = {});
 
-/// Deprecated version of createInvocation with individual optional args.
-std::unique_ptr createInvocationFromCommandLine(
-ArrayRef Args,
-IntrusiveRefCntPtr Diags =
-IntrusiveRefCntPtr(),
-IntrusiveRefCntPtr VFS = nullptr,
-bool ShouldRecoverOnErrors = false,
-std::vector *CC1Args = nullptr, bool ProbePrecompiled = true);
-
 } // namespace clang
 
 #endif // LLVM_CLANG_FRONTEND_UTILS_H

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 5f587cc1c023..1d0f472e9c6e 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1729,8 +1729,11 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
 CaptureDroppedDiagnostics Capture(CaptureDiagnostics, *Diags,
   &StoredDiagnostics, nullptr);
 
-CI = createInvocationFromCommandLine(
-llvm::makeArrayRef(ArgBegin, ArgEnd), Diags, VFS);
+CreateInvocationOptions CIOpts;
+CIOpts.VFS = VFS;
+CIOpts.Diags = Diags;
+CI = createInvocation(llvm::makeArrayRef(ArgBegin, ArgEnd),
+  std::move(CIOpts));
 if (!CI)
   return nullptr;
   }

diff  --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp 
b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index 2a98aab44ccb..49e814b31b43 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -104,12 +104,3 @@ clang::createInvocation(ArrayRef ArgList,
 return nullptr;
   return CI;
 }
-
-std::unique_ptr clang::createInvocationFromCommandLine(
-ArrayRef Args, IntrusiveRefCntPtr Diags,
-IntrusiveRefCntPtr VFS, bool ShouldRecoverOnErrors,
-std::vector *CC1Args, bool ProbePrecompiled) {
-  return createInvocation(
-  Args, CreateInvocationOptions{Diags, VFS, ShouldRecoverOnErrors,
-ProbePrecompiled, CC1Args});
-}

diff  --git a/clang/tools/c-index-test/core_main.cpp 
b/clang/tools/c-index-test/core_main.cpp
index 7037252ffa0e..c5f47baa8458 100644
--- a/clang/tools/c-index-test/core_main.cpp
+++ b/clang/tools/c-index-test/core_main.cpp
@@ -13,6 +13,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/USRGeneration.h"
@@ -220,7 +221,9 @@ static bool printSourceSymbols(const char *Executable,
   ArgsWithProgName.append(Args.begin(), Args.end());
   IntrusiveRefCntPtr
 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
-  auto CInvok = createInvocationFromCommandLine(ArgsWithProgName, Diags);
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = Diags;
+  auto CInvok = createInvocation(ArgsWithProgName, std::move(CIOpts));
   if (!CInvok)
 return true;
 

diff  --git a/clang/tools/diagtool/ShowEnabledWarnings.cpp 
b/clang/tools/diagtool/ShowEnabledWarnings.cpp
index ae2d3e37e845..e5a7b2532824 100644
--- a/clang/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/clang/tools/diagtool/ShowEnabledWarnings.cpp
@@ -59,15 +59,16 @@ createDiagnostics(unsigned int argc, char **argv) {
   // Buffer diagnostics from argument parsing so that we can output them using 
a
   // well formed diagnostic object.
   TextDiagnosticBuffer *DiagsBuffer = new TextDiagnostic

[Lldb-commits] [PATCH] D125012: [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC

2022-05-06 Thread Sam McCall via 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 rG499d0b96cb52: [clang] createInvocationFromCommandLine -> 
createInvocation, delete former. NFC (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D125012?vs=427314&id=427634#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125012

Files:
  clang/include/clang/Frontend/Utils.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
  clang/tools/c-index-test/core_main.cpp
  clang/tools/diagtool/ShowEnabledWarnings.cpp
  clang/tools/libclang/Indexing.cpp
  clang/unittests/Frontend/ASTUnitTest.cpp
  clang/unittests/Frontend/CompilerInstanceTest.cpp
  clang/unittests/Serialization/ModuleCacheTest.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp
  clang/unittests/Tooling/Syntax/TreeTestBase.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -663,9 +663,11 @@
llvm::make_range(compiler_invocation_arguments.begin(),
 compiler_invocation_arguments.end()));
 
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = diagnostics_engine;
   std::shared_ptr invocation =
-  clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs,
- diagnostics_engine);
+  clang::createInvocation(compiler_invocation_argument_cstrs,
+  std::move(CIOpts));
 
   if (!invocation)
 return nullptr;
Index: clang/unittests/Tooling/Syntax/TreeTestBase.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -134,7 +134,10 @@
 ArgsCStr.push_back(arg.c_str());
   }
 
-  Invocation = createInvocationFromCommandLine(ArgsCStr, Diags, FS);
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = Diags;
+  CIOpts.VFS = FS;
+  Invocation = createInvocation(ArgsCStr, std::move(CIOpts));
   assert(Invocation);
   Invocation->getFrontendOpts().DisableFree = false;
   Invocation->getPreprocessorOpts().addRemappedFile(
Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -125,7 +125,10 @@
   Diags->setClient(new IgnoringDiagConsumer);
 std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
   FileName};
-auto CI = createInvocationFromCommandLine(Args, Diags, FS);
+CreateInvocationOptions CIOpts;
+CIOpts.Diags = Diags;
+CIOpts.VFS = FS;
+auto CI = createInvocation(Args, std::move(CIOpts));
 assert(CI);
 CI->getFrontendOpts().DisableFree = false;
 CI->getPreprocessorOpts().addRemappedFile(
Index: clang/unittests/Serialization/ModuleCacheTest.cpp
===
--- clang/unittests/Serialization/ModuleCacheTest.cpp
+++ clang/unittests/Serialization/ModuleCacheTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
@@ -95,13 +96,15 @@
   MCPArg.append(ModuleCachePath);
   IntrusiveRefCntPtr Diags =
   CompilerInstance::createDiagnostics(new DiagnosticOptions());
+  CreateInvocationOptions CIOpts;
+  CIOpts.Diags = Diags;
 
   // First run should pass with no errors
   const char *Args[] = {"clang","-fmodules",  "-Fframeworks",
 MCPArg.c_str(), "-working-directory", TestDir.c_str(),
 "test.m"};
   std::shared_ptr Invocation =
-  createInvocationFromCommandLine(Args, Diags);
+  createInvocation(Args, CIOpts);
   ASSERT_TRUE(Invocation);
   CompilerInstance Instance;
   Instance.setDiagnostics(Diags.get());
@@ -124,7 +127,7 @@
  "-Fframeworks",  MCPArg.c_str(), "-working-directory",
  TestDir.c_str(), "test.m"};
   std::shared_ptr Invocation2 =
-  createInvocationFromCommandLine(Args2, Diags);
+  createInvocation(Args2, CIOpts);
   ASSERT_TRUE(Invocation2);
   CompilerInstance Instance2(Instance.getPCHContainerOperations(),
  &Instance.getModuleCache());
@@ -142,13 +145,15 @@
   MCPArg.append(

[Lldb-commits] [PATCH] D125012: [clang] createInvocationFromCommandLine -> createInvocation, delete former. NFC

2022-05-06 Thread Sam McCall via Phabricator via lldb-commits
sammccall added a comment.

Sorry, bad merge and this broke everything.
Fixed in f44552ab387b9087fb815251064782f8fb60e643


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125012

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


[Lldb-commits] [lldb] 6ed81ab - Fix LLDB test broken by 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5

2022-05-06 Thread Sam McCall via lldb-commits

Author: Sam McCall
Date: 2022-05-06T17:09:02+02:00
New Revision: 6ed81abec2531984e8068de80637bc9f5a041655

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

LOG: Fix LLDB test broken by 499d0b96cb52c828e7fc4d58825b5e8b3f9931c5

Added: 


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

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 385bb51eca5b0..38dd55bc76d36 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -663,7 +663,7 @@ ClangModulesDeclVendor::Create(Target &target) {
llvm::make_range(compiler_invocation_arguments.begin(),
 compiler_invocation_arguments.end()));
 
-  CreateInvocationOptions CIOpts;
+  clang::CreateInvocationOptions CIOpts;
   CIOpts.Diags = diagnostics_engine;
   std::shared_ptr invocation =
   clang::createInvocation(compiler_invocation_argument_cstrs,



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


[Lldb-commits] [PATCH] D125107: [lldb] Parallelize fetching symbol files in crashlog.py

2022-05-06 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: mib, clayborg.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
JDevlieghere requested review of this revision.

When using dsymForUUID, the majority of time symbolication a crashlog with 
crashlog.py is spent waiting for it to complete. Currently, we're calling 
dsymForUUID sequentially when iterating over the modules. We can drastically 
cut down this time by calling dsymForUUID in parallel. This patch uses Python's 
ThreadPoolExecutor (introduced in Python 3.2) to parallelize this IO-bound 
operation.

The performance improvement is hard to benchmark, because even with an empty 
local cache, consecutive calls to dsymForUUID for the same UUID complete 
faster. With warm caches, I'm seeing a ~30% performance improvement (~90s -> 
~30s). I suspect the gains will be much bigger for a cold cache.


https://reviews.llvm.org/D125107

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.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 cmd
 import contextlib
 import datetime
@@ -43,6 +42,7 @@
 import sys
 import time
 import uuid
+import concurrent.futures
 
 try:
 # First try for LLDB in case PYTHONPATH is already correctly setup.
@@ -269,7 +269,7 @@
 self.resolved = True
 uuid_str = self.get_normalized_uuid_string()
 if self.show_symbol_progress():
-print('Getting symbols for %s %s...\n' % (uuid_str, 
self.path), end=' ')
+print('Getting symbols for %s %s...' % (uuid_str, self.path))
 if os.path.exists(self.dsymForUUIDBinary):
 dsym_for_uuid_command = '%s %s' % (
 self.dsymForUUIDBinary, uuid_str)
@@ -319,7 +319,7 @@
 pass
 if (self.resolved_path and os.path.exists(self.resolved_path)) or (
 self.path and os.path.exists(self.path)):
-print('Resolved symbols for %s %s...\n' % (uuid_str, 
self.path), end=' ')
+print('Resolved symbols for %s %s...' % (uuid_str, self.path))
 return True
 else:
 self.unavailable = True
@@ -914,7 +914,6 @@
 option_parser = CrashLogOptionParser()
 return option_parser.format_help()
 
-
 def SymbolicateCrashLog(crash_log, options):
 if options.debug:
 crash_log.dump()
@@ -961,9 +960,16 @@
 else:
 print('error: can\'t find image for identifier "%s"' % 
ident)
 
-for image in images_to_load:
-if image not in loaded_images:
-err = image.add_module(target)
+futures = []
+with concurrent.futures.ThreadPoolExecutor() as executor:
+def add_module(image, target):
+return image, image.add_module(target)
+
+for image in images_to_load:
+futures.append(executor.submit(add_module, image=image, 
target=target))
+
+for future in concurrent.futures.as_completed(futures):
+image, err = future.result()
 if err:
 print(err)
 else:


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.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 cmd
 import contextlib
 import datetime
@@ -43,6 +42,7 @@
 import sys
 import time
 import uuid
+import concurrent.futures
 
 try:
 # First try for LLDB in case PYTHONPATH is already correctly setup.
@@ -269,7 +269,7 @@
 self.resolved = True
 uuid_str = self.get_normalized_uuid_string()
 if self.show_symbol_progress():
-print('Getting symbols for %s %s...\n' % (uuid_str, self.path), end=' ')
+print('Getting symbols for %s %s...' % (uuid_str, self.path))
 if os.path.exists(self.dsymForUUIDBinary):
 dsym_for_uuid_command = '%s %s' % (
 self.dsymForUUIDBinary, uuid_str)
@@ -319,7 +319,7 @@
 pass
 if (self.resolved_path and os.path.exists(self.resolved_path)) or (
 self.path and os.path.exists(self.path)):
-print('Resolved symbols for %s %s...\n' % (uuid_str, self.path), end=' ')
+print('Resolved symbols for %s %s...' % (uuid_str, self.path))
 r

[Lldb-commits] [PATCH] D125107: [lldb] Parallelize fetching symbol files in crashlog.py

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



Comment at: lldb/examples/python/crashlog.py:272
 if self.show_symbol_progress():
-print('Getting symbols for %s %s...\n' % (uuid_str, 
self.path), end=' ')
+print('Getting symbols for %s %s...' % (uuid_str, self.path))
 if os.path.exists(self.dsymForUUIDBinary):

The changes to this line and the one below are the result of "Getting symbols 
[...]" and "Resolved symbols [...]" no longer appearing after each other. By 
parallelizing this operation you get a bunch of consecutive "Getting symbols 
[...]" followed by a bunch of "Resolved symbols [...]" lines. 


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

https://reviews.llvm.org/D125107

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


[Lldb-commits] [PATCH] D125107: [lldb] Parallelize fetching symbol files in crashlog.py

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

Very cool! LGTM!


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

https://reviews.llvm.org/D125107

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


[Lldb-commits] [PATCH] D124785: [lldb/Core] Fix "sticky" long progress messages

2022-05-06 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 427692.
mib added a comment.

Add test


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

https://reviews.llvm.org/D124785

Files:
  lldb/include/lldb/Core/DebuggerEvents.h
  lldb/source/Core/Debugger.cpp
  
lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py


Index: 
lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py
@@ -0,0 +1,38 @@
+"""
+Test resizing in our IOHandlers.
+"""
+
+import os
+import pexpect
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestTrimmedProgressReporting(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
+def test_resize(self):
+self.build()
+# Start with a small window
+self.launch(executable=self.getBuildArtifact("a.out"),
+dimensions=(5,5), timeout=1)
+
+# Now resize to something bigger
+self.child.setwinsize(100,500)
+
+patterns = ['Locating external symbol file for',
+'Parsing symbol table for', pexpect.EOF, pexpect.TIMEOUT]
+
+match_index = self.child.expect(patterns)
+
+self.quit()
+
+self.assertTrue(match_index, len(patterns) - 1) # match TIMEOUT
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1857,11 +1857,26 @@
 output->Printf(
 "%s", ansi::FormatAnsiTerminalCodes(ansi_prefix, use_color).c_str());
 
-  // Print the progress message.
+  // Trim the progress message if it exceeds the window's width and print it.
   std::string message = data->GetMessage();
-  if (data->GetTotal() != UINT64_MAX) {
+  uint64_t progress_total = data->GetTotal();
+  uint32_t term_width = GetTerminalWidth();
+
+  size_t prefix_width = 0;
+  if (data->IsFinite()) {
+prefix_width += 4; // '[%PRIu64/%PRIu64] %s'
+prefix_width += std::to_string(progress_total).size() * 2;
+  }
+
+  const size_t suffix_width = 3; // %s...
+
+  if (message.size() + prefix_width + suffix_width >= term_width)
+message.erase(message.begin() + term_width - prefix_width - suffix_width,
+  message.end());
+
+  if (data->IsFinite()) {
 output->Printf("[%" PRIu64 "/%" PRIu64 "] %s...", data->GetCompleted(),
-   data->GetTotal(), message.c_str());
+   progress_total, message.c_str());
   } else {
 output->Printf("%s...", message.c_str());
   }
Index: lldb/include/lldb/Core/DebuggerEvents.h
===
--- lldb/include/lldb/Core/DebuggerEvents.h
+++ lldb/include/lldb/Core/DebuggerEvents.h
@@ -32,6 +32,7 @@
 
   static const ProgressEventData *GetEventDataFromEvent(const Event 
*event_ptr);
   uint64_t GetID() const { return m_id; }
+  bool IsFinite() const { return m_total != UINT64_MAX; }
   uint64_t GetCompleted() const { return m_completed; }
   uint64_t GetTotal() const { return m_total; }
   const std::string &GetMessage() const { return m_message; }


Index: lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py
===
--- /dev/null
+++ lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py
@@ -0,0 +1,38 @@
+"""
+Test resizing in our IOHandlers.
+"""
+
+import os
+import pexpect
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+class TestTrimmedProgressReporting(PExpectTest):
+
+mydir = TestBase.compute_mydir(__file__)
+
+# PExpect uses many timeouts internally and doesn't play well
+# under ASAN on a loaded machine..
+@skipIfAsan
+@skipIfEditlineSupportMissing
+@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
+def test_resize(self):
+self.build()
+# Start with a small window
+self.launch(executable=self.getBuildArtifact("a.out"),
+dimensions=(5,5), timeout=1)
+
+# Now resize to something bigger
+self.child.setwinsize(100,500)
+
+patterns = ['Locating external symbol file for',
+'Parsing symbol table for', pexpect.EOF, pexpect.TIMEOUT]
+
+match_index = self.child.expect(patterns)
+
+self.quit()
+
+self.assertTrue(match_index, len(patterns) - 1) # match TIMEOUT
Index: lldb/source/Core/Debugge

[Lldb-commits] [PATCH] D124785: [lldb/Core] Fix "sticky" long progress messages

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



Comment at: lldb/source/Core/Debugger.cpp:1873-1875
+  if (message.size() + prefix_width + suffix_width >= term_width)
+message.erase(message.begin() + term_width - prefix_width - suffix_width,
+  message.end());

Instead of computing the length string like this, would it make sense to write 
the message to a temporary stream/buffer and then trim the string dumping it to 
the real async output stream? I'm worried about the two accidentally getting 
out of sync.



Comment at: 
lldb/test/API/functionalities/progress_reporting/TestTrimmedProgressReporting.py:25-34
+self.launch(executable=self.getBuildArtifact("a.out"),
+dimensions=(5,5), timeout=1)
+
+# Now resize to something bigger
+self.child.setwinsize(100,500)
+
+patterns = ['Locating external symbol file for',

I don't understand how this guarantees that we cut off the string at the exact 
width of the window?


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

https://reviews.llvm.org/D124785

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


[Lldb-commits] [PATCH] D124731: [lldb] Consider binary as module of last resort

2022-05-06 Thread Will Hawkins via Phabricator via lldb-commits
hawkinsw updated this revision to Diff 427791.
hawkinsw added a comment.

Updated patch including responses to helpful feedback from @jingham.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124731

Files:
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp


Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -121,16 +121,27 @@
 
   if (filter.AddressPasses(m_addr)) {
 if (breakpoint.GetNumLocations() == 0) {
-  // If the address is just an offset, and we're given a module, see if we
-  // can find the appropriate module loaded in the binary, and fix up
-  // m_addr to use that.
-  if (!m_addr.IsSectionOffset() && m_module_filespec) {
+  // If the address is just an offset ...
+  if (!m_addr.IsSectionOffset()) {
+ModuleSP containing_module_sp = nullptr;
 Target &target = breakpoint.GetTarget();
-ModuleSpec module_spec(m_module_filespec);
-ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
-if (module_sp) {
+if (m_module_filespec) {
+  // ... and we're given a module, see if we can find the
+  // appropriate module loaded in the binary, and fix up
+  // m_addr to use that.
+  ModuleSpec module_spec(m_module_filespec);
+  containing_module_sp =
+  target.GetImages().FindFirstModule(module_spec);
+} else {
+  // ... and we're not given a module, see if the offset is
+  // somewhere in the executable module. If it is, then we'll
+  // fix up m_addr to use that.
+  containing_module_sp = target.GetExecutableModule();
+}
+if (containing_module_sp) {
   Address tmp_address;
-  if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
+  if (containing_module_sp->ResolveFileAddress(m_addr.GetOffset(),
+   tmp_address))
 m_addr = tmp_address;
 }
   }


Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -121,16 +121,27 @@
 
   if (filter.AddressPasses(m_addr)) {
 if (breakpoint.GetNumLocations() == 0) {
-  // If the address is just an offset, and we're given a module, see if we
-  // can find the appropriate module loaded in the binary, and fix up
-  // m_addr to use that.
-  if (!m_addr.IsSectionOffset() && m_module_filespec) {
+  // If the address is just an offset ...
+  if (!m_addr.IsSectionOffset()) {
+ModuleSP containing_module_sp = nullptr;
 Target &target = breakpoint.GetTarget();
-ModuleSpec module_spec(m_module_filespec);
-ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
-if (module_sp) {
+if (m_module_filespec) {
+  // ... and we're given a module, see if we can find the
+  // appropriate module loaded in the binary, and fix up
+  // m_addr to use that.
+  ModuleSpec module_spec(m_module_filespec);
+  containing_module_sp =
+  target.GetImages().FindFirstModule(module_spec);
+} else {
+  // ... and we're not given a module, see if the offset is
+  // somewhere in the executable module. If it is, then we'll
+  // fix up m_addr to use that.
+  containing_module_sp = target.GetExecutableModule();
+}
+if (containing_module_sp) {
   Address tmp_address;
-  if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address))
+  if (containing_module_sp->ResolveFileAddress(m_addr.GetOffset(),
+   tmp_address))
 m_addr = tmp_address;
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D124731: [lldb] Consider binary as module of last resort

2022-05-06 Thread Will Hawkins via Phabricator via lldb-commits
hawkinsw updated this revision to Diff 427794.
hawkinsw added a comment.

(for real) Updating the patch based on helpful feedback from @jingham.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124731

Files:
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Commands/Options.td
  lldb/test/API/commands/breakpoint/set/address-nomodule/Makefile
  
lldb/test/API/commands/breakpoint/set/address-nomodule/TestBreakpointAddressNoModule.py
  lldb/test/API/commands/breakpoint/set/address-nomodule/inferior.c

Index: lldb/test/API/commands/breakpoint/set/address-nomodule/inferior.c
===
--- /dev/null
+++ lldb/test/API/commands/breakpoint/set/address-nomodule/inferior.c
@@ -0,0 +1,6 @@
+int function(int a) { return a; }
+
+int main() {
+  int f = function(10);
+  return f;
+}
Index: lldb/test/API/commands/breakpoint/set/address-nomodule/TestBreakpointAddressNoModule.py
===
--- /dev/null
+++ lldb/test/API/commands/breakpoint/set/address-nomodule/TestBreakpointAddressNoModule.py
@@ -0,0 +1,36 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def get_address_from_symbol(self, symbol):
+target = lldbutil.run_to_breakpoint_make_target(self, "a.out", True)
+bp = target.BreakpointCreateByName(symbol, None)
+address = bp.GetLocationAtIndex(0).GetAddress().GetFileAddress()
+return address
+
+def test_set_address_no_module(self):
+self.build()
+
+main_address = self.get_address_from_symbol("main")
+
+tgt = lldbutil.run_to_breakpoint_make_target(self)
+dbg = tgt.GetDebugger()
+
+dbg.HandleCommand(f"break set -a {main_address:#x}")
+self.assertTrue(tgt.GetNumBreakpoints() == 1)
+
+bp = tgt.GetBreakpointAtIndex(0)
+self.assertTrue(bp != None)
+
+_, _, thread, _ = lldbutil.run_to_breakpoint_do_run(self, tgt, bp)
+self.assertTrue(thread.GetNumFrames() >= 1)
+
+thread_pc = thread.GetFrameAtIndex(0).GetPCAddress()
+self.assertTrue(thread_pc != None)
+
+self.assertTrue(main_address==thread_pc.GetFileAddress())
Index: lldb/test/API/commands/breakpoint/set/address-nomodule/Makefile
===
--- /dev/null
+++ lldb/test/API/commands/breakpoint/set/address-nomodule/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := inferior.c
+
+include Makefile.rules
Index: lldb/source/Commands/Options.td
===
--- lldb/source/Commands/Options.td
+++ lldb/source/Commands/Options.td
@@ -128,13 +128,15 @@
 Arg<"AddressOrExpression">, Required,
 Desc<"Set the breakpoint at the specified address.  If the address maps "
 "uniquely to a particular binary, then the address will be converted to "
-"a \"file\"address, so that the breakpoint will track that binary+offset "
+"a \"file\" address, so that the breakpoint will track that binary+offset "
 "no matter where the binary eventually loads.  Alternately, if you also "
 "specify the module - with the -s option - then the address will be "
 "treated as a file address in that module, and resolved accordingly.  "
 "Again, this will allow lldb to track that offset on subsequent reloads.  "
 "The module need not have been loaded at the time you specify this "
-"breakpoint, and will get resolved when the module is loaded.">;
+"breakpoint, and will get resolved when the module is loaded.  If no "
+"module is specified, the binary being debugged is considered as a "
+"fallback.">;
   def breakpoint_set_name : Option<"name", "n">, Group<3>, Arg<"FunctionName">,
 Completion<"Symbol">, Required,
 Desc<"Set the breakpoint by function name.  Can be repeated multiple times "
Index: lldb/source/Breakpoint/BreakpointResolverAddress.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -121,16 +121,27 @@
 
   if (filter.AddressPasses(m_addr)) {
 if (breakpoint.GetNumLocations() == 0) {
-  // If the address is just an offset, and we're given a module, see if we
-  // can find the appropriate module loaded in the binary, and fix up
-  // m_addr to use that.
-  if (!m_addr.IsSectionOffset() && m_module_filespec) {
+  // If the address is just an offset ...
+  if (!m_addr.IsSectionOffset()) {
+ModuleSP containing_module_sp = nullptr;
 Target &target = breakpoint.GetTarget();
-ModuleSpec module_spec(m_module_filespec);
-ModuleSP module_sp = targe

[Lldb-commits] [PATCH] D124731: [lldb] Consider binary as module of last resort

2022-05-06 Thread Will Hawkins via Phabricator via lldb-commits
hawkinsw added a comment.

In D124731#3498195 , @hawkinsw wrote:

> (for real) Updating the patch based on helpful feedback from @jingham.

I used to know better how to make sure that phabricator notified people that 
the commit was updated based on their feedback, but I've since forgotten! 
Sorry! I hope that you didn't get spammed @jingham. Thanks again for the 
helpful review! It was fun to get to learn the unit-testing system. I hope that 
the test is acceptable!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124731

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


[Lldb-commits] [PATCH] D125148: Add an example command that runs to one of a set of breakpoints

2022-05-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham created this revision.
jingham added reviewers: JDevlieghere, kastiglione.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In a situation where you have a lot of breakpoints set, some enabled and some 
not, and you want to continue till you hit one breakpoint but don't want to hit 
any of the others in the course of doing that, you have to hand disable the 
other breakpoints, then continue, then re-enable the ones that were enabled 
when you started (but not the others).  That's tedious but easily done with 
scripting.  I wrote up this little example for somebody and it seems generally 
useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125148

Files:
  lldb/examples/python/cont_to_bkpt.py


Index: lldb/examples/python/cont_to_bkpt.py
===
--- /dev/null
+++ lldb/examples/python/cont_to_bkpt.py
@@ -0,0 +1,63 @@
+import lldb
+
+class ContinueToBreakpoint:
+def __init__(self, debugger, unused):
+self.dbg = debugger
+self.interp = debugger.GetCommandInterpreter()
+
+def __call__(self, debugger, command, exe_ctx, result):
+bkpt_strs = command.split()
+bkpt_ids = []
+for str in bkpt_strs:
+try:
+int_val = int(str)
+except:
+result.SetError("Input must be breakpoint id's: 
{0}".format(str))
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+
+bkpt_ids.append(int(str))
+
+if len(bkpt_ids) == 0:
+result.SetError("No breakpoint to run to")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+target = exe_ctx.target
+if  not exe_ctx.target.IsValid():
+result.SetError("Need a valid target")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+if not exe_ctx.process.IsValid():
+result.SetError("Need a valid process")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+
+disabled_bkpts = []
+for idx in range(0, exe_ctx.target.num_breakpoints):
+bkpt = target.GetBreakpointAtIndex(idx)
+bkpt_id = bkpt.GetID()
+if not bkpt_id in bkpt_ids:
+if bkpt.enabled:
+disabled_bkpts.append(bkpt)
+bkpt.enabled = False
+old_async = debugger.GetAsync()
+debugger.SetAsync(False)
+exe_ctx.process.Continue()
+strm = lldb.SBStream()
+if exe_ctx.process.state == lldb.eStateExited:
+result.PutCString("process exited with state: 
{0}".format(exe_ctx.process.exit_state))
+else:
+thread = exe_ctx.process.GetSelectedThread()
+thread.GetStatus(strm)
+result.PutCString(strm.GetData())
+
+result.SetStatus(lldb.eReturnStatusSuccessFinishResult)
+for bkpt in disabled_bkpts:
+bkpt.enabled = True;
+debugger.SetAsync(old_async)
+
+def get_short_help(self):
+return "takes a list of breakpoint ID's and continues the process 
until one of the breakpoint IDs passed in is hit"
+
+def __lldb_init_module(debugger, unused):
+debugger.HandleCommand("command script add -c {0}.ContinueToBreakpoint 
continue_to_bkpts".format(__name__))


Index: lldb/examples/python/cont_to_bkpt.py
===
--- /dev/null
+++ lldb/examples/python/cont_to_bkpt.py
@@ -0,0 +1,63 @@
+import lldb
+
+class ContinueToBreakpoint:
+def __init__(self, debugger, unused):
+self.dbg = debugger
+self.interp = debugger.GetCommandInterpreter()
+
+def __call__(self, debugger, command, exe_ctx, result):
+bkpt_strs = command.split()
+bkpt_ids = []
+for str in bkpt_strs:
+try:
+int_val = int(str)
+except:
+result.SetError("Input must be breakpoint id's: {0}".format(str))
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+
+bkpt_ids.append(int(str))
+
+if len(bkpt_ids) == 0:
+result.SetError("No breakpoint to run to")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+target = exe_ctx.target
+if  not exe_ctx.target.IsValid():
+result.SetError("Need a valid target")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+if not exe_ctx.process.IsValid():
+result.SetError("Need a valid process")
+result.SetStatus(lldb.eReturnStatusFailed)
+return
+
+disabled_bkpts = []
+for idx in range(0, exe_ctx.target.num_breakpoints):
+bkpt = target.GetBreakpointAtIndex(idx)
+bkpt_id 

[Lldb-commits] [PATCH] D125148: Add an example command that runs to one of a set of breakpoints

2022-05-06 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/cont_to_bkpt.py:13
+try:
+int_val = int(str)
+except:

is it worth supporting named breakpoints in addition to IDs



Comment at: lldb/examples/python/cont_to_bkpt.py:19
+
+bkpt_ids.append(int(str))
+

should this be int_value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125148

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


[Lldb-commits] [PATCH] D125148: Add an example command that runs to one of a set of breakpoints

2022-05-06 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/cont_to_bkpt.py:21
+
+if len(bkpt_ids) == 0:
+result.SetError("No breakpoint to run to")

can also be `if not bkpt_ids:`



Comment at: lldb/examples/python/cont_to_bkpt.py:31-32
+if not exe_ctx.process.IsValid():
+result.SetError("Need a valid process")
+result.SetStatus(lldb.eReturnStatusFailed)
+return

these `SetStatus` lines aren't necessary since `SetError(…)` internally calls 
`SetStatus(eReturnStatusFailed)`.



Comment at: lldb/examples/python/cont_to_bkpt.py:39
+bkpt_id = bkpt.GetID()
+if not bkpt_id in bkpt_ids:
+if bkpt.enabled:

can also be `if bkpt_id not in bkpt_ids:`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125148

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


[Lldb-commits] [PATCH] D125148: Add an example command that runs to one of a set of breakpoints

2022-05-06 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/cont_to_bkpt.py:5-6
+def __init__(self, debugger, unused):
+self.dbg = debugger
+self.interp = debugger.GetCommandInterpreter()
+

Are these properties needed by lldb? They aren't used in `__call__`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125148

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


[Lldb-commits] [PATCH] D125154: [lldb] Specify aguments of `image list`

2022-05-06 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added reviewers: aprantl, jingham.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Register positional argument details in `CommandObjectTargetModulesList`.

I recently learned that `image list` takes a module name, but the help info
does not indicate this. With this change, `help image list` will show that it
accepts zero or more module names.

This makes it easier to get info abot specific modules, without having to
find/grep through the full image list.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125154

Files:
  lldb/source/Commands/CommandObjectTarget.cpp


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -50,6 +50,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
 
 #include "llvm/ADT/ScopeExit.h"
@@ -2882,8 +2883,10 @@
   CommandObjectTargetModulesList(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "target modules list",
-"List current executable and dependent shared library images.",
-"target modules list []") {}
+"List current executable and dependent shared library images.") {
+CommandArgumentData module_arg{eArgTypeShlibName, eArgRepeatStar};
+m_arguments.push_back({module_arg});
+  }
 
   ~CommandObjectTargetModulesList() override = default;
 


Index: lldb/source/Commands/CommandObjectTarget.cpp
===
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ lldb/source/Commands/CommandObjectTarget.cpp
@@ -50,6 +50,7 @@
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Timer.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-private-enumerations.h"
 
 #include "llvm/ADT/ScopeExit.h"
@@ -2882,8 +2883,10 @@
   CommandObjectTargetModulesList(CommandInterpreter &interpreter)
   : CommandObjectParsed(
 interpreter, "target modules list",
-"List current executable and dependent shared library images.",
-"target modules list []") {}
+"List current executable and dependent shared library images.") {
+CommandArgumentData module_arg{eArgTypeShlibName, eArgRepeatStar};
+m_arguments.push_back({module_arg});
+  }
 
   ~CommandObjectTargetModulesList() override = default;
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits