struct _JsonNode* mu_msg_to_json (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti, MuMsgOptions opts) { JsonNode *node; JsonBuilder *bob; time_t t; size_t s; g_return_val_if_fail (msg, NULL); g_return_val_if_fail (!((opts & MU_MSG_OPTION_HEADERS_ONLY) && (opts & MU_MSG_OPTION_EXTRACT_IMAGES)),NULL); bob = json_builder_new (); bob = json_builder_begin_object (bob); if (ti) add_thread_info (bob, ti); add_string_member (bob, "subject", mu_msg_get_subject (msg)); /* in the no-headers-only case (see below) we get a more complete list * of contacts, so no need to get them here if that's the case */ if (opts & MU_MSG_OPTION_HEADERS_ONLY) add_contacts (bob, msg); t = mu_msg_get_date (msg); if (t != (time_t)-1) add_int_member (bob, "date", t); s = mu_msg_get_size (msg); if (s != (size_t)-1) add_int_member (bob, "size", s); add_string_member (bob, "message-id", mu_msg_get_msgid (msg)); add_string_member (bob, "mailing-list", mu_msg_get_mailing_list (msg)); add_string_member (bob, "path", mu_msg_get_path (msg)); add_string_member (bob, "maildir", mu_msg_get_maildir (msg)); add_string_member (bob, "priority", mu_msg_prio_name(mu_msg_get_prio(msg))); add_flags (bob, msg); add_list_member (bob, "tags", mu_msg_get_tags(msg)); add_list_member (bob, "references", mu_msg_get_references (msg)); add_string_member (bob, "in-reply-to", mu_msg_get_header (msg, "In-Reply-To")); /* headers are retrieved from the database, views from the * message file file attr things can only be gotten from the * file (ie., mu view), not from the database (mu find). */ if (!(opts & MU_MSG_OPTION_HEADERS_ONLY)) add_file_parts (bob, msg, opts); bob = json_builder_end_object (bob); node = json_builder_get_root (bob); g_clear_object (&bob); return node; }
// read regs and create thread from NT_PRSTATUS entries from core file static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size_t nbytes) { // we have to read prstatus_t from buf // assert(nbytes == sizeof(prstaus_t), "size mismatch on prstatus_t"); prstatus_t* prstat = (prstatus_t*) buf; thread_info* newthr; print_debug("got integer regset for lwp %d\n", prstat->pr_pid); // we set pthread_t to -1 for core dump if((newthr = add_thread_info(ph, (pthread_t) -1, prstat->pr_pid)) == NULL) return false; // copy regs memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct)); if (is_debug()) { print_debug("integer regset\n"); #ifdef i386 // print the regset print_debug("\teax = 0x%x\n", newthr->regs.eax); print_debug("\tebx = 0x%x\n", newthr->regs.ebx); print_debug("\tecx = 0x%x\n", newthr->regs.ecx); print_debug("\tedx = 0x%x\n", newthr->regs.edx); print_debug("\tesp = 0x%x\n", newthr->regs.esp); print_debug("\tebp = 0x%x\n", newthr->regs.ebp); print_debug("\tesi = 0x%x\n", newthr->regs.esi); print_debug("\tedi = 0x%x\n", newthr->regs.edi); print_debug("\teip = 0x%x\n", newthr->regs.eip); #endif #if defined(amd64) || defined(x86_64) // print the regset print_debug("\tr15 = 0x%lx\n", newthr->regs.r15); print_debug("\tr14 = 0x%lx\n", newthr->regs.r14); print_debug("\tr13 = 0x%lx\n", newthr->regs.r13); print_debug("\tr12 = 0x%lx\n", newthr->regs.r12); print_debug("\trbp = 0x%lx\n", newthr->regs.rbp); print_debug("\trbx = 0x%lx\n", newthr->regs.rbx); print_debug("\tr11 = 0x%lx\n", newthr->regs.r11); print_debug("\tr10 = 0x%lx\n", newthr->regs.r10); print_debug("\tr9 = 0x%lx\n", newthr->regs.r9); print_debug("\tr8 = 0x%lx\n", newthr->regs.r8); print_debug("\trax = 0x%lx\n", newthr->regs.rax); print_debug("\trcx = 0x%lx\n", newthr->regs.rcx); print_debug("\trdx = 0x%lx\n", newthr->regs.rdx); print_debug("\trsi = 0x%lx\n", newthr->regs.rsi); print_debug("\trdi = 0x%lx\n", newthr->regs.rdi); print_debug("\torig_rax = 0x%lx\n", newthr->regs.orig_rax); print_debug("\trip = 0x%lx\n", newthr->regs.rip); print_debug("\tcs = 0x%lx\n", newthr->regs.cs); print_debug("\teflags = 0x%lx\n", newthr->regs.eflags); print_debug("\trsp = 0x%lx\n", newthr->regs.rsp); print_debug("\tss = 0x%lx\n", newthr->regs.ss); print_debug("\tfs_base = 0x%lx\n", newthr->regs.fs_base); print_debug("\tgs_base = 0x%lx\n", newthr->regs.gs_base); print_debug("\tds = 0x%lx\n", newthr->regs.ds); print_debug("\tes = 0x%lx\n", newthr->regs.es); print_debug("\tfs = 0x%lx\n", newthr->regs.fs); print_debug("\tgs = 0x%lx\n", newthr->regs.gs); #endif } return true; }
// callback for read_thread_info static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) { return add_thread_info(ph, pthread_id, lwp_id) != NULL; }