[Lldb-commits] [PATCH] D152918: [lldb] Add register field tables to the "register info" command

2023-06-21 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcfe5a52a39d: [lldb] Add register field tables to the 
register info command (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152918

Files:
  lldb/include/lldb/Core/DumpRegisterInfo.h
  lldb/source/Commands/CommandObjectRegister.cpp
  lldb/source/Core/DumpRegisterInfo.cpp
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
  lldb/unittests/Core/DumpRegisterInfoTest.cpp

Index: lldb/unittests/Core/DumpRegisterInfoTest.cpp
===
--- lldb/unittests/Core/DumpRegisterInfoTest.cpp
+++ lldb/unittests/Core/DumpRegisterInfoTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "lldb/Core/DumpRegisterInfo.h"
+#include "lldb/Target/RegisterFlags.h"
 #include "lldb/Utility/StreamString.h"
 #include "gtest/gtest.h"
 
@@ -14,27 +15,28 @@
 
 TEST(DoDumpRegisterInfoTest, MinimumInfo) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)");
 }
 
 TEST(DoDumpRegisterInfoTest, AltName) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", "bar", 4, {}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", "bar", 4, {}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo (bar)\n"
   "   Size: 4 bytes (32 bits)");
 }
 
 TEST(DoDumpRegisterInfoTest, Invalidates) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2"}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2"}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "Invalidates: foo2");
 
   strm.Clear();
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2", "foo3", "foo4"}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2", "foo3", "foo4"}, {}, {},
+ nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "Invalidates: foo2, foo3, foo4");
@@ -42,13 +44,14 @@
 
 TEST(DoDumpRegisterInfoTest, ReadFrom) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1"}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1"}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "  Read from: foo1");
 
   strm.Clear();
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1", "foo2", "foo3"}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1", "foo2", "foo3"}, {},
+ nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "  Read from: foo1, foo2, foo3");
@@ -56,14 +59,15 @@
 
 TEST(DoDumpRegisterInfoTest, InSets) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {{"set1", 101}});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {{"set1", 101}}, nullptr,
+ 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "In sets: set1 (index 101)");
 
   strm.Clear();
   DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {},
- {{"set1", 0}, {"set2", 1}, {"set3", 2}});
+ {{"set1", 0}, {"set2", 1}, {"set3", 2}}, nullptr, 0);
   ASSERT_EQ(strm.GetString(),
 "   Name: foo\n"
 "   Size: 4 bytes (32 bits)\n"
@@ -73,10 +77,28 @@
 TEST(DoDumpRegisterInfoTest, MaxInfo) {
   StreamString strm;
   DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2", "foo3"},
- {"foo3", "foo4"}, {{"set1", 1}, {"set2", 2}});
+ {"foo3", "foo4"}, {{"set1", 1}, {"set2", 2}}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "Invalidates: foo2, foo3\n"
   "  Read from: foo3, foo4\n"
   "In sets: set1 (index 1), set2 (index 2)");
 }
+
+TEST(DoDumpRegisterInfoTest, FieldsTable) {
+  // This is thoroughly tested in RegisterFlags itself, only checking the
+  // integration here.
+  StreamString strm;
+  RegisterFlags flags(
+  "", 4,
+  

[Lldb-commits] [PATCH] D152918: [lldb] Add register field tables to the "register info" command

2023-06-14 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.  Putting this in `register info` is good, it's not too easily 
discoverable (to be honest I didn't know this command existed today), but as 
you say, the number of people who want to see this are relatively small so 
putting it in a more mainstream command like register read may not be the best 
choice.  We can start with only in `register info`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152918

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


[Lldb-commits] [PATCH] D152918: [lldb] Add register field tables to the "register info" command

2023-06-14 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

This is the major use case for the command. With these diagrams matching the 
architecture manual (mostly) you can use them to work out what mask/shift you 
need. You'll be able to print a register, see that the field isn't the right 
value, then "register info" and realise what you did wrong. The audience for it 
is small but when I was one of that audience (different debugger though) I 
really appreciated not having to leave the debugger to do this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152918

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


[Lldb-commits] [PATCH] D152918: [lldb] Add register field tables to the "register info" command

2023-06-14 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 teaches DumpRegisterInfo to generate a table from the register
flags type. It just calls a method on RegisterFlags.

As such, the extra tests are minimal and only show that the intergration
works. Exhaustive formatting tests are done with RegisterFlags itself.

Example:

  (lldb) register info cpsr
 Name: cpsr
 Size: 4 bytes (32 bits)
  In sets: general (index 0)
  
  | 31 | 30 | 29 | 28 | 27-26 | 25  | 24  | 23  | 22  | 21 | 20 | 19-13 |  12  
| 11-10 | 9 | 8 | 7 | 6 | 5 |  4  | 3-2 | 1 | 0  |
  
|||||---|-|-|-|-|||---|--|---|---|---|---|---|---|-|-|---||
  | N  | Z  | C  | V  |   | TCO | DIT | UAO | PAN | SS | IL |   | SSBS 
|   | D | A | I | F |   | nRW | EL  |   | SP |

LLDB limits the max terminal width to 80 chars by default.
So to get that full width output you will need to change the "term-width"
setting to something higher.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152918

Files:
  lldb/include/lldb/Core/DumpRegisterInfo.h
  lldb/source/Commands/CommandObjectRegister.cpp
  lldb/source/Core/DumpRegisterInfo.cpp
  lldb/test/API/commands/register/register/register_command/TestRegisters.py
  lldb/test/API/functionalities/gdb_remote_client/TestXMLRegisterFlags.py
  lldb/unittests/Core/DumpRegisterInfoTest.cpp

Index: lldb/unittests/Core/DumpRegisterInfoTest.cpp
===
--- lldb/unittests/Core/DumpRegisterInfoTest.cpp
+++ lldb/unittests/Core/DumpRegisterInfoTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "lldb/Core/DumpRegisterInfo.h"
+#include "lldb/Target/RegisterFlags.h"
 #include "lldb/Utility/StreamString.h"
 #include "gtest/gtest.h"
 
@@ -14,27 +15,28 @@
 
 TEST(DoDumpRegisterInfoTest, MinimumInfo) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)");
 }
 
 TEST(DoDumpRegisterInfoTest, AltName) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", "bar", 4, {}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", "bar", 4, {}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo (bar)\n"
   "   Size: 4 bytes (32 bits)");
 }
 
 TEST(DoDumpRegisterInfoTest, Invalidates) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2"}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2"}, {}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "Invalidates: foo2");
 
   strm.Clear();
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2", "foo3", "foo4"}, {}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {"foo2", "foo3", "foo4"}, {}, {},
+ nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "Invalidates: foo2, foo3, foo4");
@@ -42,13 +44,14 @@
 
 TEST(DoDumpRegisterInfoTest, ReadFrom) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1"}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1"}, {}, nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "  Read from: foo1");
 
   strm.Clear();
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1", "foo2", "foo3"}, {});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {"foo1", "foo2", "foo3"}, {},
+ nullptr, 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "  Read from: foo1, foo2, foo3");
@@ -56,14 +59,15 @@
 
 TEST(DoDumpRegisterInfoTest, InSets) {
   StreamString strm;
-  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {{"set1", 101}});
+  DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {}, {{"set1", 101}}, nullptr,
+ 0);
   ASSERT_EQ(strm.GetString(), "   Name: foo\n"
   "   Size: 4 bytes (32 bits)\n"
   "In sets: set1 (index 101)");
 
   strm.Clear();
   DoDumpRegisterInfo(strm, "foo", nullptr, 4, {}, {},
- {{"set1", 0}, {"set2", 1}, {"set3", 2}});
+ {{"set1", 0}, {"set2", 1}, {"set3", 2}}, nullptr, 0);
   ASSERT_EQ(strm.GetString(),
 "   Name: foo\n"