Skip to content

The _code field in an NSError is signed, not unsigned. #119764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lldb/source/Plugins/Language/ObjC/NSError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ 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,
ptr_size, 0, error);
int64_t code = process_sp->ReadSignedIntegerFromMemory(code_location,
ptr_size, 0, error);
if (error.Fail())
return false;

Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ 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"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading