[Lldb-commits] [lldb] 9179b07 - [LLDB] Complete a missing register format mapping in the gdb-remote p… (#152170)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 5 10:53:18 PDT 2025
Author: Walter Erquinigo
Date: 2025-08-05T13:53:15-04:00
New Revision: 9179b079812319010ab09718926ee73ca26ecc78
URL: https://github.com/llvm/llvm-project/commit/9179b079812319010ab09718926ee73ca26ecc78
DIFF: https://github.com/llvm/llvm-project/commit/9179b079812319010ab09718926ee73ca26ecc78.diff
LOG: [LLDB] Complete a missing register format mapping in the gdb-remote p… (#152170)
…rotocol
When writing a custom gdb-remote server I realized that the encoder and
decoder of register formats is incomplete.
- Add the encoder on the server side and add an llvm_unreachable is
there's a missing case.
- Add a decoder on the client side that doesn't fail. We have to keep it
flexible.
I couldn't figure out an easy way to test this but the changes seem very
straightforward to me.
Added:
Modified:
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 89d2730cfccd0..04786afedc184 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -41,6 +41,7 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UnimplementedError.h"
#include "lldb/Utility/UriParser.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/TargetParser/Triple.h"
@@ -536,14 +537,54 @@ static llvm::StringRef GetEncodingNameOrEmpty(const RegisterInfo ®_info) {
static llvm::StringRef GetFormatNameOrEmpty(const RegisterInfo ®_info) {
switch (reg_info.format) {
+ case eFormatDefault:
+ return "";
+ case eFormatBoolean:
+ return "boolean";
case eFormatBinary:
return "binary";
+ case eFormatBytes:
+ return "bytes";
+ case eFormatBytesWithASCII:
+ return "bytes-with-ascii";
+ case eFormatChar:
+ return "char";
+ case eFormatCharPrintable:
+ return "char-printable";
+ case eFormatComplex:
+ return "complex";
+ case eFormatCString:
+ return "cstring";
case eFormatDecimal:
return "decimal";
+ case eFormatEnum:
+ return "enum";
case eFormatHex:
return "hex";
+ case eFormatHexUppercase:
+ return "hex-uppercase";
case eFormatFloat:
return "float";
+ case eFormatOctal:
+ return "octal";
+ case eFormatOSType:
+ return "ostype";
+ case eFormatUnicode16:
+ return "unicode16";
+ case eFormatUnicode32:
+ return "unicode32";
+ case eFormatUnsigned:
+ return "unsigned";
+ case eFormatPointer:
+ return "pointer";
+ case eFormatVectorOfChar:
+ return "vector-char";
+ case eFormatVectorOfSInt64:
+ return "vector-sint64";
+ case eFormatVectorOfFloat16:
+ return "vector-float16";
+ case eFormatVectorOfFloat64:
+ return "vector-float64";
case eFormatVectorOfSInt8:
return "vector-sint8";
case eFormatVectorOfUInt8:
@@ -562,8 +603,24 @@ static llvm::StringRef GetFormatNameOrEmpty(const RegisterInfo ®_info) {
return "vector-uint64";
case eFormatVectorOfUInt128:
return "vector-uint128";
+ case eFormatComplexInteger:
+ return "complex-integer";
+ case eFormatCharArray:
+ return "char-array";
+ case eFormatAddressInfo:
+ return "address-info";
+ case eFormatHexFloat:
+ return "hex-float";
+ case eFormatInstruction:
+ return "instruction";
+ case eFormatVoid:
+ return "void";
+ case eFormatUnicode8:
+ return "unicode8";
+ case eFormatFloat128:
+ return "float128";
default:
- return "";
+ llvm_unreachable("Unkown register format")
};
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index f610422d34169..85e141d41747e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -481,10 +481,29 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
.Success())
reg_info.format =
llvm::StringSwitch<Format>(value)
+ .Case("boolean", eFormatBoolean)
.Case("binary", eFormatBinary)
+ .Case("bytes", eFormatBytes)
+ .Case("bytes-with-ascii", eFormatBytesWithASCII)
+ .Case("char", eFormatChar)
+ .Case("char-printable", eFormatCharPrintable)
+ .Case("complex", eFormatComplex)
+ .Case("cstring", eFormatCString)
.Case("decimal", eFormatDecimal)
+ .Case("enum", eFormatEnum)
.Case("hex", eFormatHex)
+ .Case("hex-uppercase", eFormatHexUppercase)
.Case("float", eFormatFloat)
+ .Case("octal", eFormatOctal)
+ .Case("ostype", eFormatOSType)
+ .Case("unicode16", eFormatUnicode16)
+ .Case("unicode32", eFormatUnicode32)
+ .Case("unsigned", eFormatUnsigned)
+ .Case("pointer", eFormatPointer)
+ .Case("vector-char", eFormatVectorOfChar)
+ .Case("vector-sint64", eFormatVectorOfSInt64)
+ .Case("vector-float16", eFormatVectorOfFloat16)
+ .Case("vector-float64", eFormatVectorOfFloat64)
.Case("vector-sint8", eFormatVectorOfSInt8)
.Case("vector-uint8", eFormatVectorOfUInt8)
.Case("vector-sint16", eFormatVectorOfSInt16)
@@ -494,6 +513,14 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
.Case("vector-float32", eFormatVectorOfFloat32)
.Case("vector-uint64", eFormatVectorOfUInt64)
.Case("vector-uint128", eFormatVectorOfUInt128)
+ .Case("complex-integer", eFormatComplexInteger)
+ .Case("char-array", eFormatCharArray)
+ .Case("address-info", eFormatAddressInfo)
+ .Case("hex-float", eFormatHexFloat)
+ .Case("instruction", eFormatInstruction)
+ .Case("void", eFormatVoid)
+ .Case("unicode8", eFormatUnicode8)
+ .Case("float128", eFormatFloat128)
.Default(eFormatInvalid);
} else if (name == "set") {
reg_info.set_name.SetString(value);
More information about the lldb-commits
mailing list