- port_status = info.mpie_status;
- get_receive_port_context(taskinfo->task, taskinfo->table[k].iin_name, &port_context);
- printf(" - 0x%08x %s --%s%s%s%s%s%s %5d %s%s%s %5d %5.0d %5.0d %s %6d %8d 0x%016llx 0x%08x (%d) %s\n",
- taskinfo->table[k].iin_object,
- (taskinfo->table[k].iin_type & MACH_PORT_TYPE_SEND) ? "recv,send ":"recv ",
- SHOW_PORT_STATUS_FLAGS(port_status.mps_flags),
- info.mpie_boost_cnt,
- (taskinfo->table[k].iin_type & MACH_PORT_TYPE_DNREQUEST) ? "D" : "-",
- (port_status.mps_nsrequest) ? "N" : "-",
- (port_status.mps_pdrequest) ? "P" : "-",
- 1,
- taskinfo->table[k].iin_urefs,
- port_status.mps_sorights,
- (port_status.mps_srights) ? "Y" : "N",
- port_status.mps_qlimit,
- port_status.mps_msgcount,
- (uint64_t)port_context,
- taskinfo->table[k].iin_name,
- pid,
- taskinfo->processName);
- break;
- }
- }
- }
-
- ret = vm_deallocate(mach_task_self(), (vm_address_t)members,
- membersCnt * sizeof(mach_port_name_t));
- if (ret != KERN_SUCCESS) {
- fprintf(stderr, "vm_deallocate() failed: %s\n",
- mach_error_string(ret));
- exit(1);
- }
- portsetcount++;
- continue;
- }
-
- if (taskinfo->table[i].iin_type & MACH_PORT_TYPE_SEND) {
- send = TRUE;
- sendrights = taskinfo->table[i].iin_urefs;
- sendcount++;
- }
-
- if (taskinfo->table[i].iin_type & MACH_PORT_TYPE_DNREQUEST) {
- dnreq = TRUE;
- dncount++;
- }
-
- if (taskinfo->table[i].iin_type & MACH_PORT_TYPE_RECEIVE) {
- mach_port_status_t status;
- mach_port_info_ext_t info;
- mach_port_context_t context = (mach_port_context_t)0;
- ret = get_recieve_port_status(taskinfo->task, taskinfo->table[i].iin_name, &info);
- get_receive_port_context(taskinfo->task, taskinfo->table[i].iin_name, &context);
- /* its ok to fail in fetching attributes */
- if (ret < 0) {
- continue;
+ }
+ JSON_ARRAY_END(json); // port status flags
+ JSON_OBJECT_SET(json, boosts, %d, info.mpie_boost_cnt);
+
+ JSON_KEY(json, notifications);
+ JSON_ARRAY_BEGIN(json);
+ if (taskinfo->table[k].iin_type & MACH_PORT_TYPE_DNREQUEST) {
+ JSON_ARRAY_APPEND(json, "dead name");
+ }
+ if (port_status.mps_nsrequest) {
+ JSON_ARRAY_APPEND(json, "no sender");
+ }
+ if (port_status.mps_nsrequest) {
+ JSON_ARRAY_APPEND(json, "port destroy request");
+ }
+ JSON_ARRAY_END(json); // notifications
+
+ JSON_OBJECT_SET(json, recv_rights, %d, 1);
+ JSON_OBJECT_SET(json, send_rights, %d, taskinfo->table[k].iin_urefs);
+ JSON_OBJECT_SET(json, send_once_rights, %d, port_status.mps_sorights);
+ JSON_OBJECT_SET_BOOL(json, oref, port_status.mps_srights);
+ JSON_OBJECT_SET(json, queue_limit, %d, port_status.mps_qlimit);
+ JSON_OBJECT_SET(json, msg_count, %d, port_status.mps_msgcount);
+ JSON_OBJECT_SET(json, context, "0x%016llx", (uint64_t)port_context);
+ JSON_OBJECT_SET(json, identifier, "0x%08x", taskinfo->table[k].iin_name);
+ JSON_OBJECT_SET(json, pid, %d, taskinfo->pid);
+ JSON_OBJECT_SET(json, process, "%s", taskinfo->processName);
+ JSON_OBJECT_END(json); // member
+
+ printf(" - 0x%08x %s --%s%s%s%s%s%s %5d %s%s%s %5d %5.0d %5.0d %s %6d %8d 0x%016llx 0x%08x (%d) %s\n",
+ taskinfo->table[k].iin_object,
+ (taskinfo->table[k].iin_type & MACH_PORT_TYPE_SEND) ? "recv,send ":"recv ",
+ SHOW_PORT_STATUS_FLAGS(port_status.mps_flags),
+ info.mpie_boost_cnt,
+ (taskinfo->table[k].iin_type & MACH_PORT_TYPE_DNREQUEST) ? "D" : "-",
+ (port_status.mps_nsrequest) ? "N" : "-",
+ (port_status.mps_pdrequest) ? "P" : "-",
+ 1,
+ taskinfo->table[k].iin_urefs,
+ port_status.mps_sorights,
+ (port_status.mps_srights) ? "Y" : "N",
+ port_status.mps_qlimit,
+ port_status.mps_msgcount,
+ (uint64_t)port_context,
+ taskinfo->table[k].iin_name,
+ taskinfo->pid,
+ taskinfo->processName);
+ break;
+ }
+ }
+ }
+
+ JSON_ARRAY_END(json); // members
+ JSON_OBJECT_END(json); // port-set
+
+ ret = vm_deallocate(mach_task_self(), (vm_address_t)members,
+ membersCnt * sizeof(mach_port_name_t));
+ if (ret != KERN_SUCCESS) {
+ fprintf(stderr, "vm_deallocate() failed: %s\n",
+ mach_error_string(ret));
+ exit(1);
+ }
+ counts->portsetcount++;
+ return;
+ }
+
+ if (entry->iin_type & MACH_PORT_TYPE_SEND) {
+ send = TRUE;
+ sendrights = entry->iin_urefs;
+ counts->sendcount++;
+ }
+
+ if (entry->iin_type & MACH_PORT_TYPE_DNREQUEST) {
+ dnreq = TRUE;
+ counts->dncount++;
+ }
+
+ if (entry->iin_type & MACH_PORT_TYPE_RECEIVE) {
+ mach_port_status_t status;
+ mach_port_info_ext_t info;
+ mach_port_context_t context = (mach_port_context_t)0;
+ struct k2n_table_node *k2nnode;
+ ret = get_recieve_port_status(taskinfo->task, entry->iin_name, &info);
+ get_receive_port_context(taskinfo->task, entry->iin_name, &context);
+ /* its ok to fail in fetching attributes */
+ if (ret < 0) {
+ return;
+ }
+ status = info.mpie_status;
+
+ JSON_OBJECT_BEGIN(json);
+ JSON_OBJECT_SET(json, type, "port");
+ JSON_OBJECT_SET(json, name, "0x%08x", entry->iin_name);
+ JSON_OBJECT_SET(json, ipc-object, "0x%08x", entry->iin_object);
+
+ JSON_KEY(json, rights);
+ JSON_ARRAY_BEGIN(json);
+ JSON_ARRAY_APPEND(json, "recv");
+ if (send) JSON_ARRAY_APPEND(json, "send");
+ JSON_ARRAY_END(json); // rights
+
+ JSON_KEY(json, port_status_flags);
+ JSON_ARRAY_BEGIN(json);
+ port_status_flag_idx = 0;
+ while (0 != port_status_flags[port_status_flag_idx++].flag) {
+ if (status.mps_flags & INDEX_TO_PORT_FLAG(port_status_flag_idx)) {
+ JSON_ARRAY_APPEND(json, "%s", port_status_flags[port_status_flag_idx].name);