[Lldb-commits] [lldb] The _code field in an NSError is signed, not unsigned. (PR #119764)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 12 13:24:53 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: None (jimingham)
<details>
<summary>Changes</summary>
The NSError summary provider was fetching and printing the `_code` field as an unsigned integer, but it's defined to be an NSInteger, which is signed.
---
Full diff: https://github.com/llvm/llvm-project/pull/119764.diff
3 Files Affected:
- (modified) lldb/source/Plugins/Language/ObjC/NSError.cpp (+4-4)
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py (+2-2)
- (modified) lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m (+1-1)
``````````diff
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 2356bc4ef4babd..389ff5a7edb1bf 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -66,7 +66,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
lldb::addr_t domain_location = ptr_value + 3 * ptr_size;
Status error;
- uint64_t code = process_sp->ReadUnsignedIntegerFromMemory(code_location,
+ int64_t code = process_sp->ReadSignedIntegerFromMemory(code_location,
ptr_size, 0, error);
if (error.Fail())
return false;
@@ -77,7 +77,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
return false;
if (!domain_str_value) {
- stream.Printf("domain: nil - code: %" PRIu64, code);
+ stream.Printf("domain: nil - code: %" PRIi64, code);
return true;
}
@@ -98,11 +98,11 @@ bool lldb_private::formatters::NSError_SummaryProvider(
StreamString domain_str_summary;
if (NSStringSummaryProvider(*domain_str_sp, domain_str_summary, options) &&
!domain_str_summary.Empty()) {
- stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(),
+ stream.Printf("domain: %s - code: %" PRIi64, domain_str_summary.GetData(),
code);
return true;
} else {
- stream.Printf("domain: nil - code: %" PRIu64, code);
+ stream.Printf("domain: nil - code: %" PRIi64, code);
return true;
}
}
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
index 8a052cf84ef0ee..8709386bfbd384 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
@@ -23,10 +23,10 @@ def test_nserror_with_run_command_no_const(self):
self.appkit_tester_impl(self.nserror_data_formatter_commands, False)
def nserror_data_formatter_commands(self):
- self.expect("frame variable nserror", substrs=['domain: @"Foobar" - code: 12'])
+ self.expect("frame variable nserror", substrs=['domain: @"Foobar" - code: -1234'])
self.expect(
- "frame variable nserrorptr", substrs=['domain: @"Foobar" - code: 12']
+ "frame variable nserrorptr", substrs=['domain: @"Foobar" - code: -1234']
)
self.expect("frame variable nserror->_userInfo", substrs=["2 key/value pairs"])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
index 0ca5cf98bd3a53..314bada49303d3 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-objc/main.m
@@ -618,7 +618,7 @@ int main(int argc, const char *argv[]) {
NSDictionary *error_userInfo = @{@"a" : @1, @"b" : @2};
NSError *nserror = [[NSError alloc] initWithDomain:@"Foobar"
- code:12
+ code:-1234
userInfo:error_userInfo];
NSError **nserrorptr = &nserror;
``````````
</details>
https://github.com/llvm/llvm-project/pull/119764
More information about the lldb-commits
mailing list