mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
AK: Add a getter to JsonValue to get machine-native addresses
This commit is contained in:
parent
36e36507d5
commit
11e02f222d
Notes:
sideshowbarker
2024-07-18 08:36:52 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/11e02f222d2 Pull-request: https://github.com/SerenityOS/serenity/pull/8925 Reviewed-by: https://github.com/awesomekling
3 changed files with 14 additions and 9 deletions
|
@ -91,6 +91,15 @@ public:
|
|||
u32 to_u32(u32 default_value = 0) const { return to_number<u32>(default_value); }
|
||||
u64 to_u64(u64 default_value = 0) const { return to_number<u64>(default_value); }
|
||||
|
||||
FlatPtr to_addr(FlatPtr default_value = 0) const
|
||||
{
|
||||
#ifdef __LP64__
|
||||
return to_u64(default_value);
|
||||
#else
|
||||
return to_u32(default_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool to_bool(bool default_value = false) const
|
||||
{
|
||||
if (!is_bool())
|
||||
|
|
|
@ -108,7 +108,7 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
|
|||
|
||||
stack.ensure_capacity(json.value().as_array().size());
|
||||
for (auto& value : json.value().as_array().values()) {
|
||||
stack.append(value.to_u32());
|
||||
stack.append(value.to_addr());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
|
|||
for (auto& region_value : json.value().as_array().values()) {
|
||||
auto& region = region_value.as_object();
|
||||
auto name = region.get("name").to_string();
|
||||
auto address = region.get("address").to_u32();
|
||||
auto size = region.get("size").to_u32();
|
||||
auto address = region.get("address").to_addr();
|
||||
auto size = region.get("size").to_addr();
|
||||
|
||||
String path;
|
||||
if (name == "/usr/lib/Loader.so") {
|
||||
|
|
|
@ -55,16 +55,12 @@ int main(int argc, char** argv)
|
|||
|
||||
Vector<JsonValue> sorted_regions = json.value().as_array().values();
|
||||
quick_sort(sorted_regions, [](auto& a, auto& b) {
|
||||
return a.as_object().get("address").to_u64() < b.as_object().get("address").to_u64();
|
||||
return a.as_object().get("address").to_addr() < b.as_object().get("address").to_addr();
|
||||
});
|
||||
|
||||
for (auto& value : sorted_regions) {
|
||||
auto& map = value.as_object();
|
||||
#if ARCH(I386)
|
||||
auto address = map.get("address").to_u32();
|
||||
#else
|
||||
auto address = map.get("address").to_u64();
|
||||
#endif
|
||||
auto address = map.get("address").to_addr();
|
||||
auto size = map.get("size").to_string();
|
||||
|
||||
auto access = String::formatted("{}{}{}{}{}",
|
||||
|
|
Loading…
Add table
Reference in a new issue