AllocatedMemoryCache::AllocatedBlockSP AllocatedMemoryCache::AllocatePage (uint32_t byte_size, uint32_t permissions, uint32_t chunk_size, Error &error) { AllocatedBlockSP block_sp; const size_t page_size = 4096; const size_t num_pages = (byte_size + page_size - 1) / page_size; const size_t page_byte_size = num_pages * page_size; addr_t addr = m_process.DoAllocateMemory(page_byte_size, permissions, error); LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) { log->Printf ("Process::DoAllocateMemory (byte_size = 0x%8.8zx, permissions = %s) => 0x%16.16llx", page_byte_size, GetPermissionsAsCString(permissions), (uint64_t)addr); } if (addr != LLDB_INVALID_ADDRESS) { block_sp.reset (new AllocatedBlock (addr, page_byte_size, permissions, chunk_size)); m_memory_map.insert (std::make_pair (permissions, block_sp)); } return block_sp; }
void POSIXThread::BreakNotify(const ProcessMessage &message) { bool status; LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); assert(GetRegisterContext()); status = GetRegisterContextPOSIX()->UpdateAfterBreakpoint(); assert(status && "Breakpoint update failed!"); // With our register state restored, resolve the breakpoint object // corresponding to our current PC. assert(GetRegisterContext()); lldb::addr_t pc = GetRegisterContext()->GetPC(); if (log) log->Printf ("POSIXThread::%s () PC=0x%8.8llx", __FUNCTION__, pc); lldb::BreakpointSiteSP bp_site(GetProcess()->GetBreakpointSiteList().FindByAddress(pc)); assert(bp_site); lldb::break_id_t bp_id = bp_site->GetID(); assert(bp_site && bp_site->ValidForThisThread(this)); m_breakpoint = bp_site; m_stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*this, bp_id); }
void DWARFDebugAranges::Sort (bool minimize) { Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); size_t orig_arange_size = 0; if (log) { orig_arange_size = m_aranges.GetSize(); log->Printf ("DWARFDebugAranges::Sort(minimize = %u) with %zu entries", minimize, orig_arange_size); } m_aranges.Sort(); m_aranges.CombineConsecutiveEntriesWithEqualData(); if (log) { if (minimize) { const size_t new_arange_size = m_aranges.GetSize(); const size_t delta = orig_arange_size - new_arange_size; log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", new_arange_size, delta, delta * sizeof(Range)); } Dump (log.get()); } }
lldb::addr_t AllocatedMemoryCache::AllocateMemory (size_t byte_size, uint32_t permissions, Error &error) { Mutex::Locker locker (m_mutex); addr_t addr = LLDB_INVALID_ADDRESS; std::pair<PermissionsToBlockMap::iterator, PermissionsToBlockMap::iterator> range = m_memory_map.equal_range (permissions); for (PermissionsToBlockMap::iterator pos = range.first; pos != range.second; ++pos) { addr = (*pos).second->ReserveBlock (byte_size); } if (addr == LLDB_INVALID_ADDRESS) { AllocatedBlockSP block_sp (AllocatePage (byte_size, permissions, 16, error)); if (block_sp) addr = block_sp->ReserveBlock (byte_size); } LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) log->Printf ("AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8zx, permissions = %s) => 0x%16.16llx", byte_size, GetPermissionsAsCString(permissions), (uint64_t)addr); return addr; }
bool CommunicationKDP::SendRequestPacketNoLock (const PacketStreamType &request_packet) { if (IsConnected()) { const char *packet_data = request_packet.GetData(); const size_t packet_size = request_packet.GetSize(); LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (log) { PacketStreamType log_strm; DumpPacket (log_strm, packet_data, packet_size); log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData()); } ConnectionStatus status = eConnectionStatusSuccess; size_t bytes_written = Write (packet_data, packet_size, status, NULL); if (bytes_written == packet_size) return true; if (log) log->Printf ("error: failed to send packet entire packet %" PRIu64 " of %" PRIu64 " bytes sent", (uint64_t)bytes_written, (uint64_t)packet_size); } return false; }
bool BreakpointLocation::ShouldStop (StoppointCallbackContext *context) { bool should_stop = true; LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); m_hit_count++; if (!IsEnabled()) return false; if (m_hit_count <= GetIgnoreCount()) return false; // We only run synchronous callbacks in ShouldStop: context->is_synchronous = true; should_stop = InvokeCallback (context); if (log) { StreamString s; GetDescription (&s, lldb::eDescriptionLevelVerbose); log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing"); } return should_stop; }
bool BreakpointLocation::ResolveBreakpointSite () { if (m_bp_site_sp) return true; Process *process = m_owner.GetTarget().GetProcessSP().get(); if (process == NULL) return false; if (m_owner.GetTarget().GetSectionLoadList().IsEmpty()) return false; BreakpointLocationSP this_sp(this); lldb::break_id_t new_id = process->CreateBreakpointSite (this_sp, false); if (new_id == LLDB_INVALID_BREAK_ID) { LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); if (log) log->Warning ("Tried to add breakpoint site at 0x%llx but it was already present.\n", m_address.GetOpcodeLoadAddress (&m_owner.GetTarget())); return false; } return true; }
bool POSIXThread::Resume() { lldb::StateType resume_state = GetResumeState(); ProcessMonitor &monitor = GetMonitor(); bool status; LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("POSIXThread::%s ()", __FUNCTION__); switch (resume_state) { default: assert(false && "Unexpected state for resume!"); status = false; break; case lldb::eStateRunning: SetState(resume_state); status = monitor.Resume(GetID(), GetResumeSignal()); break; case lldb::eStateStepping: SetState(resume_state); status = monitor.SingleStep(GetID(), GetResumeSignal()); break; } return status; }
bool DWARFDebugPubnames::Extract(const DataExtractor& data) { Timer scoped_timer (__PRETTY_FUNCTION__, "DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize()); LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES)); if (log) log->Printf("DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize()); if (data.ValidOffset(0)) { uint32_t offset = 0; DWARFDebugPubnamesSet set; while (data.ValidOffset(offset)) { if (set.Extract(data, &offset)) { m_sets.push_back(set); offset = set.GetOffsetOfNextEntry(); } else break; } if (log) Dump (log.get()); return true; } return false; }
POSIXThread::POSIXThread(Process &process, lldb::tid_t tid) : Thread(process, tid), m_frame_ap(0) { LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("POSIXThread::%s (tid = %i)", __FUNCTION__, tid); }
size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock (DataExtractor &packet, uint32_t timeout_usec) { uint8_t buffer[8192]; Error error; LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS | KDP_LOG_VERBOSE)); // Check for a packet from our cache first without trying any reading... if (CheckForPacket (NULL, 0, packet)) return packet.GetByteSize(); bool timed_out = false; while (IsConnected() && !timed_out) { lldb::ConnectionStatus status = eConnectionStatusNoConnection; size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error); if (log) log->Printf ("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, status = %s, error = %s) => bytes_read = %" PRIu64, __PRETTY_FUNCTION__, timeout_usec, Communication::ConnectionStatusAsCString (status), error.AsCString(), (uint64_t)bytes_read); if (bytes_read > 0) { if (CheckForPacket (buffer, bytes_read, packet)) return packet.GetByteSize(); } else { switch (status) { case eConnectionStatusTimedOut: timed_out = true; break; case eConnectionStatusSuccess: //printf ("status = success but error = %s\n", error.AsCString("<invalid>")); break; case eConnectionStatusEndOfFile: case eConnectionStatusNoConnection: case eConnectionStatusLostConnection: case eConnectionStatusError: Disconnect(); break; } } } packet.Clear (); return 0; }
void ProcessKDPLog::LogIf (uint32_t mask, const char *format, ...) { LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (mask)); if (log) { va_list args; va_start (args, format); log->VAPrintf (format, args); va_end (args); } }
void POSIXThread::RefreshStateAfterStop() { LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("POSIXThread::%s ()", __FUNCTION__); // Let all threads recover from stopping and do any clean up based // on the previous thread state (if any). ProcessSP base = GetProcess(); ProcessPOSIX &process = static_cast<ProcessPOSIX&>(*base); process.GetThreadList().RefreshStateAfterStop(); }
void ProcessPOSIXLog::DisableLog (Args &args, Stream *feedback_strm) { LogSP log (GetLog ()); if (log) { uint32_t flag_bits = 0; const size_t argc = args.GetArgumentCount (); if (argc > 0) { flag_bits = log->GetMask().Get(); for (size_t i = 0; i < argc; ++i) { const char *arg = args.GetArgumentAtIndex (i); if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~POSIX_LOG_ALL; else if (::strcasecmp (arg, "async") == 0 ) flag_bits &= ~POSIX_LOG_ASYNC; else if (::strncasecmp (arg, "break", 5) == 0 ) flag_bits &= ~POSIX_LOG_BREAKPOINTS; else if (::strncasecmp (arg, "comm", 4) == 0 ) flag_bits &= ~POSIX_LOG_COMM; else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~POSIX_LOG_DEFAULT; else if (::strcasecmp (arg, "packets") == 0 ) flag_bits &= ~POSIX_LOG_PACKETS; else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY; else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~POSIX_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~POSIX_LOG_PROCESS; else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~POSIX_LOG_PTRACE; else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~POSIX_LOG_REGISTERS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~POSIX_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~POSIX_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~POSIX_LOG_VERBOSE; else if (::strncasecmp (arg, "watch", 5) == 0 ) flag_bits &= ~POSIX_LOG_WATCHPOINTS; else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); ListLogCategories (feedback_strm); } } } if (flag_bits == 0) GetLog ().reset(); else log->GetMask().Reset (flag_bits); } return; }
kern_return_t RegisterContextMach_x86_64::ReadGPR (bool force) { int set = GPRRegSet; if (force || !RegisterSetIsCached(set)) { mach_msg_type_number_t count = GPRWordCount; SetError(GPRRegSet, Read, ::thread_get_state(GetThreadID(), set, (thread_state_t)&gpr, &count)); LogSP log (ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_THREAD)); if (log) LogGPR (log.get(), "RegisterContextMach_x86_64::ReadGPR(thread = 0x%4.4x)", GetThreadID()); } return GetError(GPRRegSet, Read); }
void POSIXThread::CrashNotify(const ProcessMessage &message) { int signo = message.GetSignal(); assert(message.GetKind() == ProcessMessage::eCrashMessage); LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log) log->Printf ("POSIXThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason()); m_stop_info = lldb::StopInfoSP(new POSIXCrashStopInfo( *this, signo, message.GetCrashReason())); SetResumeSignal(signo); }
void RegisterContext_i386::LogGPR(const char *title) { LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_REGISTERS)); if (log) { if (title) log->Printf ("%s", title); for (uint32_t i=0; i<k_num_gpr_registers; i++) { uint32_t reg = gpr_eax + i; log->Printf("%12s = 0x%8.8x", g_register_infos[reg].name, (&user.regs)[reg]); } } }
bool AllocatedBlock::FreeBlock (addr_t addr) { uint32_t offset = addr - m_addr; OffsetToChunkSize::iterator pos = m_offset_to_chunk_size.find (offset); bool success = false; if (pos != m_offset_to_chunk_size.end()) { m_offset_to_chunk_size.erase (pos); success = true; } LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); if (log) log->Printf ("AllocatedBlock::FreeBlock (addr = 0x%16.16llx) => %i", (uint64_t)addr, success); return success; }
kern_return_t RegisterContextMach_x86_64::WriteGPR () { int set = GPRRegSet; if (!RegisterSetIsCached(set)) { SetError (set, Write, -1); return KERN_INVALID_ARGUMENT; } LogSP log (ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_THREAD)); if (log) LogGPR (log.get(), "RegisterContextMach_x86_64::WriteGPR (thread = 0x%4.4x)", GetThreadID()); SetError (set, Write, ::thread_set_state(GetThreadID(), set, (thread_state_t)&gpr, GPRWordCount)); SetError (set, Read, -1); return GetError (set, Write); }
void ProcessGDBRemoteLog::DisableLog (const char **categories, Stream *feedback_strm) { LogSP log (GetLog ()); if (log) { uint32_t flag_bits = 0; if (categories[0] != NULL) { flag_bits = log->GetMask().Get(); for (size_t i = 0; categories[i] != NULL; ++i) { const char *arg = categories[i]; if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~GDBR_LOG_ALL; else if (::strcasecmp (arg, "async") == 0 ) flag_bits &= ~GDBR_LOG_ASYNC; else if (::strncasecmp (arg, "break", 5) == 0 ) flag_bits &= ~GDBR_LOG_BREAKPOINTS; else if (::strncasecmp (arg, "comm", 4) == 0 ) flag_bits &= ~GDBR_LOG_COMM; else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~GDBR_LOG_DEFAULT; else if (::strcasecmp (arg, "packets") == 0 ) flag_bits &= ~GDBR_LOG_PACKETS; else if (::strcasecmp (arg, "memory") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY; else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~GDBR_LOG_PROCESS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~GDBR_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~GDBR_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~GDBR_LOG_VERBOSE; else if (::strncasecmp (arg, "watch", 5) == 0 ) flag_bits &= ~GDBR_LOG_WATCHPOINTS; else { feedback_strm->Printf("error: unrecognized log category '%s'\n", arg); ListLogCategories (feedback_strm); } } } if (flag_bits == 0) GetLog ().reset(); else log->GetMask().Reset (flag_bits); } return; }
void SBDebugger::Destroy (SBDebugger &debugger) { LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { SBStream sstr; debugger.GetDescription (sstr); log->Printf ("SBDebugger::Destroy () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData()); } Debugger::Destroy (debugger.m_opaque_sp); if (debugger.m_opaque_sp.get() != NULL) debugger.m_opaque_sp.reset(); }
void SBDebugger::MemoryPressureDetected () { // Since this function can be call asynchronously, we allow it to be // non-mandatory. We have seen deadlocks with this function when called // so we need to safeguard against this until we can determine what is // causing the deadlocks. LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); const bool mandatory = false; if (log) { log->Printf ("SBDebugger::MemoryPressureDetected (), mandatory = %d", mandatory); } ModuleList::RemoveOrphanSharedModules(mandatory); }
bool CommunicationKDP::SendRequestAndGetReply (const CommandType command, const uint8_t request_sequence_id, const PacketStreamType &request_packet, DataExtractor &reply_packet) { if (IsRunning()) { LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PACKETS)); if (log) { PacketStreamType log_strm; DumpPacket (log_strm, request_packet.GetData(), request_packet.GetSize()); log->Printf("error: kdp running, not sending packet: %.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData()); } return false; } Mutex::Locker locker(m_sequence_mutex); #ifdef LLDB_CONFIGURATION_DEBUG // NOTE: this only works for packets that are in native endian byte order assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2))); #endif if (SendRequestPacketNoLock(request_packet)) { if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ())) { uint32_t offset = 0; const uint8_t reply_command = reply_packet.GetU8 (&offset); const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset); if ((reply_command & eCommandTypeMask) == command) { if (request_sequence_id == reply_sequence_id) { if (command == KDP_RESUMECPUS) m_is_running.SetValue(true, eBroadcastAlways); return true; } } } } reply_packet.Clear(); return false; }
bool AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr) { Mutex::Locker locker (m_mutex); PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); bool success = false; for (pos = m_memory_map.begin(); pos != end; ++pos) { if (pos->second->Contains (addr)) { success = pos->second->FreeBlock (addr); break; } } LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) log->Printf("AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16llx) => %i", (uint64_t)addr, success); return success; }
DWARFDebugAranges & DWARFDebugInfo::GetCompileUnitAranges () { if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data) { LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); m_cu_aranges_ap.reset (new DWARFDebugAranges()); const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data(); if (debug_aranges_data.GetByteSize() > 0) { if (log) log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" from .debug_aranges", m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(), m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString()); m_cu_aranges_ap->Extract (debug_aranges_data); } else { if (log) log->Printf ("DWARFDebugInfo::GetCompileUnitAranges() for \"%s/%s\" by parsing", m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(), m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString()); const uint32_t num_compile_units = GetNumCompileUnits(); uint32_t idx; const bool clear_dies_if_already_not_parsed = true; for (idx = 0; idx < num_compile_units; ++idx) { DWARFCompileUnit* cu = GetCompileUnitAtIndex(idx); if (cu) cu->BuildAddressRangeTable (m_dwarf2Data, m_cu_aranges_ap.get(), clear_dies_if_already_not_parsed); } } const bool minimize = true; m_cu_aranges_ap->Sort (minimize); } return *m_cu_aranges_ap.get(); }
const DWARFDebugAranges & DWARFCompileUnit::GetFunctionAranges () { if (m_func_aranges_ap.get() == NULL) { m_func_aranges_ap.reset (new DWARFDebugAranges()); LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); if (log) { m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(), "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]", GetOffset()); } const DWARFDebugInfoEntry* die = DIE(); if (die) die->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get()); const bool minimize = false; m_func_aranges_ap->Sort(minimize); } return *m_func_aranges_ap.get(); }
void POSIXThread::Notify(const ProcessMessage &message) { LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log) log->Printf ("POSIXThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind()); switch (message.GetKind()) { default: assert(false && "Unexpected message kind!"); break; case ProcessMessage::eLimboMessage: LimboNotify(message); break; case ProcessMessage::eSignalMessage: SignalNotify(message); break; case ProcessMessage::eSignalDeliveredMessage: SignalDeliveredNotify(message); break; case ProcessMessage::eTraceMessage: TraceNotify(message); break; case ProcessMessage::eBreakpointMessage: BreakNotify(message); break; case ProcessMessage::eCrashMessage: CrashNotify(message); break; } }
lldb::RegisterContextSP POSIXThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) { lldb::RegisterContextSP reg_ctx_sp; uint32_t concrete_frame_idx = 0; LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD)); if (log && log->GetMask().Test(POSIX_LOG_VERBOSE)) log->Printf ("POSIXThread::%s ()", __FUNCTION__); if (frame) concrete_frame_idx = frame->GetConcreteFrameIndex(); if (concrete_frame_idx == 0) reg_ctx_sp = GetRegisterContext(); else { assert(GetUnwinder()); reg_ctx_sp = GetUnwinder()->CreateRegisterContextForFrame(frame); } return reg_ctx_sp; }
extern long PtraceWrapper(int req, ::pid_t pid, void *addr, int data, const char* reqName, const char* file, int line) { long int result; LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE)); if (log) { log->Printf("ptrace(%s, %u, %p, %x) called from file %s line %d", reqName, pid, addr, data, file, line); if (req == PT_IO) { struct ptrace_io_desc *pi = (struct ptrace_io_desc *) addr; log->Printf("PT_IO: op=%s offs=%zx size=%ld", Get_PT_IO_OP(pi->piod_op), pi->piod_offs, pi->piod_len); } } //PtraceDisplayBytes(req, data); errno = 0; result = ptrace(req, pid, (caddr_t) addr, data); //PtraceDisplayBytes(req, data); if (log && (result == -1 || errno != 0)) { const char* str; switch (errno) { case ESRCH: str = "ESRCH"; break; case EINVAL: str = "EINVAL"; break; case EBUSY: str = "EBUSY"; break; case EPERM: str = "EPERM"; break; default: str = "<unknown>"; } log->Printf("ptrace() failed; errno=%d (%s)", errno, str); } if (log) { if (req == PT_GETREGS) { struct reg *r = (struct reg *) addr; log->Printf("PT_GETREGS: ip=0x%lx", r->r_rip); log->Printf("PT_GETREGS: sp=0x%lx", r->r_rsp); log->Printf("PT_GETREGS: bp=0x%lx", r->r_rbp); log->Printf("PT_GETREGS: ax=0x%lx", r->r_rax); } } return result; }
void ModuleList::LogUUIDAndPaths (LogSP &log_sp, const char *prefix_cstr) { if (log_sp) { Mutex::Locker locker(m_modules_mutex); char uuid_cstr[256]; collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end(); for (pos = begin; pos != end; ++pos) { Module *module = pos->get(); module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr)); const FileSpec &module_file_spec = module->GetFileSpec(); log_sp->Printf ("%s[%u] %s (%s) \"%s/%s\"", prefix_cstr ? prefix_cstr : "", (uint32_t)std::distance (begin, pos), uuid_cstr, module->GetArchitecture().GetArchitectureName(), module_file_spec.GetDirectory().GetCString(), module_file_spec.GetFilename().GetCString()); } } }