This is an archive of the discontinued LLVM Phabricator instance.

[lldb] StructuredData should not truncate uint64_t values
ClosedPublic

Authored by bulbazord on Feb 16 2023, 6:26 PM.

Details

Summary

In json::Value, getAsInteger returns an optional<int64_t> and getAsNumber
returns an optional<double>. If a value is larger than what an int64_t
can hold but smaller than what a uint64_t can hold, the getAsInteger
function will fail but the getAsNumber will succeed. However, the value
shouldn't be interpreted as a double.

rdar://105556974

Diff Detail

Event Timeline

bulbazord created this revision.Feb 16 2023, 6:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2023, 6:26 PM
bulbazord requested review of this revision.Feb 16 2023, 6:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2023, 6:26 PM
bulbazord edited the summary of this revision. (Show Details)Feb 16 2023, 6:30 PM
mib added a comment.Feb 16 2023, 6:41 PM

Should we also add a negative integer to the dictionary to make sure this didn't cause a regression ?

lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py
23–31

Ditto (hex)

136

nit: I think the hex representation would be cleaner.

Should we also add a negative integer to the dictionary to make sure this didn't cause a regression ?

Negative integers are not correctly handled currently. I plan on fixing that in a follow-up. See:

(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> foo = lldb.SBStructuredData()
>>> foo.SetFromJSON('{"foo": -5}')
error: <NULL>
>>> foo.GetValueForKey('foo').GetIntegerValue()
18446744073709551611
mib accepted this revision.Feb 16 2023, 7:01 PM

LGTM then (with nits ;p)

This revision is now accepted and ready to land.Feb 16 2023, 7:01 PM

Address comments

This revision was landed with ongoing or failed builds.Feb 17 2023, 12:40 PM
This revision was automatically updated to reflect the committed changes.