[Lldb-commits] [lldb] ObjectFileJSON and Section changes to support section.address field i… (PR #101062)

Ilhan Raja via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 29 14:53:21 PDT 2024


YungRaj wrote:

> This patch fixes the deserialization of the "address" field which surely can be tested in isolation. The existing test (`TestObjectFileJSON.py`) has `address` set to zero, which is why this happens to work today. It should be possible to either update the test or add a new one that has a non-zero section address, which would fail prior to this patch, but pass with it.

I was hoping to fix everything in one Pull Request so that it at least becomes usable once this merges. I can handle the unit test changes, but I'm unsure how to fix the other memory reading issue while debugging the target. I describe it in brief on that other comment.

Basically reading the memory of the symbolicated address reads from the JSON Object File instead of the live memory.

```
ilhanraja at ilhanrajas-Virtual-Machine build % bin/lldb
(lldb) target create /Users/ilhanraja/Downloads/symbols.json 
Current executable set to '/Users/ilhanraja/Downloads/symbols.json' (arm64e).
(lldb) gdb-remote 10.11.1.2:4000
Kernel UUID: 894FC3F0-4DF9-3A70-A4EE-75646151C8A7
Load Address: 0xfffffff00700c000
Process 1 stopped
* thread #1, stop reason = signal SIGINT
    frame #0: 0xfffffff007d56080
error: 0xffffffffffffffff can't be resolved
(lldb) bt
* thread #1, stop reason = signal SIGINT
  * frame #0: 0xfffffff007d56080
    frame #1: 0xfffffff007ecafe8
    frame #2: 0xfffffff007dc2d50
    frame #3: 0xfffffff007dc2fb8
(lldb) image lookup -r -s ipc
74 symbols match the regular expression 'ipc' in /Users/ilhanraja/Downloads/symbols.json:
        Address: symbols.json[0xfffffff007d62124] (symbols.json.com.apple.kernel:__text + 106788)
        Summary: symbols.json`ipc_hash_delete
        Address: symbols.json[0xfffffff007d6264c] (symbols.json.com.apple.kernel:__text + 108108)
        Summary: symbols.json`ipc_importance_task_check_transition
        Address: symbols.json[0xfffffff007d62774] (symbols.json.com.apple.kernel:__text + 108404)
        Summary: symbols.json`ipc_importance_task_propagate_assertion_locked
        Address: symbols.json[0xfffffff007d66b80] (symbols.json.com.apple.kernel:__text + 125824)
        Summary: symbols.json`ipc_kmsg_alloc
        Address: symbols.json[0xfffffff007d66e30] (symbols.json.com.apple.kernel:__text + 126512)
        Summary: symbols.json`ipc_kmsg_alloc_uext_reply
        Address: symbols.json[0xfffffff007d671c4] (symbols.json.com.apple.kernel:__text + 127428)
        Summary: symbols.json`ipc_kmsg_enqueue_qos
        Address: symbols.json[0xfffffff007d675f8] (symbols.json.com.apple.kernel:__text + 128504)
        Summary: symbols.json`ipc_kmsg_clean_body
        Address: symbols.json[0xfffffff007d6af48] (symbols.json.com.apple.kernel:__text + 143176)
        Summary: symbols.json`_ipc_kmsg_option_check
        Address: symbols.json[0xfffffff007d6b0fc] (symbols.json.com.apple.kernel:__text + 143612)
        Summary: symbols.json`ipc_kmsg_validate_reply_port_locked
        Address: symbols.json[0xfffffff007d6bf78] (symbols.json.com.apple.kernel:__text + 147320)
        Summary: symbols.json`ipc_kmsg_link_reply_context_locked
        Address: symbols.json[0xfffffff007d6cf5c] (symbols.json.com.apple.kernel:__text + 151388)
        Summary: symbols.json`ipc_kmsg_get_thread_group
        Address: symbols.json[0xfffffff007d6e65c] (symbols.json.com.apple.kernel:__text + 157276)
        Summary: symbols.json`ipc_mqueue_destroy_locked
        Address: symbols.json[0xfffffff007d6e6fc] (symbols.json.com.apple.kernel:__text + 157436)
        Summary: symbols.json`ipc_mqueue_set_qlimit_locked
        Address: symbols.json[0xfffffff007d6e87c] (symbols.json.com.apple.kernel:__text + 157820)
        Summary: symbols.json`ipc_notify_port_deleted
        Address: symbols.json[0xfffffff007d6e8e0] (symbols.json.com.apple.kernel:__text + 157920)
        Summary: symbols.json`ipc_notify_no_senders_prepare
        Address: symbols.json[0xfffffff007d6ea50] (symbols.json.com.apple.kernel:__text + 158288)
        Summary: symbols.json`ipc_notify_send_once_and_unlock
        Address: symbols.json[0xfffffff007d6eb6c] (symbols.json.com.apple.kernel:__text + 158572)
        Summary: symbols.json`ipc_object_deallocate_queue_invoke
        Address: symbols.json[0xfffffff007d6ec7c] (symbols.json.com.apple.kernel:__text + 158844)
        Summary: symbols.json`ipc_object_release
        Address: symbols.json[0xfffffff007d6f300] (symbols.json.com.apple.kernel:__text + 160512)
        Summary: symbols.json`ipc_object_alloc
        Address: symbols.json[0xfffffff007d6f400] (symbols.json.com.apple.kernel:__text + 160768)
        Summary: symbols.json`ipc_object_alloc_name
        Address: symbols.json[0xfffffff007d70844] (symbols.json.com.apple.kernel:__text + 165956)
        Summary: symbols.json`ipc_object_lock_allow_invalid
        Address: symbols.json[0xfffffff007d70970] (symbols.json.com.apple.kernel:__text + 166256)
        Summary: symbols.json`ipc_port_reference
        Address: symbols.json[0xfffffff007d709f4] (symbols.json.com.apple.kernel:__text + 166388)
        Summary: symbols.json`ipc_port_translate_send
        Address: symbols.json[0xfffffff007d70a5c] (symbols.json.com.apple.kernel:__text + 166492)
        Summary: symbols.json`ipc_port_translate_receive
        Address: symbols.json[0xfffffff007d714d0] (symbols.json.com.apple.kernel:__text + 169168)
        Summary: symbols.json`ipc_port_clear_receiver
        Address: symbols.json[0xfffffff007d7179c] (symbols.json.com.apple.kernel:__text + 169884)
        Summary: symbols.json`ipc_port_alloc
        Address: symbols.json[0xfffffff007d72cc8] (symbols.json.com.apple.kernel:__text + 175304)
        Summary: symbols.json`ipc_port_send_update_inheritor
        Address: symbols.json[0xfffffff007d72fd0] (symbols.json.com.apple.kernel:__text + 176080)
        Summary: symbols.json`ipc_port_recv_update_inheritor
        Address: symbols.json[0xfffffff007d734a8] (symbols.json.com.apple.kernel:__text + 177320)
        Summary: symbols.json`ipc_port_adjust_port_locked
        Address: symbols.json[0xfffffff007d73af4] (symbols.json.com.apple.kernel:__text + 178932)
        Summary: symbols.json`ipc_port_get_receiver_task_locked
        Address: symbols.json[0xfffffff007d73dc4] (symbols.json.com.apple.kernel:__text + 179652)
        Summary: symbols.json`ipc_port_make_send_any_locked
        Address: symbols.json[0xfffffff007d74018] (symbols.json.com.apple.kernel:__text + 180248)
        Summary: symbols.json`ipc_port_copy_send_any_locked
        Address: symbols.json[0xfffffff007d74074] (symbols.json.com.apple.kernel:__text + 180340)
        Summary: symbols.json`ipc_port_copy_send_any
        Address: symbols.json[0xfffffff007d7411c] (symbols.json.com.apple.kernel:__text + 180508)
        Summary: symbols.json`ipc_port_copy_send_mqueue
        Address: symbols.json[0xfffffff007d74220] (symbols.json.com.apple.kernel:__text + 180768)
        Summary: symbols.json`ipc_port_copyout_send
        Address: symbols.json[0xfffffff007d74298] (symbols.json.com.apple.kernel:__text + 180888)
        Summary: symbols.json`ipc_port_copyout_send_pinned
        Address: symbols.json[0xfffffff007d743a0] (symbols.json.com.apple.kernel:__text + 181152)
        Summary: symbols.json`ipc_port_release_send_and_unlock
        Address: symbols.json[0xfffffff007d74808] (symbols.json.com.apple.kernel:__text + 182280)
        Summary: symbols.json`ipc_port_release_sonce_and_unlock
        Address: symbols.json[0xfffffff007d76320] (symbols.json.com.apple.kernel:__text + 189216)
        Summary: symbols.json`ipc_pset_alloc_name
        Address: symbols.json[0xfffffff007d7749c] (symbols.json.com.apple.kernel:__text + 193692)
        Summary: symbols.json`ipc_right_request_cancel
        Address: symbols.json[0xfffffff007d79ab4] (symbols.json.com.apple.kernel:__text + 203444)
        Summary: symbols.json`ipc_right_copyin_check_guard_locked
        Address: symbols.json[0xfffffff007d7a3c8] (symbols.json.com.apple.kernel:__text + 205768)
        Summary: symbols.json`_ipc_space_retire_table
        Address: symbols.json[0xfffffff007d7a4d0] (symbols.json.com.apple.kernel:__text + 206032)
        Summary: symbols.json`ipc_space_free
        Address: symbols.json[0xfffffff007d7a560] (symbols.json.com.apple.kernel:__text + 206176)
        Summary: symbols.json`ipc_space_rand_freelist
        Address: symbols.json[0xfffffff007d7ad6c] (symbols.json.com.apple.kernel:__text + 208236)
        Summary: symbols.json`ipc_service_port_label_alloc
        Address: symbols.json[0xfffffff007d7af8c] (symbols.json.com.apple.kernel:__text + 208780)
        Summary: symbols.json`ipc_service_port_derive_sblabel
        Address: symbols.json[0xfffffff007d7b140] (symbols.json.com.apple.kernel:__text + 209216)
        Summary: symbols.json`ipc_service_port_get_sblabel
        Address: symbols.json[0xfffffff007d96804] (symbols.json.com.apple.kernel:__text + 321540)
        Summary: symbols.json`_ipc_kobject_label_substitute_thread
        Address: symbols.json[0xfffffff007d968dc] (symbols.json.com.apple.kernel:__text + 321756)
        Summary: symbols.json`_ipc_kobject_label_substitute_thread_read
        Address: symbols.json[0xfffffff007d9ea14] (symbols.json.com.apple.kernel:__text + 354836)
        Summary: symbols.json`ipc_thread_init_exc_actions
        Address: symbols.json[0xfffffff007e07e70] (symbols.json.com.apple.kernel:__text + 786032)
        Summary: symbols.json`get_task_ipcspace
        Address: symbols.json[0xfffffff008240ae4] (symbols.json.com.apple.kernel:__text + 5212900)
        Summary: symbols.json`uipc_sockaddr
        Address: symbols.json[0xfffffff008240b70] (symbols.json.com.apple.kernel:__text + 5213040)
        Summary: symbols.json`uipc_shutdown
        Address: symbols.json[0xfffffff008240cb4] (symbols.json.com.apple.kernel:__text + 5213364)
        Summary: symbols.json`uipc_sense
        Address: symbols.json[0xfffffff008242b80] (symbols.json.com.apple.kernel:__text + 5221248)
        Summary: symbols.json`uipc_rcvd
        Address: symbols.json[0xfffffff008242c98] (symbols.json.com.apple.kernel:__text + 5221528)
        Summary: symbols.json`uipc_peeraddr
        Address: symbols.json[0xfffffff008242e30] (symbols.json.com.apple.kernel:__text + 5221936)
        Summary: symbols.json`uipc_listen
        Address: symbols.json[0xfffffff008243978] (symbols.json.com.apple.kernel:__text + 5224824)
        Summary: symbols.json`uipc_accept
        Address: symbols.json[0xfffffff008243a4c] (symbols.json.com.apple.kernel:__text + 5225036)
        Summary: symbols.json`uipc_abort
        Address: symbols.json[0xfffffff0083507d0] (symbols.json.com.apple.kernel:__text + 6326224)
        Summary: symbols.json`IODispatchQueue::SetPort(ipc_port
        Address: symbols.json[0xfffffff0083565d4] (symbols.json.com.apple.kernel:__text + 6350292)
        Summary: symbols.json`IOEventLink::SetEventlinkPort(ipc_port
        Address: symbols.json[0xfffffff00835703c] (symbols.json.com.apple.kernel:__text + 6352956)
        Summary: symbols.json`IOWorkGroup::SetWorkGroupPort(ipc_port
        Address: symbols.json[0xfffffff0083fe7fc] (symbols.json.com.apple.kernel:__text + 7038972)
        Summary: symbols.json`IOUserClient::registerNotificationPort(ipc_port
        Address: symbols.json[0xfffffff00840363c] (symbols.json.com.apple.kernel:__text + 7059004)
        Summary: symbols.json`__ZN12IOUserClient17setAsyncReferenceEPjP8ipc_portPvS3__0_1
        Address: symbols.json[0xfffffff0084051e8] (symbols.json.com.apple.kernel:__text + 7066088)
        Summary: symbols.json`IOUserClient::releaseNotificationPort(ipc_port
        Address: symbols.json[0xfffffff00840f9d8] (symbols.json.com.apple.kernel:__text + 7109080)
        Summary: symbols.json`IODataQueue::setNotificationPort(ipc_port
        Address: symbols.json[0xfffffff00849a380] (symbols.json.com.apple.kernel:__text + 7676800)
        Summary: symbols.json`ipc_importance_init
        Address: symbols.json[0xfffffff00849a3a0] (symbols.json.com.apple.kernel:__text + 7676832)
        Summary: symbols.json`ipc_importance_thread_call_init
        Address: symbols.json[0xfffffff00849a5a0] (symbols.json.com.apple.kernel:__text + 7677344)
        Summary: symbols.json`ipc_object_validate_preflight_panic
        Address: symbols.json[0xfffffff00849a5d0] (symbols.json.com.apple.kernel:__text + 7677392)
        Summary: symbols.json`__ipc_port_inactive_panic
        Address: symbols.json[0xfffffff00849a698] (symbols.json.com.apple.kernel:__text + 7677592)
        Summary: symbols.json`ipc_voucher_init
        Address: symbols.json[0xfffffff00849ad30] (symbols.json.com.apple.kernel:__text + 7679280)
        Summary: symbols.json`__ipc_kobject_dealloc_bad_type_panic
        Address: symbols.json[0xfffffff00849ad6c] (symbols.json.com.apple.kernel:__text + 7679340)
        Summary: symbols.json`__ipc_kobject_dealloc_bad_mscount_panic
        Address: symbols.json[0xfffffff00849ada4] (symbols.json.com.apple.kernel:__text + 7679396)
        Summary: symbols.json`__ipc_kobject_dealloc_bad_srights_panic

(lldb) memory read 0xfffffff007d6264c
0xfffffff007d6264c: 34 34 30 30 35 31 32 32 33 32 37 35 35 32 0a 20  44005122327552. 
0xfffffff007d6265c: 20 20 20 20 20 20 20 7d 2c 0a 20 20 20 20 20 20         },.      
(lldb) memory read 0xfffffff007d62620 -c 512 
0xfffffff007d62620: 74 79 70 65 22 3a 20 22 63 6f 64 65 22 2c 0a 20  type": "code",. 
0xfffffff007d62630: 20 20 20 20 20 20 20 20 20 20 20 22 61 64 64 72             "addr
0xfffffff007d62640: 65 73 73 22 3a 20 31 38 34 34 36 37 34 34 30 30  ess": 1844674400
0xfffffff007d62650: 35 31 32 32 33 32 37 35 35 32 0a 20 20 20 20 20  5122327552.     
0xfffffff007d62660: 20 20 20 7d 2c 0a 20 20 20 20 20 20 20 20 7b 0a     },.        {.
0xfffffff007d62670: 20 20 20 20 20 20 20 20 20 20 20 20 22 6e 61 6d              "nam
0xfffffff007d62680: 65 22 3a 20 22 5f 6f 73 65 6e 76 69 72 6f 6e 6d  e": "_osenvironm
0xfffffff007d62690: 65 6e 74 5f 69 73 5f 64 69 61 67 6e 6f 73 74 69  ent_is_diagnosti
0xfffffff007d626a0: 63 73 22 2c 0a 20 20 20 20 20 20 20 20 20 20 20  cs",.           
0xfffffff007d626b0: 20 22 74 79 70 65 22 3a 20 22 63 6f 64 65 22 2c   "type": "code",
0xfffffff007d626c0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 61 64  .            "ad
0xfffffff007d626d0: 64 72 65 73 73 22 3a 20 31 38 34 34 36 37 34 34  dress": 18446744
0xfffffff007d626e0: 30 30 35 31 32 32 33 33 33 37 39 32 0a 20 20 20  005122333792.   
0xfffffff007d626f0: 20 20 20 20 20 7d 2c 0a 20 20 20 20 20 20 20 20       },.        
0xfffffff007d62700: 7b 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 6e  {.            "n
0xfffffff007d62710: 61 6d 65 22 3a 20 22 64 65 66 5f 46 46 46 46 46  ame": "def_FFFFF
0xfffffff007d62720: 46 46 30 30 37 45 32 33 39 44 34 22 2c 0a 20 20  FF007E239D4",.  
0xfffffff007d62730: 20 20 20 20 20 20 20 20 20 20 22 74 79 70 65 22            "type"
0xfffffff007d62740: 3a 20 22 63 6f 64 65 22 2c 0a 20 20 20 20 20 20  : "code",.      
0xfffffff007d62750: 20 20 20 20 20 20 22 61 64 64 72 65 73 73 22 3a        "address":
0xfffffff007d62760: 20 31 38 34 34 36 37 34 34 30 30 35 31 32 32 33   184467440051223
0xfffffff007d62770: 34 33 35 38 30 0a 20 20 20 20 20 20 20 20 7d 2c  43580.        },
0xfffffff007d62780: 0a 20 20 20 20 20 20 20 20 7b 0a 20 20 20 20 20  .        {.     
```

https://github.com/llvm/llvm-project/pull/101062


More information about the lldb-commits mailing list