From dawn at burble.org Mon Oct 17 12:36:09 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 17 Oct 2011 10:36:09 -0700 Subject: [Lldb-commits] [PATCH] fixes for Linux In-Reply-To: <20111015025853.GA24361@bloodbath.burble.org> References: <20111015025853.GA24361@bloodbath.burble.org> Message-ID: <20111017173609.GA13868@bloodbath.burble.org> Seems I forgot the patch? Doh! On Fri, Oct 14, 2011 at 07:58:53PM -0700, dawn at burble.org wrote: > This patch fixes debugging of single threaded apps on Linux. > It also adds some asserts and additional logging support. > > Thanks in advance, > -Dawn > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -------------- next part -------------- Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 142029) +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) @@ -119,7 +119,7 @@ LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessLinux::%s(pid = %i)", __FUNCTION__, GetID()); m_monitor = new ProcessMonitor(this, pid, error); @@ -328,6 +328,10 @@ void ProcessLinux::RefreshStateAfterStop() { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("ProcessLinux::%s()", __FUNCTION__); + Mutex::Locker lock(m_message_mutex); if (m_message_queue.empty()) return; @@ -335,10 +339,15 @@ ProcessMessage &message = m_message_queue.front(); // Resolve the thread this message corresponds to and pass it along. + // FIXME: we're really dealing with the pid here. This should get + // fixed when this code is fixed to handle multiple threads. lldb::tid_t tid = message.GetTID(); + if (log) + log->Printf ("ProcessLinux::%s() pid = %i", __FUNCTION__, tid); LinuxThread *thread = static_cast( GetThreadList().FindThreadByID(tid, false).get()); + assert(thread); thread->Notify(message); m_message_queue.pop(); @@ -355,6 +364,7 @@ ProcessLinux::DoReadMemory(addr_t vm_addr, void *buf, size_t size, Error &error) { + assert(m_monitor); return m_monitor->ReadMemory(vm_addr, buf, size, error); } @@ -362,6 +372,7 @@ ProcessLinux::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, Error &error) { + assert(m_monitor); return m_monitor->WriteMemory(vm_addr, buf, size, error); } @@ -453,12 +464,22 @@ uint32_t ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { - // FIXME: Should this be implemented? LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessLinux::%s() (pid = %i)", __FUNCTION__, GetID()); - return 0; + // Update the process thread list with this new thread. + // FIXME: We should be using tid, not pid. + assert(m_monitor); + ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false)); + if (!thread_sp) + thread_sp.reset(new LinuxThread(*this, GetID())); + + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("ProcessLinux::%s() updated pid = %i", __FUNCTION__, GetID()); + new_thread_list.AddThread(thread_sp); + + return new_thread_list.GetSize(false); } ByteOrder Index: source/Plugins/Process/Linux/ProcessLinuxLog.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinuxLog.cpp (revision 142029) +++ source/Plugins/Process/Linux/ProcessLinuxLog.cpp (working copy) @@ -69,6 +69,8 @@ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~LINUX_LOG_PROCESS; + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~LINUX_LOG_PTRACE; + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~LINUX_LOG_REGISTERS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~LINUX_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~LINUX_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~LINUX_LOG_VERBOSE; @@ -126,6 +128,8 @@ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= LINUX_LOG_PROCESS; + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= LINUX_LOG_PTRACE; + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= LINUX_LOG_REGISTERS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= LINUX_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= LINUX_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= LINUX_LOG_VERBOSE; @@ -162,6 +166,10 @@ " data-short - log memory bytes for memory reads and writes for short transactions only\n" " data-long - log memory bytes for memory reads and writes for all transactions\n" " process - log process events and activities\n" +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION + " ptrace - log all calls to ptrace\n" +#endif + " registers - log register read/writes\n" " thread - log thread events and activities\n" " step - log step related activities\n" " verbose - enable verbose logging\n" @@ -181,3 +189,5 @@ va_end (args); } } + +int ProcessLinuxLog::m_nestinglevel; Index: source/Plugins/Process/Linux/ProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.h (revision 142029) +++ source/Plugins/Process/Linux/ProcessLinux.h (working copy) @@ -177,7 +177,8 @@ /// Registers the given message with this process. void SendMessage(const ProcessMessage &message); - ProcessMonitor &GetMonitor() { return *m_monitor; } + ProcessMonitor & + GetMonitor() { assert(m_monitor); return *m_monitor; } lldb_private::UnixSignals & GetUnixSignals(); Index: source/Plugins/Process/Linux/ProcessLinuxLog.h =================================================================== --- source/Plugins/Process/Linux/ProcessLinuxLog.h (revision 142029) +++ source/Plugins/Process/Linux/ProcessLinuxLog.h (working copy) @@ -29,11 +29,18 @@ #define LINUX_LOG_STEP (1u << 9) #define LINUX_LOG_COMM (1u << 10) #define LINUX_LOG_ASYNC (1u << 11) +#define LINUX_LOG_PTRACE (1u << 12) +#define LINUX_LOG_REGISTERS (1u << 13) #define LINUX_LOG_ALL (UINT32_MAX) #define LINUX_LOG_DEFAULT LINUX_LOG_PACKETS +// The size which determines "short memory reads/writes". +#define LINUX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t)) + class ProcessLinuxLog { + static int m_nestinglevel; + public: static lldb::LogSP GetLogIfAllCategoriesSet(uint32_t mask = 0); @@ -42,13 +49,50 @@ DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm); static lldb::LogSP - EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm); + EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, + lldb_private::Args &args, lldb_private::Stream *feedback_strm); static void ListLogCategories (lldb_private::Stream *strm); static void LogIf (uint32_t mask, const char *format, ...); + + // The following functions can be used to enable the client to limit + // logging to only the top level function calls. This is useful for + // recursive functions. FIXME: not thread safe! + // Example: + // void NestingFunc() { + // LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet(LINUX_LOG_ALL)); + // if (log) + // { + // ProcessLinuxLog::IncNestLevel(); + // if (ProcessLinuxLog::AtTopNestLevel()) + // log->Print(msg); + // } + // NestingFunc(); + // if (log) + // ProcessLinuxLog::DecNestLevel(); + // } + + static bool + AtTopNestLevel() + { + return m_nestinglevel == 1; + } + + static void + IncNestLevel() + { + ++m_nestinglevel; + } + + static void + DecNestLevel() + { + --m_nestinglevel; + assert(m_nestinglevel >= 0); + } }; #endif // liblldb_ProcessLinuxLog_h_ Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp =================================================================== --- source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (revision 142029) +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (working copy) @@ -12,6 +12,7 @@ #include "lldb/Host/Endian.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" #include "RegisterContextLinux_i386.h" @@ -31,7 +32,6 @@ gpr_esp, gpr_ss, gpr_eflags, - gpr_orig_ax, gpr_eip, gpr_cs, gpr_ds, @@ -189,7 +189,6 @@ gpr_esp, gpr_ss, gpr_eflags, - gpr_orig_ax, gpr_eip, gpr_cs, gpr_ds, @@ -330,12 +329,17 @@ }; +#ifndef NDEBUG +static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); +#endif + static unsigned GetRegOffset(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); return g_register_infos[reg].byte_offset; } +#if 0 // These functions are currently not in use. static unsigned GetRegSize(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); @@ -351,6 +355,7 @@ { return (k_first_fpr <= reg && reg <= k_last_fpr); } +#endif RegisterContextLinux_i386::RegisterContextLinux_i386(Thread &thread, @@ -383,12 +388,14 @@ size_t RegisterContextLinux_i386::GetRegisterCount() { + assert(k_num_register_infos == k_num_registers); return k_num_registers; } const RegisterInfo * RegisterContextLinux_i386::GetRegisterInfoAtIndex(uint32_t reg) { + assert(k_num_register_infos == k_num_registers); if (reg < k_num_registers) return &g_register_infos[reg]; else @@ -410,6 +417,26 @@ return NULL; } +unsigned +RegisterContextLinux_i386::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + for (reg = 0; reg < k_num_registers; reg++) + { + if (g_register_infos[reg].byte_offset == offset) + break; + } + assert(reg < k_num_registers && "Invalid register offset."); + return reg; +} + +const char * +RegisterContextLinux_i386::GetRegisterName(unsigned reg) +{ + assert(reg < k_num_registers && "Invalid register offset."); + return g_register_infos[reg].name; +} + bool RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) @@ -588,11 +615,31 @@ return WriteRegisterFromUnsigned(gpr_eflags, eflags); } +void +RegisterContextLinux_i386::LogGPR(const char *title) +{ + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); + if (log) + { + if (title) + log->Printf ("%s", title); + for (uint32_t i=0; iPrintf("%12s = 0x%8.8x", g_register_infos[reg].name, (&user.regs)[reg]); + } + } +} + bool RegisterContextLinux_i386::ReadGPR() { - ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadGPR(&user.regs); + bool result; + + ProcessMonitor &monitor = GetMonitor(); + result = monitor.ReadGPR(&user.regs); + LogGPR("RegisterContextLinux_i386::ReadGPR()"); + return result; } bool Index: source/Plugins/Process/Linux/ProcessMessage.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMessage.cpp (revision 142029) +++ source/Plugins/Process/Linux/ProcessMessage.cpp (working copy) @@ -89,3 +89,157 @@ return str; } + +const char * +ProcessMessage::PrintCrashReason(CrashReason reason) +{ +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION + // Just return the code in asci for integration builds. + chcar str[8]; + sprintf(str, "%d", reason); +#else + const char *str = NULL; + + switch (reason) + { + default: + assert(false && "invalid CrashReason"); + break; + + case eInvalidCrashReason: + str = "eInvalidCrashReason"; + break; + + // SIGSEGV crash rcase easons. + case eInvalidAddress: + str = "eInvalidAddress"; + break; + case ePrivilegedAddress: + str = "ePrivilegedAddress"; + break; + + // SIGILL crash rcase easons. + case eIllegalOpcode: + str = "eIllegalOpcode"; + break; + case eIllegalOperand: + str = "eIllegalOperand"; + break; + case eIllegalAddressingMode: + str = "eIllegalAddressingMode"; + break; + case eIllegalTrap: + str = "eIllegalTrap"; + break; + case ePrivilegedOpcode: + str = "ePrivilegedOpcode"; + break; + case ePrivilegedRegister: + str = "ePrivilegedRegister"; + break; + case eCoprocessorError: + str = "eCoprocessorError"; + break; + case eInternalStackError: + str = "eInternalStackError"; + break; + + // SIGBUS crash rcase easons: + case eIllegalAlignment: + str = "eIllegalAlignment"; + break; + case eIllegalAddress: + str = "eIllegalAddress"; + break; + case eHardwareError: + str = "eHardwareError"; + break; + + // SIGFPE crash rcase easons: + case eIntegerDivideByZero: + str = "eIntegerDivideByZero"; + break; + case eIntegerOverflow: + str = "eIntegerOverflow"; + break; + case eFloatDivideByZero: + str = "eFloatDivideByZero"; + break; + case eFloatOverflow: + str = "eFloatOverflow"; + break; + case eFloatUnderflow: + str = "eFloatUnderflow"; + break; + case eFloatInexactResult: + str = "eFloatInexactResult"; + break; + case eFloatInvalidOperation: + str = "eFloatInvalidOperation"; + break; + case eFloatSubscriptRange: + str = "eFloatSubscriptRange"; + break; + } +#endif + + return str; +} + +const char * +ProcessMessage::PrintCrashReason() const +{ + return PrintCrashReason(m_crash_reason); +} + +const char * +ProcessMessage::PrintKind(Kind kind) +{ +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION + // Just return the code in asci for integration builds. + chcar str[8]; + sprintf(str, "%d", reason); +#else + const char *str = NULL; + + switch (kind) + { + default: + assert(false && "invalid Kind"); + break; + + case eInvalidMessage: + str = "eInvalidMessage"; + break; + case eExitMessage: + str = "eExitMessage"; + break; + case eLimboMessage: + str = "eLimboMessage"; + break; + case eSignalMessage: + str = "eSignalMessage"; + break; + case eSignalDeliveredMessage: + str = "eSignalDeliveredMessage"; + break; + case eTraceMessage: + str = "eTraceMessage"; + break; + case eBreakpointMessage: + str = "eBreakpointMessage"; + break; + case eCrashMessage: + str = "eCrashMessage"; + break; + } +#endif + + return str; +} + +const char * +ProcessMessage::PrintKind() const +{ + return PrintKind(m_kind); +} Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 142029) +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) @@ -19,6 +19,7 @@ // C++ Includes // Other libraries and framework includes +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" @@ -29,11 +30,60 @@ #include "LinuxThread.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" using namespace lldb_private; +// FIXME: this code is host-dependent with respect to types and +// endianness and needs to be fixed. For example, lldb::addr_t is +// hard-coded to uint64_t, but on a 32-bit Linux host, ptrace requires +// 32-bit pointer arguments. This code uses casts to work around the +// problem. + +// We disable the tracing of ptrace calls for integration builds to +// avoid the additional indirection and checks. +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION + +// Wrapper for ptrace to catch errors and log calls. +extern long +PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, + const char* reqName, const char* file, int line) +{ + int result; + + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PTRACE)); + if (log) + log->Printf("ptrace(%s, %u, %p, %p) called from file %s line %d", + reqName, pid, addr, data, file, line); + + errno = 0; + result = ptrace(req, pid, addr, 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 = ""; + } + log->Printf("ptrace() failed; errno=%d (%s)", errno, str); + } + + return result; +} + +#define PTRACE(req, pid, addr, data) \ + PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__) +#else +#define PTRACE ptrace +#endif + //------------------------------------------------------------------------------ // Static implementations of ProcessMonitor::ReadMemory and // ProcessMonitor::WriteMemory. This enables mutual recursion between these @@ -48,25 +98,49 @@ size_t remainder; long data; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); + if (log) + ProcessLinuxLog::IncNestLevel(); + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, + pid, word_size, (void*)vm_addr, buf, size); + + assert(sizeof(data) >= word_size); + assert(sizeof(void*) == word_size); for (bytes_read = 0; bytes_read < size; bytes_read += remainder) { errno = 0; - data = ptrace(PTRACE_PEEKDATA, pid, vm_addr, NULL); - + data = PTRACE(PTRACE_PEEKDATA, pid, (void*)vm_addr, NULL); if (data == -1L && errno) { error.SetErrorToErrno(); + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_read; } remainder = size - bytes_read; remainder = remainder > word_size ? word_size : remainder; + + // Copy the data into our buffer + if (log) + memset(dst, 0, sizeof(dst)); for (unsigned i = 0; i < remainder; ++i) dst[i] = ((data >> i*8) & 0xFF); + + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)dst, (unsigned long)data); + vm_addr += word_size; dst += word_size; } + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_read; } @@ -78,6 +152,14 @@ size_t bytes_written = 0; size_t remainder; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); + if (log) + ProcessLinuxLog::IncNestLevel(); + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, + pid, word_size, (void*)vm_addr, buf, size); + + assert(sizeof(void*) == word_size); for (bytes_written = 0; bytes_written < size; bytes_written += remainder) { remainder = size - bytes_written; @@ -86,12 +168,22 @@ if (remainder == word_size) { unsigned long data = 0; + assert(sizeof(data) >= word_size); for (unsigned i = 0; i < word_size; ++i) data |= (unsigned long)src[i] << i*8; - if (ptrace(PTRACE_POKEDATA, pid, vm_addr, data)) + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)src, data); + + if (PTRACE(PTRACE_POKEDATA, pid, (void*)vm_addr, (void*)data)) { error.SetErrorToErrno(); + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; } } @@ -100,18 +192,35 @@ unsigned char buff[8]; if (DoReadMemory(pid, word_size, vm_addr, buff, word_size, error) != word_size) + { + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; + } memcpy(buff, src, remainder); if (DoWriteMemory(pid, word_size, vm_addr, buff, word_size, error) != word_size) + { + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; + } + + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)src, *(unsigned long*)buff); } vm_addr += word_size; src += word_size; } + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; } @@ -216,6 +325,7 @@ m_result = DoWriteMemory(pid, word_size, m_addr, m_buff, m_size, m_error); } + //------------------------------------------------------------------------------ /// @class ReadRegOperation /// @brief Implements ProcessMonitor::ReadRegisterValue. @@ -238,11 +348,11 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) { lldb::pid_t pid = monitor->GetPID(); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); // Set errno to zero so that we can detect a failed peek. errno = 0; - uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); - + uint32_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); if (data == -1UL && errno) m_result = false; else @@ -250,6 +360,9 @@ m_value = data; m_result = true; } + if (log) + log->Printf ("ProcessMonitor::%s() reg %s: 0x%x", __FUNCTION__, + LinuxThread::GetRegisterNameFromOffset(m_offset), data); } //------------------------------------------------------------------------------ @@ -273,9 +386,22 @@ void WriteRegOperation::Execute(ProcessMonitor *monitor) { + void* buf; lldb::pid_t pid = monitor->GetPID(); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) + if (sizeof(void*) == sizeof(uint64_t)) + buf = (void*) m_value.GetAsUInt64(); + else + { + assert(sizeof(void*) == sizeof(uint32_t)); + buf = (void*) m_value.GetAsUInt32(); + } + + if (log) + log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, + LinuxThread::GetRegisterNameFromOffset(m_offset), buf); + if (PTRACE(PTRACE_POKEUSER, pid, (void*)m_offset, buf)) m_result = false; else m_result = true; @@ -301,7 +427,7 @@ void ReadGPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -327,7 +453,7 @@ void ReadFPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -353,7 +479,7 @@ void WriteGPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -379,7 +505,7 @@ void WriteFPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -410,7 +536,7 @@ if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) data = m_signo; - if (ptrace(PTRACE_CONT, m_tid, NULL, data)) + if (PTRACE(PTRACE_CONT, m_tid, NULL, (void*)data)) m_result = false; else m_result = true; @@ -441,7 +567,7 @@ if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) data = m_signo; - if (ptrace(PTRACE_SINGLESTEP, m_tid, NULL, data)) + if (PTRACE(PTRACE_SINGLESTEP, m_tid, NULL, (void*)data)) m_result = false; else m_result = true; @@ -467,7 +593,7 @@ void SiginfoOperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) + if (PTRACE(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) m_result = false; else m_result = true; @@ -493,7 +619,7 @@ void EventMessageOperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) + if (PTRACE(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) m_result = false; else m_result = true; @@ -518,7 +644,7 @@ { lldb::pid_t pid = monitor->GetPID(); - if (ptrace(PTRACE_KILL, pid, NULL, NULL)) + if (PTRACE(PTRACE_KILL, pid, NULL, NULL)) m_result = false; else m_result = true; @@ -756,6 +882,7 @@ lldb::pid_t pid; lldb::ThreadSP inferior; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); // Propagate the environment if one is not supplied. if (envp == NULL || envp[0] == NULL) @@ -789,7 +916,7 @@ if (pid == 0) { // Trace this process. - if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) + if (PTRACE(PTRACE_TRACEME, 0, NULL, NULL) < 0) exit(ePtraceFailed); // Do not inherit setgid powers. @@ -861,7 +988,7 @@ // Have the child raise an event on exit. This is used to keep the child in // limbo until it is destroyed. - if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT) < 0) + if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)PTRACE_O_TRACEEXIT) < 0) { args->m_error.SetErrorToErrno(); goto FINISH; @@ -880,9 +1007,12 @@ // Update the process thread list with this new thread and mark it as // current. + // FIXME: should we be letting UpdateThreadList handle this? + // FIXME: by using pids instead of tids, we can only support one thread. inferior.reset(new LinuxThread(process, pid)); + if (log) + log->Printf ("ProcessMonitor::%s() adding pid = %i", __FUNCTION__, pid); process.GetThreadList().AddThread(inferior); - process.GetThreadList().SetSelectedThreadByID(pid); // Let our process instance know the thread has stopped. process.SendMessage(ProcessMessage::Trace(pid)); @@ -943,6 +1073,7 @@ ProcessLinux &process = monitor->GetProcess(); lldb::ThreadSP inferior; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); if (pid <= 1) { @@ -952,7 +1083,7 @@ } // Attach to the requested process. - if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) + if (PTRACE(PTRACE_ATTACH, pid, NULL, NULL) < 0) { args->m_error.SetErrorToErrno(); goto FINISH; @@ -968,6 +1099,8 @@ // Update the process thread list with the attached thread and // mark it as current. inferior.reset(new LinuxThread(process, pid)); + if (log) + log->Printf ("ProcessMonitor::%s() adding tid = %i", __FUNCTION__, pid); process.GetThreadList().AddThread(inferior); process.GetThreadList().SetSelectedThreadByID(pid); @@ -987,6 +1120,7 @@ ProcessMessage message; ProcessMonitor *monitor = static_cast(callback_baton); ProcessLinux *process = monitor->m_process; + assert(process); bool stop_monitoring; siginfo_t info; @@ -1017,7 +1151,8 @@ { ProcessMessage message; - assert(info->si_signo == SIGTRAP && "Unexpected child signal!"); + assert(monitor); + assert(info && info->si_signo == SIGTRAP && "Unexpected child signal!"); switch (info->si_code) { Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp =================================================================== --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (revision 142029) +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (working copy) @@ -405,6 +405,7 @@ return g_register_infos[reg].byte_offset; } +#if 0 // These functions are currently not being used. static unsigned GetRegSize(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); @@ -420,6 +421,7 @@ { return (k_first_fpr <= reg && reg <= k_last_fpr); } +#endif RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread, uint32_t concrete_frame_idx) @@ -478,6 +480,26 @@ return NULL; } +unsigned +RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + for (reg = 0; reg < k_num_registers; reg++) + { + if (g_register_infos[reg].byte_offset == offset) + break; + } + assert(reg < k_num_registers && "Invalid register offset."); + return reg; +} + +const char * +RegisterContextLinux_x86_64::GetRegisterName(unsigned reg) +{ + assert(reg < k_num_registers && "Invalid register offset."); + return g_register_infos[reg].name; +} + bool RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) Index: source/Plugins/Process/Linux/LinuxThread.cpp =================================================================== --- source/Plugins/Process/Linux/LinuxThread.cpp (revision 142029) +++ source/Plugins/Process/Linux/LinuxThread.cpp (working copy) @@ -13,14 +13,15 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" - #include "LinuxStopInfo.h" #include "LinuxThread.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" #include "RegisterContextLinux_i386.h" #include "RegisterContextLinux_x86_64.h" @@ -33,6 +34,9 @@ : Thread(process, tid), m_frame_ap(0) { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s (tid = %i)", __FUNCTION__, tid); } LinuxThread::~LinuxThread() @@ -50,6 +54,14 @@ void LinuxThread::RefreshStateAfterStop() { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s ()", __FUNCTION__); + + // Let all threads recover from stopping and do any clean up based + // on the previous thread state (if any). + ProcessLinux &process = static_cast(GetProcess()); + process.GetThreadList().RefreshStateAfterStop(); } const char * @@ -91,13 +103,20 @@ lldb::RegisterContextSP reg_ctx_sp; uint32_t concrete_frame_idx = 0; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%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; } @@ -136,6 +155,10 @@ ProcessMonitor &monitor = GetMonitor(); bool status; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s ()", __FUNCTION__); + switch (resume_state) { default: @@ -160,6 +183,10 @@ void LinuxThread::Notify(const ProcessMessage &message) { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log) + log->Printf ("LinuxThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind()); + switch (message.GetKind()) { default: @@ -196,14 +223,20 @@ LinuxThread::BreakNotify(const ProcessMessage &message) { bool status; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + assert(GetRegisterContextLinux()); status = GetRegisterContextLinux()->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 ("LinuxThread::%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)); @@ -250,7 +283,68 @@ assert(message.GetKind() == ProcessMessage::eCrashMessage); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log) + log->Printf ("LinuxThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason()); + m_stop_info = lldb::StopInfoSP(new LinuxCrashStopInfo( *this, signo, message.GetCrashReason())); SetResumeSignal(signo); } + +unsigned +LinuxThread::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + ArchSpec arch = Host::GetArchitecture(); + + switch (arch.GetCore()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCore_x86_32_i386: + case ArchSpec::eCore_x86_32_i486: + case ArchSpec::eCore_x86_32_i486sx: + reg = RegisterContextLinux_i386::GetRegisterIndexFromOffset(offset); + break; + + case ArchSpec::eCore_x86_64_x86_64: + reg = RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(offset); + break; + } + return reg; +} + +const char * +LinuxThread::GetRegisterName(unsigned reg) +{ + const char * name; + ArchSpec arch = Host::GetArchitecture(); + + switch (arch.GetCore()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCore_x86_32_i386: + case ArchSpec::eCore_x86_32_i486: + case ArchSpec::eCore_x86_32_i486sx: + name = RegisterContextLinux_i386::GetRegisterName(reg); + break; + + case ArchSpec::eCore_x86_64_x86_64: + name = RegisterContextLinux_x86_64::GetRegisterName(reg); + break; + } + return name; +} + +const char * +LinuxThread::GetRegisterNameFromOffset(unsigned offset) +{ + return GetRegisterName(GetRegisterIndexFromOffset(offset)); +} + Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.h =================================================================== --- source/Plugins/Process/Linux/RegisterContextLinux_i386.h (revision 142029) +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.h (working copy) @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Log.h" #include "RegisterContextLinux.h" class RegisterContextLinux_i386 : public RegisterContextLinux @@ -42,6 +43,12 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + #if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); @@ -153,6 +160,8 @@ ProcessMonitor &GetMonitor(); + void LogGPR(const char *title); + bool ReadGPR(); bool ReadFPR(); }; Index: source/Plugins/Process/Linux/ProcessMessage.h =================================================================== --- source/Plugins/Process/Linux/ProcessMessage.h (revision 142029) +++ source/Plugins/Process/Linux/ProcessMessage.h (working copy) @@ -140,6 +140,18 @@ static const char * GetCrashReasonString(CrashReason reason); + const char * + PrintCrashReason() const; + + static const char * + PrintCrashReason(CrashReason reason); + + const char * + PrintKind() const; + + static const char * + PrintKind(Kind); + private: ProcessMessage(lldb::tid_t tid, Kind kind, int status = 0, lldb::addr_t addr = 0) Index: source/Plugins/Process/Linux/LinuxThread.h =================================================================== --- source/Plugins/Process/Linux/LinuxThread.h (revision 142029) +++ source/Plugins/Process/Linux/LinuxThread.h (working copy) @@ -48,6 +48,20 @@ CreateRegisterContextForFrame (lldb_private::StackFrame *frame); //-------------------------------------------------------------------------- + // These static functions provide a mapping from the register offset + // back to the register index or name for use in debugging or log + // output. + + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + + static const char * + GetRegisterNameFromOffset(unsigned offset); + + //-------------------------------------------------------------------------- // These methods form a specialized interface to linux threads. // bool Resume(); Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h =================================================================== --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (revision 142029) +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (working copy) @@ -41,6 +41,12 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + virtual bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); From johnny.chen at apple.com Mon Oct 17 13:58:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 18:58:01 -0000 Subject: [Lldb-commits] [lldb] r142227 - in /lldb/trunk: include/lldb/API/SBWatchpoint.h include/lldb/Breakpoint/Watchpoint.h scripts/Python/interface/SBWatchpoint.i source/API/SBWatchpoint.cpp source/Breakpoint/Watchpoint.cpp source/Commands/CommandObjectWatchpoint.cpp source/Commands/CommandObjectWatchpoint.h source/Target/StopInfo.cpp test/functionalities/watchpoint/multiple_threads/main.cpp test/functionalities/watchpoint/watchpoint_commands/condition/ Message-ID: <20111017185801.2FC70312800A@llvm.org> Author: johnny Date: Mon Oct 17 13:58:00 2011 New Revision: 142227 URL: http://llvm.org/viewvc/llvm-project?rev=142227&view=rev Log: Add a commnad to set a condition for a watchpoint. Example: watchpoint modify -c 'global==5' modifies the last created watchpoint so that the condition expression is evaluated at the stop point to decide whether we should proceed with the stopping. Also add SBWatchpont::SetCondition(const char *condition) to set condition programmatically. Test cases to come later. Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/ Modified: lldb/trunk/include/lldb/API/SBWatchpoint.h lldb/trunk/include/lldb/Breakpoint/Watchpoint.h lldb/trunk/scripts/Python/interface/SBWatchpoint.i lldb/trunk/source/API/SBWatchpoint.cpp lldb/trunk/source/Breakpoint/Watchpoint.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.h lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp Modified: lldb/trunk/include/lldb/API/SBWatchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBWatchpoint.h?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBWatchpoint.h (original) +++ lldb/trunk/include/lldb/API/SBWatchpoint.h Mon Oct 17 13:58:00 2011 @@ -63,6 +63,12 @@ void SetIgnoreCount (uint32_t n); + const char * + GetCondition (); + + void + SetCondition (const char *condition); + bool GetDescription (lldb::SBStream &description, DescriptionLevel level); Modified: lldb/trunk/include/lldb/Breakpoint/Watchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Watchpoint.h?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/Watchpoint.h (original) +++ lldb/trunk/include/lldb/Breakpoint/Watchpoint.h Mon Oct 17 13:58:00 2011 @@ -53,6 +53,7 @@ void SetIgnoreCount (uint32_t n); void SetWatchpointType (uint32_t type); bool SetCallback (WatchpointHitCallback callback, void *callback_baton); + void ClearCallback(); void SetDeclInfo (std::string &str); void GetDescription (Stream *s, lldb::DescriptionLevel level); void Dump (Stream *s) const; @@ -60,6 +61,39 @@ Target &GetTarget() { return *m_target; } const Error &GetError() { return m_error; } + //------------------------------------------------------------------ + /// Invoke the callback action when the watchpoint is hit. + /// + /// @param[in] context + /// Described the watchpoint event. + /// + /// @return + /// \b true if the target should stop at this watchpoint and \b false not. + //------------------------------------------------------------------ + bool + InvokeCallback (StoppointCallbackContext *context); + + //------------------------------------------------------------------ + // Condition + //------------------------------------------------------------------ + //------------------------------------------------------------------ + /// Set the breakpoint's condition. + /// + /// @param[in] condition + /// The condition expression to evaluate when the breakpoint is hit. + /// Pass in NULL to clear the condition. + //------------------------------------------------------------------ + void SetCondition (const char *condition); + + //------------------------------------------------------------------ + /// Return a pointer to the text of the condition expression. + /// + /// @return + /// A pointer to the condition expression text, or NULL if no + // condition has been set. + //------------------------------------------------------------------ + const char *GetConditionText () const; + private: friend class Target; @@ -78,6 +112,7 @@ std::string m_decl_str; // Declaration information, if any. Error m_error; // An error object describing errors creating watchpoint. + std::auto_ptr m_condition_ap; // The condition to test. static lldb::break_id_t GetNextID(); Modified: lldb/trunk/scripts/Python/interface/SBWatchpoint.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBWatchpoint.i?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBWatchpoint.i (original) +++ lldb/trunk/scripts/Python/interface/SBWatchpoint.i Mon Oct 17 13:58:00 2011 @@ -66,6 +66,12 @@ void SetIgnoreCount (uint32_t n); + const char * + GetCondition (); + + void + SetCondition (const char *condition); + bool GetDescription (lldb::SBStream &description, DescriptionLevel level); }; Modified: lldb/trunk/source/API/SBWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBWatchpoint.cpp?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/source/API/SBWatchpoint.cpp (original) +++ lldb/trunk/source/API/SBWatchpoint.cpp Mon Oct 17 13:58:00 2011 @@ -205,6 +205,27 @@ } } +const char * +SBWatchpoint::GetCondition () +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + return m_opaque_sp->GetConditionText (); + } + return NULL; +} + +void +SBWatchpoint::SetCondition (const char *condition) +{ + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + m_opaque_sp->SetCondition (condition); + } +} + bool SBWatchpoint::GetDescription (SBStream &description, DescriptionLevel level) { Modified: lldb/trunk/source/Breakpoint/Watchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Watchpoint.cpp?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Watchpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Watchpoint.cpp Mon Oct 17 13:58:00 2011 @@ -13,7 +13,12 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Stream.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/ThreadSpec.h" +#include "lldb/Target/ThreadPlanTestCondition.h" using namespace lldb; using namespace lldb_private; @@ -82,16 +87,7 @@ if (m_hit_count <= GetIgnoreCount()) return false; - uint32_t access = 0; - if (m_watch_was_read) - access |= LLDB_WATCH_TYPE_READ; - if (m_watch_was_written) - access |= LLDB_WATCH_TYPE_WRITE; - - if (m_callback) - return m_callback(m_callback_baton, context, GetID(), access); - else - return true; + return true; } void @@ -124,8 +120,12 @@ m_watch_read ? "r" : "", m_watch_write ? "w" : ""); - if (description_level >= lldb::eDescriptionLevelFull) - s->Printf("\n declare @ '%s'", m_decl_str.c_str()); + if (description_level >= lldb::eDescriptionLevelFull) { + if (m_decl_str.c_str()) + s->Printf("\n declare @ '%s'", m_decl_str.c_str()); + if (GetConditionText()) + s->Printf("\n condition = '%s'", GetConditionText()); + } if (description_level >= lldb::eDescriptionLevelVerbose) if (m_callback) @@ -184,3 +184,44 @@ { m_ignore_count = n; } + +bool +Watchpoint::InvokeCallback (StoppointCallbackContext *context) +{ + if (m_callback && context->is_synchronous) + { + uint32_t access = 0; + if (m_watch_was_read) + access |= LLDB_WATCH_TYPE_READ; + if (m_watch_was_written) + access |= LLDB_WATCH_TYPE_WRITE; + return m_callback(m_callback_baton, context, GetID(), access); + } + else + return true; +} + +void +Watchpoint::SetCondition (const char *condition) +{ + if (condition == NULL || condition[0] == '\0') + { + if (m_condition_ap.get()) + m_condition_ap.reset(); + } + else + { + // Pass NULL for expr_prefix (no translation-unit level definitions). + m_condition_ap.reset(new ClangUserExpression (condition, NULL)); + } +} + +const char * +Watchpoint::GetConditionText () const +{ + if (m_condition_ap.get()) + return m_condition_ap->GetUserText(); + else + return NULL; +} + Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Mon Oct 17 13:58:00 2011 @@ -156,18 +156,21 @@ CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter)); CommandObjectSP delete_command_object (new CommandObjectWatchpointDelete (interpreter)); CommandObjectSP ignore_command_object (new CommandObjectWatchpointIgnore (interpreter)); + CommandObjectSP modify_command_object (new CommandObjectWatchpointModify (interpreter)); list_command_object->SetCommandName ("watchpoint list"); enable_command_object->SetCommandName("watchpoint enable"); disable_command_object->SetCommandName("watchpoint disable"); delete_command_object->SetCommandName("watchpoint delete"); ignore_command_object->SetCommandName("watchpoint ignore"); + modify_command_object->SetCommandName("watchpoint modify"); status = LoadSubCommand ("list", list_command_object); status = LoadSubCommand ("enable", enable_command_object); status = LoadSubCommand ("disable", disable_command_object); status = LoadSubCommand ("delete", delete_command_object); status = LoadSubCommand ("ignore", ignore_command_object); + status = LoadSubCommand ("modify", modify_command_object); } CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint() @@ -693,3 +696,151 @@ return result.Succeeded(); } +//------------------------------------------------------------------------- +// CommandObjectWatchpointModify::CommandOptions +//------------------------------------------------------------------------- +#pragma mark Modify::CommandOptions + +CommandObjectWatchpointModify::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : + Options (interpreter), + m_condition (), + m_condition_passed (false) +{ +} + +CommandObjectWatchpointModify::CommandOptions::~CommandOptions () +{ +} + +OptionDefinition +CommandObjectWatchpointModify::CommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_ALL, false, "condition", 'c', required_argument, NULL, NULL, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true."}, +{ 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL } +}; + +const OptionDefinition* +CommandObjectWatchpointModify::CommandOptions::GetDefinitions () +{ + return g_option_table; +} + +Error +CommandObjectWatchpointModify::CommandOptions::SetOptionValue (uint32_t option_idx, const char *option_arg) +{ + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'c': + if (option_arg != NULL) + m_condition.assign (option_arg); + else + m_condition.clear(); + m_condition_passed = true; + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +CommandObjectWatchpointModify::CommandOptions::OptionParsingStarting () +{ + m_condition.clear(); + m_condition_passed = false; +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointModify +//------------------------------------------------------------------------- +#pragma mark Modify + +CommandObjectWatchpointModify::CommandObjectWatchpointModify (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "watchpoint modify", + "Modify the options on a watchpoint or set of watchpoints in the executable. " + "If no watchpoint is specified, act on the last created watchpoint. " + "Passing an empty argument clears the modification.", + NULL), + m_options (interpreter) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID, eArgTypeWatchpointIDRange); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back (arg); +} + +CommandObjectWatchpointModify::~CommandObjectWatchpointModify () +{ +} + +Options * +CommandObjectWatchpointModify::GetOptions () +{ + return &m_options; +} + +bool +CommandObjectWatchpointModify::Execute +( + Args& args, + CommandReturnObject &result +) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (!CheckTargetForWatchpointOperations(target, result)) + return false; + + Mutex::Locker locker; + target->GetWatchpointList().GetListMutex(locker); + + const WatchpointList &watchpoints = target->GetWatchpointList(); + + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendError("No watchpoints exist to be modified."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (args.GetArgumentCount() == 0) + { + WatchpointSP wp_sp = target->GetLastCreatedWatchpoint(); + wp_sp->SetCondition(m_options.m_condition.c_str()); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + // Particular watchpoints selected; set condition on them. + std::vector wp_ids; + if (!VerifyWatchpointIDs(args, wp_ids)) + { + result.AppendError("Invalid watchpoints specification."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + int count = 0; + const size_t size = wp_ids.size(); + for (size_t i = 0; i < size; ++i) + { + WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]); + if (wp_sp) + { + wp_sp->SetCondition(m_options.m_condition.c_str()); + ++count; + } + } + result.AppendMessageWithFormat("%d watchpoints modified.\n",count); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.h?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.h Mon Oct 17 13:58:00 2011 @@ -190,6 +190,58 @@ CommandOptions m_options; }; +//------------------------------------------------------------------------- +// CommandObjectWatchpointModify +//------------------------------------------------------------------------- + +class CommandObjectWatchpointModify : public CommandObject +{ +public: + + CommandObjectWatchpointModify (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointModify (); + + virtual bool + Execute (Args& command, + CommandReturnObject &result); + + virtual Options * + GetOptions (); + + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter); + + virtual + ~CommandOptions (); + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg); + + void + OptionParsingStarting (); + + const OptionDefinition* + GetDefinitions (); + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + std::string m_condition; + bool m_condition_passed; + }; + +private: + CommandOptions m_options; +}; + } // namespace lldb_private #endif // liblldb_CommandObjectWatchpoint_h_ Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Mon Oct 17 13:58:00 2011 @@ -346,6 +346,12 @@ ShouldStop (Event *event_ptr) { // ShouldStop() method is idempotent and should not affect hit count. + // See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent() + // -->Process()::ShouldBroadcastEvent()->ThreadList::ShouldStop()-> + // Thread::ShouldStop()->ThreadPlanBase::ShouldStop()-> + // StopInfoWatchpoint::ShouldStop() and + // Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()-> + // StopInfoWatchpoint::PerformAction(). if (m_should_stop_is_valid) return m_should_stop; @@ -376,6 +382,118 @@ return m_should_stop; } + // Perform any action that is associated with this stop. This is done as the + // Event is removed from the event queue. + virtual void + PerformAction (Event *event_ptr) + { + LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); + // We're going to calculate if we should stop or not in some way during the course of + // this code. Also by default we're going to stop, so set that here. + m_should_stop = true; + + WatchpointSP wp_sp = + m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue()); + if (wp_sp) + { + StoppointCallbackContext context (event_ptr, + &m_thread.GetProcess(), + &m_thread, + m_thread.GetStackFrameAtIndex(0).get(), + false); + bool stop_requested = wp_sp->InvokeCallback (&context); + // Also make sure that the callback hasn't continued the target. + // If it did, when we'll set m_should_start to false and get out of here. + if (GetPrivateState() == eStateRunning) + m_should_stop = false; + + if (m_should_stop && !stop_requested) + { + // We have been vetoed. + m_should_stop = false; + } + + if (m_should_stop && wp_sp->GetConditionText() != NULL) + { + // We need to make sure the user sees any parse errors in their condition, so we'll hook the + // constructor errors up to the debugger's Async I/O. + StoppointCallbackContext context (event_ptr, + &m_thread.GetProcess(), + &m_thread, + m_thread.GetStackFrameAtIndex(0).get(), + false); + ExecutionResults result_code; + ValueObjectSP result_value_sp; + const bool discard_on_error = true; + Error error; + result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx, + eExecutionPolicyAlways, + discard_on_error, + wp_sp->GetConditionText(), + NULL, + result_value_sp, + error); + if (result_code == eExecutionCompleted) + { + if (result_value_sp) + { + Scalar scalar_value; + if (result_value_sp->ResolveValue (scalar_value)) + { + if (scalar_value.ULongLong(1) == 0) + { + // We have been vetoed. This takes precedence over querying + // the watchpoint whether it should stop (aka ignore count and + // friends). See also StopInfoWatchpoint::ShouldStop() as well + // as Process::ProcessEventData::DoOnRemoval(). + m_should_stop = false; + } + else + m_should_stop = true; + if (log) + log->Printf("Condition successfully evaluated, result is %s.\n", + m_should_stop ? "true" : "false"); + } + else + { + m_should_stop = true; + if (log) + log->Printf("Failed to get an integer result from the expression."); + } + } + } + else + { + Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger(); + StreamSP error_sp = debugger.GetAsyncErrorStream (); + error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint "); + wp_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief); + error_sp->Printf (": \"%s\"", + wp_sp->GetConditionText()); + error_sp->EOL(); + const char *err_str = error.AsCString(""); + if (log) + log->Printf("Error evaluating condition: \"%s\"\n", err_str); + + error_sp->PutCString (err_str); + error_sp->EOL(); + error_sp->Flush(); + // If the condition fails to be parsed or run, we should stop. + m_should_stop = true; + } + } + } + else + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + + if (log) + log->Printf ("Process::%s could not find watchpoint id: %lld...", __FUNCTION__, m_value); + } + if (log) + log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop); + } + virtual const char * GetDescription () { Modified: lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp?rev=142227&r1=142226&r2=142227&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp (original) +++ lldb/trunk/test/functionalities/watchpoint/multiple_threads/main.cpp Mon Oct 17 13:58:00 2011 @@ -30,8 +30,10 @@ ::pthread_mutex_lock (&g_access_mutex); uint32_t old_val = g_val; - if (flag != 0) + if (flag != 0) { + printf("changing g_val to %d...\n", (old_val + 1)); g_val = old_val + 1; + } if (flag == 0) ::pthread_mutex_unlock (&g_access_mutex); From johnny.chen at apple.com Mon Oct 17 15:26:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 20:26:07 -0000 Subject: [Lldb-commits] [lldb] r142241 - /lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py Message-ID: <20111017202608.065E22A6C12C@llvm.org> Author: johnny Date: Mon Oct 17 15:26:07 2011 New Revision: 142241 URL: http://llvm.org/viewvc/llvm-project?rev=142241&view=rev Log: Fix wrong docstring. Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py?rev=142241&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py Mon Oct 17 15:26:07 2011 @@ -0,0 +1,91 @@ +""" +Test watchpoint modify command to set condition on a watchpoint. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class WatchpointCmdConditionTestCase(TestBase): + + mydir = os.path.join("functionalities", "watchpoint", "watchpoint_commands", "condition") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + # And the watchpoint variable declaration line number. + self.decl = line_number(self.source, '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test method. + self.exe_name = self.testMethodName + self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_watchpoint_cond_with_dsym(self): + """Test watchpoint condition.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.watchpoint_condition() + + def test_watchpoint_cond_with_dwarf(self): + """Test watchpoint condition.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.watchpoint_condition() + + def watchpoint_condition(self): + """Do watchpoint condition 'global==5'.""" + exe = os.path.join(os.getcwd(), self.exe_name) + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Add a breakpoint to set a watchpoint when stopped on the breakpoint. + self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % + (self.source, self.line)) + + # Run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped again due to the breakpoint. + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + # Now let's set a write-type watchpoint for 'global'. + # With a condition of 'global==5'. + self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED, + substrs = ['Watchpoint created', 'size = 4', 'type = w', + '%s:%d' % (self.source, self.decl)]) + + self.runCmd("watchpoint modify -c 'global==5'") + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 0 initially. + self.expect("watchpoint list -v", + substrs = ['hit_count = 0', 'global==5']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (write type). + # The stop reason of the thread should be watchpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stop reason = watchpoint']) + self.expect("frame variable -g global", + substrs = ['(int32_t)', 'global = 5']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should now be 2. + self.expect("watchpoint list -v", + substrs = ['hit_count = 5']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From johnny.chen at apple.com Mon Oct 17 15:28:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 20:28:39 -0000 Subject: [Lldb-commits] [lldb] r142242 - /lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py Message-ID: <20111017202839.742D2312800A@llvm.org> Author: johnny Date: Mon Oct 17 15:28:39 2011 New Revision: 142242 URL: http://llvm.org/viewvc/llvm-project?rev=142242&view=rev Log: Rename test file. Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py - copied, changed from r142241, lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py Copied: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py (from r142241, lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py?p2=lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py&p1=lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py&r1=142241&r2=142242&rev=142242&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py Mon Oct 17 15:28:39 2011 @@ -7,7 +7,7 @@ import lldb from lldbtest import * -class WatchpointCmdConditionTestCase(TestBase): +class WatchpointConditionCmdTestCase(TestBase): mydir = os.path.join("functionalities", "watchpoint", "watchpoint_commands", "condition") From granata.enrico at gmail.com Mon Oct 17 16:45:27 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Mon, 17 Oct 2011 21:45:27 -0000 Subject: [Lldb-commits] [lldb] r142283 - in /lldb/trunk: include/lldb/Host/ include/lldb/Interpreter/ scripts/Python/ source/API/ source/Commands/ source/Host/common/ source/Interpreter/ test/functionalities/command_script/import/ test/functionalities/command_script/import/bar/ test/functionalities/command_script/import/foo/ test/functionalities/command_script/import/foo/bar/ Message-ID: <20111017214527.9A9352A6C12C@llvm.org> Author: enrico Date: Mon Oct 17 16:45:27 2011 New Revision: 142283 URL: http://llvm.org/viewvc/llvm-project?rev=142283&view=rev Log: this patch introduces a new command script import command which takes as input a filename for a Python script and imports the module contained in that file. the containing directory is added to the Python path such that dependencies are honored. also, the module may contain an __lldb_init_module(debugger,dict) function, which gets called after importing, and which can somehow initialize the module's interaction with lldb Added: lldb/trunk/test/functionalities/command_script/import/ lldb/trunk/test/functionalities/command_script/import/Makefile lldb/trunk/test/functionalities/command_script/import/TestImport.py lldb/trunk/test/functionalities/command_script/import/bar/ lldb/trunk/test/functionalities/command_script/import/bar/bar.py lldb/trunk/test/functionalities/command_script/import/bar/barutil.py lldb/trunk/test/functionalities/command_script/import/dummymodule.py lldb/trunk/test/functionalities/command_script/import/foo/ lldb/trunk/test/functionalities/command_script/import/foo/bar/ lldb/trunk/test/functionalities/command_script/import/foo/bar/foobar.py lldb/trunk/test/functionalities/command_script/import/foo/foo.py lldb/trunk/test/functionalities/command_script/import/foo/foo2.py lldb/trunk/test/functionalities/command_script/import/main.c Modified: lldb/trunk/include/lldb/Host/FileSpec.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Host/common/FileSpec.cpp lldb/trunk/source/Interpreter/ScriptInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Host/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/FileSpec.h (original) +++ lldb/trunk/include/lldb/Host/FileSpec.h Mon Oct 17 16:45:27 2011 @@ -357,6 +357,34 @@ size_t GetPath (char *path, size_t max_path_length) const; + //------------------------------------------------------------------ + /// Extract the extension of the file. + /// + /// Returns a ConstString that represents the extension of the filename + /// for this FileSpec object. If this object does not represent a file, + /// or the filename has no extension, ConstString(NULL) is returned. + /// The dot ('.') character is not returned as part of the extension + /// + /// @return + /// Returns the extension of the file as a ConstString object. + //------------------------------------------------------------------ + ConstString + GetFileNameExtension () const; + + //------------------------------------------------------------------ + /// Return the filename without the extension part + /// + /// Returns a ConstString that represents the filename of this object + /// without the extension part (e.g. for a file named "foo.bar", "foo" + /// is returned) + /// + /// @return + /// Returns the filename without extension + /// as a ConstString object. + //------------------------------------------------------------------ + ConstString + GetFileNameStrippingExtension () const; + FileType GetFileType () const; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Mon Oct 17 16:45:27 2011 @@ -11,7 +11,10 @@ #define liblldb_ScriptInterpreter_h_ #include "lldb/lldb-private.h" + #include "lldb/Core/Broadcaster.h" +#include "lldb/Core/Error.h" + #include "lldb/Utility/PseudoTerminal.h" @@ -48,24 +51,28 @@ const char* args, std::string& err_msg, lldb_private::CommandReturnObject& cmd_retobj); + + typedef bool (*SWIGPythonCallModuleInit) (const std::string python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger); typedef enum { - eCharPtr, - eBool, - eShortInt, - eShortIntUnsigned, - eInt, - eIntUnsigned, - eLongInt, - eLongIntUnsigned, - eLongLong, - eLongLongUnsigned, - eFloat, - eDouble, - eChar, - eCharStrOrNone - } ReturnType; + eScriptReturnTypeCharPtr, + eScriptReturnTypeBool, + eScriptReturnTypeShortInt, + eScriptReturnTypeShortIntUnsigned, + eScriptReturnTypeInt, + eScriptReturnTypeIntUnsigned, + eScriptReturnTypeLongInt, + eScriptReturnTypeLongIntUnsigned, + eScriptReturnTypeLongLong, + eScriptReturnTypeLongLongUnsigned, + eScriptReturnTypeFloat, + eScriptReturnTypeDouble, + eScriptReturnTypeChar, + eScriptReturnTypeCharStrOrNone + } ScriptReturnType; ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang); @@ -79,7 +86,7 @@ ExecuteInterpreterLoop () = 0; virtual bool - ExecuteOneLineWithReturn (const char *in_string, ReturnType return_type, void *ret_value) + ExecuteOneLineWithReturn (const char *in_string, ScriptReturnType return_type, void *ret_value) { return true; } @@ -176,20 +183,28 @@ } virtual bool - RunScriptBasedCommand(const char* impl_function, - const char* args, - lldb_private::CommandReturnObject& cmd_retobj, - Error& error) + RunScriptBasedCommand (const char* impl_function, + const char* args, + lldb_private::CommandReturnObject& cmd_retobj, + Error& error) { return false; } virtual std::string - GetDocumentationForItem(const char* item) + GetDocumentationForItem (const char* item) { return std::string(""); } + virtual bool + LoadScriptingModule (const char* filename, + lldb_private::Error& error) + { + error.SetErrorString("loading unimplemented"); + return false; + } + const char * GetScriptInterpreterPtyName (); @@ -212,7 +227,8 @@ SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, - SWIGPythonCallCommand python_swig_call_command); + SWIGPythonCallCommand python_swig_call_command, + SWIGPythonCallModuleInit python_swig_call_mod_init); static void TerminateInterpreter (); Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Mon Oct 17 16:45:27 2011 @@ -40,7 +40,7 @@ bool ExecuteOneLineWithReturn (const char *in_string, - ScriptInterpreter::ReturnType return_type, + ScriptInterpreter::ScriptReturnType return_type, void *ret_value); bool @@ -108,7 +108,11 @@ lldb::ValueObjectSP valobj); virtual std::string - GetDocumentationForItem(const char* item); + GetDocumentationForItem (const char* item); + + virtual bool + LoadScriptingModule (const char* filename, + lldb_private::Error& error); void CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, @@ -141,7 +145,8 @@ SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, - SWIGPythonCallCommand python_swig_call_command); + SWIGPythonCallCommand python_swig_call_command, + SWIGPythonCallModuleInit python_swig_call_mod_init); protected: Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Mon Oct 17 16:45:27 2011 @@ -676,7 +676,89 @@ PyErr_Print(); PyErr_Clear (); } -return retval; + return retval; +} + +SWIGEXPORT bool +LLDBSwigPythonCallModuleInit +( + const std::string python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger +) +{ + + lldb::SBDebugger debugger_sb(debugger); + + bool retval = false; + + PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0); + + if (DebuggerObj_PyObj == NULL) + return retval; + + if (!(python_module_name.length()) || !session_dictionary_name) + return retval; + + PyObject *session_dict, *pfunc; + PyObject *pargs, *pvalue; + + session_dict = FindSessionDictionary (session_dictionary_name); + + std::string python_function_name_string = python_module_name + (".__lldb_init_module"); + const char* python_function_name = python_function_name_string.c_str(); + + if (session_dict != NULL) + { + pfunc = ResolvePythonName (python_function_name, session_dict); + + if (PyErr_Occurred()) // this might not exist.. let's make sure we handle that + { + PyErr_Clear(); + return true; + } + + if (pfunc == NULL) + return true; + else + { + // Set up the arguments and call the function. + + if (PyCallable_Check (pfunc)) + { + pargs = PyTuple_New (2); + if (pargs == NULL) + { + if (PyErr_Occurred()) + PyErr_Clear(); + return retval; + } + + PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj + PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (PyErr_Occurred ()) + { + PyErr_Print(); + PyErr_Clear(); + } + else + { + retval = true; + Py_XDECREF (pvalue); + } + Py_INCREF (session_dict); + } + else if (PyErr_Occurred()) + { + PyErr_Print(); + PyErr_Clear(); + } + } + } + return retval; } %} Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Oct 17 16:45:27 2011 @@ -358,6 +358,13 @@ lldb_private::CommandReturnObject& cmd_retobj ); +extern "C" bool LLDBSwigPythonCallModuleInit +( + const std::string python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger +); + extern "C" void init_lldb(void); @@ -377,6 +384,7 @@ LLDBSwigPython_GetIndexOfChildWithName, LLDBSWIGPython_CastPyObjectToSBValue, LLDBSwigPython_UpdateSynthProviderInstance, - LLDBSwigPythonCallCommand); + LLDBSwigPythonCallCommand, + LLDBSwigPythonCallModuleInit); } } Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Mon Oct 17 16:45:27 2011 @@ -1220,6 +1220,78 @@ }; +//------------------------------------------------------------------------- +// CommandObjectCommandsScriptImport +//------------------------------------------------------------------------- + +class CommandObjectCommandsScriptImport : public CommandObject +{ +public: + CommandObjectCommandsScriptImport (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "command script import", + "Import a scripting module in LLDB.", + NULL) + { + CommandArgumentEntry arg1; + CommandArgumentData cmd_arg; + + // Define the first (and only) variant of this arg. + cmd_arg.arg_type = eArgTypePath; + cmd_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (cmd_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + } + + ~CommandObjectCommandsScriptImport () + { + } + + bool + Execute + ( + Args& args, + CommandReturnObject &result + ) + { + + if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) + { + result.AppendError ("only scripting language supported for module importing is currently Python"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + size_t argc = args.GetArgumentCount(); + + if (argc != 1) + { + result.AppendError ("'command script import' requires one argument"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + std::string path = args.GetArgumentAtIndex(0); + Error error; + + if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(path.c_str(), + error)) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendErrorWithFormat("module importing failed: %s", error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + + return result.Succeeded(); + } +}; //------------------------------------------------------------------------- // CommandObjectCommandsScriptAdd @@ -1684,6 +1756,7 @@ LoadSubCommand ("delete", CommandObjectSP (new CommandObjectCommandsScriptDelete (interpreter))); LoadSubCommand ("clear", CommandObjectSP (new CommandObjectCommandsScriptClear (interpreter))); LoadSubCommand ("list", CommandObjectSP (new CommandObjectCommandsScriptList (interpreter))); + LoadSubCommand ("import", CommandObjectSP (new CommandObjectCommandsScriptImport (interpreter))); } ~CommandObjectMultiwordCommandsScript () Modified: lldb/trunk/source/Host/common/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/source/Host/common/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Mon Oct 17 16:45:27 2011 @@ -699,10 +699,39 @@ return ::snprintf (path, path_max_len, "%s", filename); } } - path[0] = '\0'; + if (path) + path[0] = '\0'; return 0; } +ConstString +FileSpec::GetFileNameExtension () const +{ + const char *filename = m_filename.GetCString(); + if (filename == NULL) + return ConstString(); + + char* dot_pos = strrchr(filename, '.'); + if (dot_pos == NULL) + return ConstString(); + + return ConstString(dot_pos+1); +} + +ConstString +FileSpec::GetFileNameStrippingExtension () const +{ + const char *filename = m_filename.GetCString(); + if (filename == NULL) + return ConstString(); + + char* dot_pos = strrchr(filename, '.'); + if (dot_pos == NULL) + return m_filename; + + return ConstString(filename, dot_pos-filename); +} + //------------------------------------------------------------------ // Returns a shared pointer to a data buffer that contains all or // part of the contents of a file. The data is memory mapped and Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Mon Oct 17 16:45:27 2011 @@ -100,7 +100,8 @@ SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, - SWIGPythonCallCommand python_swig_call_command) + SWIGPythonCallCommand python_swig_call_command, + SWIGPythonCallModuleInit python_swig_call_mod_init) { ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback, python_swig_breakpoint_callback, @@ -111,7 +112,8 @@ python_swig_get_index_child, python_swig_cast_to_sbvalue, python_swig_update_provider, - python_swig_call_command); + python_swig_call_command, + python_swig_call_mod_init); } void Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=142283&r1=142282&r2=142283&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Oct 17 16:45:27 2011 @@ -42,6 +42,7 @@ static ScriptInterpreter::SWIGPythonCastPyObjectToSBValue g_swig_cast_to_sbvalue = NULL; static ScriptInterpreter::SWIGPythonUpdateSynthProviderInstance g_swig_update_provider = NULL; static ScriptInterpreter::SWIGPythonCallCommand g_swig_call_command = NULL; +static ScriptInterpreter::SWIGPythonCallModuleInit g_swig_call_module_init = NULL; static int _check_and_flush (FILE *stream) @@ -199,6 +200,10 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); + run_string.Printf ("run_one_line (%s, 'import os')", m_dictionary_name.c_str()); + PyRun_SimpleString (run_string.GetData()); + + run_string.Clear(); run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %d')", m_dictionary_name.c_str(), interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); @@ -702,7 +707,7 @@ bool ScriptInterpreterPython::ExecuteOneLineWithReturn (const char *in_string, - ScriptInterpreter::ReturnType return_type, + ScriptInterpreter::ScriptReturnType return_type, void *ret_value) { @@ -783,85 +788,85 @@ { switch (return_type) { - case eCharPtr: // "char *" + case eScriptReturnTypeCharPtr: // "char *" { const char format[3] = "s#"; success = PyArg_Parse (py_return, format, (char **) ret_value); break; } - case eCharStrOrNone: // char* or NULL if py_return == Py_None + case eScriptReturnTypeCharStrOrNone: // char* or NULL if py_return == Py_None { const char format[3] = "z"; success = PyArg_Parse (py_return, format, (char **) ret_value); break; } - case eBool: + case eScriptReturnTypeBool: { const char format[2] = "b"; success = PyArg_Parse (py_return, format, (bool *) ret_value); break; } - case eShortInt: + case eScriptReturnTypeShortInt: { const char format[2] = "h"; success = PyArg_Parse (py_return, format, (short *) ret_value); break; } - case eShortIntUnsigned: + case eScriptReturnTypeShortIntUnsigned: { const char format[2] = "H"; success = PyArg_Parse (py_return, format, (unsigned short *) ret_value); break; } - case eInt: + case eScriptReturnTypeInt: { const char format[2] = "i"; success = PyArg_Parse (py_return, format, (int *) ret_value); break; } - case eIntUnsigned: + case eScriptReturnTypeIntUnsigned: { const char format[2] = "I"; success = PyArg_Parse (py_return, format, (unsigned int *) ret_value); break; } - case eLongInt: + case eScriptReturnTypeLongInt: { const char format[2] = "l"; success = PyArg_Parse (py_return, format, (long *) ret_value); break; } - case eLongIntUnsigned: + case eScriptReturnTypeLongIntUnsigned: { const char format[2] = "k"; success = PyArg_Parse (py_return, format, (unsigned long *) ret_value); break; } - case eLongLong: + case eScriptReturnTypeLongLong: { const char format[2] = "L"; success = PyArg_Parse (py_return, format, (long long *) ret_value); break; } - case eLongLongUnsigned: + case eScriptReturnTypeLongLongUnsigned: { const char format[2] = "K"; success = PyArg_Parse (py_return, format, (unsigned long long *) ret_value); break; } - case eFloat: + case eScriptReturnTypeFloat: { const char format[2] = "f"; success = PyArg_Parse (py_return, format, (float *) ret_value); break; } - case eDouble: + case eScriptReturnTypeDouble: { const char format[2] = "d"; success = PyArg_Parse (py_return, format, (double *) ret_value); break; } - case eChar: + case eScriptReturnTypeChar: { const char format[2] = "c"; success = PyArg_Parse (py_return, format, (char *) ret_value); @@ -1825,6 +1830,98 @@ } bool +ScriptInterpreterPython::LoadScriptingModule (const char* pathname, + lldb_private::Error& error) +{ + if (!pathname || !pathname[0]) + { + error.SetErrorString("invalid pathname"); + return false; + } + + if (!g_swig_call_module_init) + { + error.SetErrorString("internal helper function missing"); + return false; + } + + ScriptInterpreterPython *python_interpreter = this; + + lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().GetSP(); + + FILE *tmp_fh = (python_interpreter->m_dbg_stdout ? python_interpreter->m_dbg_stdout : stdout); + + { + Locker py_lock(python_interpreter, tmp_fh); + + FileSpec target_file(pathname, true); + + // TODO: would we want to reject any other value? + if (target_file.GetFileType() == FileSpec::eFileTypeInvalid || + target_file.GetFileType() == FileSpec::eFileTypeUnknown) + { + error.SetErrorString("invalid pathname"); + return false; + } + + const char* directory = target_file.GetDirectory().GetCString(); + std::string basename(target_file.GetFilename().GetCString()); + + // now make sure that Python has "directory" in the search path + StreamString command_stream; + command_stream.Printf("if not (sys.path.__contains__('%s')):\n sys.path.append('%s');\n\n", + directory, + directory); + bool syspath_retval = python_interpreter->ExecuteMultipleLines(command_stream.GetData()); + if (!syspath_retval) + { + error.SetErrorString("Python sys.path handling failed"); + return false; + } + + // strip .py or .pyc extension + ConstString extension = target_file.GetFileNameExtension(); + if (::strcmp(extension.GetCString(), "py") == 0) + basename.resize(basename.length()-3); + else if(::strcmp(extension.GetCString(), "pyc") == 0) + basename.resize(basename.length()-4); + + // check if the module is already import-ed + command_stream.Clear(); + command_stream.Printf("sys.getrefcount(%s)",basename.c_str()); + int refcount = 0; + // this call will fail if the module does not exist (because the parameter to it is not a string + // but an actual Python module object, which is non-existant if the module was not imported before) + if (python_interpreter->ExecuteOneLineWithReturn(command_stream.GetData(), + ScriptInterpreterPython::eScriptReturnTypeInt, &refcount) && refcount > 0) + { + error.SetErrorString("module already imported"); + return false; + } + + // now actually do the import + command_stream.Clear(); + command_stream.Printf("import %s",basename.c_str()); + bool import_retval = python_interpreter->ExecuteOneLine(command_stream.GetData(), NULL); + if (!import_retval) + { + error.SetErrorString("Python import statement failed"); + return false; + } + + // call __lldb_module_init(debugger,dict) + if (!g_swig_call_module_init (basename, + python_interpreter->m_dictionary_name.c_str(), + debugger_sp)) + { + error.SetErrorString("calling __lldb_module_init failed"); + return false; + } + return true; + } +} + +bool ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, const char* args, lldb_private::CommandReturnObject& cmd_retobj, @@ -1886,7 +1983,7 @@ char* result_ptr = NULL; // Python is going to point this to valid data if ExecuteOneLineWithReturn returns successfully if (ExecuteOneLineWithReturn (command.c_str(), - ScriptInterpreter::eCharStrOrNone, + ScriptInterpreter::eScriptReturnTypeCharStrOrNone, &result_ptr) && result_ptr) { return std::string(result_ptr); @@ -1905,7 +2002,8 @@ SWIGPythonGetIndexOfChildWithName python_swig_get_index_child, SWIGPythonCastPyObjectToSBValue python_swig_cast_to_sbvalue, SWIGPythonUpdateSynthProviderInstance python_swig_update_provider, - SWIGPythonCallCommand python_swig_call_command) + SWIGPythonCallCommand python_swig_call_command, + SWIGPythonCallModuleInit python_swig_call_mod_init) { g_swig_init_callback = python_swig_init_callback; g_swig_breakpoint_callback = python_swig_breakpoint_callback; @@ -1917,6 +2015,7 @@ g_swig_cast_to_sbvalue = python_swig_cast_to_sbvalue; g_swig_update_provider = python_swig_update_provider; g_swig_call_command = python_swig_call_command; + g_swig_call_module_init = python_swig_call_mod_init; } void Added: lldb/trunk/test/functionalities/command_script/import/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/Makefile?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/Makefile (added) +++ lldb/trunk/test/functionalities/command_script/import/Makefile Mon Oct 17 16:45:27 2011 @@ -0,0 +1,6 @@ +LEVEL = ../../../make + +C_SOURCES := main.c +EXE := hello_world + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/command_script/import/TestImport.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/TestImport.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/TestImport.py (added) +++ lldb/trunk/test/functionalities/command_script/import/TestImport.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,71 @@ +"""Test custom import command to import files by path.""" + +import os, sys, time +import unittest2 +import lldb +from lldbtest import * + +class ImportTestCase(TestBase): + + mydir = os.path.join("functionalities", "command_script", "import") + + @python_api_test + def test_import_command(self): + """Import some Python scripts by path and test them""" + self.run_test() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def run_test(self): + """Import some Python scripts by path and test them.""" + + # This is the function to remove the custom commands in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('command script delete foo2cmd', check=False) + self.runCmd('command script delete foocmd', check=False) + self.runCmd('command script delete foobarcmd', check=False) + self.runCmd('command script delete barcmd', check=False) + self.runCmd('command script delete barothercmd', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + self.runCmd("command script import ./foo/foo.py") + self.runCmd("command script import ./foo/foo2.py") + self.runCmd("command script import ./foo/bar/foobar.py") + self.runCmd("command script import ./bar/bar.py") + + self.expect("command script import ./nosuchfile.py", + error=True, startstr='error: module importing failed') + self.expect("command script import ./nosuchfolder/", + error=True, startstr='error: module importing failed') + self.expect("command script import ./foo/foo.py", + error=True, startstr='error: module importing failed') + + self.runCmd("script import dummymodule") + self.expect("command script import ./dummymodule.py", + error=True, startstr='error: module importing failed') + + self.runCmd("command script add -f foo.foo_function foocmd") + self.runCmd("command script add -f foobar.foo_function foobarcmd") + self.runCmd("command script add -f bar.bar_function barcmd") + self.expect("foocmd hello", + substrs = ['foo says', 'hello']) + self.expect("foo2cmd hello", + substrs = ['foo2 says', 'hello']) + self.expect("barcmd hello", + substrs = ['barutil says', 'bar told me', 'hello']) + self.expect("barothercmd hello", + substrs = ['barutil says', 'bar told me', 'hello']) + self.expect("foobarcmd hello", + substrs = ['foobar says', 'hello']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/command_script/import/bar/bar.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/bar/bar.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/bar/bar.py (added) +++ lldb/trunk/test/functionalities/command_script/import/bar/bar.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,10 @@ +def bar_function(debugger, args, result, dict): + global UtilityModule + result.Printf(UtilityModule.barutil_function("bar told me " + args)) + return None + +def __lldb_init_module(debugger, session_dict): + global UtilityModule + UtilityModule = __import__("barutil") + debugger.HandleCommand("command script add -f bar.bar_function barothercmd") + return None \ No newline at end of file Added: lldb/trunk/test/functionalities/command_script/import/bar/barutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/bar/barutil.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/bar/barutil.py (added) +++ lldb/trunk/test/functionalities/command_script/import/bar/barutil.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,2 @@ +def barutil_function(x): + return "barutil says: " + x Added: lldb/trunk/test/functionalities/command_script/import/dummymodule.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/dummymodule.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/dummymodule.py (added) +++ lldb/trunk/test/functionalities/command_script/import/dummymodule.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,2 @@ +def no_useful_code(foo): + return foo Added: lldb/trunk/test/functionalities/command_script/import/foo/bar/foobar.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/foo/bar/foobar.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/foo/bar/foobar.py (added) +++ lldb/trunk/test/functionalities/command_script/import/foo/bar/foobar.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,3 @@ +def foo_function(debugger, args, result, dict): + result.Printf("foobar says " + args) + return None Added: lldb/trunk/test/functionalities/command_script/import/foo/foo.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/foo/foo.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/foo/foo.py (added) +++ lldb/trunk/test/functionalities/command_script/import/foo/foo.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,3 @@ +def foo_function(debugger, args, result, dict): + result.Printf("foo says " + args) + return None Added: lldb/trunk/test/functionalities/command_script/import/foo/foo2.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/foo/foo2.py?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/foo/foo2.py (added) +++ lldb/trunk/test/functionalities/command_script/import/foo/foo2.py Mon Oct 17 16:45:27 2011 @@ -0,0 +1,7 @@ +def foo2_function(debugger, args, result, dict): + result.Printf("foo2 says " + args) + return None + +def __lldb_init_module(debugger, session_dict): + debugger.HandleCommand("command script add -f foo2.foo2_function foo2cmd") + return None \ No newline at end of file Added: lldb/trunk/test/functionalities/command_script/import/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/import/main.c?rev=142283&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/import/main.c (added) +++ lldb/trunk/test/functionalities/command_script/import/main.c Mon Oct 17 16:45:27 2011 @@ -0,0 +1,15 @@ +#include + +int main(int argc, char const *argv[]) { + printf("Hello world.\n"); // Set break point at this line. + if (argc == 1) + return 0; + + // Waiting to be attached by the debugger, otherwise. + char line[100]; + while (fgets(line, sizeof(line), stdin)) { // Waiting to be attached... + printf("input line=>%s\n", line); + } + + printf("Exiting now\n"); +} From johnny.chen at apple.com Mon Oct 17 17:17:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 22:17:48 -0000 Subject: [Lldb-commits] [lldb] r142291 - in /lldb/trunk/test: functionalities/watchpoint/watchpoint_commands/condition/Makefile functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py functionalities/watchpoint/watchpoint_commands/condition/main.cpp python_api/default-constructor/sb_watchpoint.py python_api/watchpoint/condition/ python_api/watchpoint/condition/Makefile python_api/watchpoint/condition/TestWatchpointConditionAPI.py python_api/watchpoint/condition/main.cpp Message-ID: <20111017221748.17B94312800A@llvm.org> Author: johnny Date: Mon Oct 17 17:17:47 2011 New Revision: 142291 URL: http://llvm.org/viewvc/llvm-project?rev=142291&view=rev Log: Add test cases for setting condition on a watchpoint for both command and API. Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp lldb/trunk/test/python_api/watchpoint/condition/ lldb/trunk/test/python_api/watchpoint/condition/Makefile lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py lldb/trunk/test/python_api/watchpoint/condition/main.cpp Removed: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py Modified: lldb/trunk/test/python_api/default-constructor/sb_watchpoint.py Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile?rev=142291&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/Makefile Mon Oct 17 17:17:47 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Removed: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py?rev=142290&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointCmdCondition.py (removed) @@ -1,91 +0,0 @@ -""" -Test watchpoint modify command to set condition on a watchpoint. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class WatchpointCmdConditionTestCase(TestBase): - - mydir = os.path.join("functionalities", "watchpoint", "watchpoint_commands", "condition") - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Our simple source filename. - self.source = 'main.cpp' - # Find the line number to break inside main(). - self.line = line_number(self.source, '// Set break point at this line.') - # And the watchpoint variable declaration line number. - self.decl = line_number(self.source, '// Watchpoint variable declaration.') - # Build dictionary to have unique executable names for each test method. - self.exe_name = self.testMethodName - self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_watchpoint_cond_with_dsym(self): - """Test watchpoint condition.""" - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.watchpoint_condition() - - def test_watchpoint_cond_with_dwarf(self): - """Test watchpoint condition.""" - self.buildDwarf(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.watchpoint_condition() - - def watchpoint_condition(self): - """Do watchpoint condition 'global==5'.""" - exe = os.path.join(os.getcwd(), self.exe_name) - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Add a breakpoint to set a watchpoint when stopped on the breakpoint. - self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" % - (self.source, self.line)) - - # Run the program. - self.runCmd("run", RUN_SUCCEEDED) - - # We should be stopped again due to the breakpoint. - # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - - # Now let's set a write-type watchpoint for 'global'. - # With a condition of 'global==5'. - self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED, - substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) - - self.runCmd("watchpoint modify -c 'global==5'") - - # Use the '-v' option to do verbose listing of the watchpoint. - # The hit count should be 0 initially. - self.expect("watchpoint list -v", - substrs = ['hit_count = 0', 'global==5']) - - self.runCmd("process continue") - - # We should be stopped again due to the watchpoint (write type). - # The stop reason of the thread should be watchpoint. - self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, - substrs = ['stop reason = watchpoint']) - self.expect("frame variable -g global", - substrs = ['(int32_t)', 'global = 5']) - - # Use the '-v' option to do verbose listing of the watchpoint. - # The hit count should now be 2. - self.expect("watchpoint list -v", - substrs = ['hit_count = 5']) - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp?rev=142291&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp Mon Oct 17 17:17:47 2011 @@ -0,0 +1,28 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int32_t global = 0; // Watchpoint variable declaration. + +static void modify(int32_t &var) { + ++var; +} + +int main(int argc, char** argv) { + int local = 0; + printf("&global=%p\n", &global); + printf("about to write to 'global'...\n"); // Set break point at this line. + // When stopped, watch 'global', + // for the condition "global == 5". + for (int i = 0; i < 10; ++i) + modify(global); + + printf("global=%d\n", global); +} Modified: lldb/trunk/test/python_api/default-constructor/sb_watchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_watchpoint.py?rev=142291&r1=142290&r2=142291&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_watchpoint.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_watchpoint.py Mon Oct 17 17:17:47 2011 @@ -18,3 +18,5 @@ obj.GetIgnoreCount() obj.SetIgnoreCount(5) obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelVerbose) + obj.SetCondition("shouldWeStop()") + obj.GetCondition() Added: lldb/trunk/test/python_api/watchpoint/condition/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/condition/Makefile?rev=142291&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/condition/Makefile (added) +++ lldb/trunk/test/python_api/watchpoint/condition/Makefile Mon Oct 17 17:17:47 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py?rev=142291&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py (added) +++ lldb/trunk/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py Mon Oct 17 17:17:47 2011 @@ -0,0 +1,101 @@ +""" +Test watchpoint condition API. +""" + +import os, time +import unittest2 +import lldb +import lldbutil +from lldbtest import * + +class WatchpointConditionAPITestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint", "condition") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.cpp' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + # And the watchpoint variable declaration line number. + self.decl = line_number(self.source, '// Watchpoint variable declaration.') + # Build dictionary to have unique executable names for each test method. + self.exe_name = self.testMethodName + self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_watchpoint_cond_api_with_dsym(self): + """Test watchpoint condition API.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.watchpoint_condition_api() + + def test_watchpoint_cond_api_with_dwarf(self): + """Test watchpoint condition API.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.watchpoint_condition_api() + + def watchpoint_condition_api(self): + """Do watchpoint condition API to set condition as 'global==5'.""" + exe = os.path.join(os.getcwd(), self.exe_name) + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c. + breakpoint = target.BreakpointCreateByLocation(self.source, self.line) + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + + # We should be stopped due to the breakpoint. Get frame #0. + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + frame0 = thread.GetFrameAtIndex(0) + + # Watch 'global' for write. + value = frame0.FindValue('global', lldb.eValueTypeVariableGlobal) + watchpoint = value.Watch(True, False, True) + self.assertTrue(value and watchpoint, + "Successfully found the variable and set a watchpoint") + self.DebugSBValue(value) + + # Now set the condition as "global==5". + watchpoint.SetCondition('global==5') + self.expect(watchpoint.GetCondition(), exe=False, + startstr = 'global==5') + + # Hide stdout if not running with '-t' option. + if not self.TraceOn(): + self.HideStdout() + + print watchpoint + + # Continue. Expect the program to stop due to the variable being written to. + process.Continue() + + if (self.TraceOn()): + lldbutil.print_stacktraces(process) + + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonWatchpoint) + self.assertTrue(thread, "The thread stopped due to watchpoint") + self.DebugSBValue(value) + + # Verify that the condition is met. + self.assertTrue(value.GetValueAsUnsigned() == 5) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/watchpoint/condition/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/condition/main.cpp?rev=142291&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/condition/main.cpp (added) +++ lldb/trunk/test/python_api/watchpoint/condition/main.cpp Mon Oct 17 17:17:47 2011 @@ -0,0 +1,28 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int32_t global = 0; // Watchpoint variable declaration. + +static void modify(int32_t &var) { + ++var; +} + +int main(int argc, char** argv) { + int local = 0; + printf("&global=%p\n", &global); + printf("about to write to 'global'...\n"); // Set break point at this line. + // When stopped, watch 'global', + // for the condition "global == 5". + for (int i = 0; i < 10; ++i) + modify(global); + + printf("global=%d\n", global); +} From dawn at burble.org Mon Oct 17 18:06:13 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 17 Oct 2011 16:06:13 -0700 Subject: [Lldb-commits] [PATCH] work-around for compiling with gcc Message-ID: <20111017230613.GB18711@bloodbath.burble.org> This patch alloows lldb to build under GCC. See emails under the thread "[lldb-dev] one more bug in evaluation" for more information. Please commit! Thanks in advance, -Dawn From dawn at burble.org Mon Oct 17 18:10:46 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 17 Oct 2011 16:10:46 -0700 Subject: [Lldb-commits] [PATCH] work-around for compiling with gcc In-Reply-To: <20111017230613.GB18711@bloodbath.burble.org> References: <20111017230613.GB18711@bloodbath.burble.org> Message-ID: <20111017231046.GA19106@bloodbath.burble.org> Forgot the attachment! -Dawn On Mon, Oct 17, 2011 at 04:06:13PM -0700, dawn at burble.org wrote: > This patch alloows lldb to build under GCC. See emails under the > thread "[lldb-dev] one more bug in evaluation" for more information. > > Please commit! > > Thanks in advance, > -Dawn > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -------------- next part -------------- Index: include/lldb/Symbol/ClangASTImporter.h =================================================================== --- include/lldb/Symbol/ClangASTImporter.h (revision 142299) +++ include/lldb/Symbol/ClangASTImporter.h (working copy) @@ -17,6 +17,11 @@ #include "clang/AST/ASTImporter.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" +#if defined(__GNUC__) && !defined(__clang__) +// Gcc complains about ClangNamespaceDecl being an incomplete type +// without this. +#include "lldb/Symbol/ClangNamespaceDecl.h" +#endif namespace lldb_private { From johnny.chen at apple.com Mon Oct 17 18:18:19 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 23:18:19 -0000 Subject: [Lldb-commits] [lldb] r142305 - /lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Message-ID: <20111017231819.944713524001@llvm.org> Author: johnny Date: Mon Oct 17 18:18:19 2011 New Revision: 142305 URL: http://llvm.org/viewvc/llvm-project?rev=142305&view=rev Log: This patch alloows lldb to build under GCC. from dawn at burble.org Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=142305&r1=142304&r2=142305&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Mon Oct 17 18:18:19 2011 @@ -17,6 +17,11 @@ #include "clang/AST/ASTImporter.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" +#if defined(__GNUC__) && !defined(__clang__) +// Gcc complains about ClangNamespaceDecl being an incomplete type +// without this. +#include "lldb/Symbol/ClangNamespaceDecl.h" +#endif namespace lldb_private { From johnny.chen at apple.com Mon Oct 17 18:21:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 17 Oct 2011 16:21:57 -0700 Subject: [Lldb-commits] [PATCH] work-around for compiling with gcc In-Reply-To: <20111017231046.GA19106@bloodbath.burble.org> References: <20111017230613.GB18711@bloodbath.burble.org> <20111017231046.GA19106@bloodbath.burble.org> Message-ID: <7366B024-D8CE-4719-997F-6924C75B9954@apple.com> http://llvm.org/viewvc/llvm-project?rev=142305&view=rev Thanks! On Oct 17, 2011, at 4:10 PM, dawn at burble.org wrote: > Forgot the attachment! > > -Dawn > > On Mon, Oct 17, 2011 at 04:06:13PM -0700, dawn at burble.org wrote: >> This patch alloows lldb to build under GCC. See emails under the >> thread "[lldb-dev] one more bug in evaluation" for more information. >> >> Please commit! >> >> Thanks in advance, >> -Dawn >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20111017/810a6991/attachment-0001.html From dawn at burble.org Mon Oct 17 21:46:00 2011 From: dawn at burble.org (dawn at burble.org) Date: Mon, 17 Oct 2011 19:46:00 -0700 Subject: [Lldb-commits] [PATCH] fixes for Linux In-Reply-To: <20111017173609.GA13868@bloodbath.burble.org> References: <20111015025853.GA24361@bloodbath.burble.org> <20111017173609.GA13868@bloodbath.burble.org> Message-ID: <20111018024600.GA23486@bloodbath.burble.org> Just in case you missed it, this patch (attached in previous email) is still awaiting review. Please review and commit if acceptable. Thanks again! -Dawn On Mon, Oct 17, 2011 at 10:36:09AM -0700, dawn at burble.org wrote: > Seems I forgot the patch? Doh! > > On Fri, Oct 14, 2011 at 07:58:53PM -0700, dawn at burble.org wrote: > > This patch fixes debugging of single threaded apps on Linux. > > It also adds some asserts and additional logging support. > > > > Thanks in advance, > > -Dawn > > _______________________________________________ > > lldb-commits mailing list > > lldb-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > Index: source/Plugins/Process/Linux/ProcessLinux.cpp > =================================================================== > --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 142029) > +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) > @@ -119,7 +119,7 @@ > > LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); > if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); > + log->Printf ("ProcessLinux::%s(pid = %i)", __FUNCTION__, GetID()); > > m_monitor = new ProcessMonitor(this, pid, error); > > @@ -328,6 +328,10 @@ > void > ProcessLinux::RefreshStateAfterStop() > { > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("ProcessLinux::%s()", __FUNCTION__); > + > Mutex::Locker lock(m_message_mutex); > if (m_message_queue.empty()) > return; > @@ -335,10 +339,15 @@ > ProcessMessage &message = m_message_queue.front(); > > // Resolve the thread this message corresponds to and pass it along. > + // FIXME: we're really dealing with the pid here. This should get > + // fixed when this code is fixed to handle multiple threads. > lldb::tid_t tid = message.GetTID(); > + if (log) > + log->Printf ("ProcessLinux::%s() pid = %i", __FUNCTION__, tid); > LinuxThread *thread = static_cast( > GetThreadList().FindThreadByID(tid, false).get()); > > + assert(thread); > thread->Notify(message); > > m_message_queue.pop(); > @@ -355,6 +364,7 @@ > ProcessLinux::DoReadMemory(addr_t vm_addr, > void *buf, size_t size, Error &error) > { > + assert(m_monitor); > return m_monitor->ReadMemory(vm_addr, buf, size, error); > } > > @@ -362,6 +372,7 @@ > ProcessLinux::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, > Error &error) > { > + assert(m_monitor); > return m_monitor->WriteMemory(vm_addr, buf, size, error); > } > > @@ -453,12 +464,22 @@ > uint32_t > ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) > { > - // FIXME: Should this be implemented? > LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); > + log->Printf ("ProcessLinux::%s() (pid = %i)", __FUNCTION__, GetID()); > > - return 0; > + // Update the process thread list with this new thread. > + // FIXME: We should be using tid, not pid. > + assert(m_monitor); > + ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false)); > + if (!thread_sp) > + thread_sp.reset(new LinuxThread(*this, GetID())); > + > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("ProcessLinux::%s() updated pid = %i", __FUNCTION__, GetID()); > + new_thread_list.AddThread(thread_sp); > + > + return new_thread_list.GetSize(false); > } > > ByteOrder > Index: source/Plugins/Process/Linux/ProcessLinuxLog.cpp > =================================================================== > --- source/Plugins/Process/Linux/ProcessLinuxLog.cpp (revision 142029) > +++ source/Plugins/Process/Linux/ProcessLinuxLog.cpp (working copy) > @@ -69,6 +69,8 @@ > else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_SHORT; > else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_LONG; > else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~LINUX_LOG_PROCESS; > + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~LINUX_LOG_PTRACE; > + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~LINUX_LOG_REGISTERS; > else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~LINUX_LOG_STEP; > else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~LINUX_LOG_THREAD; > else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~LINUX_LOG_VERBOSE; > @@ -126,6 +128,8 @@ > else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_SHORT; > else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_LONG; > else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= LINUX_LOG_PROCESS; > + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= LINUX_LOG_PTRACE; > + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= LINUX_LOG_REGISTERS; > else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= LINUX_LOG_STEP; > else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= LINUX_LOG_THREAD; > else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= LINUX_LOG_VERBOSE; > @@ -162,6 +166,10 @@ > " data-short - log memory bytes for memory reads and writes for short transactions only\n" > " data-long - log memory bytes for memory reads and writes for all transactions\n" > " process - log process events and activities\n" > +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION > + " ptrace - log all calls to ptrace\n" > +#endif > + " registers - log register read/writes\n" > " thread - log thread events and activities\n" > " step - log step related activities\n" > " verbose - enable verbose logging\n" > @@ -181,3 +189,5 @@ > va_end (args); > } > } > + > +int ProcessLinuxLog::m_nestinglevel; > Index: source/Plugins/Process/Linux/ProcessLinux.h > =================================================================== > --- source/Plugins/Process/Linux/ProcessLinux.h (revision 142029) > +++ source/Plugins/Process/Linux/ProcessLinux.h (working copy) > @@ -177,7 +177,8 @@ > /// Registers the given message with this process. > void SendMessage(const ProcessMessage &message); > > - ProcessMonitor &GetMonitor() { return *m_monitor; } > + ProcessMonitor & > + GetMonitor() { assert(m_monitor); return *m_monitor; } > > lldb_private::UnixSignals & > GetUnixSignals(); > Index: source/Plugins/Process/Linux/ProcessLinuxLog.h > =================================================================== > --- source/Plugins/Process/Linux/ProcessLinuxLog.h (revision 142029) > +++ source/Plugins/Process/Linux/ProcessLinuxLog.h (working copy) > @@ -29,11 +29,18 @@ > #define LINUX_LOG_STEP (1u << 9) > #define LINUX_LOG_COMM (1u << 10) > #define LINUX_LOG_ASYNC (1u << 11) > +#define LINUX_LOG_PTRACE (1u << 12) > +#define LINUX_LOG_REGISTERS (1u << 13) > #define LINUX_LOG_ALL (UINT32_MAX) > #define LINUX_LOG_DEFAULT LINUX_LOG_PACKETS > > +// The size which determines "short memory reads/writes". > +#define LINUX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t)) > + > class ProcessLinuxLog > { > + static int m_nestinglevel; > + > public: > static lldb::LogSP > GetLogIfAllCategoriesSet(uint32_t mask = 0); > @@ -42,13 +49,50 @@ > DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm); > > static lldb::LogSP > - EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm); > + EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, > + lldb_private::Args &args, lldb_private::Stream *feedback_strm); > > static void > ListLogCategories (lldb_private::Stream *strm); > > static void > LogIf (uint32_t mask, const char *format, ...); > + > + // The following functions can be used to enable the client to limit > + // logging to only the top level function calls. This is useful for > + // recursive functions. FIXME: not thread safe! > + // Example: > + // void NestingFunc() { > + // LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet(LINUX_LOG_ALL)); > + // if (log) > + // { > + // ProcessLinuxLog::IncNestLevel(); > + // if (ProcessLinuxLog::AtTopNestLevel()) > + // log->Print(msg); > + // } > + // NestingFunc(); > + // if (log) > + // ProcessLinuxLog::DecNestLevel(); > + // } > + > + static bool > + AtTopNestLevel() > + { > + return m_nestinglevel == 1; > + } > + > + static void > + IncNestLevel() > + { > + ++m_nestinglevel; > + } > + > + static void > + DecNestLevel() > + { > + --m_nestinglevel; > + assert(m_nestinglevel >= 0); > + } > }; > > #endif // liblldb_ProcessLinuxLog_h_ > Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp > =================================================================== > --- source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (revision 142029) > +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (working copy) > @@ -12,6 +12,7 @@ > #include "lldb/Host/Endian.h" > > #include "ProcessLinux.h" > +#include "ProcessLinuxLog.h" > #include "ProcessMonitor.h" > #include "RegisterContextLinux_i386.h" > > @@ -31,7 +32,6 @@ > gpr_esp, > gpr_ss, > gpr_eflags, > - gpr_orig_ax, > gpr_eip, > gpr_cs, > gpr_ds, > @@ -189,7 +189,6 @@ > gpr_esp, > gpr_ss, > gpr_eflags, > - gpr_orig_ax, > gpr_eip, > gpr_cs, > gpr_ds, > @@ -330,12 +329,17 @@ > > }; > > +#ifndef NDEBUG > +static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); > +#endif > + > static unsigned GetRegOffset(unsigned reg) > { > assert(reg < k_num_registers && "Invalid register number."); > return g_register_infos[reg].byte_offset; > } > > +#if 0 // These functions are currently not in use. > static unsigned GetRegSize(unsigned reg) > { > assert(reg < k_num_registers && "Invalid register number."); > @@ -351,6 +355,7 @@ > { > return (k_first_fpr <= reg && reg <= k_last_fpr); > } > +#endif > > > RegisterContextLinux_i386::RegisterContextLinux_i386(Thread &thread, > @@ -383,12 +388,14 @@ > size_t > RegisterContextLinux_i386::GetRegisterCount() > { > + assert(k_num_register_infos == k_num_registers); > return k_num_registers; > } > > const RegisterInfo * > RegisterContextLinux_i386::GetRegisterInfoAtIndex(uint32_t reg) > { > + assert(k_num_register_infos == k_num_registers); > if (reg < k_num_registers) > return &g_register_infos[reg]; > else > @@ -410,6 +417,26 @@ > return NULL; > } > > +unsigned > +RegisterContextLinux_i386::GetRegisterIndexFromOffset(unsigned offset) > +{ > + unsigned reg; > + for (reg = 0; reg < k_num_registers; reg++) > + { > + if (g_register_infos[reg].byte_offset == offset) > + break; > + } > + assert(reg < k_num_registers && "Invalid register offset."); > + return reg; > +} > + > +const char * > +RegisterContextLinux_i386::GetRegisterName(unsigned reg) > +{ > + assert(reg < k_num_registers && "Invalid register offset."); > + return g_register_infos[reg].name; > +} > + > bool > RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, > RegisterValue &value) > @@ -588,11 +615,31 @@ > return WriteRegisterFromUnsigned(gpr_eflags, eflags); > } > > +void > +RegisterContextLinux_i386::LogGPR(const char *title) > +{ > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); > + if (log) > + { > + if (title) > + log->Printf ("%s", title); > + for (uint32_t i=0; i + { > + uint32_t reg = gpr_eax + i; > + log->Printf("%12s = 0x%8.8x", g_register_infos[reg].name, (&user.regs)[reg]); > + } > + } > +} > + > bool > RegisterContextLinux_i386::ReadGPR() > { > - ProcessMonitor &monitor = GetMonitor(); > - return monitor.ReadGPR(&user.regs); > + bool result; > + > + ProcessMonitor &monitor = GetMonitor(); > + result = monitor.ReadGPR(&user.regs); > + LogGPR("RegisterContextLinux_i386::ReadGPR()"); > + return result; > } > > bool > Index: source/Plugins/Process/Linux/ProcessMessage.cpp > =================================================================== > --- source/Plugins/Process/Linux/ProcessMessage.cpp (revision 142029) > +++ source/Plugins/Process/Linux/ProcessMessage.cpp (working copy) > @@ -89,3 +89,157 @@ > > return str; > } > + > +const char * > +ProcessMessage::PrintCrashReason(CrashReason reason) > +{ > +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION > + // Just return the code in asci for integration builds. > + chcar str[8]; > + sprintf(str, "%d", reason); > +#else > + const char *str = NULL; > + > + switch (reason) > + { > + default: > + assert(false && "invalid CrashReason"); > + break; > + > + case eInvalidCrashReason: > + str = "eInvalidCrashReason"; > + break; > + > + // SIGSEGV crash rcase easons. > + case eInvalidAddress: > + str = "eInvalidAddress"; > + break; > + case ePrivilegedAddress: > + str = "ePrivilegedAddress"; > + break; > + > + // SIGILL crash rcase easons. > + case eIllegalOpcode: > + str = "eIllegalOpcode"; > + break; > + case eIllegalOperand: > + str = "eIllegalOperand"; > + break; > + case eIllegalAddressingMode: > + str = "eIllegalAddressingMode"; > + break; > + case eIllegalTrap: > + str = "eIllegalTrap"; > + break; > + case ePrivilegedOpcode: > + str = "ePrivilegedOpcode"; > + break; > + case ePrivilegedRegister: > + str = "ePrivilegedRegister"; > + break; > + case eCoprocessorError: > + str = "eCoprocessorError"; > + break; > + case eInternalStackError: > + str = "eInternalStackError"; > + break; > + > + // SIGBUS crash rcase easons: > + case eIllegalAlignment: > + str = "eIllegalAlignment"; > + break; > + case eIllegalAddress: > + str = "eIllegalAddress"; > + break; > + case eHardwareError: > + str = "eHardwareError"; > + break; > + > + // SIGFPE crash rcase easons: > + case eIntegerDivideByZero: > + str = "eIntegerDivideByZero"; > + break; > + case eIntegerOverflow: > + str = "eIntegerOverflow"; > + break; > + case eFloatDivideByZero: > + str = "eFloatDivideByZero"; > + break; > + case eFloatOverflow: > + str = "eFloatOverflow"; > + break; > + case eFloatUnderflow: > + str = "eFloatUnderflow"; > + break; > + case eFloatInexactResult: > + str = "eFloatInexactResult"; > + break; > + case eFloatInvalidOperation: > + str = "eFloatInvalidOperation"; > + break; > + case eFloatSubscriptRange: > + str = "eFloatSubscriptRange"; > + break; > + } > +#endif > + > + return str; > +} > + > +const char * > +ProcessMessage::PrintCrashReason() const > +{ > + return PrintCrashReason(m_crash_reason); > +} > + > +const char * > +ProcessMessage::PrintKind(Kind kind) > +{ > +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION > + // Just return the code in asci for integration builds. > + chcar str[8]; > + sprintf(str, "%d", reason); > +#else > + const char *str = NULL; > + > + switch (kind) > + { > + default: > + assert(false && "invalid Kind"); > + break; > + > + case eInvalidMessage: > + str = "eInvalidMessage"; > + break; > + case eExitMessage: > + str = "eExitMessage"; > + break; > + case eLimboMessage: > + str = "eLimboMessage"; > + break; > + case eSignalMessage: > + str = "eSignalMessage"; > + break; > + case eSignalDeliveredMessage: > + str = "eSignalDeliveredMessage"; > + break; > + case eTraceMessage: > + str = "eTraceMessage"; > + break; > + case eBreakpointMessage: > + str = "eBreakpointMessage"; > + break; > + case eCrashMessage: > + str = "eCrashMessage"; > + break; > + } > +#endif > + > + return str; > +} > + > +const char * > +ProcessMessage::PrintKind() const > +{ > + return PrintKind(m_kind); > +} > Index: source/Plugins/Process/Linux/ProcessMonitor.cpp > =================================================================== > --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 142029) > +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) > @@ -19,6 +19,7 @@ > > // C++ Includes > // Other libraries and framework includes > +#include "lldb/Core/Debugger.h" > #include "lldb/Core/Error.h" > #include "lldb/Core/RegisterValue.h" > #include "lldb/Core/Scalar.h" > @@ -29,11 +30,60 @@ > > #include "LinuxThread.h" > #include "ProcessLinux.h" > +#include "ProcessLinuxLog.h" > #include "ProcessMonitor.h" > > > using namespace lldb_private; > > +// FIXME: this code is host-dependent with respect to types and > +// endianness and needs to be fixed. For example, lldb::addr_t is > +// hard-coded to uint64_t, but on a 32-bit Linux host, ptrace requires > +// 32-bit pointer arguments. This code uses casts to work around the > +// problem. > + > +// We disable the tracing of ptrace calls for integration builds to > +// avoid the additional indirection and checks. > +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION > + > +// Wrapper for ptrace to catch errors and log calls. > +extern long > +PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, > + const char* reqName, const char* file, int line) > +{ > + int result; > + > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PTRACE)); > + if (log) > + log->Printf("ptrace(%s, %u, %p, %p) called from file %s line %d", > + reqName, pid, addr, data, file, line); > + > + errno = 0; > + result = ptrace(req, pid, addr, 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 = ""; > + } > + log->Printf("ptrace() failed; errno=%d (%s)", errno, str); > + } > + > + return result; > +} > + > +#define PTRACE(req, pid, addr, data) \ > + PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__) > +#else > +#define PTRACE ptrace > +#endif > + > //------------------------------------------------------------------------------ > // Static implementations of ProcessMonitor::ReadMemory and > // ProcessMonitor::WriteMemory. This enables mutual recursion between these > @@ -48,25 +98,49 @@ > size_t remainder; > long data; > > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); > + if (log) > + ProcessLinuxLog::IncNestLevel(); > + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) > + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, > + pid, word_size, (void*)vm_addr, buf, size); > + > + assert(sizeof(data) >= word_size); > + assert(sizeof(void*) == word_size); > for (bytes_read = 0; bytes_read < size; bytes_read += remainder) > { > errno = 0; > - data = ptrace(PTRACE_PEEKDATA, pid, vm_addr, NULL); > - > + data = PTRACE(PTRACE_PEEKDATA, pid, (void*)vm_addr, NULL); > if (data == -1L && errno) > { > error.SetErrorToErrno(); > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_read; > } > > remainder = size - bytes_read; > remainder = remainder > word_size ? word_size : remainder; > + > + // Copy the data into our buffer > + if (log) > + memset(dst, 0, sizeof(dst)); > for (unsigned i = 0; i < remainder; ++i) > dst[i] = ((data >> i*8) & 0xFF); > + > + if (log && ProcessLinuxLog::AtTopNestLevel() && > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && > + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) > + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, > + (void*)vm_addr, *(unsigned long*)dst, (unsigned long)data); > + > vm_addr += word_size; > dst += word_size; > } > > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_read; > } > > @@ -78,6 +152,14 @@ > size_t bytes_written = 0; > size_t remainder; > > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); > + if (log) > + ProcessLinuxLog::IncNestLevel(); > + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) > + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, > + pid, word_size, (void*)vm_addr, buf, size); > + > + assert(sizeof(void*) == word_size); > for (bytes_written = 0; bytes_written < size; bytes_written += remainder) > { > remainder = size - bytes_written; > @@ -86,12 +168,22 @@ > if (remainder == word_size) > { > unsigned long data = 0; > + assert(sizeof(data) >= word_size); > for (unsigned i = 0; i < word_size; ++i) > data |= (unsigned long)src[i] << i*8; > > - if (ptrace(PTRACE_POKEDATA, pid, vm_addr, data)) > + if (log && ProcessLinuxLog::AtTopNestLevel() && > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && > + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) > + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, > + (void*)vm_addr, *(unsigned long*)src, data); > + > + if (PTRACE(PTRACE_POKEDATA, pid, (void*)vm_addr, (void*)data)) > { > error.SetErrorToErrno(); > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_written; > } > } > @@ -100,18 +192,35 @@ > unsigned char buff[8]; > if (DoReadMemory(pid, word_size, vm_addr, > buff, word_size, error) != word_size) > + { > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_written; > + } > > memcpy(buff, src, remainder); > > if (DoWriteMemory(pid, word_size, vm_addr, > buff, word_size, error) != word_size) > + { > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_written; > + } > + > + if (log && ProcessLinuxLog::AtTopNestLevel() && > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || > + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && > + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) > + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, > + (void*)vm_addr, *(unsigned long*)src, *(unsigned long*)buff); > } > > vm_addr += word_size; > src += word_size; > } > + if (log) > + ProcessLinuxLog::DecNestLevel(); > return bytes_written; > } > > @@ -216,6 +325,7 @@ > m_result = DoWriteMemory(pid, word_size, m_addr, m_buff, m_size, m_error); > } > > + > //------------------------------------------------------------------------------ > /// @class ReadRegOperation > /// @brief Implements ProcessMonitor::ReadRegisterValue. > @@ -238,11 +348,11 @@ > ReadRegOperation::Execute(ProcessMonitor *monitor) > { > lldb::pid_t pid = monitor->GetPID(); > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); > > // Set errno to zero so that we can detect a failed peek. > errno = 0; > - uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); > - > + uint32_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); > if (data == -1UL && errno) > m_result = false; > else > @@ -250,6 +360,9 @@ > m_value = data; > m_result = true; > } > + if (log) > + log->Printf ("ProcessMonitor::%s() reg %s: 0x%x", __FUNCTION__, > + LinuxThread::GetRegisterNameFromOffset(m_offset), data); > } > > //------------------------------------------------------------------------------ > @@ -273,9 +386,22 @@ > void > WriteRegOperation::Execute(ProcessMonitor *monitor) > { > + void* buf; > lldb::pid_t pid = monitor->GetPID(); > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); > > - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) > + if (sizeof(void*) == sizeof(uint64_t)) > + buf = (void*) m_value.GetAsUInt64(); > + else > + { > + assert(sizeof(void*) == sizeof(uint32_t)); > + buf = (void*) m_value.GetAsUInt32(); > + } > + > + if (log) > + log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, > + LinuxThread::GetRegisterNameFromOffset(m_offset), buf); > + if (PTRACE(PTRACE_POKEUSER, pid, (void*)m_offset, buf)) > m_result = false; > else > m_result = true; > @@ -301,7 +427,7 @@ > void > ReadGPROperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) > + if (PTRACE(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) > m_result = false; > else > m_result = true; > @@ -327,7 +453,7 @@ > void > ReadFPROperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) > + if (PTRACE(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) > m_result = false; > else > m_result = true; > @@ -353,7 +479,7 @@ > void > WriteGPROperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) > + if (PTRACE(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) > m_result = false; > else > m_result = true; > @@ -379,7 +505,7 @@ > void > WriteFPROperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) > + if (PTRACE(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) > m_result = false; > else > m_result = true; > @@ -410,7 +536,7 @@ > if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) > data = m_signo; > > - if (ptrace(PTRACE_CONT, m_tid, NULL, data)) > + if (PTRACE(PTRACE_CONT, m_tid, NULL, (void*)data)) > m_result = false; > else > m_result = true; > @@ -441,7 +567,7 @@ > if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) > data = m_signo; > > - if (ptrace(PTRACE_SINGLESTEP, m_tid, NULL, data)) > + if (PTRACE(PTRACE_SINGLESTEP, m_tid, NULL, (void*)data)) > m_result = false; > else > m_result = true; > @@ -467,7 +593,7 @@ > void > SiginfoOperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) > + if (PTRACE(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) > m_result = false; > else > m_result = true; > @@ -493,7 +619,7 @@ > void > EventMessageOperation::Execute(ProcessMonitor *monitor) > { > - if (ptrace(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) > + if (PTRACE(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) > m_result = false; > else > m_result = true; > @@ -518,7 +644,7 @@ > { > lldb::pid_t pid = monitor->GetPID(); > > - if (ptrace(PTRACE_KILL, pid, NULL, NULL)) > + if (PTRACE(PTRACE_KILL, pid, NULL, NULL)) > m_result = false; > else > m_result = true; > @@ -756,6 +882,7 @@ > lldb::pid_t pid; > > lldb::ThreadSP inferior; > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); > > // Propagate the environment if one is not supplied. > if (envp == NULL || envp[0] == NULL) > @@ -789,7 +916,7 @@ > if (pid == 0) > { > // Trace this process. > - if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) > + if (PTRACE(PTRACE_TRACEME, 0, NULL, NULL) < 0) > exit(ePtraceFailed); > > // Do not inherit setgid powers. > @@ -861,7 +988,7 @@ > > // Have the child raise an event on exit. This is used to keep the child in > // limbo until it is destroyed. > - if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT) < 0) > + if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)PTRACE_O_TRACEEXIT) < 0) > { > args->m_error.SetErrorToErrno(); > goto FINISH; > @@ -880,9 +1007,12 @@ > > // Update the process thread list with this new thread and mark it as > // current. > + // FIXME: should we be letting UpdateThreadList handle this? > + // FIXME: by using pids instead of tids, we can only support one thread. > inferior.reset(new LinuxThread(process, pid)); > + if (log) > + log->Printf ("ProcessMonitor::%s() adding pid = %i", __FUNCTION__, pid); > process.GetThreadList().AddThread(inferior); > - process.GetThreadList().SetSelectedThreadByID(pid); > > // Let our process instance know the thread has stopped. > process.SendMessage(ProcessMessage::Trace(pid)); > @@ -943,6 +1073,7 @@ > ProcessLinux &process = monitor->GetProcess(); > > lldb::ThreadSP inferior; > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); > > if (pid <= 1) > { > @@ -952,7 +1083,7 @@ > } > > // Attach to the requested process. > - if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) > + if (PTRACE(PTRACE_ATTACH, pid, NULL, NULL) < 0) > { > args->m_error.SetErrorToErrno(); > goto FINISH; > @@ -968,6 +1099,8 @@ > // Update the process thread list with the attached thread and > // mark it as current. > inferior.reset(new LinuxThread(process, pid)); > + if (log) > + log->Printf ("ProcessMonitor::%s() adding tid = %i", __FUNCTION__, pid); > process.GetThreadList().AddThread(inferior); > process.GetThreadList().SetSelectedThreadByID(pid); > > @@ -987,6 +1120,7 @@ > ProcessMessage message; > ProcessMonitor *monitor = static_cast(callback_baton); > ProcessLinux *process = monitor->m_process; > + assert(process); > bool stop_monitoring; > siginfo_t info; > > @@ -1017,7 +1151,8 @@ > { > ProcessMessage message; > > - assert(info->si_signo == SIGTRAP && "Unexpected child signal!"); > + assert(monitor); > + assert(info && info->si_signo == SIGTRAP && "Unexpected child signal!"); > > switch (info->si_code) > { > Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp > =================================================================== > --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (revision 142029) > +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (working copy) > @@ -405,6 +405,7 @@ > return g_register_infos[reg].byte_offset; > } > > +#if 0 // These functions are currently not being used. > static unsigned GetRegSize(unsigned reg) > { > assert(reg < k_num_registers && "Invalid register number."); > @@ -420,6 +421,7 @@ > { > return (k_first_fpr <= reg && reg <= k_last_fpr); > } > +#endif > > RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread, > uint32_t concrete_frame_idx) > @@ -478,6 +480,26 @@ > return NULL; > } > > +unsigned > +RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(unsigned offset) > +{ > + unsigned reg; > + for (reg = 0; reg < k_num_registers; reg++) > + { > + if (g_register_infos[reg].byte_offset == offset) > + break; > + } > + assert(reg < k_num_registers && "Invalid register offset."); > + return reg; > +} > + > +const char * > +RegisterContextLinux_x86_64::GetRegisterName(unsigned reg) > +{ > + assert(reg < k_num_registers && "Invalid register offset."); > + return g_register_infos[reg].name; > +} > + > bool > RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, > RegisterValue &value) > Index: source/Plugins/Process/Linux/LinuxThread.cpp > =================================================================== > --- source/Plugins/Process/Linux/LinuxThread.cpp (revision 142029) > +++ source/Plugins/Process/Linux/LinuxThread.cpp (working copy) > @@ -13,14 +13,15 @@ > // C++ Includes > // Other libraries and framework includes > // Project includes > +#include "lldb/Core/Debugger.h" > #include "lldb/Host/Host.h" > #include "lldb/Target/Process.h" > #include "lldb/Target/StopInfo.h" > #include "lldb/Target/Target.h" > - > #include "LinuxStopInfo.h" > #include "LinuxThread.h" > #include "ProcessLinux.h" > +#include "ProcessLinuxLog.h" > #include "ProcessMonitor.h" > #include "RegisterContextLinux_i386.h" > #include "RegisterContextLinux_x86_64.h" > @@ -33,6 +34,9 @@ > : Thread(process, tid), > m_frame_ap(0) > { > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("LinuxThread::%s (tid = %i)", __FUNCTION__, tid); > } > > LinuxThread::~LinuxThread() > @@ -50,6 +54,14 @@ > void > LinuxThread::RefreshStateAfterStop() > { > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("LinuxThread::%s ()", __FUNCTION__); > + > + // Let all threads recover from stopping and do any clean up based > + // on the previous thread state (if any). > + ProcessLinux &process = static_cast(GetProcess()); > + process.GetThreadList().RefreshStateAfterStop(); > } > > const char * > @@ -91,13 +103,20 @@ > lldb::RegisterContextSP reg_ctx_sp; > uint32_t concrete_frame_idx = 0; > > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("LinuxThread::%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; > } > @@ -136,6 +155,10 @@ > ProcessMonitor &monitor = GetMonitor(); > bool status; > > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) > + log->Printf ("LinuxThread::%s ()", __FUNCTION__); > + > switch (resume_state) > { > default: > @@ -160,6 +183,10 @@ > void > LinuxThread::Notify(const ProcessMessage &message) > { > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log) > + log->Printf ("LinuxThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind()); > + > switch (message.GetKind()) > { > default: > @@ -196,14 +223,20 @@ > LinuxThread::BreakNotify(const ProcessMessage &message) > { > bool status; > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > > + assert(GetRegisterContextLinux()); > status = GetRegisterContextLinux()->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 ("LinuxThread::%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)); > > @@ -250,7 +283,68 @@ > > assert(message.GetKind() == ProcessMessage::eCrashMessage); > > + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); > + if (log) > + log->Printf ("LinuxThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason()); > + > m_stop_info = lldb::StopInfoSP(new LinuxCrashStopInfo( > *this, signo, message.GetCrashReason())); > SetResumeSignal(signo); > } > + > +unsigned > +LinuxThread::GetRegisterIndexFromOffset(unsigned offset) > +{ > + unsigned reg; > + ArchSpec arch = Host::GetArchitecture(); > + > + switch (arch.GetCore()) > + { > + default: > + assert(false && "CPU type not supported!"); > + break; > + > + case ArchSpec::eCore_x86_32_i386: > + case ArchSpec::eCore_x86_32_i486: > + case ArchSpec::eCore_x86_32_i486sx: > + reg = RegisterContextLinux_i386::GetRegisterIndexFromOffset(offset); > + break; > + > + case ArchSpec::eCore_x86_64_x86_64: > + reg = RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(offset); > + break; > + } > + return reg; > +} > + > +const char * > +LinuxThread::GetRegisterName(unsigned reg) > +{ > + const char * name; > + ArchSpec arch = Host::GetArchitecture(); > + > + switch (arch.GetCore()) > + { > + default: > + assert(false && "CPU type not supported!"); > + break; > + > + case ArchSpec::eCore_x86_32_i386: > + case ArchSpec::eCore_x86_32_i486: > + case ArchSpec::eCore_x86_32_i486sx: > + name = RegisterContextLinux_i386::GetRegisterName(reg); > + break; > + > + case ArchSpec::eCore_x86_64_x86_64: > + name = RegisterContextLinux_x86_64::GetRegisterName(reg); > + break; > + } > + return name; > +} > + > +const char * > +LinuxThread::GetRegisterNameFromOffset(unsigned offset) > +{ > + return GetRegisterName(GetRegisterIndexFromOffset(offset)); > +} > + > Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.h > =================================================================== > --- source/Plugins/Process/Linux/RegisterContextLinux_i386.h (revision 142029) > +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.h (working copy) > @@ -14,6 +14,7 @@ > // C++ Includes > // Other libraries and framework includes > // Project includes > +#include "lldb/Core/Log.h" > #include "RegisterContextLinux.h" > > class RegisterContextLinux_i386 : public RegisterContextLinux > @@ -42,6 +43,12 @@ > const lldb_private::RegisterSet * > GetRegisterSet(uint32_t set); > > + static unsigned > + GetRegisterIndexFromOffset(unsigned offset); > + > + static const char * > + GetRegisterName(unsigned reg); > + > #if 0 > bool > ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); > @@ -153,6 +160,8 @@ > > ProcessMonitor &GetMonitor(); > > + void LogGPR(const char *title); > + > bool ReadGPR(); > bool ReadFPR(); > }; > Index: source/Plugins/Process/Linux/ProcessMessage.h > =================================================================== > --- source/Plugins/Process/Linux/ProcessMessage.h (revision 142029) > +++ source/Plugins/Process/Linux/ProcessMessage.h (working copy) > @@ -140,6 +140,18 @@ > static const char * > GetCrashReasonString(CrashReason reason); > > + const char * > + PrintCrashReason() const; > + > + static const char * > + PrintCrashReason(CrashReason reason); > + > + const char * > + PrintKind() const; > + > + static const char * > + PrintKind(Kind); > + > private: > ProcessMessage(lldb::tid_t tid, Kind kind, > int status = 0, lldb::addr_t addr = 0) > Index: source/Plugins/Process/Linux/LinuxThread.h > =================================================================== > --- source/Plugins/Process/Linux/LinuxThread.h (revision 142029) > +++ source/Plugins/Process/Linux/LinuxThread.h (working copy) > @@ -48,6 +48,20 @@ > CreateRegisterContextForFrame (lldb_private::StackFrame *frame); > > //-------------------------------------------------------------------------- > + // These static functions provide a mapping from the register offset > + // back to the register index or name for use in debugging or log > + // output. > + > + static unsigned > + GetRegisterIndexFromOffset(unsigned offset); > + > + static const char * > + GetRegisterName(unsigned reg); > + > + static const char * > + GetRegisterNameFromOffset(unsigned offset); > + > + //-------------------------------------------------------------------------- > // These methods form a specialized interface to linux threads. > // > bool Resume(); > Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h > =================================================================== > --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (revision 142029) > +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (working copy) > @@ -41,6 +41,12 @@ > const lldb_private::RegisterSet * > GetRegisterSet(uint32_t set); > > + static unsigned > + GetRegisterIndexFromOffset(unsigned offset); > + > + static const char * > + GetRegisterName(unsigned reg); > + > virtual bool > ReadRegister(const lldb_private::RegisterInfo *reg_info, > lldb_private::RegisterValue &value); > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From jmolenda at apple.com Mon Oct 17 21:57:27 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 18 Oct 2011 02:57:27 -0000 Subject: [Lldb-commits] [lldb] r142331 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp RegisterContextLLDB.h Message-ID: <20111018025727.4623A2A6C12C@llvm.org> Author: jmolenda Date: Mon Oct 17 21:57:27 2011 New Revision: 142331 URL: http://llvm.org/viewvc/llvm-project?rev=142331&view=rev Log: Add code to RegisterContextLLDB::InitializeNonZerothFrame to detect a multiple stack frames with the same CFA (or an alternating sequence between two CFA values) to catch a handful of unwind cases where lldb will inf loop trying to unwind a stack. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=142331&r1=142330&r2=142331&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Oct 17 21:57:27 2011 @@ -448,6 +448,38 @@ return; } + // If we have a bad stack setup, we can get the same CFA value multiple times -- or even + // more devious, we can actually oscillate between two CFA values. Detect that here and + // break out to avoid a possible infinite loop in lldb trying to unwind the stack. + addr_t next_frame_cfa; + addr_t next_next_frame_cfa = LLDB_INVALID_ADDRESS; + if (m_next_frame.get() && m_next_frame->GetCFA(next_frame_cfa)) + { + bool repeating_frames = false; + if (next_frame_cfa == m_cfa) + { + repeating_frames = true; + } + else + { + if (m_next_frame->GetNextFrame() && m_next_frame->GetNextFrame()->GetCFA(next_next_frame_cfa) + && next_next_frame_cfa == m_cfa) + { + repeating_frames = true; + } + } + if (repeating_frames) + { + if (log) + { + log->Printf("%*sFrame %u same CFA address as next frame, assuming the unwind is looping - stopping", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); + } + m_frame_type = eNotAValidFrame; + return; + } + } + if (log) { log->Printf("%*sFrame %u initialized frame current pc is 0x%llx cfa is 0x%llx", @@ -1219,6 +1251,13 @@ return true; } + +RegisterContextLLDB::SharedPtr +RegisterContextLLDB::GetNextFrame () +{ + return m_next_frame; +} + // Retrieve the address of the start of the function of THIS frame bool Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=142331&r1=142330&r2=142331&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon Oct 17 21:57:27 2011 @@ -122,6 +122,9 @@ void InitializeNonZerothFrame(); + SharedPtr + GetNextFrame (); + // Provide a location for where THIS function saved the CALLER's register value // Or a frame "below" this one saved it, i.e. a function called by this one, preserved a register that this // function didn't modify/use. From scallanan at apple.com Tue Oct 18 11:46:55 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 18 Oct 2011 16:46:55 -0000 Subject: [Lldb-commits] [lldb] r142359 - in /lldb/trunk: include/lldb/Expression/ASTDumper.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ASTDumper.cpp source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111018164655.5449A3128034@llvm.org> Author: spyffe Date: Tue Oct 18 11:46:55 2011 New Revision: 142359 URL: http://llvm.org/viewvc/llvm-project?rev=142359&view=rev Log: Improved logging, replacing the old ASTDumper (which we never used) with a much simpler class that wraps the relevant dump functions in Clang. This class also knows to disable external lookups on DeclContexts being dumped so it should be safe to print incomplete Decls. Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ASTDumper.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTDumper.h?rev=142359&r1=142358&r2=142359&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTDumper.h (original) +++ lldb/trunk/include/lldb/Expression/ASTDumper.h Tue Oct 18 11:46:55 2011 @@ -16,156 +16,22 @@ namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class ASTDumper ASTDumper.h "lldb/Expression/ASTDumper.h" -/// @brief Encapsulates a recursive dumper for Clang AST nodes. -/// -/// ASTDumper contains a variety of methods for printing fields of Clang -/// AST structures, for debugging purposes. It prints the AST objects -/// hierarchically: -/// -/// --- -/// class : InheritedClass -/// someAccessor() : result -/// accessorReturningObject() : -/// class : ChildClass [object returned by accessorReturningObject] -/// ... -/// class : BaseClass [same object as InheritedClass] -/// baseAccessor() : result -/// -/// The output format is YAML. -//---------------------------------------------------------------------- -class ASTDumper : - public clang::DeclVisitor , - public clang::StmtVisitor , - public clang::TypeVisitor -{ -private: - ASTDumper (Stream &stream) : - m_stream(stream), - m_base_indentation(stream.GetIndentLevel()), - m_max_indentation(10) - { - } - - // MARK: Utility functions - - bool KeepDumping () - { - return (m_stream.GetIndentLevel() - m_base_indentation <= m_max_indentation); - } - - void PushIndent() - { - m_stream.IndentMore(1); - } - - void PopIndent() - { - m_stream.IndentLess(1); - } - - bool Visiting (const void *entity) - { - return m_visited_entities.count(entity); - } - - void WillVisit (const void *entity) - { - m_visited_entities.insert(entity); - } - - void DidVisit (const void *entity) - { - m_visited_entities.erase(entity); - } +class ASTDumper +{ public: - // MARK: DeclVisitor - - void VisitDecl (clang::Decl *decl); - void VisitTranslationUnitDecl (clang::TranslationUnitDecl *translation_unit_decl); - void VisitNamedDecl (clang::NamedDecl *named_decl); - void VisitNamespaceDecl (clang::NamespaceDecl *namespace_decl); - void VisitValueDecl (clang::ValueDecl *value_decl); - void VisitDeclaratorDecl (clang::DeclaratorDecl *declarator_decl); - void VisitVarDecl (clang::VarDecl *var_decl); - void VisitTypeDecl (clang::TypeDecl *type_decl); - void VisitTagDecl (clang::TagDecl *tag_decl); - void VisitRecordDecl (clang::RecordDecl *record_decl); - void VisitCXXRecordDecl (clang::CXXRecordDecl *cxx_record_decl); - - // MARK: StmtVisitor - - // MARK: TypeVisitor - - void VisitType (const clang::Type *type); - void VisitReferenceType (const clang::ReferenceType *reference_type); - void VisitLValueReferenceType (const clang::LValueReferenceType *lvalue_reference_type); - void VisitPointerType (const clang::PointerType *pointer_type); - void VisitTagType (const clang::TagType *tag_type); - void VisitRecordType (const clang::RecordType *record_type); - + ASTDumper (clang::Decl *decl); + ASTDumper (clang::DeclContext *decl_ctx); + ASTDumper (clang::Type *type); + ASTDumper (clang::QualType type); + ASTDumper (lldb::clang_type_t type); + + std::string AsString(); + void ToSTDERR(); + void ToLog(lldb::LogSP &log, const char *prefix); + void ToStream(lldb::StreamSP &stream); private: - llvm::DenseSet m_visited_entities; ///< A set of all entities that have already been printed, to prevent loops - Stream &m_stream; ///< A stream to print output to - unsigned m_base_indentation; ///< The indentation of m_stream when the ASTDumper was entered - unsigned m_max_indentation; ///< The maximum depth of indentation (added to m_base_indentation) -public: - //------------------------------------------------------------------ - /// DumpDecl - Create an ASTDumper and use it to dump a Decl. - /// - /// @param[in] stream - /// The stream to use when printing output. - /// - /// @param[in] decl - /// The AST Decl to print. - //------------------------------------------------------------------ - static void DumpDecl (Stream &stream, clang::Decl *decl) - { - ASTDumper dumper(stream); - - stream.Printf("---\n"); - - dumper.::clang::DeclVisitor::Visit(decl); - } - - //------------------------------------------------------------------ - /// DumpDecl - Create an ASTDumper and use it to dump a Stmt. - /// - /// @param[in] stream - /// The stream to use when printing output. - /// - /// @param[in] stmt - /// The AST Stmt to print. - //------------------------------------------------------------------ - static void DumpStmt (Stream &stream, clang::Stmt *stmt) - { - ASTDumper dumper(stream); - - stream.Printf("---\n"); - - dumper.::clang::StmtVisitor::Visit(stmt); - } - - //------------------------------------------------------------------ - /// DumpDecl - Create an ASTDumper and use it to dump a Type. - /// - /// @param[in] stream - /// The stream to use when printing output. - /// - /// @param[in] type - /// The AST Type to print. - //------------------------------------------------------------------ - static void DumpType (Stream &stream, clang::Type *type) - { - ASTDumper dumper(stream); - - stream.Printf("---\n"); - - dumper.::clang::TypeVisitor::Visit(type); - } + std::string m_dump; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=142359&r1=142358&r2=142359&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Oct 18 11:46:55 2011 @@ -1076,7 +1076,7 @@ AddOneType (NameSearchContext &context, TypeFromUser &type, unsigned int current_id, - bool add_method = false); + bool add_method); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing the struct. Modified: lldb/trunk/source/Expression/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTDumper.cpp?rev=142359&r1=142358&r2=142359&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTDumper.cpp (original) +++ lldb/trunk/source/Expression/ASTDumper.cpp Tue Oct 18 11:46:55 2011 @@ -7,538 +7,118 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Core/Log.h" #include "lldb/Expression/ASTDumper.h" -using namespace lldb_private; -using namespace clang; - -// MARK: Utility functions +#include "llvm/Support/raw_ostream.h" -static const char* SfB (bool b) -{ - return b ? "True" : "False"; -} - -// MARK: DeclVisitor +using namespace lldb_private; -void ASTDumper::VisitDecl (clang::Decl *decl) +ASTDumper::ASTDumper (clang::Decl *decl) { - m_stream.Indent(); m_stream.Printf("class : Decl\n"); - m_stream.Indent(); m_stream.Printf("getDeclKindName() : %s\n", decl->getDeclKindName()); - m_stream.Indent(); m_stream.Printf("getTranslationUnitDecl() : "); + clang::DeclContext *decl_ctx = llvm::dyn_cast(decl); - TranslationUnitDecl *translation_unit_decl = decl->getTranslationUnitDecl(); + bool has_external_lexical_storage; + bool has_external_visible_storage; - if (translation_unit_decl) - { - if (KeepDumping() && !Visiting(translation_unit_decl)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(translation_unit_decl); - VisitTranslationUnitDecl(translation_unit_decl); - DidVisit(translation_unit_decl); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - - m_stream.Indent(); m_stream.Printf("getAccess() : "); - switch (decl->getAccess()) - { - default: m_stream.Printf("~\n"); - case AS_public: m_stream.Printf("AS_public\n"); - case AS_protected: m_stream.Printf("AS_protected\n"); - case AS_private: m_stream.Printf("AS_private\n"); - case AS_none: m_stream.Printf("AS_none\n"); - } - m_stream.Indent(); m_stream.Printf("getMaxAlignment() : %d\n", decl->getMaxAlignment()); - m_stream.Indent(); m_stream.Printf("isInvalidDecl() : %s\n", SfB(decl->isInvalidDecl())); - m_stream.Indent(); m_stream.Printf("isImplicit() : %s\n", SfB(decl->isImplicit())); - m_stream.Indent(); m_stream.Printf("isUsed() : %s\n", SfB(decl->isUsed())); - m_stream.Indent(); m_stream.Printf("isOutOfLine() : %s\n", SfB(decl->isOutOfLine())); - m_stream.Indent(); m_stream.Printf("isCanonicalDecl() : %s\n", SfB(decl->isCanonicalDecl())); - m_stream.Indent(); m_stream.Printf("hasBody() : %s\n", SfB(decl->hasBody())); - m_stream.Indent(); m_stream.Printf("isTemplateParameter() : %s\n", SfB(decl->isTemplateParameter())); - m_stream.Indent(); m_stream.Printf("isTemplateParameterPack() : %s\n", SfB(decl->isTemplateParameterPack())); - m_stream.Indent(); m_stream.Printf("isParameterPack() : %s\n", SfB(decl->isParameterPack())); - m_stream.Indent(); m_stream.Printf("isFunctionOrFunctionTemplate() : %s\n", SfB(decl->isFunctionOrFunctionTemplate())); - m_stream.Indent(); m_stream.Printf("getFriendObjectKind() : "); - switch (decl->getFriendObjectKind()) + if (decl_ctx) { - default: m_stream.Printf("~\n"); break; - case Decl::FOK_None: m_stream.Printf("FOK_None\n"); break; - case Decl::FOK_Declared: m_stream.Printf("FOK_Declared\n"); break; - case Decl::FOK_Undeclared: m_stream.Printf("FOK_Undeclared\n"); break; + has_external_lexical_storage = decl_ctx->hasExternalLexicalStorage(); + has_external_visible_storage = decl_ctx->hasExternalVisibleStorage(); + decl_ctx->setHasExternalLexicalStorage(false); + decl_ctx->setHasExternalVisibleStorage(false); } -} - -void ASTDumper::VisitTranslationUnitDecl (clang::TranslationUnitDecl *translation_unit_decl) -{ - m_stream.Indent(); m_stream.Printf("class : TranslationUnitDecl\n"); - m_stream.Indent(); m_stream.Printf("getAnonymousNamespace() : "); - NamespaceDecl *anonymous_namespace = translation_unit_decl->getAnonymousNamespace(); + llvm::raw_string_ostream os(m_dump); + decl->print (os); + os.flush(); - if (anonymous_namespace) - { - if (KeepDumping() && !Visiting(anonymous_namespace)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(anonymous_namespace); - VisitNamespaceDecl(anonymous_namespace); - DidVisit(anonymous_namespace); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else + if (decl_ctx) { - m_stream.Printf("~\n"); + decl_ctx->setHasExternalLexicalStorage(has_external_lexical_storage); + decl_ctx->setHasExternalVisibleStorage(has_external_visible_storage); } - - VisitDecl (translation_unit_decl); } -void ASTDumper::VisitNamedDecl (clang::NamedDecl *named_decl) +ASTDumper::ASTDumper (clang::DeclContext *decl_ctx) { - m_stream.Indent(); m_stream.Printf("class : NamedDecl\n"); - m_stream.Indent(); m_stream.Printf("getNameAsString() : %s\n", named_decl->getNameAsString().c_str()); - m_stream.Indent(); m_stream.Printf("hasLinkage() : %s\n", SfB(named_decl->hasLinkage())); - m_stream.Indent(); m_stream.Printf("isCXXClassMember() : %s\n", SfB(named_decl->isCXXClassMember())); - m_stream.Indent(); m_stream.Printf("isCXXInstanceMember() : %s\n", SfB(named_decl->isCXXClassMember())); - m_stream.Indent(); m_stream.Printf("getVisibility() : "); - switch (named_decl->getVisibility()) - { - default: m_stream.Printf("~\n"); break; - case HiddenVisibility: m_stream.Printf("HiddenVisibility\n"); break; - case ProtectedVisibility: m_stream.Printf("ProtectedVisibility\n"); break; - case DefaultVisibility: m_stream.Printf("DefaultVisibility\n"); break; - } - m_stream.Indent(); m_stream.Printf("getUnderlyingDecl() : "); + bool has_external_lexical_storage = decl_ctx->hasExternalLexicalStorage(); + bool has_external_visible_storage = decl_ctx->hasExternalVisibleStorage(); - NamedDecl *underlying_decl = named_decl->getUnderlyingDecl(); + decl_ctx->setHasExternalLexicalStorage(false); + decl_ctx->setHasExternalVisibleStorage(false); - if (underlying_decl) + if (clang::Decl *decl = llvm::dyn_cast(decl_ctx)) { - if (KeepDumping() && !Visiting(underlying_decl)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(underlying_decl); - ::clang::DeclVisitor::Visit(underlying_decl); - DidVisit(underlying_decl); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } + llvm::raw_string_ostream os(m_dump); + decl->print (os); + os.flush(); } else { - m_stream.Printf("~\n"); + m_dump.assign(""); } - VisitDecl (named_decl); -} - -void ASTDumper::VisitNamespaceDecl (clang::NamespaceDecl *namespace_decl) -{ - m_stream.Indent(); m_stream.Printf("class : NamespaceDecl\n"); - m_stream.Indent(); m_stream.Printf("isAnonymousNamespace() : %s\n", SfB(namespace_decl->isAnonymousNamespace())); - m_stream.Indent(); m_stream.Printf("isInline() : %s\n", SfB(namespace_decl->isInline())); - m_stream.Indent(); m_stream.Printf("isOriginalNamespace() : %s\n", SfB(namespace_decl->isOriginalNamespace())); - - VisitNamedDecl (namespace_decl); + decl_ctx->setHasExternalLexicalStorage(has_external_lexical_storage); + decl_ctx->setHasExternalVisibleStorage(has_external_visible_storage); } -void ASTDumper::VisitValueDecl (clang::ValueDecl *value_decl) +ASTDumper::ASTDumper (clang::Type *type) { - m_stream.Indent(); m_stream.Printf("class : ValueDecl\n"); - m_stream.Indent(); m_stream.Printf("getType() : "); - if (value_decl->getType().getTypePtrOrNull()) - { - const clang::Type *type_ptr = value_decl->getType().getTypePtr(); - - if (KeepDumping() && !Visiting(type_ptr)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(type_ptr); - ::clang::TypeVisitor::Visit(type_ptr); - DidVisit(type_ptr); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - - VisitNamedDecl (value_decl); + m_dump = clang::QualType(type, 0).getAsString(); } -void ASTDumper::VisitDeclaratorDecl (clang::DeclaratorDecl *declarator_decl) +ASTDumper::ASTDumper (clang::QualType type) { - m_stream.Indent(); m_stream.Printf("class : DeclaratorDecl\n"); - VisitValueDecl (declarator_decl); + m_dump = type.getAsString(); } -void ASTDumper::VisitVarDecl (clang::VarDecl *var_decl) +ASTDumper::ASTDumper (lldb::clang_type_t type) { - m_stream.Indent(); m_stream.Printf("class : VarDecl\n"); - VisitDeclaratorDecl (var_decl); + m_dump = clang::QualType::getFromOpaquePtr(type).getAsString(); } - -void ASTDumper::VisitTypeDecl (clang::TypeDecl *type_decl) -{ - m_stream.Indent(); m_stream.Printf("class : TypeDecl\n"); - m_stream.Indent(); m_stream.Printf("getTypeForDecl() : "); - - const clang::Type *type_for_decl = type_decl->getTypeForDecl(); - - if (type_for_decl) - { - if (KeepDumping() && !Visiting(type_for_decl)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(type_for_decl); - ::clang::TypeVisitor::Visit(type_for_decl); - DidVisit(type_for_decl); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - VisitNamedDecl (type_decl); -} - -void ASTDumper::VisitTagDecl (clang::TagDecl *tag_decl) +std::string ASTDumper::AsString() { - m_stream.Indent(); m_stream.Printf("class : TagDecl\n"); - m_stream.Indent(); m_stream.Printf("getDefinition() : %s\n", SfB((bool)tag_decl->getDefinition())); - m_stream.Indent(); m_stream.Printf("isBeingDefined() : %s\n", SfB(tag_decl->isBeingDefined())); - m_stream.Indent(); m_stream.Printf("isEmbeddedInDeclarator() : %s\n", SfB(tag_decl->isEmbeddedInDeclarator())); - m_stream.Indent(); m_stream.Printf("isDependentType() : %s\n", SfB(tag_decl->isDependentType())); - m_stream.Indent(); m_stream.Printf("getDefinition() : "); - - TagDecl *definition = tag_decl->getDefinition(); - - if (definition) - { - if (KeepDumping() && !Visiting(definition)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(definition); - ::clang::DeclVisitor::Visit(tag_decl->getDefinition()); - DidVisit(definition); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - m_stream.Indent(); m_stream.Printf("getKindName() : %s\n", tag_decl->getKindName()); - - VisitTypeDecl(tag_decl); + return m_dump; } -void ASTDumper::VisitRecordDecl (clang::RecordDecl *record_decl) +void ASTDumper::ToSTDERR() { - m_stream.Indent(); m_stream.Printf("class : RecordDecl\n"); - m_stream.Indent(); m_stream.Printf("hasFlexibleArrayMember() : %s\n", SfB(record_decl->hasFlexibleArrayMember())); - m_stream.Indent(); m_stream.Printf("isAnonymousStructOrUnion() : %s\n", SfB(record_decl->isAnonymousStructOrUnion())); - m_stream.Indent(); m_stream.Printf("hasObjectMember() : %s\n", SfB(record_decl->hasObjectMember())); - m_stream.Indent(); m_stream.Printf("isInjectedClassName() : %s\n", SfB(record_decl->isInjectedClassName())); - m_stream.Indent(); m_stream.Printf("field_begin() ... field_end() : "); - if (KeepDumping()) - { - if (record_decl->field_empty()) - { - m_stream.Printf("~\n"); - } - else - { - m_stream.Printf("\n"); - PushIndent(); - for (RecordDecl::field_iterator iter = record_decl->field_begin(), end_iter = record_decl->field_end(); - iter != end_iter; - ++iter) - { - m_stream.Indent(); m_stream.Printf("- field:\n"); - PushIndent(); - if (Visiting (*iter)) - { - m_stream.Indent(); m_stream.Printf("capped\n"); - } - else - { - WillVisit(*iter); - ::clang::DeclVisitor::Visit(*iter); - DidVisit(*iter); - } - PopIndent(); - } - PopIndent(); - } - } - else - { - m_stream.Printf("capped\n"); - } - - VisitTagDecl (record_decl); + fprintf(stderr, "%s\n", m_dump.c_str()); } -void ASTDumper::VisitCXXRecordDecl (clang::CXXRecordDecl *cxx_record_decl) +void ASTDumper::ToLog(lldb::LogSP &log, const char *prefix) { - m_stream.Indent(); m_stream.Printf("class : CXXRecordDecl\n"); - m_stream.Indent(); m_stream.Printf("isDynamicClass() : %s\n", SfB(cxx_record_decl->isDynamicClass())); - m_stream.Indent(); m_stream.Printf("bases_begin() ... bases_end() : "); - if (KeepDumping()) - { - if (cxx_record_decl->bases_begin() == cxx_record_decl->bases_end()) - { - m_stream.Printf("~\n"); - } - else - { - m_stream.Printf("\n"); - PushIndent(); - for (CXXRecordDecl::base_class_iterator iter = cxx_record_decl->bases_begin(), end_iter = cxx_record_decl->bases_end(); - iter != end_iter; - ++iter) - { - m_stream.Indent(); m_stream.Printf("- CXXBaseSpecifier:\n"); - PushIndent(); - m_stream.Indent(); m_stream.Printf("isVirtual() : %s\n", SfB(iter->isVirtual())); - m_stream.Indent(); m_stream.Printf("isBaseOfClass() : %s\n", SfB(iter->isBaseOfClass())); - m_stream.Indent(); m_stream.Printf("isPackExpansion() : %s\n", SfB(iter->isPackExpansion())); - m_stream.Indent(); m_stream.Printf("getAccessSpecifier() : "); - switch (iter->getAccessSpecifier()) - { - default: m_stream.Printf("~\n"); break; - case clang::AS_none: m_stream.Printf("AS_none\n"); break; - case clang::AS_private: m_stream.Printf("AS_private\n"); break; - case clang::AS_protected: m_stream.Printf("AS_protected\n"); break; - case clang::AS_public: m_stream.Printf("AS_public\n"); break; - } - m_stream.Indent(); m_stream.Printf("getType() : "); - const clang::Type *base_type = iter->getType().getTypePtr(); - - if (Visiting(base_type)) - { - m_stream.Printf("capped\n"); - } - else - { - m_stream.Printf("\n"); - PushIndent(); - WillVisit(base_type); - ::clang::TypeVisitor::Visit(base_type); - DidVisit(base_type); - PopIndent(); - } - PopIndent(); - } - PopIndent(); - } - } - else - { - m_stream.Printf("capped\n"); - } + size_t len = m_dump.length() + 1; - VisitRecordDecl(cxx_record_decl); -} - -// MARK: TypeVisitor - -void ASTDumper::VisitType (const clang::Type *type) -{ - m_stream.Indent(); m_stream.Printf("class : Type\n"); - m_stream.Indent(); m_stream.Printf("getTypeClass() : "); - switch (type->getTypeClass()) - { - default: m_stream.Printf("~\n"); break; -#define TYPE(Class, Base) case clang::Type::Class: m_stream.Printf("%s\n", #Class); break; -#define ABSTRACT_TYPE(Class, Base) -#include "clang/AST/TypeNodes.def" - } - m_stream.Indent(); m_stream.Printf("isFromAST() : %s\n", SfB(type->isFromAST())); - m_stream.Indent(); m_stream.Printf("containsUnexpandedParameterPack() : %s\n", SfB(type->containsUnexpandedParameterPack())); - m_stream.Indent(); m_stream.Printf("isCanonicalUnqualified() : %s\n", SfB(type->isCanonicalUnqualified())); - m_stream.Indent(); m_stream.Printf("isIncompleteType() : %s\n", SfB(type->isIncompleteType())); - m_stream.Indent(); m_stream.Printf("isObjectType() : %s\n", SfB(type->isObjectType())); - m_stream.Indent(); m_stream.Printf("isLiteralType() : %s\n", SfB(type->isLiteralType())); - m_stream.Indent(); m_stream.Printf("isBuiltinType() : %s\n", SfB(type->isBuiltinType())); - m_stream.Indent(); m_stream.Printf("isPlaceholderType() : %s\n", SfB(type->isPlaceholderType())); - m_stream.Indent(); m_stream.Printf("isScalarType() : %s\n", SfB(type->isScalarType())); - m_stream.Indent(); m_stream.Printf("getScalarTypeKind() : "); - if (type->isScalarType()) - { - switch (type->getScalarTypeKind()) - { - default: m_stream.Printf("~\n"); break; - case clang::Type::STK_CPointer: m_stream.Printf("STK_CPointer\n"); break; - case clang::Type::STK_MemberPointer: m_stream.Printf("STK_MemberPointer\n"); break; - case clang::Type::STK_Bool: m_stream.Printf("STK_Bool\n"); break; - case clang::Type::STK_Integral: m_stream.Printf("STK_Integral\n"); break; - case clang::Type::STK_Floating: m_stream.Printf("STK_Floating\n"); break; - case clang::Type::STK_IntegralComplex: m_stream.Printf("STK_IntegralComplex\n"); break; - case clang::Type::STK_FloatingComplex: m_stream.Printf("STK_FloatingComplex\n"); break; - } - } - else - { - m_stream.Printf("~\n"); - } - // ... -} - -void ASTDumper::VisitReferenceType(const clang::ReferenceType *reference_type) -{ - m_stream.Indent(); m_stream.Printf("class : ReferenceType\n"); - m_stream.Indent(); m_stream.Printf("isSpelledAsLValue() : %s\n", SfB(reference_type->isSpelledAsLValue())); - m_stream.Indent(); m_stream.Printf("isInnerRef() : %s\n", SfB(reference_type->isInnerRef())); - m_stream.Indent(); m_stream.Printf("getPointeeType() : "); + char *alloc = (char*)malloc(len); + char *str = alloc; - const clang::Type *pointee_type = reference_type->getPointeeType().getTypePtrOrNull(); + memcpy(str, m_dump.c_str(), len); - if (pointee_type) - { - if (KeepDumping() && !Visiting(pointee_type)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(pointee_type); - ::clang::TypeVisitor::Visit(pointee_type); - DidVisit(pointee_type); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - VisitType(reference_type); -} - -void ASTDumper::VisitLValueReferenceType(const clang::LValueReferenceType *lvalue_reference_type) -{ - m_stream.Indent(); m_stream.Printf("class : LValueReferenceType\n"); - m_stream.Indent(); m_stream.Printf("isSugared() : %s\n", SfB(lvalue_reference_type->isSugared())); - VisitReferenceType(lvalue_reference_type); -} - -void ASTDumper::VisitPointerType(const clang::PointerType *pointer_type) -{ - m_stream.Indent(); m_stream.Printf("class : PointerType\n"); - m_stream.Indent(); m_stream.Printf("getPointeeType() : "); + char *end = NULL; - const clang::Type *pointee_type = pointer_type->getPointeeType().getTypePtrOrNull(); + end = strchr(str, '\n'); - if (pointee_type) - { - if (KeepDumping() && !Visiting(pointee_type)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(pointee_type); - ::clang::TypeVisitor::Visit(pointee_type); - DidVisit(pointee_type); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else + while (end) { - m_stream.Printf("~\n"); + *end = '\0'; + + log->Printf("%s%s", prefix, str); + + *end = '\n'; + + str = end + 1; + end = strchr(str, '\n'); } - m_stream.Indent(); m_stream.Printf("isSugared() : %s\n", SfB (pointer_type->isSugared())); - VisitType(pointer_type); -} - -void ASTDumper::VisitTagType(const clang::TagType *tag_type) -{ - m_stream.Indent(); m_stream.Printf("class : TagType\n"); - m_stream.Indent(); m_stream.Printf("getDecl() : "); - Decl *decl = tag_type->getDecl(); - - if (decl) - { - if (KeepDumping() && !Visiting(decl)) - { - m_stream.Printf("\n"); - - PushIndent(); - WillVisit(decl); - ::clang::DeclVisitor::Visit(decl); - DidVisit(decl); - PopIndent(); - } - else - { - m_stream.Printf("capped\n"); - } - } - else - { - m_stream.Printf("~\n"); - } - m_stream.Indent(); m_stream.Printf("isBeingDefined() : %s\n", SfB(tag_type->isBeingDefined())); - VisitType(tag_type); + log->Printf("%s%s", prefix, str); + + free(alloc); } -void ASTDumper::VisitRecordType(const clang::RecordType *record_type) +void ASTDumper::ToStream(lldb::StreamSP &stream) { - m_stream.Indent(); m_stream.Printf("class : RecordType\n"); - m_stream.Indent(); m_stream.Printf("hasConstFields() : %s\n", SfB(record_type->hasConstFields())); - VisitTagType(record_type); + stream->PutCString(m_dump.c_str()); } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142359&r1=142358&r2=142359&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Oct 18 11:46:55 2011 @@ -43,7 +43,6 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include "llvm/Support/raw_ostream.h" using namespace lldb; using namespace lldb_private; @@ -2181,13 +2180,11 @@ if (log) { - StreamString type_stream; - class_user_type.DumpTypeCode(&type_stream); - type_stream.Flush(); - log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, type_stream.GetString().c_str()); + std::string type_string = ASTDumper(pointer_target_qual_type).AsString(); + log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, type_string.c_str()); } - AddOneType(context, class_user_type, true); + AddOneType(context, class_user_type, current_id, true); return; } @@ -2234,13 +2231,11 @@ if (log) { - StreamString type_stream; - class_user_type.DumpTypeCode(&type_stream); - type_stream.Flush(); - log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, type_stream.GetString().c_str()); + std::string type_string = ASTDumper(pointer_target_type).AsString(); + log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, type_string.c_str()); } - AddOneType(context, class_user_type, false); + AddOneType(context, class_user_type, current_id, false); return; } @@ -2298,12 +2293,14 @@ if (m_parser_vars->m_exe_ctx->GetRegisterContext()) { const RegisterInfo *reg_info(m_parser_vars->m_exe_ctx->GetRegisterContext()->GetRegisterInfoByName(reg_name)); - - if (log) - log->Printf(" FEVD[%u] Found register %s", current_id, reg_info->name); - + if (reg_info) + { + if (log) + log->Printf(" FEVD[%u] Found register %s", current_id, reg_info->name); + AddOneRegister(context, reg_info, current_id); + } } } else @@ -2512,7 +2509,7 @@ TypeFromUser user_type(type_sp->GetClangFullType(), type_sp->GetClangAST()); - AddOneType(context, user_type, false); + AddOneType(context, user_type, current_id, false); } } @@ -2535,6 +2532,9 @@ static unsigned int invocation_id = 0; unsigned int current_id = invocation_id++; + if (current_id == 1686) + fprintf(stderr, "here\n"); + if (log) { if (const NamedDecl *context_named_decl = dyn_cast(context_decl)) @@ -2566,12 +2566,9 @@ return ELR_Failure; if (log) - { - std::string decl_print_string; - llvm::raw_string_ostream decl_print_stream(decl_print_string); - original_decl->print(decl_print_stream); - decl_print_stream.flush(); - log->Printf(" FELD[%u] Original decl:\n%s", current_id, decl_print_string.c_str()); + { + log->Printf(" FELD[%u] Original decl:", current_id); + ASTDumper(original_decl).ToLog(log, " "); } if (TagDecl *original_tag_decl = dyn_cast(original_decl)) @@ -2597,10 +2594,7 @@ { if (log) { - std::string decl_print_string; - llvm::raw_string_ostream decl_print_stream(decl_print_string); - decl->print(decl_print_stream); - decl_print_stream.flush(); + std::string decl_print_string = ASTDumper(decl).AsString(); if (const NamedDecl *context_named_decl = dyn_cast(context_decl)) log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), decl_print_string.c_str()); @@ -2785,19 +2779,9 @@ if (log) { - std::string var_decl_print_string; - llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); - var_decl->print(var_decl_print_stream); - var_decl_print_stream.flush(); + std::string var_decl_print_string = ASTDumper(var_decl).AsString(); log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), var_decl_print_string.c_str()); - - //if (log->GetVerbose()) - //{ - // StreamString var_decl_dump_string; - // ASTDumper::DumpDecl(var_decl_dump_string, var_decl); - // log->Printf("%s\n", var_decl_dump_string.GetData()); - //} } } @@ -2825,10 +2809,7 @@ if (log) { - std::string var_decl_print_string; - llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); - var_decl->print(var_decl_print_stream); - var_decl_print_stream.flush(); + std::string var_decl_print_string = ASTDumper(var_decl).AsString(); log->Printf(" FEVD[%u] Added pvar %s, returned %s", current_id, pvar_sp->GetName().GetCString(), var_decl_print_string.c_str()); } @@ -2887,19 +2868,9 @@ if (log) { - std::string var_decl_print_string; - llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); - var_decl->print(var_decl_print_stream); - var_decl_print_stream.flush(); + std::string var_decl_print_string = ASTDumper(var_decl).AsString(); log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), var_decl_print_string.c_str()); - - //if (log->GetVerbose()) - //{ - // StreamString var_decl_dump_string; - // ASTDumper::DumpDecl(var_decl_dump_string, var_decl); - // log->Printf("%s\n", var_decl_dump_string.GetData()); - //} } } @@ -2931,10 +2902,7 @@ if (log) { - std::string var_decl_print_string; - llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); - var_decl->print(var_decl_print_stream); - var_decl_print_stream.flush(); + std::string var_decl_print_string = ASTDumper((clang::Decl*)var_decl).AsString(); log->Printf("Variable of unknown type now has Decl %s", var_decl_print_string.c_str()); } @@ -2997,10 +2965,7 @@ if (log && log->GetVerbose()) { - std::string var_decl_print_string; - llvm::raw_string_ostream var_decl_print_stream(var_decl_print_string); - var_decl->print(var_decl_print_stream); - var_decl_print_stream.flush(); + std::string var_decl_print_string = ASTDumper(var_decl).AsString(); log->Printf(" FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), var_decl_print_string.c_str()); } @@ -3108,10 +3073,7 @@ if (log) { - std::string fun_decl_print_string; - llvm::raw_string_ostream fun_decl_print_stream(fun_decl_print_string); - fun_decl->print(fun_decl_print_stream); - fun_decl_print_stream.flush(); + std::string fun_decl_print_string = ASTDumper(fun_decl).AsString(); log->Printf(" FEVD[%u] Found %s function %s, returned %s", current_id, From scallanan at apple.com Tue Oct 18 12:45:25 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 18 Oct 2011 17:45:25 -0000 Subject: [Lldb-commits] [lldb] r142376 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111018174525.805223128034@llvm.org> Author: spyffe Date: Tue Oct 18 12:45:25 2011 New Revision: 142376 URL: http://llvm.org/viewvc/llvm-project?rev=142376&view=rev Log: Removed some debug support I accidentally committed. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142376&r1=142375&r2=142376&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Oct 18 12:45:25 2011 @@ -2532,9 +2532,6 @@ static unsigned int invocation_id = 0; unsigned int current_id = invocation_id++; - if (current_id == 1686) - fprintf(stderr, "here\n"); - if (log) { if (const NamedDecl *context_named_decl = dyn_cast(context_decl)) From johnny.chen at apple.com Tue Oct 18 13:09:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 18:09:30 -0000 Subject: [Lldb-commits] [lldb] r142384 - in /lldb/trunk/source/Plugins/Process/Linux: LinuxThread.cpp LinuxThread.h ProcessLinux.cpp ProcessLinux.h ProcessLinuxLog.cpp ProcessLinuxLog.h ProcessMessage.cpp ProcessMessage.h ProcessMonitor.cpp RegisterContextLinux_i386.cpp RegisterContextLinux_i386.h RegisterContextLinux_x86_64.cpp RegisterContextLinux_x86_64.h Message-ID: <20111018180931.159723128034@llvm.org> Author: johnny Date: Tue Oct 18 13:09:30 2011 New Revision: 142384 URL: http://llvm.org/viewvc/llvm-project?rev=142384&view=rev Log: This patch fixes debugging of single threaded apps on Linux. It also adds some asserts and additional logging support. from dawn at burble.org Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.h lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp Tue Oct 18 13:09:30 2011 @@ -13,14 +13,15 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" - #include "LinuxStopInfo.h" #include "LinuxThread.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" #include "RegisterContextLinux_i386.h" #include "RegisterContextLinux_x86_64.h" @@ -33,6 +34,9 @@ : Thread(process, tid), m_frame_ap(0) { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s (tid = %i)", __FUNCTION__, tid); } LinuxThread::~LinuxThread() @@ -50,6 +54,14 @@ void LinuxThread::RefreshStateAfterStop() { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s ()", __FUNCTION__); + + // Let all threads recover from stopping and do any clean up based + // on the previous thread state (if any). + ProcessLinux &process = static_cast(GetProcess()); + process.GetThreadList().RefreshStateAfterStop(); } const char * @@ -91,13 +103,20 @@ lldb::RegisterContextSP reg_ctx_sp; uint32_t concrete_frame_idx = 0; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%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; } @@ -136,6 +155,10 @@ ProcessMonitor &monitor = GetMonitor(); bool status; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("LinuxThread::%s ()", __FUNCTION__); + switch (resume_state) { default: @@ -160,6 +183,10 @@ void LinuxThread::Notify(const ProcessMessage &message) { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log) + log->Printf ("LinuxThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind()); + switch (message.GetKind()) { default: @@ -196,14 +223,20 @@ LinuxThread::BreakNotify(const ProcessMessage &message) { bool status; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + assert(GetRegisterContextLinux()); status = GetRegisterContextLinux()->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 ("LinuxThread::%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)); @@ -250,7 +283,68 @@ assert(message.GetKind() == ProcessMessage::eCrashMessage); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); + if (log) + log->Printf ("LinuxThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason()); + m_stop_info = lldb::StopInfoSP(new LinuxCrashStopInfo( *this, signo, message.GetCrashReason())); SetResumeSignal(signo); } + +unsigned +LinuxThread::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + ArchSpec arch = Host::GetArchitecture(); + + switch (arch.GetCore()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCore_x86_32_i386: + case ArchSpec::eCore_x86_32_i486: + case ArchSpec::eCore_x86_32_i486sx: + reg = RegisterContextLinux_i386::GetRegisterIndexFromOffset(offset); + break; + + case ArchSpec::eCore_x86_64_x86_64: + reg = RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(offset); + break; + } + return reg; +} + +const char * +LinuxThread::GetRegisterName(unsigned reg) +{ + const char * name; + ArchSpec arch = Host::GetArchitecture(); + + switch (arch.GetCore()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCore_x86_32_i386: + case ArchSpec::eCore_x86_32_i486: + case ArchSpec::eCore_x86_32_i486sx: + name = RegisterContextLinux_i386::GetRegisterName(reg); + break; + + case ArchSpec::eCore_x86_64_x86_64: + name = RegisterContextLinux_x86_64::GetRegisterName(reg); + break; + } + return name; +} + +const char * +LinuxThread::GetRegisterNameFromOffset(unsigned offset) +{ + return GetRegisterName(GetRegisterIndexFromOffset(offset)); +} + Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h Tue Oct 18 13:09:30 2011 @@ -48,6 +48,20 @@ CreateRegisterContextForFrame (lldb_private::StackFrame *frame); //-------------------------------------------------------------------------- + // These static functions provide a mapping from the register offset + // back to the register index or name for use in debugging or log + // output. + + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + + static const char * + GetRegisterNameFromOffset(unsigned offset); + + //-------------------------------------------------------------------------- // These methods form a specialized interface to linux threads. // bool Resume(); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Tue Oct 18 13:09:30 2011 @@ -119,7 +119,7 @@ LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessLinux::%s(pid = %i)", __FUNCTION__, GetID()); m_monitor = new ProcessMonitor(this, pid, error); @@ -328,6 +328,10 @@ void ProcessLinux::RefreshStateAfterStop() { + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("ProcessLinux::%s()", __FUNCTION__); + Mutex::Locker lock(m_message_mutex); if (m_message_queue.empty()) return; @@ -335,10 +339,15 @@ ProcessMessage &message = m_message_queue.front(); // Resolve the thread this message corresponds to and pass it along. + // FIXME: we're really dealing with the pid here. This should get + // fixed when this code is fixed to handle multiple threads. lldb::tid_t tid = message.GetTID(); + if (log) + log->Printf ("ProcessLinux::%s() pid = %i", __FUNCTION__, tid); LinuxThread *thread = static_cast( GetThreadList().FindThreadByID(tid, false).get()); + assert(thread); thread->Notify(message); m_message_queue.pop(); @@ -355,6 +364,7 @@ ProcessLinux::DoReadMemory(addr_t vm_addr, void *buf, size_t size, Error &error) { + assert(m_monitor); return m_monitor->ReadMemory(vm_addr, buf, size, error); } @@ -362,6 +372,7 @@ ProcessLinux::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, Error &error) { + assert(m_monitor); return m_monitor->WriteMemory(vm_addr, buf, size, error); } @@ -453,12 +464,22 @@ uint32_t ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) { - // FIXME: Should this be implemented? LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessLinux::%s() (pid = %i)", __FUNCTION__, GetID()); + + // Update the process thread list with this new thread. + // FIXME: We should be using tid, not pid. + assert(m_monitor); + ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false)); + if (!thread_sp) + thread_sp.reset(new LinuxThread(*this, GetID())); + + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) + log->Printf ("ProcessLinux::%s() updated pid = %i", __FUNCTION__, GetID()); + new_thread_list.AddThread(thread_sp); - return 0; + return new_thread_list.GetSize(false); } ByteOrder Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Tue Oct 18 13:09:30 2011 @@ -177,7 +177,8 @@ /// Registers the given message with this process. void SendMessage(const ProcessMessage &message); - ProcessMonitor &GetMonitor() { return *m_monitor; } + ProcessMonitor & + GetMonitor() { assert(m_monitor); return *m_monitor; } lldb_private::UnixSignals & GetUnixSignals(); Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.cpp Tue Oct 18 13:09:30 2011 @@ -69,6 +69,8 @@ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~LINUX_LOG_PROCESS; + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~LINUX_LOG_PTRACE; + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~LINUX_LOG_REGISTERS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~LINUX_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~LINUX_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~LINUX_LOG_VERBOSE; @@ -126,6 +128,8 @@ else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_SHORT; else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_LONG; else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= LINUX_LOG_PROCESS; + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= LINUX_LOG_PTRACE; + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= LINUX_LOG_REGISTERS; else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= LINUX_LOG_STEP; else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= LINUX_LOG_THREAD; else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= LINUX_LOG_VERBOSE; @@ -162,6 +166,10 @@ " data-short - log memory bytes for memory reads and writes for short transactions only\n" " data-long - log memory bytes for memory reads and writes for all transactions\n" " process - log process events and activities\n" +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION + " ptrace - log all calls to ptrace\n" +#endif + " registers - log register read/writes\n" " thread - log thread events and activities\n" " step - log step related activities\n" " verbose - enable verbose logging\n" @@ -181,3 +189,5 @@ va_end (args); } } + +int ProcessLinuxLog::m_nestinglevel; Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinuxLog.h Tue Oct 18 13:09:30 2011 @@ -29,11 +29,18 @@ #define LINUX_LOG_STEP (1u << 9) #define LINUX_LOG_COMM (1u << 10) #define LINUX_LOG_ASYNC (1u << 11) +#define LINUX_LOG_PTRACE (1u << 12) +#define LINUX_LOG_REGISTERS (1u << 13) #define LINUX_LOG_ALL (UINT32_MAX) #define LINUX_LOG_DEFAULT LINUX_LOG_PACKETS +// The size which determines "short memory reads/writes". +#define LINUX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t)) + class ProcessLinuxLog { + static int m_nestinglevel; + public: static lldb::LogSP GetLogIfAllCategoriesSet(uint32_t mask = 0); @@ -42,13 +49,50 @@ DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm); static lldb::LogSP - EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm); + EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, + lldb_private::Args &args, lldb_private::Stream *feedback_strm); static void ListLogCategories (lldb_private::Stream *strm); static void LogIf (uint32_t mask, const char *format, ...); + + // The following functions can be used to enable the client to limit + // logging to only the top level function calls. This is useful for + // recursive functions. FIXME: not thread safe! + // Example: + // void NestingFunc() { + // LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet(LINUX_LOG_ALL)); + // if (log) + // { + // ProcessLinuxLog::IncNestLevel(); + // if (ProcessLinuxLog::AtTopNestLevel()) + // log->Print(msg); + // } + // NestingFunc(); + // if (log) + // ProcessLinuxLog::DecNestLevel(); + // } + + static bool + AtTopNestLevel() + { + return m_nestinglevel == 1; + } + + static void + IncNestLevel() + { + ++m_nestinglevel; + } + + static void + DecNestLevel() + { + --m_nestinglevel; + assert(m_nestinglevel >= 0); + } }; #endif // liblldb_ProcessLinuxLog_h_ Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.cpp Tue Oct 18 13:09:30 2011 @@ -89,3 +89,157 @@ return str; } + +const char * +ProcessMessage::PrintCrashReason(CrashReason reason) +{ +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION + // Just return the code in asci for integration builds. + chcar str[8]; + sprintf(str, "%d", reason); +#else + const char *str = NULL; + + switch (reason) + { + default: + assert(false && "invalid CrashReason"); + break; + + case eInvalidCrashReason: + str = "eInvalidCrashReason"; + break; + + // SIGSEGV crash rcase easons. + case eInvalidAddress: + str = "eInvalidAddress"; + break; + case ePrivilegedAddress: + str = "ePrivilegedAddress"; + break; + + // SIGILL crash rcase easons. + case eIllegalOpcode: + str = "eIllegalOpcode"; + break; + case eIllegalOperand: + str = "eIllegalOperand"; + break; + case eIllegalAddressingMode: + str = "eIllegalAddressingMode"; + break; + case eIllegalTrap: + str = "eIllegalTrap"; + break; + case ePrivilegedOpcode: + str = "ePrivilegedOpcode"; + break; + case ePrivilegedRegister: + str = "ePrivilegedRegister"; + break; + case eCoprocessorError: + str = "eCoprocessorError"; + break; + case eInternalStackError: + str = "eInternalStackError"; + break; + + // SIGBUS crash rcase easons: + case eIllegalAlignment: + str = "eIllegalAlignment"; + break; + case eIllegalAddress: + str = "eIllegalAddress"; + break; + case eHardwareError: + str = "eHardwareError"; + break; + + // SIGFPE crash rcase easons: + case eIntegerDivideByZero: + str = "eIntegerDivideByZero"; + break; + case eIntegerOverflow: + str = "eIntegerOverflow"; + break; + case eFloatDivideByZero: + str = "eFloatDivideByZero"; + break; + case eFloatOverflow: + str = "eFloatOverflow"; + break; + case eFloatUnderflow: + str = "eFloatUnderflow"; + break; + case eFloatInexactResult: + str = "eFloatInexactResult"; + break; + case eFloatInvalidOperation: + str = "eFloatInvalidOperation"; + break; + case eFloatSubscriptRange: + str = "eFloatSubscriptRange"; + break; + } +#endif + + return str; +} + +const char * +ProcessMessage::PrintCrashReason() const +{ + return PrintCrashReason(m_crash_reason); +} + +const char * +ProcessMessage::PrintKind(Kind kind) +{ +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION + // Just return the code in asci for integration builds. + chcar str[8]; + sprintf(str, "%d", reason); +#else + const char *str = NULL; + + switch (kind) + { + default: + assert(false && "invalid Kind"); + break; + + case eInvalidMessage: + str = "eInvalidMessage"; + break; + case eExitMessage: + str = "eExitMessage"; + break; + case eLimboMessage: + str = "eLimboMessage"; + break; + case eSignalMessage: + str = "eSignalMessage"; + break; + case eSignalDeliveredMessage: + str = "eSignalDeliveredMessage"; + break; + case eTraceMessage: + str = "eTraceMessage"; + break; + case eBreakpointMessage: + str = "eBreakpointMessage"; + break; + case eCrashMessage: + str = "eCrashMessage"; + break; + } +#endif + + return str; +} + +const char * +ProcessMessage::PrintKind() const +{ + return PrintKind(m_kind); +} Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h Tue Oct 18 13:09:30 2011 @@ -140,6 +140,18 @@ static const char * GetCrashReasonString(CrashReason reason); + const char * + PrintCrashReason() const; + + static const char * + PrintCrashReason(CrashReason reason); + + const char * + PrintKind() const; + + static const char * + PrintKind(Kind); + private: ProcessMessage(lldb::tid_t tid, Kind kind, int status = 0, lldb::addr_t addr = 0) Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Oct 18 13:09:30 2011 @@ -19,6 +19,7 @@ // C++ Includes // Other libraries and framework includes +#include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/Scalar.h" @@ -29,11 +30,60 @@ #include "LinuxThread.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" using namespace lldb_private; +// FIXME: this code is host-dependent with respect to types and +// endianness and needs to be fixed. For example, lldb::addr_t is +// hard-coded to uint64_t, but on a 32-bit Linux host, ptrace requires +// 32-bit pointer arguments. This code uses casts to work around the +// problem. + +// We disable the tracing of ptrace calls for integration builds to +// avoid the additional indirection and checks. +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION + +// Wrapper for ptrace to catch errors and log calls. +extern long +PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, + const char* reqName, const char* file, int line) +{ + int result; + + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PTRACE)); + if (log) + log->Printf("ptrace(%s, %u, %p, %p) called from file %s line %d", + reqName, pid, addr, data, file, line); + + errno = 0; + result = ptrace(req, pid, addr, 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 = ""; + } + log->Printf("ptrace() failed; errno=%d (%s)", errno, str); + } + + return result; +} + +#define PTRACE(req, pid, addr, data) \ + PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__) +#else +#define PTRACE ptrace +#endif + //------------------------------------------------------------------------------ // Static implementations of ProcessMonitor::ReadMemory and // ProcessMonitor::WriteMemory. This enables mutual recursion between these @@ -48,25 +98,49 @@ size_t remainder; long data; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); + if (log) + ProcessLinuxLog::IncNestLevel(); + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, + pid, word_size, (void*)vm_addr, buf, size); + + assert(sizeof(data) >= word_size); + assert(sizeof(void*) == word_size); for (bytes_read = 0; bytes_read < size; bytes_read += remainder) { errno = 0; - data = ptrace(PTRACE_PEEKDATA, pid, vm_addr, NULL); - + data = PTRACE(PTRACE_PEEKDATA, pid, (void*)vm_addr, NULL); if (data == -1L && errno) { error.SetErrorToErrno(); + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_read; } remainder = size - bytes_read; remainder = remainder > word_size ? word_size : remainder; + + // Copy the data into our buffer + if (log) + memset(dst, 0, sizeof(dst)); for (unsigned i = 0; i < remainder; ++i) dst[i] = ((data >> i*8) & 0xFF); + + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)dst, (unsigned long)data); + vm_addr += word_size; dst += word_size; } + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_read; } @@ -78,6 +152,14 @@ size_t bytes_written = 0; size_t remainder; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); + if (log) + ProcessLinuxLog::IncNestLevel(); + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, + pid, word_size, (void*)vm_addr, buf, size); + + assert(sizeof(void*) == word_size); for (bytes_written = 0; bytes_written < size; bytes_written += remainder) { remainder = size - bytes_written; @@ -86,12 +168,22 @@ if (remainder == word_size) { unsigned long data = 0; + assert(sizeof(data) >= word_size); for (unsigned i = 0; i < word_size; ++i) data |= (unsigned long)src[i] << i*8; - if (ptrace(PTRACE_POKEDATA, pid, vm_addr, data)) + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)src, data); + + if (PTRACE(PTRACE_POKEDATA, pid, (void*)vm_addr, (void*)data)) { error.SetErrorToErrno(); + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; } } @@ -100,18 +192,35 @@ unsigned char buff[8]; if (DoReadMemory(pid, word_size, vm_addr, buff, word_size, error) != word_size) + { + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; + } memcpy(buff, src, remainder); if (DoWriteMemory(pid, word_size, vm_addr, buff, word_size, error) != word_size) + { + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; + } + + if (log && ProcessLinuxLog::AtTopNestLevel() && + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, + (void*)vm_addr, *(unsigned long*)src, *(unsigned long*)buff); } vm_addr += word_size; src += word_size; } + if (log) + ProcessLinuxLog::DecNestLevel(); return bytes_written; } @@ -216,6 +325,7 @@ m_result = DoWriteMemory(pid, word_size, m_addr, m_buff, m_size, m_error); } + //------------------------------------------------------------------------------ /// @class ReadRegOperation /// @brief Implements ProcessMonitor::ReadRegisterValue. @@ -238,11 +348,11 @@ ReadRegOperation::Execute(ProcessMonitor *monitor) { lldb::pid_t pid = monitor->GetPID(); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); // Set errno to zero so that we can detect a failed peek. errno = 0; - uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); - + uint32_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); if (data == -1UL && errno) m_result = false; else @@ -250,6 +360,9 @@ m_value = data; m_result = true; } + if (log) + log->Printf ("ProcessMonitor::%s() reg %s: 0x%x", __FUNCTION__, + LinuxThread::GetRegisterNameFromOffset(m_offset), data); } //------------------------------------------------------------------------------ @@ -273,9 +386,22 @@ void WriteRegOperation::Execute(ProcessMonitor *monitor) { + void* buf; lldb::pid_t pid = monitor->GetPID(); + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) + if (sizeof(void*) == sizeof(uint64_t)) + buf = (void*) m_value.GetAsUInt64(); + else + { + assert(sizeof(void*) == sizeof(uint32_t)); + buf = (void*) m_value.GetAsUInt32(); + } + + if (log) + log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, + LinuxThread::GetRegisterNameFromOffset(m_offset), buf); + if (PTRACE(PTRACE_POKEUSER, pid, (void*)m_offset, buf)) m_result = false; else m_result = true; @@ -301,7 +427,7 @@ void ReadGPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -327,7 +453,7 @@ void ReadFPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -353,7 +479,7 @@ void WriteGPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -379,7 +505,7 @@ void WriteFPROperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) + if (PTRACE(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) m_result = false; else m_result = true; @@ -410,7 +536,7 @@ if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) data = m_signo; - if (ptrace(PTRACE_CONT, m_tid, NULL, data)) + if (PTRACE(PTRACE_CONT, m_tid, NULL, (void*)data)) m_result = false; else m_result = true; @@ -441,7 +567,7 @@ if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) data = m_signo; - if (ptrace(PTRACE_SINGLESTEP, m_tid, NULL, data)) + if (PTRACE(PTRACE_SINGLESTEP, m_tid, NULL, (void*)data)) m_result = false; else m_result = true; @@ -467,7 +593,7 @@ void SiginfoOperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) + if (PTRACE(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) m_result = false; else m_result = true; @@ -493,7 +619,7 @@ void EventMessageOperation::Execute(ProcessMonitor *monitor) { - if (ptrace(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) + if (PTRACE(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) m_result = false; else m_result = true; @@ -518,7 +644,7 @@ { lldb::pid_t pid = monitor->GetPID(); - if (ptrace(PTRACE_KILL, pid, NULL, NULL)) + if (PTRACE(PTRACE_KILL, pid, NULL, NULL)) m_result = false; else m_result = true; @@ -756,6 +882,7 @@ lldb::pid_t pid; lldb::ThreadSP inferior; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); // Propagate the environment if one is not supplied. if (envp == NULL || envp[0] == NULL) @@ -789,7 +916,7 @@ if (pid == 0) { // Trace this process. - if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) + if (PTRACE(PTRACE_TRACEME, 0, NULL, NULL) < 0) exit(ePtraceFailed); // Do not inherit setgid powers. @@ -861,7 +988,7 @@ // Have the child raise an event on exit. This is used to keep the child in // limbo until it is destroyed. - if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT) < 0) + if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)PTRACE_O_TRACEEXIT) < 0) { args->m_error.SetErrorToErrno(); goto FINISH; @@ -880,9 +1007,12 @@ // Update the process thread list with this new thread and mark it as // current. + // FIXME: should we be letting UpdateThreadList handle this? + // FIXME: by using pids instead of tids, we can only support one thread. inferior.reset(new LinuxThread(process, pid)); + if (log) + log->Printf ("ProcessMonitor::%s() adding pid = %i", __FUNCTION__, pid); process.GetThreadList().AddThread(inferior); - process.GetThreadList().SetSelectedThreadByID(pid); // Let our process instance know the thread has stopped. process.SendMessage(ProcessMessage::Trace(pid)); @@ -943,6 +1073,7 @@ ProcessLinux &process = monitor->GetProcess(); lldb::ThreadSP inferior; + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); if (pid <= 1) { @@ -952,7 +1083,7 @@ } // Attach to the requested process. - if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) + if (PTRACE(PTRACE_ATTACH, pid, NULL, NULL) < 0) { args->m_error.SetErrorToErrno(); goto FINISH; @@ -968,6 +1099,8 @@ // Update the process thread list with the attached thread and // mark it as current. inferior.reset(new LinuxThread(process, pid)); + if (log) + log->Printf ("ProcessMonitor::%s() adding tid = %i", __FUNCTION__, pid); process.GetThreadList().AddThread(inferior); process.GetThreadList().SetSelectedThreadByID(pid); @@ -987,6 +1120,7 @@ ProcessMessage message; ProcessMonitor *monitor = static_cast(callback_baton); ProcessLinux *process = monitor->m_process; + assert(process); bool stop_monitoring; siginfo_t info; @@ -1017,7 +1151,8 @@ { ProcessMessage message; - assert(info->si_signo == SIGTRAP && "Unexpected child signal!"); + assert(monitor); + assert(info && info->si_signo == SIGTRAP && "Unexpected child signal!"); switch (info->si_code) { Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp Tue Oct 18 13:09:30 2011 @@ -12,6 +12,7 @@ #include "lldb/Host/Endian.h" #include "ProcessLinux.h" +#include "ProcessLinuxLog.h" #include "ProcessMonitor.h" #include "RegisterContextLinux_i386.h" @@ -31,7 +32,6 @@ gpr_esp, gpr_ss, gpr_eflags, - gpr_orig_ax, gpr_eip, gpr_cs, gpr_ds, @@ -189,7 +189,6 @@ gpr_esp, gpr_ss, gpr_eflags, - gpr_orig_ax, gpr_eip, gpr_cs, gpr_ds, @@ -330,12 +329,17 @@ }; +#ifndef NDEBUG +static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); +#endif + static unsigned GetRegOffset(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); return g_register_infos[reg].byte_offset; } +#if 0 // These functions are currently not in use. static unsigned GetRegSize(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); @@ -351,6 +355,7 @@ { return (k_first_fpr <= reg && reg <= k_last_fpr); } +#endif RegisterContextLinux_i386::RegisterContextLinux_i386(Thread &thread, @@ -383,12 +388,14 @@ size_t RegisterContextLinux_i386::GetRegisterCount() { + assert(k_num_register_infos == k_num_registers); return k_num_registers; } const RegisterInfo * RegisterContextLinux_i386::GetRegisterInfoAtIndex(uint32_t reg) { + assert(k_num_register_infos == k_num_registers); if (reg < k_num_registers) return &g_register_infos[reg]; else @@ -410,6 +417,26 @@ return NULL; } +unsigned +RegisterContextLinux_i386::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + for (reg = 0; reg < k_num_registers; reg++) + { + if (g_register_infos[reg].byte_offset == offset) + break; + } + assert(reg < k_num_registers && "Invalid register offset."); + return reg; +} + +const char * +RegisterContextLinux_i386::GetRegisterName(unsigned reg) +{ + assert(reg < k_num_registers && "Invalid register offset."); + return g_register_infos[reg].name; +} + bool RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) @@ -588,11 +615,31 @@ return WriteRegisterFromUnsigned(gpr_eflags, eflags); } +void +RegisterContextLinux_i386::LogGPR(const char *title) +{ + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); + if (log) + { + if (title) + log->Printf ("%s", title); + for (uint32_t i=0; iPrintf("%12s = 0x%8.8x", g_register_infos[reg].name, (&user.regs)[reg]); + } + } +} + bool RegisterContextLinux_i386::ReadGPR() { - ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadGPR(&user.regs); + bool result; + + ProcessMonitor &monitor = GetMonitor(); + result = monitor.ReadGPR(&user.regs); + LogGPR("RegisterContextLinux_i386::ReadGPR()"); + return result; } bool Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.h Tue Oct 18 13:09:30 2011 @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Log.h" #include "RegisterContextLinux.h" class RegisterContextLinux_i386 : public RegisterContextLinux @@ -42,6 +43,12 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + #if 0 bool ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); @@ -153,6 +160,8 @@ ProcessMonitor &GetMonitor(); + void LogGPR(const char *title); + bool ReadGPR(); bool ReadFPR(); }; Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Tue Oct 18 13:09:30 2011 @@ -405,6 +405,7 @@ return g_register_infos[reg].byte_offset; } +#if 0 // These functions are currently not being used. static unsigned GetRegSize(unsigned reg) { assert(reg < k_num_registers && "Invalid register number."); @@ -420,6 +421,7 @@ { return (k_first_fpr <= reg && reg <= k_last_fpr); } +#endif RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread, uint32_t concrete_frame_idx) @@ -478,6 +480,26 @@ return NULL; } +unsigned +RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(unsigned offset) +{ + unsigned reg; + for (reg = 0; reg < k_num_registers; reg++) + { + if (g_register_infos[reg].byte_offset == offset) + break; + } + assert(reg < k_num_registers && "Invalid register offset."); + return reg; +} + +const char * +RegisterContextLinux_x86_64::GetRegisterName(unsigned reg) +{ + assert(reg < k_num_registers && "Invalid register offset."); + return g_register_infos[reg].name; +} + bool RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h?rev=142384&r1=142383&r2=142384&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Tue Oct 18 13:09:30 2011 @@ -41,6 +41,12 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); + static unsigned + GetRegisterIndexFromOffset(unsigned offset); + + static const char * + GetRegisterName(unsigned reg); + virtual bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); From johnny.chen at apple.com Tue Oct 18 13:13:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 11:13:03 -0700 Subject: [Lldb-commits] [PATCH] fixes for Linux In-Reply-To: <20111018024600.GA23486@bloodbath.burble.org> References: <20111015025853.GA24361@bloodbath.burble.org> <20111017173609.GA13868@bloodbath.burble.org> <20111018024600.GA23486@bloodbath.burble.org> Message-ID: Checked in r142384. Thanks! On Oct 17, 2011, at 7:46 PM, dawn at burble.org wrote: > Just in case you missed it, this patch (attached in previous email) is > still awaiting review. Please review and commit if acceptable. > > Thanks again! > -Dawn > > On Mon, Oct 17, 2011 at 10:36:09AM -0700, dawn at burble.org wrote: >> Seems I forgot the patch? Doh! >> >> On Fri, Oct 14, 2011 at 07:58:53PM -0700, dawn at burble.org wrote: >>> This patch fixes debugging of single threaded apps on Linux. >>> It also adds some asserts and additional logging support. >>> >>> Thanks in advance, >>> -Dawn >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > >> Index: source/Plugins/Process/Linux/ProcessLinux.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) >> @@ -119,7 +119,7 @@ >> >> LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); >> if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); >> + log->Printf ("ProcessLinux::%s(pid = %i)", __FUNCTION__, GetID()); >> >> m_monitor = new ProcessMonitor(this, pid, error); >> >> @@ -328,6 +328,10 @@ >> void >> ProcessLinux::RefreshStateAfterStop() >> { >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("ProcessLinux::%s()", __FUNCTION__); >> + >> Mutex::Locker lock(m_message_mutex); >> if (m_message_queue.empty()) >> return; >> @@ -335,10 +339,15 @@ >> ProcessMessage &message = m_message_queue.front(); >> >> // Resolve the thread this message corresponds to and pass it along. >> + // FIXME: we're really dealing with the pid here. This should get >> + // fixed when this code is fixed to handle multiple threads. >> lldb::tid_t tid = message.GetTID(); >> + if (log) >> + log->Printf ("ProcessLinux::%s() pid = %i", __FUNCTION__, tid); >> LinuxThread *thread = static_cast( >> GetThreadList().FindThreadByID(tid, false).get()); >> >> + assert(thread); >> thread->Notify(message); >> >> m_message_queue.pop(); >> @@ -355,6 +364,7 @@ >> ProcessLinux::DoReadMemory(addr_t vm_addr, >> void *buf, size_t size, Error &error) >> { >> + assert(m_monitor); >> return m_monitor->ReadMemory(vm_addr, buf, size, error); >> } >> >> @@ -362,6 +372,7 @@ >> ProcessLinux::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, >> Error &error) >> { >> + assert(m_monitor); >> return m_monitor->WriteMemory(vm_addr, buf, size, error); >> } >> >> @@ -453,12 +464,22 @@ >> uint32_t >> ProcessLinux::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) >> { >> - // FIXME: Should this be implemented? >> LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> - log->Printf ("ProcessLinux::%s (pid = %i)", __FUNCTION__, GetID()); >> + log->Printf ("ProcessLinux::%s() (pid = %i)", __FUNCTION__, GetID()); >> >> - return 0; >> + // Update the process thread list with this new thread. >> + // FIXME: We should be using tid, not pid. >> + assert(m_monitor); >> + ThreadSP thread_sp (old_thread_list.FindThreadByID (GetID(), false)); >> + if (!thread_sp) >> + thread_sp.reset(new LinuxThread(*this, GetID())); >> + >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("ProcessLinux::%s() updated pid = %i", __FUNCTION__, GetID()); >> + new_thread_list.AddThread(thread_sp); >> + >> + return new_thread_list.GetSize(false); >> } >> >> ByteOrder >> Index: source/Plugins/Process/Linux/ProcessLinuxLog.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessLinuxLog.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessLinuxLog.cpp (working copy) >> @@ -69,6 +69,8 @@ >> else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_SHORT; >> else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits &= ~LINUX_LOG_MEMORY_DATA_LONG; >> else if (::strcasecmp (arg, "process") == 0 ) flag_bits &= ~LINUX_LOG_PROCESS; >> + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits &= ~LINUX_LOG_PTRACE; >> + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits &= ~LINUX_LOG_REGISTERS; >> else if (::strcasecmp (arg, "step") == 0 ) flag_bits &= ~LINUX_LOG_STEP; >> else if (::strcasecmp (arg, "thread") == 0 ) flag_bits &= ~LINUX_LOG_THREAD; >> else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits &= ~LINUX_LOG_VERBOSE; >> @@ -126,6 +128,8 @@ >> else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_SHORT; >> else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= LINUX_LOG_MEMORY_DATA_LONG; >> else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= LINUX_LOG_PROCESS; >> + else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= LINUX_LOG_PTRACE; >> + else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= LINUX_LOG_REGISTERS; >> else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= LINUX_LOG_STEP; >> else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= LINUX_LOG_THREAD; >> else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= LINUX_LOG_VERBOSE; >> @@ -162,6 +166,10 @@ >> " data-short - log memory bytes for memory reads and writes for short transactions only\n" >> " data-long - log memory bytes for memory reads and writes for all transactions\n" >> " process - log process events and activities\n" >> +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION >> + " ptrace - log all calls to ptrace\n" >> +#endif >> + " registers - log register read/writes\n" >> " thread - log thread events and activities\n" >> " step - log step related activities\n" >> " verbose - enable verbose logging\n" >> @@ -181,3 +189,5 @@ >> va_end (args); >> } >> } >> + >> +int ProcessLinuxLog::m_nestinglevel; >> Index: source/Plugins/Process/Linux/ProcessLinux.h >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessLinux.h (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessLinux.h (working copy) >> @@ -177,7 +177,8 @@ >> /// Registers the given message with this process. >> void SendMessage(const ProcessMessage &message); >> >> - ProcessMonitor &GetMonitor() { return *m_monitor; } >> + ProcessMonitor & >> + GetMonitor() { assert(m_monitor); return *m_monitor; } >> >> lldb_private::UnixSignals & >> GetUnixSignals(); >> Index: source/Plugins/Process/Linux/ProcessLinuxLog.h >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessLinuxLog.h (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessLinuxLog.h (working copy) >> @@ -29,11 +29,18 @@ >> #define LINUX_LOG_STEP (1u << 9) >> #define LINUX_LOG_COMM (1u << 10) >> #define LINUX_LOG_ASYNC (1u << 11) >> +#define LINUX_LOG_PTRACE (1u << 12) >> +#define LINUX_LOG_REGISTERS (1u << 13) >> #define LINUX_LOG_ALL (UINT32_MAX) >> #define LINUX_LOG_DEFAULT LINUX_LOG_PACKETS >> >> +// The size which determines "short memory reads/writes". >> +#define LINUX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t)) >> + >> class ProcessLinuxLog >> { >> + static int m_nestinglevel; >> + >> public: >> static lldb::LogSP >> GetLogIfAllCategoriesSet(uint32_t mask = 0); >> @@ -42,13 +49,50 @@ >> DisableLog (lldb_private::Args &args, lldb_private::Stream *feedback_strm); >> >> static lldb::LogSP >> - EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, lldb_private::Args &args, lldb_private::Stream *feedback_strm); >> + EnableLog (lldb::StreamSP &log_stream_sp, uint32_t log_options, >> + lldb_private::Args &args, lldb_private::Stream *feedback_strm); >> >> static void >> ListLogCategories (lldb_private::Stream *strm); >> >> static void >> LogIf (uint32_t mask, const char *format, ...); >> + >> + // The following functions can be used to enable the client to limit >> + // logging to only the top level function calls. This is useful for >> + // recursive functions. FIXME: not thread safe! >> + // Example: >> + // void NestingFunc() { >> + // LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet(LINUX_LOG_ALL)); >> + // if (log) >> + // { >> + // ProcessLinuxLog::IncNestLevel(); >> + // if (ProcessLinuxLog::AtTopNestLevel()) >> + // log->Print(msg); >> + // } >> + // NestingFunc(); >> + // if (log) >> + // ProcessLinuxLog::DecNestLevel(); >> + // } >> + >> + static bool >> + AtTopNestLevel() >> + { >> + return m_nestinglevel == 1; >> + } >> + >> + static void >> + IncNestLevel() >> + { >> + ++m_nestinglevel; >> + } >> + >> + static void >> + DecNestLevel() >> + { >> + --m_nestinglevel; >> + assert(m_nestinglevel >= 0); >> + } >> }; >> >> #endif // liblldb_ProcessLinuxLog_h_ >> Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (working copy) >> @@ -12,6 +12,7 @@ >> #include "lldb/Host/Endian.h" >> >> #include "ProcessLinux.h" >> +#include "ProcessLinuxLog.h" >> #include "ProcessMonitor.h" >> #include "RegisterContextLinux_i386.h" >> >> @@ -31,7 +32,6 @@ >> gpr_esp, >> gpr_ss, >> gpr_eflags, >> - gpr_orig_ax, >> gpr_eip, >> gpr_cs, >> gpr_ds, >> @@ -189,7 +189,6 @@ >> gpr_esp, >> gpr_ss, >> gpr_eflags, >> - gpr_orig_ax, >> gpr_eip, >> gpr_cs, >> gpr_ds, >> @@ -330,12 +329,17 @@ >> >> }; >> >> +#ifndef NDEBUG >> +static size_t k_num_register_infos = (sizeof(g_register_infos)/sizeof(RegisterInfo)); >> +#endif >> + >> static unsigned GetRegOffset(unsigned reg) >> { >> assert(reg < k_num_registers && "Invalid register number."); >> return g_register_infos[reg].byte_offset; >> } >> >> +#if 0 // These functions are currently not in use. >> static unsigned GetRegSize(unsigned reg) >> { >> assert(reg < k_num_registers && "Invalid register number."); >> @@ -351,6 +355,7 @@ >> { >> return (k_first_fpr <= reg && reg <= k_last_fpr); >> } >> +#endif >> >> >> RegisterContextLinux_i386::RegisterContextLinux_i386(Thread &thread, >> @@ -383,12 +388,14 @@ >> size_t >> RegisterContextLinux_i386::GetRegisterCount() >> { >> + assert(k_num_register_infos == k_num_registers); >> return k_num_registers; >> } >> >> const RegisterInfo * >> RegisterContextLinux_i386::GetRegisterInfoAtIndex(uint32_t reg) >> { >> + assert(k_num_register_infos == k_num_registers); >> if (reg < k_num_registers) >> return &g_register_infos[reg]; >> else >> @@ -410,6 +417,26 @@ >> return NULL; >> } >> >> +unsigned >> +RegisterContextLinux_i386::GetRegisterIndexFromOffset(unsigned offset) >> +{ >> + unsigned reg; >> + for (reg = 0; reg < k_num_registers; reg++) >> + { >> + if (g_register_infos[reg].byte_offset == offset) >> + break; >> + } >> + assert(reg < k_num_registers && "Invalid register offset."); >> + return reg; >> +} >> + >> +const char * >> +RegisterContextLinux_i386::GetRegisterName(unsigned reg) >> +{ >> + assert(reg < k_num_registers && "Invalid register offset."); >> + return g_register_infos[reg].name; >> +} >> + >> bool >> RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, >> RegisterValue &value) >> @@ -588,11 +615,31 @@ >> return WriteRegisterFromUnsigned(gpr_eflags, eflags); >> } >> >> +void >> +RegisterContextLinux_i386::LogGPR(const char *title) >> +{ >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); >> + if (log) >> + { >> + if (title) >> + log->Printf ("%s", title); >> + for (uint32_t i=0; i> + { >> + uint32_t reg = gpr_eax + i; >> + log->Printf("%12s = 0x%8.8x", g_register_infos[reg].name, (&user.regs)[reg]); >> + } >> + } >> +} >> + >> bool >> RegisterContextLinux_i386::ReadGPR() >> { >> - ProcessMonitor &monitor = GetMonitor(); >> - return monitor.ReadGPR(&user.regs); >> + bool result; >> + >> + ProcessMonitor &monitor = GetMonitor(); >> + result = monitor.ReadGPR(&user.regs); >> + LogGPR("RegisterContextLinux_i386::ReadGPR()"); >> + return result; >> } >> >> bool >> Index: source/Plugins/Process/Linux/ProcessMessage.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessMessage.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessMessage.cpp (working copy) >> @@ -89,3 +89,157 @@ >> >> return str; >> } >> + >> +const char * >> +ProcessMessage::PrintCrashReason(CrashReason reason) >> +{ >> +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION >> + // Just return the code in asci for integration builds. >> + chcar str[8]; >> + sprintf(str, "%d", reason); >> +#else >> + const char *str = NULL; >> + >> + switch (reason) >> + { >> + default: >> + assert(false && "invalid CrashReason"); >> + break; >> + >> + case eInvalidCrashReason: >> + str = "eInvalidCrashReason"; >> + break; >> + >> + // SIGSEGV crash rcase easons. >> + case eInvalidAddress: >> + str = "eInvalidAddress"; >> + break; >> + case ePrivilegedAddress: >> + str = "ePrivilegedAddress"; >> + break; >> + >> + // SIGILL crash rcase easons. >> + case eIllegalOpcode: >> + str = "eIllegalOpcode"; >> + break; >> + case eIllegalOperand: >> + str = "eIllegalOperand"; >> + break; >> + case eIllegalAddressingMode: >> + str = "eIllegalAddressingMode"; >> + break; >> + case eIllegalTrap: >> + str = "eIllegalTrap"; >> + break; >> + case ePrivilegedOpcode: >> + str = "ePrivilegedOpcode"; >> + break; >> + case ePrivilegedRegister: >> + str = "ePrivilegedRegister"; >> + break; >> + case eCoprocessorError: >> + str = "eCoprocessorError"; >> + break; >> + case eInternalStackError: >> + str = "eInternalStackError"; >> + break; >> + >> + // SIGBUS crash rcase easons: >> + case eIllegalAlignment: >> + str = "eIllegalAlignment"; >> + break; >> + case eIllegalAddress: >> + str = "eIllegalAddress"; >> + break; >> + case eHardwareError: >> + str = "eHardwareError"; >> + break; >> + >> + // SIGFPE crash rcase easons: >> + case eIntegerDivideByZero: >> + str = "eIntegerDivideByZero"; >> + break; >> + case eIntegerOverflow: >> + str = "eIntegerOverflow"; >> + break; >> + case eFloatDivideByZero: >> + str = "eFloatDivideByZero"; >> + break; >> + case eFloatOverflow: >> + str = "eFloatOverflow"; >> + break; >> + case eFloatUnderflow: >> + str = "eFloatUnderflow"; >> + break; >> + case eFloatInexactResult: >> + str = "eFloatInexactResult"; >> + break; >> + case eFloatInvalidOperation: >> + str = "eFloatInvalidOperation"; >> + break; >> + case eFloatSubscriptRange: >> + str = "eFloatSubscriptRange"; >> + break; >> + } >> +#endif >> + >> + return str; >> +} >> + >> +const char * >> +ProcessMessage::PrintCrashReason() const >> +{ >> + return PrintCrashReason(m_crash_reason); >> +} >> + >> +const char * >> +ProcessMessage::PrintKind(Kind kind) >> +{ >> +#ifdef LLDB_CONFIGURATION_BUILDANDINTEGRATION >> + // Just return the code in asci for integration builds. >> + chcar str[8]; >> + sprintf(str, "%d", reason); >> +#else >> + const char *str = NULL; >> + >> + switch (kind) >> + { >> + default: >> + assert(false && "invalid Kind"); >> + break; >> + >> + case eInvalidMessage: >> + str = "eInvalidMessage"; >> + break; >> + case eExitMessage: >> + str = "eExitMessage"; >> + break; >> + case eLimboMessage: >> + str = "eLimboMessage"; >> + break; >> + case eSignalMessage: >> + str = "eSignalMessage"; >> + break; >> + case eSignalDeliveredMessage: >> + str = "eSignalDeliveredMessage"; >> + break; >> + case eTraceMessage: >> + str = "eTraceMessage"; >> + break; >> + case eBreakpointMessage: >> + str = "eBreakpointMessage"; >> + break; >> + case eCrashMessage: >> + str = "eCrashMessage"; >> + break; >> + } >> +#endif >> + >> + return str; >> +} >> + >> +const char * >> +ProcessMessage::PrintKind() const >> +{ >> + return PrintKind(m_kind); >> +} >> Index: source/Plugins/Process/Linux/ProcessMonitor.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) >> @@ -19,6 +19,7 @@ >> >> // C++ Includes >> // Other libraries and framework includes >> +#include "lldb/Core/Debugger.h" >> #include "lldb/Core/Error.h" >> #include "lldb/Core/RegisterValue.h" >> #include "lldb/Core/Scalar.h" >> @@ -29,11 +30,60 @@ >> >> #include "LinuxThread.h" >> #include "ProcessLinux.h" >> +#include "ProcessLinuxLog.h" >> #include "ProcessMonitor.h" >> >> >> using namespace lldb_private; >> >> +// FIXME: this code is host-dependent with respect to types and >> +// endianness and needs to be fixed. For example, lldb::addr_t is >> +// hard-coded to uint64_t, but on a 32-bit Linux host, ptrace requires >> +// 32-bit pointer arguments. This code uses casts to work around the >> +// problem. >> + >> +// We disable the tracing of ptrace calls for integration builds to >> +// avoid the additional indirection and checks. >> +#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION >> + >> +// Wrapper for ptrace to catch errors and log calls. >> +extern long >> +PtraceWrapper(__ptrace_request req, pid_t pid, void *addr, void *data, >> + const char* reqName, const char* file, int line) >> +{ >> + int result; >> + >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PTRACE)); >> + if (log) >> + log->Printf("ptrace(%s, %u, %p, %p) called from file %s line %d", >> + reqName, pid, addr, data, file, line); >> + >> + errno = 0; >> + result = ptrace(req, pid, addr, 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 = ""; >> + } >> + log->Printf("ptrace() failed; errno=%d (%s)", errno, str); >> + } >> + >> + return result; >> +} >> + >> +#define PTRACE(req, pid, addr, data) \ >> + PtraceWrapper((req), (pid), (addr), (data), #req, __FILE__, __LINE__) >> +#else >> +#define PTRACE ptrace >> +#endif >> + >> //------------------------------------------------------------------------------ >> // Static implementations of ProcessMonitor::ReadMemory and >> // ProcessMonitor::WriteMemory. This enables mutual recursion between these >> @@ -48,25 +98,49 @@ >> size_t remainder; >> long data; >> >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); >> + if (log) >> + ProcessLinuxLog::IncNestLevel(); >> + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) >> + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, >> + pid, word_size, (void*)vm_addr, buf, size); >> + >> + assert(sizeof(data) >= word_size); >> + assert(sizeof(void*) == word_size); >> for (bytes_read = 0; bytes_read < size; bytes_read += remainder) >> { >> errno = 0; >> - data = ptrace(PTRACE_PEEKDATA, pid, vm_addr, NULL); >> - >> + data = PTRACE(PTRACE_PEEKDATA, pid, (void*)vm_addr, NULL); >> if (data == -1L && errno) >> { >> error.SetErrorToErrno(); >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_read; >> } >> >> remainder = size - bytes_read; >> remainder = remainder > word_size ? word_size : remainder; >> + >> + // Copy the data into our buffer >> + if (log) >> + memset(dst, 0, sizeof(dst)); >> for (unsigned i = 0; i < remainder; ++i) >> dst[i] = ((data >> i*8) & 0xFF); >> + >> + if (log && ProcessLinuxLog::AtTopNestLevel() && >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && >> + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) >> + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, >> + (void*)vm_addr, *(unsigned long*)dst, (unsigned long)data); >> + >> vm_addr += word_size; >> dst += word_size; >> } >> >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_read; >> } >> >> @@ -78,6 +152,14 @@ >> size_t bytes_written = 0; >> size_t remainder; >> >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_ALL)); >> + if (log) >> + ProcessLinuxLog::IncNestLevel(); >> + if (log && ProcessLinuxLog::AtTopNestLevel() && log->GetMask().Test(LINUX_LOG_MEMORY)) >> + log->Printf ("ProcessMonitor::%s(%d, %d, %p, %p, %d, _)", __FUNCTION__, >> + pid, word_size, (void*)vm_addr, buf, size); >> + >> + assert(sizeof(void*) == word_size); >> for (bytes_written = 0; bytes_written < size; bytes_written += remainder) >> { >> remainder = size - bytes_written; >> @@ -86,12 +168,22 @@ >> if (remainder == word_size) >> { >> unsigned long data = 0; >> + assert(sizeof(data) >= word_size); >> for (unsigned i = 0; i < word_size; ++i) >> data |= (unsigned long)src[i] << i*8; >> >> - if (ptrace(PTRACE_POKEDATA, pid, vm_addr, data)) >> + if (log && ProcessLinuxLog::AtTopNestLevel() && >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && >> + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) >> + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, >> + (void*)vm_addr, *(unsigned long*)src, data); >> + >> + if (PTRACE(PTRACE_POKEDATA, pid, (void*)vm_addr, (void*)data)) >> { >> error.SetErrorToErrno(); >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_written; >> } >> } >> @@ -100,18 +192,35 @@ >> unsigned char buff[8]; >> if (DoReadMemory(pid, word_size, vm_addr, >> buff, word_size, error) != word_size) >> + { >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_written; >> + } >> >> memcpy(buff, src, remainder); >> >> if (DoWriteMemory(pid, word_size, vm_addr, >> buff, word_size, error) != word_size) >> + { >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_written; >> + } >> + >> + if (log && ProcessLinuxLog::AtTopNestLevel() && >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_LONG) || >> + (log->GetMask().Test(LINUX_LOG_MEMORY_DATA_SHORT) && >> + size <= LINUX_LOG_MEMORY_SHORT_BYTES))) >> + log->Printf ("ProcessMonitor::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__, >> + (void*)vm_addr, *(unsigned long*)src, *(unsigned long*)buff); >> } >> >> vm_addr += word_size; >> src += word_size; >> } >> + if (log) >> + ProcessLinuxLog::DecNestLevel(); >> return bytes_written; >> } >> >> @@ -216,6 +325,7 @@ >> m_result = DoWriteMemory(pid, word_size, m_addr, m_buff, m_size, m_error); >> } >> >> + >> //------------------------------------------------------------------------------ >> /// @class ReadRegOperation >> /// @brief Implements ProcessMonitor::ReadRegisterValue. >> @@ -238,11 +348,11 @@ >> ReadRegOperation::Execute(ProcessMonitor *monitor) >> { >> lldb::pid_t pid = monitor->GetPID(); >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); >> >> // Set errno to zero so that we can detect a failed peek. >> errno = 0; >> - uint32_t data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); >> - >> + uint32_t data = PTRACE(PTRACE_PEEKUSER, pid, (void*)m_offset, NULL); >> if (data == -1UL && errno) >> m_result = false; >> else >> @@ -250,6 +360,9 @@ >> m_value = data; >> m_result = true; >> } >> + if (log) >> + log->Printf ("ProcessMonitor::%s() reg %s: 0x%x", __FUNCTION__, >> + LinuxThread::GetRegisterNameFromOffset(m_offset), data); >> } >> >> //------------------------------------------------------------------------------ >> @@ -273,9 +386,22 @@ >> void >> WriteRegOperation::Execute(ProcessMonitor *monitor) >> { >> + void* buf; >> lldb::pid_t pid = monitor->GetPID(); >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_REGISTERS)); >> >> - if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.GetAsUInt64())) >> + if (sizeof(void*) == sizeof(uint64_t)) >> + buf = (void*) m_value.GetAsUInt64(); >> + else >> + { >> + assert(sizeof(void*) == sizeof(uint32_t)); >> + buf = (void*) m_value.GetAsUInt32(); >> + } >> + >> + if (log) >> + log->Printf ("ProcessMonitor::%s() reg %s: %p", __FUNCTION__, >> + LinuxThread::GetRegisterNameFromOffset(m_offset), buf); >> + if (PTRACE(PTRACE_POKEUSER, pid, (void*)m_offset, buf)) >> m_result = false; >> else >> m_result = true; >> @@ -301,7 +427,7 @@ >> void >> ReadGPROperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) >> + if (PTRACE(PTRACE_GETREGS, monitor->GetPID(), NULL, m_buf) < 0) >> m_result = false; >> else >> m_result = true; >> @@ -327,7 +453,7 @@ >> void >> ReadFPROperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) >> + if (PTRACE(PTRACE_GETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) >> m_result = false; >> else >> m_result = true; >> @@ -353,7 +479,7 @@ >> void >> WriteGPROperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) >> + if (PTRACE(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) >> m_result = false; >> else >> m_result = true; >> @@ -379,7 +505,7 @@ >> void >> WriteFPROperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) >> + if (PTRACE(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) >> m_result = false; >> else >> m_result = true; >> @@ -410,7 +536,7 @@ >> if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) >> data = m_signo; >> >> - if (ptrace(PTRACE_CONT, m_tid, NULL, data)) >> + if (PTRACE(PTRACE_CONT, m_tid, NULL, (void*)data)) >> m_result = false; >> else >> m_result = true; >> @@ -441,7 +567,7 @@ >> if (m_signo != LLDB_INVALID_SIGNAL_NUMBER) >> data = m_signo; >> >> - if (ptrace(PTRACE_SINGLESTEP, m_tid, NULL, data)) >> + if (PTRACE(PTRACE_SINGLESTEP, m_tid, NULL, (void*)data)) >> m_result = false; >> else >> m_result = true; >> @@ -467,7 +593,7 @@ >> void >> SiginfoOperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) >> + if (PTRACE(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) >> m_result = false; >> else >> m_result = true; >> @@ -493,7 +619,7 @@ >> void >> EventMessageOperation::Execute(ProcessMonitor *monitor) >> { >> - if (ptrace(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) >> + if (PTRACE(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) >> m_result = false; >> else >> m_result = true; >> @@ -518,7 +644,7 @@ >> { >> lldb::pid_t pid = monitor->GetPID(); >> >> - if (ptrace(PTRACE_KILL, pid, NULL, NULL)) >> + if (PTRACE(PTRACE_KILL, pid, NULL, NULL)) >> m_result = false; >> else >> m_result = true; >> @@ -756,6 +882,7 @@ >> lldb::pid_t pid; >> >> lldb::ThreadSP inferior; >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); >> >> // Propagate the environment if one is not supplied. >> if (envp == NULL || envp[0] == NULL) >> @@ -789,7 +916,7 @@ >> if (pid == 0) >> { >> // Trace this process. >> - if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) < 0) >> + if (PTRACE(PTRACE_TRACEME, 0, NULL, NULL) < 0) >> exit(ePtraceFailed); >> >> // Do not inherit setgid powers. >> @@ -861,7 +988,7 @@ >> >> // Have the child raise an event on exit. This is used to keep the child in >> // limbo until it is destroyed. >> - if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT) < 0) >> + if (PTRACE(PTRACE_SETOPTIONS, pid, NULL, (void*)PTRACE_O_TRACEEXIT) < 0) >> { >> args->m_error.SetErrorToErrno(); >> goto FINISH; >> @@ -880,9 +1007,12 @@ >> >> // Update the process thread list with this new thread and mark it as >> // current. >> + // FIXME: should we be letting UpdateThreadList handle this? >> + // FIXME: by using pids instead of tids, we can only support one thread. >> inferior.reset(new LinuxThread(process, pid)); >> + if (log) >> + log->Printf ("ProcessMonitor::%s() adding pid = %i", __FUNCTION__, pid); >> process.GetThreadList().AddThread(inferior); >> - process.GetThreadList().SetSelectedThreadByID(pid); >> >> // Let our process instance know the thread has stopped. >> process.SendMessage(ProcessMessage::Trace(pid)); >> @@ -943,6 +1073,7 @@ >> ProcessLinux &process = monitor->GetProcess(); >> >> lldb::ThreadSP inferior; >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_PROCESS)); >> >> if (pid <= 1) >> { >> @@ -952,7 +1083,7 @@ >> } >> >> // Attach to the requested process. >> - if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) >> + if (PTRACE(PTRACE_ATTACH, pid, NULL, NULL) < 0) >> { >> args->m_error.SetErrorToErrno(); >> goto FINISH; >> @@ -968,6 +1099,8 @@ >> // Update the process thread list with the attached thread and >> // mark it as current. >> inferior.reset(new LinuxThread(process, pid)); >> + if (log) >> + log->Printf ("ProcessMonitor::%s() adding tid = %i", __FUNCTION__, pid); >> process.GetThreadList().AddThread(inferior); >> process.GetThreadList().SetSelectedThreadByID(pid); >> >> @@ -987,6 +1120,7 @@ >> ProcessMessage message; >> ProcessMonitor *monitor = static_cast(callback_baton); >> ProcessLinux *process = monitor->m_process; >> + assert(process); >> bool stop_monitoring; >> siginfo_t info; >> >> @@ -1017,7 +1151,8 @@ >> { >> ProcessMessage message; >> >> - assert(info->si_signo == SIGTRAP && "Unexpected child signal!"); >> + assert(monitor); >> + assert(info && info->si_signo == SIGTRAP && "Unexpected child signal!"); >> >> switch (info->si_code) >> { >> Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (working copy) >> @@ -405,6 +405,7 @@ >> return g_register_infos[reg].byte_offset; >> } >> >> +#if 0 // These functions are currently not being used. >> static unsigned GetRegSize(unsigned reg) >> { >> assert(reg < k_num_registers && "Invalid register number."); >> @@ -420,6 +421,7 @@ >> { >> return (k_first_fpr <= reg && reg <= k_last_fpr); >> } >> +#endif >> >> RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread, >> uint32_t concrete_frame_idx) >> @@ -478,6 +480,26 @@ >> return NULL; >> } >> >> +unsigned >> +RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(unsigned offset) >> +{ >> + unsigned reg; >> + for (reg = 0; reg < k_num_registers; reg++) >> + { >> + if (g_register_infos[reg].byte_offset == offset) >> + break; >> + } >> + assert(reg < k_num_registers && "Invalid register offset."); >> + return reg; >> +} >> + >> +const char * >> +RegisterContextLinux_x86_64::GetRegisterName(unsigned reg) >> +{ >> + assert(reg < k_num_registers && "Invalid register offset."); >> + return g_register_infos[reg].name; >> +} >> + >> bool >> RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, >> RegisterValue &value) >> Index: source/Plugins/Process/Linux/LinuxThread.cpp >> =================================================================== >> --- source/Plugins/Process/Linux/LinuxThread.cpp (revision 142029) >> +++ source/Plugins/Process/Linux/LinuxThread.cpp (working copy) >> @@ -13,14 +13,15 @@ >> // C++ Includes >> // Other libraries and framework includes >> // Project includes >> +#include "lldb/Core/Debugger.h" >> #include "lldb/Host/Host.h" >> #include "lldb/Target/Process.h" >> #include "lldb/Target/StopInfo.h" >> #include "lldb/Target/Target.h" >> - >> #include "LinuxStopInfo.h" >> #include "LinuxThread.h" >> #include "ProcessLinux.h" >> +#include "ProcessLinuxLog.h" >> #include "ProcessMonitor.h" >> #include "RegisterContextLinux_i386.h" >> #include "RegisterContextLinux_x86_64.h" >> @@ -33,6 +34,9 @@ >> : Thread(process, tid), >> m_frame_ap(0) >> { >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("LinuxThread::%s (tid = %i)", __FUNCTION__, tid); >> } >> >> LinuxThread::~LinuxThread() >> @@ -50,6 +54,14 @@ >> void >> LinuxThread::RefreshStateAfterStop() >> { >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("LinuxThread::%s ()", __FUNCTION__); >> + >> + // Let all threads recover from stopping and do any clean up based >> + // on the previous thread state (if any). >> + ProcessLinux &process = static_cast(GetProcess()); >> + process.GetThreadList().RefreshStateAfterStop(); >> } >> >> const char * >> @@ -91,13 +103,20 @@ >> lldb::RegisterContextSP reg_ctx_sp; >> uint32_t concrete_frame_idx = 0; >> >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("LinuxThread::%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; >> } >> @@ -136,6 +155,10 @@ >> ProcessMonitor &monitor = GetMonitor(); >> bool status; >> >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log && log->GetMask().Test(LINUX_LOG_VERBOSE)) >> + log->Printf ("LinuxThread::%s ()", __FUNCTION__); >> + >> switch (resume_state) >> { >> default: >> @@ -160,6 +183,10 @@ >> void >> LinuxThread::Notify(const ProcessMessage &message) >> { >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log) >> + log->Printf ("LinuxThread::%s () message kind = '%s'", __FUNCTION__, message.PrintKind()); >> + >> switch (message.GetKind()) >> { >> default: >> @@ -196,14 +223,20 @@ >> LinuxThread::BreakNotify(const ProcessMessage &message) >> { >> bool status; >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> >> + assert(GetRegisterContextLinux()); >> status = GetRegisterContextLinux()->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 ("LinuxThread::%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)); >> >> @@ -250,7 +283,68 @@ >> >> assert(message.GetKind() == ProcessMessage::eCrashMessage); >> >> + LogSP log (ProcessLinuxLog::GetLogIfAllCategoriesSet (LINUX_LOG_THREAD)); >> + if (log) >> + log->Printf ("LinuxThread::%s () signo = %i, reason = '%s'", __FUNCTION__, signo, message.PrintCrashReason()); >> + >> m_stop_info = lldb::StopInfoSP(new LinuxCrashStopInfo( >> *this, signo, message.GetCrashReason())); >> SetResumeSignal(signo); >> } >> + >> +unsigned >> +LinuxThread::GetRegisterIndexFromOffset(unsigned offset) >> +{ >> + unsigned reg; >> + ArchSpec arch = Host::GetArchitecture(); >> + >> + switch (arch.GetCore()) >> + { >> + default: >> + assert(false && "CPU type not supported!"); >> + break; >> + >> + case ArchSpec::eCore_x86_32_i386: >> + case ArchSpec::eCore_x86_32_i486: >> + case ArchSpec::eCore_x86_32_i486sx: >> + reg = RegisterContextLinux_i386::GetRegisterIndexFromOffset(offset); >> + break; >> + >> + case ArchSpec::eCore_x86_64_x86_64: >> + reg = RegisterContextLinux_x86_64::GetRegisterIndexFromOffset(offset); >> + break; >> + } >> + return reg; >> +} >> + >> +const char * >> +LinuxThread::GetRegisterName(unsigned reg) >> +{ >> + const char * name; >> + ArchSpec arch = Host::GetArchitecture(); >> + >> + switch (arch.GetCore()) >> + { >> + default: >> + assert(false && "CPU type not supported!"); >> + break; >> + >> + case ArchSpec::eCore_x86_32_i386: >> + case ArchSpec::eCore_x86_32_i486: >> + case ArchSpec::eCore_x86_32_i486sx: >> + name = RegisterContextLinux_i386::GetRegisterName(reg); >> + break; >> + >> + case ArchSpec::eCore_x86_64_x86_64: >> + name = RegisterContextLinux_x86_64::GetRegisterName(reg); >> + break; >> + } >> + return name; >> +} >> + >> +const char * >> +LinuxThread::GetRegisterNameFromOffset(unsigned offset) >> +{ >> + return GetRegisterName(GetRegisterIndexFromOffset(offset)); >> +} >> + >> Index: source/Plugins/Process/Linux/RegisterContextLinux_i386.h >> =================================================================== >> --- source/Plugins/Process/Linux/RegisterContextLinux_i386.h (revision 142029) >> +++ source/Plugins/Process/Linux/RegisterContextLinux_i386.h (working copy) >> @@ -14,6 +14,7 @@ >> // C++ Includes >> // Other libraries and framework includes >> // Project includes >> +#include "lldb/Core/Log.h" >> #include "RegisterContextLinux.h" >> >> class RegisterContextLinux_i386 : public RegisterContextLinux >> @@ -42,6 +43,12 @@ >> const lldb_private::RegisterSet * >> GetRegisterSet(uint32_t set); >> >> + static unsigned >> + GetRegisterIndexFromOffset(unsigned offset); >> + >> + static const char * >> + GetRegisterName(unsigned reg); >> + >> #if 0 >> bool >> ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); >> @@ -153,6 +160,8 @@ >> >> ProcessMonitor &GetMonitor(); >> >> + void LogGPR(const char *title); >> + >> bool ReadGPR(); >> bool ReadFPR(); >> }; >> Index: source/Plugins/Process/Linux/ProcessMessage.h >> =================================================================== >> --- source/Plugins/Process/Linux/ProcessMessage.h (revision 142029) >> +++ source/Plugins/Process/Linux/ProcessMessage.h (working copy) >> @@ -140,6 +140,18 @@ >> static const char * >> GetCrashReasonString(CrashReason reason); >> >> + const char * >> + PrintCrashReason() const; >> + >> + static const char * >> + PrintCrashReason(CrashReason reason); >> + >> + const char * >> + PrintKind() const; >> + >> + static const char * >> + PrintKind(Kind); >> + >> private: >> ProcessMessage(lldb::tid_t tid, Kind kind, >> int status = 0, lldb::addr_t addr = 0) >> Index: source/Plugins/Process/Linux/LinuxThread.h >> =================================================================== >> --- source/Plugins/Process/Linux/LinuxThread.h (revision 142029) >> +++ source/Plugins/Process/Linux/LinuxThread.h (working copy) >> @@ -48,6 +48,20 @@ >> CreateRegisterContextForFrame (lldb_private::StackFrame *frame); >> >> //-------------------------------------------------------------------------- >> + // These static functions provide a mapping from the register offset >> + // back to the register index or name for use in debugging or log >> + // output. >> + >> + static unsigned >> + GetRegisterIndexFromOffset(unsigned offset); >> + >> + static const char * >> + GetRegisterName(unsigned reg); >> + >> + static const char * >> + GetRegisterNameFromOffset(unsigned offset); >> + >> + //-------------------------------------------------------------------------- >> // These methods form a specialized interface to linux threads. >> // >> bool Resume(); >> Index: source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h >> =================================================================== >> --- source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (revision 142029) >> +++ source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (working copy) >> @@ -41,6 +41,12 @@ >> const lldb_private::RegisterSet * >> GetRegisterSet(uint32_t set); >> >> + static unsigned >> + GetRegisterIndexFromOffset(unsigned offset); >> + >> + static const char * >> + GetRegisterName(unsigned reg); >> + >> virtual bool >> ReadRegister(const lldb_private::RegisterInfo *reg_info, >> lldb_private::RegisterValue &value); > >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Tue Oct 18 13:31:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 18:31:06 -0000 Subject: [Lldb-commits] [lldb] r142391 - /lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Message-ID: <20111018183106.676863128034@llvm.org> Author: johnny Date: Tue Oct 18 13:31:06 2011 New Revision: 142391 URL: http://llvm.org/viewvc/llvm-project?rev=142391&view=rev Log: Modify the help text for watching a variable or its pointee. Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=142391&r1=142390&r2=142391&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Tue Oct 18 13:31:06 2011 @@ -41,8 +41,8 @@ static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a variable (read, write, or read/write)."}, - { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch a location (1, 2, 4, or 8)."} + { LLDB_OPT_SET_1, false, "watch", 'w', required_argument, g_watch_type, 0, eArgTypeWatchType, "Determine how to watch a variable; or, with -x option, its pointee."}, + { LLDB_OPT_SET_1, false, "xsize", 'x', required_argument, g_watch_size, 0, eArgTypeByteSize, "Number of bytes to use to watch the pointee."} }; From johnny.chen at apple.com Tue Oct 18 13:33:33 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 18:33:33 -0000 Subject: [Lldb-commits] [lldb] r142392 - /lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Message-ID: <20111018183333.991613128034@llvm.org> Author: johnny Date: Tue Oct 18 13:33:33 2011 New Revision: 142392 URL: http://llvm.org/viewvc/llvm-project?rev=142392&view=rev Log: Remove stale comment. Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Modified: lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp?rev=142392&r1=142391&r2=142392&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupWatchpoint.cpp Tue Oct 18 13:33:33 2011 @@ -37,7 +37,6 @@ { 0, NULL, NULL } }; -// if you add any options here, remember to update the counters in OptionGroupWatchpoint::GetNumDefinitions() static OptionDefinition g_option_table[] = { From johnny.chen at apple.com Tue Oct 18 14:13:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 19:13:06 -0000 Subject: [Lldb-commits] [lldb] r142396 - in /lldb/trunk/scripts/Python/interface: SBBreakpoint.i SBBreakpointLocation.i SBWatchpoint.i Message-ID: <20111018191306.4A8C33128034@llvm.org> Author: johnny Date: Tue Oct 18 14:13:06 2011 New Revision: 142396 URL: http://llvm.org/viewvc/llvm-project?rev=142396&view=rev Log: Add docstrings for SetCondition() and GetCondition() APIs. Modified: lldb/trunk/scripts/Python/interface/SBBreakpoint.i lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i lldb/trunk/scripts/Python/interface/SBWatchpoint.i Modified: lldb/trunk/scripts/Python/interface/SBBreakpoint.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpoint.i?rev=142396&r1=142395&r2=142396&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBBreakpoint.i (original) +++ lldb/trunk/scripts/Python/interface/SBBreakpoint.i Tue Oct 18 14:13:06 2011 @@ -128,9 +128,19 @@ uint32_t GetIgnoreCount () const; + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The breakpoint stops only if the condition expression evaluates to true. + //-------------------------------------------------------------------------- + ") SetCondition; void SetCondition (const char *condition); + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the breakpoint. + //------------------------------------------------------------------ + ") GetCondition; const char * GetCondition (); Modified: lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i?rev=142396&r1=142395&r2=142396&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i (original) +++ lldb/trunk/scripts/Python/interface/SBBreakpointLocation.i Tue Oct 18 14:13:06 2011 @@ -50,9 +50,20 @@ void SetIgnoreCount (uint32_t n); + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The breakpoint location stops only if the condition expression evaluates + /// to true. + //-------------------------------------------------------------------------- + ") SetCondition; void SetCondition (const char *condition); + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the breakpoint location. + //------------------------------------------------------------------ + ") GetCondition; const char * GetCondition (); Modified: lldb/trunk/scripts/Python/interface/SBWatchpoint.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBWatchpoint.i?rev=142396&r1=142395&r2=142396&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBWatchpoint.i (original) +++ lldb/trunk/scripts/Python/interface/SBWatchpoint.i Tue Oct 18 14:13:06 2011 @@ -66,9 +66,19 @@ void SetIgnoreCount (uint32_t n); + %feature("docstring", " + //------------------------------------------------------------------ + /// Get the condition expression for the watchpoint. + //------------------------------------------------------------------ + ") GetCondition; const char * GetCondition (); + %feature("docstring", " + //-------------------------------------------------------------------------- + /// The watchpoint stops only if the condition expression evaluates to true. + //-------------------------------------------------------------------------- + ") SetCondition; void SetCondition (const char *condition); From dawn at burble.org Tue Oct 18 14:21:34 2011 From: dawn at burble.org (dawn at burble.org) Date: Tue, 18 Oct 2011 12:21:34 -0700 Subject: [Lldb-commits] [PATCH] another gcc fix Message-ID: <20111018192134.GA4544@bloodbath.burble.org> This patch fixes the build under Gcc (again). ... oh how I wish we had a build-bot for Linux :) Thanks, -Dawn -------------- next part -------------- Index: source/Host/common/FileSpec.cpp =================================================================== --- source/Host/common/FileSpec.cpp (revision 142395) +++ source/Host/common/FileSpec.cpp (working copy) @@ -711,7 +711,7 @@ if (filename == NULL) return ConstString(); - char* dot_pos = strrchr(filename, '.'); + const char* dot_pos = strrchr(filename, '.'); if (dot_pos == NULL) return ConstString(); @@ -725,7 +725,7 @@ if (filename == NULL) return ConstString(); - char* dot_pos = strrchr(filename, '.'); + const char* dot_pos = strrchr(filename, '.'); if (dot_pos == NULL) return m_filename; From johnny.chen at apple.com Tue Oct 18 14:28:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 19:28:30 -0000 Subject: [Lldb-commits] [lldb] r142402 - /lldb/trunk/source/Host/common/FileSpec.cpp Message-ID: <20111018192831.056353128034@llvm.org> Author: johnny Date: Tue Oct 18 14:28:30 2011 New Revision: 142402 URL: http://llvm.org/viewvc/llvm-project?rev=142402&view=rev Log: Fix build under gcc. Patch from Dawn. Modified: lldb/trunk/source/Host/common/FileSpec.cpp Modified: lldb/trunk/source/Host/common/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=142402&r1=142401&r2=142402&view=diff ============================================================================== --- lldb/trunk/source/Host/common/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Tue Oct 18 14:28:30 2011 @@ -711,7 +711,7 @@ if (filename == NULL) return ConstString(); - char* dot_pos = strrchr(filename, '.'); + const char* dot_pos = strrchr(filename, '.'); if (dot_pos == NULL) return ConstString(); @@ -725,7 +725,7 @@ if (filename == NULL) return ConstString(); - char* dot_pos = strrchr(filename, '.'); + const char* dot_pos = strrchr(filename, '.'); if (dot_pos == NULL) return m_filename; From johnny.chen at apple.com Tue Oct 18 14:31:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 18 Oct 2011 12:31:37 -0700 Subject: [Lldb-commits] [PATCH] another gcc fix In-Reply-To: <20111018192134.GA4544@bloodbath.burble.org> References: <20111018192134.GA4544@bloodbath.burble.org> Message-ID: <73262227-4C41-462C-AD63-9240F96FF111@apple.com> Submitted r142402. Thanks! On Oct 18, 2011, at 12:21 PM, dawn at burble.org wrote: > > This patch fixes the build under Gcc (again). > ... oh how I wish we had a build-bot for Linux :) > > Thanks, > -Dawn > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Tue Oct 18 18:36:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 18 Oct 2011 23:36:41 -0000 Subject: [Lldb-commits] [lldb] r142461 - in /lldb/trunk: include/lldb/Symbol/Type.h include/lldb/Symbol/TypeList.h include/lldb/lldb-forward-rtti.h source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/TypeList.cpp source/Target/ObjCLanguageRuntime.cpp Message-ID: <20111018233641.7DBC53128034@llvm.org> Author: gclayton Date: Tue Oct 18 18:36:41 2011 New Revision: 142461 URL: http://llvm.org/viewvc/llvm-project?rev=142461&view=rev Log: Changed lldb_private::Type over to use the intrusive ref counted pointers so we don't have to lookup types in a type list by ID. Changed the DWARF parser to remove the "can externally complete myself" bits from the type when we are in the process of completing the type itself to avoid an onslaught of external visible decl requests from the clang::ExternalASTSource. Modified: lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/include/lldb/Symbol/TypeList.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/TypeList.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Tue Oct 18 18:36:41 2011 @@ -20,7 +20,9 @@ namespace lldb_private { -class Type : public UserID +class Type : + public ReferenceCountedBaseVirtual, + public UserID { public: typedef enum EncodingDataTypeTag Modified: lldb/trunk/include/lldb/Symbol/TypeList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/TypeList.h (original) +++ lldb/trunk/include/lldb/Symbol/TypeList.h Tue Oct 18 18:36:41 2011 @@ -33,17 +33,17 @@ void Dump(Stream *s, bool show_context); - lldb::TypeSP - FindType(lldb::user_id_t uid); +// lldb::TypeSP +// FindType(lldb::user_id_t uid); TypeList FindTypes(const ConstString &name); void - Insert (lldb::TypeSP& type); + Insert (const lldb::TypeSP& type); bool - InsertUnique (lldb::TypeSP& type); + InsertUnique (const lldb::TypeSP& type); uint32_t GetSize() const; Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Oct 18 18:36:41 2011 @@ -75,7 +75,7 @@ typedef IntrusiveSharedPtr::Type ThreadSP; typedef SharedPtr::Type ThreadPlanSP; typedef SharedPtr::Type ThreadPlanTracerSP; - typedef SharedPtr::Type TypeSP; + typedef IntrusiveSharedPtr::Type TypeSP; typedef SharedPtr::Type TypeImplSP; typedef SharedPtr::Type FuncUnwindersSP; typedef SharedPtr::Type UserSettingsControllerSP; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Oct 18 18:36:41 2011 @@ -296,7 +296,7 @@ if (!class_type_or_name.IsEmpty()) { - if (class_type_or_name.GetTypeSP() != NULL) + if (class_type_or_name.GetTypeSP()) return true; else return false; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Oct 18 18:36:41 2011 @@ -496,7 +496,7 @@ const DataExtractor& SymbolFileDWARF::get_apple_namespaces_data() { - return GetCachedSectionData (flagsGotDebugTypesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces); + return GetCachedSectionData (flagsGotDebugNamespacesData, eSectionTypeDWARFAppleNamespaces, m_data_apple_namespaces); } @@ -1435,12 +1435,6 @@ const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers); if (die == NULL) { -// if (m_debug_map_symfile) -// { -// Type *type = m_die_to_type[die]; -// if (type && type->GetSymbolFile() != this) -// return type->GetClangType(); -// } // We have already resolved this type... return clang_type; } @@ -1451,6 +1445,10 @@ m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers); + // Disable external storage for this type so we don't get anymore + // clang::ExternalASTSource queries for this type. + ClangASTContext::SetHasExternalStorage (clang_type, false); + DWARFDebugInfo* debug_info = DebugInfo(); DWARFCompileUnit *curr_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get(); @@ -2764,17 +2762,9 @@ if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); - if (type_sp) - { - types.InsertUnique (type_sp); - if (types.GetSize() >= max_matches) - break; - } - else - { - ReportError ("error: can't find shared pointer for type 0x%8.8x.\n", matching_type->GetID()); - } + types.InsertUnique (TypeSP (matching_type)); + if (types.GetSize() >= max_matches) + break; } } return types.GetSize() - initial_types_size; @@ -2865,9 +2855,7 @@ if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); - assert (type_sp.get() != NULL); - types.InsertUnique (type_sp); + types.InsertUnique (TypeSP (matching_type)); ++num_matches; if (num_matches >= max_matches) break; @@ -3274,7 +3262,7 @@ else if (type_ptr != DIE_IS_BEING_PARSED) { // Grab the existing type from the master types lists - type_sp = GetTypeList()->FindType(type_ptr->GetID()); + type_sp = type_ptr; } } @@ -3549,11 +3537,7 @@ type_cu->GetOffset()); m_die_to_type[die] = resolved_type; - type_sp = GetTypeList()->FindType(resolved_type->GetID()); - if (!type_sp) - { - DEBUG_PRINTF("unable to resolve type '%s' from DIE 0x%8.8x\n", type_name.GetCString(), die->GetOffset()); - } + type_sp = resolved_type; break; } } @@ -4014,16 +3998,6 @@ clang_type, Type::eResolveStateForward)); -#if LEAVE_ENUMS_FORWARD_DECLARED - // Leave this as a forward declaration until we need - // to know the details of the type. lldb_private::Type - // will automatically call the SymbolFile virtual function - // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)" - // When the definition needs to be defined. - m_forward_decl_die_to_clang_type[die] = clang_type; - m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die; - ClangASTContext::SetHasExternalStorage (clang_type, true); -#else ast.StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { @@ -4031,7 +4005,6 @@ ParseChildEnumerators(cu_sc, clang_type, type_sp->GetByteSize(), dwarf_cu, die); } ast.CompleteTagDeclarationDefinition (clang_type); -#endif } } break; @@ -4355,7 +4328,7 @@ type_ptr = m_die_to_type[die]; if (type_ptr) { - type_sp = type_list->FindType(type_ptr->GetID()); + type_sp = type_ptr; break; } } @@ -4578,7 +4551,7 @@ } else if (type_ptr != DIE_IS_BEING_PARSED) { - type_sp = type_list->FindType(type_ptr->GetID()); + type_sp = type_ptr; } } return type_sp; @@ -5242,11 +5215,21 @@ void SymbolFileDWARF::FindExternalVisibleDeclsByName (void *baton, - const clang::DeclContext *DC, - clang::DeclarationName Name, + const clang::DeclContext *decl_context, + clang::DeclarationName decl_name, llvm::SmallVectorImpl *results) { - SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton; - - symbol_file_dwarf->SearchDeclContext (DC, Name.getAsString().c_str(), results); + + switch (decl_context->getDeclKind()) + { + case clang::Decl::Namespace: + case clang::Decl::TranslationUnit: + { + SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton; + symbol_file_dwarf->SearchDeclContext (decl_context, decl_name.getAsString().c_str(), results); + } + break; + default: + break; + } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Oct 18 18:36:41 2011 @@ -251,7 +251,8 @@ flagsGotDebugRangesData = (1 << 9), flagsGotDebugStrData = (1 << 10), flagsGotDebugNamesData = (1 << 11), - flagsGotDebugTypesData = (1 << 12) + flagsGotDebugTypesData = (1 << 12), + flagsGotDebugNamespacesData = (1 << 13) }; bool NamespaceDeclMatchesThisSymbolFile (const lldb_private::ClangNamespaceDecl *namespace_decl); Modified: lldb/trunk/source/Symbol/TypeList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/source/Symbol/TypeList.cpp (original) +++ lldb/trunk/source/Symbol/TypeList.cpp Tue Oct 18 18:36:41 2011 @@ -51,7 +51,7 @@ } void -TypeList::Insert (TypeSP& type_sp) +TypeList::Insert (const TypeSP& type_sp) { // Just push each type on the back for now. We will worry about uniquing later if (type_sp) @@ -60,7 +60,7 @@ bool -TypeList::InsertUnique (TypeSP& type_sp) +TypeList::InsertUnique (const TypeSP& type_sp) { if (type_sp) { @@ -80,14 +80,14 @@ //---------------------------------------------------------------------- // Find a base type by its unique ID. //---------------------------------------------------------------------- -TypeSP -TypeList::FindType(lldb::user_id_t uid) -{ - iterator pos = m_types.find(uid); - if (pos != m_types.end()) - return pos->second; - return TypeSP(); -} +//TypeSP +//TypeList::FindType(lldb::user_id_t uid) +//{ +// iterator pos = m_types.find(uid); +// if (pos != m_types.end()) +// return pos->second; +// return TypeSP(); +//} //---------------------------------------------------------------------- // Find a type by name. Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=142461&r1=142460&r2=142461&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Tue Oct 18 18:36:41 2011 @@ -63,7 +63,7 @@ TypeAndOrName class_type_or_name; - if (type_sp != NULL) + if (type_sp) class_type_or_name.SetTypeSP (type_sp); else if (name && *name != '\0') class_type_or_name.SetName (name); From johnny.chen at apple.com Tue Oct 18 20:06:21 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 19 Oct 2011 01:06:21 -0000 Subject: [Lldb-commits] [lldb] r142469 - in /lldb/trunk/test: benchmarks/stepping/TestRunHooksThenSteppings.py lldbtest.py Message-ID: <20111019010621.A84153128034@llvm.org> Author: johnny Date: Tue Oct 18 20:06:21 2011 New Revision: 142469 URL: http://llvm.org/viewvc/llvm-project?rev=142469&view=rev Log: Extract the run hooks functionality into the base class lldbtest.Base. Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py?rev=142469&r1=142468&r2=142469&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Tue Oct 18 20:06:21 2011 @@ -38,17 +38,13 @@ #lldb.runHooks = ['process attach -n Mail'] # Perform the run hooks to bring lldb debugger to the desired state. - if not lldb.runHooks: - self.skipTest("No runhooks specified for lldb, skip the test") - for hook in lldb.runHooks: - child.sendline(hook) - child.expect_exact(prompt) + self.runHooks(child, prompt) # Reset the stopwatch now. self.stopwatch.reset() for i in range(count): with self.stopwatch: - # Disassemble the function. + # Step through the function. child.sendline('next') # Aka 'thread step-over'. child.expect_exact(prompt) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=142469&r1=142468&r2=142469&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 18 20:06:21 2011 @@ -565,6 +565,20 @@ # See HideStdout(self). self.sys_stdout_hidden = False + def runHooks(self, child, prompt): + """Perform the run hooks to bring lldb debugger to the desired state. + + Note that child is a process spawned by pexpect.spawn(). If not, your + test case is mostly likely going to fail. + + See also dotest.py where lldb.runHooks are processed/populated. + """ + if not lldb.runHooks: + self.skipTest("No runhooks specified for lldb, skip the test") + for hook in lldb.runHooks: + child.sendline(hook) + child.expect_exact(prompt) + def HideStdout(self): """Hide output to stdout from the user. From johnny.chen at apple.com Wed Oct 19 11:48:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 19 Oct 2011 16:48:07 -0000 Subject: [Lldb-commits] [lldb] r142532 - in /lldb/trunk/test: benchmarks/stepping/TestRunHooksThenSteppings.py lldbtest.py Message-ID: <20111019164807.54A352A6C12C@llvm.org> Author: johnny Date: Wed Oct 19 11:48:07 2011 New Revision: 142532 URL: http://llvm.org/viewvc/llvm-project?rev=142532&view=rev Log: Modify lldbtest.Base.runHooks() to now take the following keyword arguments: child=None, child_prompt=None, use_cmd_api=False By default, expect a pexpect spawned child and child prompt to be supplied (use_cmd_api=False). If use_cmd_api is true, ignore the child and child prompt and use self.runCmd() to run the hooks one by one. Modify existing client to reflect the change. Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py?rev=142532&r1=142531&r2=142532&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Wed Oct 19 11:48:07 2011 @@ -38,7 +38,7 @@ #lldb.runHooks = ['process attach -n Mail'] # Perform the run hooks to bring lldb debugger to the desired state. - self.runHooks(child, prompt) + self.runHooks(child=child, child_prompt=prompt) # Reset the stopwatch now. self.stopwatch.reset() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=142532&r1=142531&r2=142532&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Oct 19 11:48:07 2011 @@ -565,9 +565,13 @@ # See HideStdout(self). self.sys_stdout_hidden = False - def runHooks(self, child, prompt): + def runHooks(self, child=None, child_prompt=None, use_cmd_api=False): """Perform the run hooks to bring lldb debugger to the desired state. + By default, expect a pexpect spawned child and child prompt to be + supplied (use_cmd_api=False). If use_cmd_api is true, ignore the child + and child prompt and use self.runCmd() to run the hooks one by one. + Note that child is a process spawned by pexpect.spawn(). If not, your test case is mostly likely going to fail. @@ -575,9 +579,15 @@ """ if not lldb.runHooks: self.skipTest("No runhooks specified for lldb, skip the test") - for hook in lldb.runHooks: - child.sendline(hook) - child.expect_exact(prompt) + if use_cmd_api: + for hook in lldb.runhooks: + self.runCmd(hook) + else: + if not child or not child_prompt: + self.fail("Both child and child_prompt need to be defined.") + for hook in lldb.runHooks: + child.sendline(hook) + child.expect_exact(child_prompt) def HideStdout(self): """Hide output to stdout from the user. From gclayton at apple.com Wed Oct 19 13:09:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 19 Oct 2011 18:09:39 -0000 Subject: [Lldb-commits] [lldb] r142534 - in /lldb/trunk: include/lldb/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Process/MacOSX-Kernel/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ Message-ID: <20111019180940.9A1302A6C12C@llvm.org> Author: gclayton Date: Wed Oct 19 13:09:39 2011 New Revision: 142534 URL: http://llvm.org/viewvc/llvm-project?rev=142534&view=rev Log: Moved lldb::user_id_t values to be 64 bit. This was going to be needed for process IDs, and thread IDs, but was mainly needed for for the UserID's for Types so that DWARF with debug map can work flawlessly. With DWARF in .o files the type ID was the DIE offset in the DWARF for the .o file which is not unique across all .o files, so now the SymbolFileDWARFDebugMap class will make the .o file index part (the high 32 bits) of the unique type identifier so it can uniquely identify the types. Modified: lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-defines.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Core/UserID.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackID.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadList.cpp lldb/trunk/source/Target/ThreadPlan.cpp lldb/trunk/source/Target/ThreadPlanBase.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Wed Oct 19 13:09:39 2011 @@ -19,7 +19,6 @@ namespace lldb_private { class Symbol : - public UserID, // Used to uniquely identify this symbol in its symbol table public SymbolContextScope { public: @@ -28,7 +27,7 @@ // and sorting requirements. Symbol(); - Symbol (lldb::user_id_t symID, + Symbol (uint32_t symID, const char *name, bool name_is_mangled, lldb::SymbolType type, @@ -41,7 +40,7 @@ uint32_t size, uint32_t flags); - Symbol (lldb::user_id_t symID, + Symbol (uint32_t symID, const char *name, bool name_is_mangled, lldb::SymbolType type, @@ -57,6 +56,9 @@ const Symbol& operator= (const Symbol& rhs); + void + Clear(); + bool Compare (const ConstString& name, lldb::SymbolType type) const; @@ -78,6 +80,18 @@ const ConstString & GetName () { return m_mangled.GetName(); } + uint32_t + GetID() const + { + return m_uid; + } + + void + SetID(uint32_t uid) + { + m_uid = uid; + } + Mangled& GetMangled () { return m_mangled; } @@ -188,6 +202,7 @@ protected: + uint32_t m_uid; // User ID (usually the original symbol table index) Mangled m_mangled; // uniqued symbol name/mangled name pair lldb::SymbolType m_type; // symbol type uint16_t m_type_data; // data specific to m_type Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Oct 19 13:09:39 2011 @@ -245,8 +245,8 @@ m_executable (), m_arguments (), m_environment (), - m_uid (LLDB_INVALID_UID), - m_gid (LLDB_INVALID_UID), + m_uid (UINT32_MAX), + m_gid (UINT32_MAX), m_arch(), m_pid (LLDB_INVALID_PROCESS_ID) { @@ -258,8 +258,8 @@ m_executable (name, false), m_arguments (), m_environment(), - m_uid (LLDB_INVALID_UID), - m_gid (LLDB_INVALID_UID), + m_uid (UINT32_MAX), + m_gid (UINT32_MAX), m_arch (arch), m_pid (pid) { @@ -271,8 +271,8 @@ m_executable.Clear(); m_arguments.Clear(); m_environment.Clear(); - m_uid = LLDB_INVALID_UID; - m_gid = LLDB_INVALID_UID; + m_uid = UINT32_MAX; + m_gid = UINT32_MAX; m_arch.Clear(); m_pid = LLDB_INVALID_PROCESS_ID; } Modified: lldb/trunk/include/lldb/lldb-defines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-defines.h (original) +++ lldb/trunk/include/lldb/lldb-defines.h Wed Oct 19 13:09:39 2011 @@ -72,7 +72,7 @@ #define LLDB_INVALID_IVAR_OFFSET UINT32_MAX #define LLDB_INVALID_IMAGE_TOKEN UINT32_MAX #define LLDB_INVALID_REGNUM UINT32_MAX -#define LLDB_INVALID_UID UINT32_MAX +#define LLDB_INVALID_UID UINT64_MAX #define LLDB_INVALID_PROCESS_ID 0 #define LLDB_INVALID_THREAD_ID 0 #define LLDB_INVALID_FRAME_ID UINT32_MAX Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Wed Oct 19 13:09:39 2011 @@ -96,7 +96,7 @@ namespace lldb { typedef uint64_t addr_t; - typedef uint32_t user_id_t; + typedef uint64_t user_id_t; typedef int32_t pid_t; typedef uint32_t tid_t; typedef int32_t break_id_t; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Oct 19 13:09:39 2011 @@ -3581,7 +3581,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - DEBUG_INFORMATION_FORMAT = dwarf; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Wed Oct 19 13:09:39 2011 @@ -174,7 +174,7 @@ if (m_opaque_ptr) { lldb::user_id_t id = m_opaque_ptr->GetID(); - description.Printf ("Block: {id: %d} ", id); + description.Printf ("Block: {id: %llu} ", id); if (IsInlined()) { description.Printf (" (inlined, '%s') ", GetInlinedName()); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Oct 19 13:09:39 2011 @@ -969,7 +969,7 @@ { const char *name = m_opaque_sp->GetInstanceName().AsCString(); user_id_t id = m_opaque_sp->GetID(); - description.Printf ("Debugger (instance: \"%s\", id: %d)", name, id); + description.Printf ("Debugger (instance: \"%s\", id: %llu)", name, id); } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Wed Oct 19 13:09:39 2011 @@ -107,9 +107,9 @@ { if (m_opaque_ptr) { - s.Printf ("SBFunction: id = 0x%8.8x, name = %s", - m_opaque_ptr->GetID(), - m_opaque_ptr->GetName().AsCString()); + s.Printf ("SBFunction: id = 0x%8.8llx, name = %s", + m_opaque_ptr->GetID(), + m_opaque_ptr->GetName().AsCString()); Type *func_type = m_opaque_ptr->GetType(); if (func_type) s.Printf(", type = %s", func_type->GetName().AsCString()); Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Oct 19 13:09:39 2011 @@ -303,7 +303,7 @@ char message[1024]; int message_len = ::snprintf (message, sizeof (message), - "Process %d %s\n", + "Process %llu %s\n", m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); @@ -321,7 +321,7 @@ char message[1024]; ::snprintf (message, sizeof (message), - "Process %d %s\n", + "Process %llu %s\n", m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); @@ -809,7 +809,7 @@ if (exe_module) exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); - description.Printf ("SBProcess: pid = %d, state = %s, threads = %d%s%s", + description.Printf ("SBProcess: pid = %llu, state = %s, threads = %d%s%s", m_opaque_sp->GetID(), lldb_private::StateAsCString (GetState()), GetNumThreads(), Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Wed Oct 19 13:09:39 2011 @@ -954,7 +954,7 @@ if (m_opaque_sp) { StreamString strm; - description.Printf("SBThread: tid = 0x%4.4x", m_opaque_sp->GetID()); + description.Printf("SBThread: tid = 0x%4.4llx", m_opaque_sp->GetID()); } else description.Printf ("No value"); Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Oct 19 13:09:39 2011 @@ -323,7 +323,7 @@ { const char *archname = exe_module->GetArchitecture().GetArchitectureName(); - result.AppendMessageWithFormat ("Process %i launched: '%s' (%s)\n", process->GetID(), filename, archname); + result.AppendMessageWithFormat ("Process %llu launched: '%s' (%s)\n", process->GetID(), filename, archname); result.SetDidChangeProcessState (true); if (m_options.stop_at_entry == false) { @@ -573,7 +573,7 @@ state = process->GetState(); if (process->IsAlive() && state != eStateConnected) { - result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before attaching.\n", + result.AppendErrorWithFormat ("Process %llu is currently being debugged, kill the process before attaching.\n", process->GetID()); result.SetStatus (eReturnStatusFailed); return false; @@ -676,7 +676,7 @@ StateType state = process->WaitForProcessToStop (NULL); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -728,7 +728,7 @@ StateType state = process->WaitForProcessToStop (NULL); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -859,13 +859,13 @@ Error error(process->Resume()); if (error.Success()) { - result.AppendMessageWithFormat ("Process %i resuming\n", process->GetID()); + result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID()); if (synchronous_execution) { state = process->WaitForProcessToStop (NULL); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -923,7 +923,7 @@ return false; } - result.AppendMessageWithFormat ("Detaching from process %i\n", process->GetID()); + result.AppendMessageWithFormat ("Detaching from process %llu\n", process->GetID()); Error error (process->Detach()); if (error.Success()) { @@ -1030,7 +1030,7 @@ { if (process->IsAlive()) { - result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before connecting.\n", + result.AppendErrorWithFormat ("Process %llu is currently being debugged, kill the process before connecting.\n", process->GetID()); result.SetStatus (eReturnStatusFailed); return false; Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Oct 19 13:09:39 2011 @@ -3581,7 +3581,7 @@ case eInputReaderDone: if (!got_interrupted && !batch_mode) { - out_stream->Printf ("Stop hook #%d added.\n", new_stop_hook->GetID()); + out_stream->Printf ("Stop hook #%llu added.\n", new_stop_hook->GetID()); out_stream->Flush(); } break; @@ -3667,7 +3667,7 @@ { // Use one-liner. new_hook_sp->GetCommandPointer()->AppendString (m_options.m_one_liner.c_str()); - result.AppendMessageWithFormat("Stop hook #%d added.\n", new_hook_sp->GetID()); + result.AppendMessageWithFormat("Stop hook #%llu added.\n", new_hook_sp->GetID()); } else { Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Wed Oct 19 13:09:39 2011 @@ -546,7 +546,7 @@ // } process->GetThreadList().SetSelectedThreadByID (thread->GetID()); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } } @@ -685,7 +685,7 @@ thread->SetResumeState (eStateSuspended); } } - result.AppendMessageWithFormat ("in process %i\n", process->GetID()); + result.AppendMessageWithFormat ("in process %llu\n", process->GetID()); } } else @@ -703,7 +703,7 @@ Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get(); if (thread == current_thread) { - result.AppendMessageWithFormat ("Resuming thread 0x%4.4x in process %i\n", thread->GetID(), process->GetID()); + result.AppendMessageWithFormat ("Resuming thread 0x%4.4llx in process %llu\n", thread->GetID(), process->GetID()); thread->SetResumeState (eStateRunning); } else @@ -716,13 +716,13 @@ Error error (process->Resume()); if (error.Success()) { - result.AppendMessageWithFormat ("Process %i resuming\n", process->GetID()); + result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID()); if (synchronous_execution) { state = process->WaitForProcessToStop (NULL); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -1043,13 +1043,13 @@ Error error (process->Resume ()); if (error.Success()) { - result.AppendMessageWithFormat ("Process %i resuming\n", process->GetID()); + result.AppendMessageWithFormat ("Process %llu resuming\n", process->GetID()); if (synchronous_execution) { StateType state = process->WaitForProcessToStop (NULL); result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %i %s\n", process->GetID(), StateAsCString (state)); + result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Wed Oct 19 13:09:39 2011 @@ -703,7 +703,7 @@ Variable *var = variable_list.GetVariableAtIndex (var_idx).get(); if (var && var->LocationIsValidForAddress (*this)) { - s->Printf (" Variable: id = {0x%8.8x}, name = \"%s\", type= \"%s\", location =", + s->Printf (" Variable: id = {0x%8.8llx}, name = \"%s\", type= \"%s\", location =", var->GetID(), var->GetName().GetCString(), var->GetType()->GetName().GetCString()); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Oct 19 13:09:39 2011 @@ -1524,7 +1524,7 @@ var_name_begin += ::strlen ("process."); if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) { - s.Printf("%i", process->GetID()); + s.Printf("%llu", process->GetID()); var_success = true; } else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) || @@ -1562,7 +1562,7 @@ var_name_begin += ::strlen ("thread."); if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) { - s.Printf("0x%4.4x", thread->GetID()); + s.Printf("0x%4.4llx", thread->GetID()); var_success = true; } else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) @@ -1733,7 +1733,7 @@ if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) { if (sc->function) - s.Printf("function{0x%8.8x}", sc->function->GetID()); + s.Printf("function{0x%8.8llx}", sc->function->GetID()); else s.Printf("symbol[%u]", sc->symbol->GetID()); Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Wed Oct 19 13:09:39 2011 @@ -228,7 +228,7 @@ { // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - s->Printf("0x%8.8x %-14s ", GetID(), GetSectionTypeAsCString (m_type)); + s->Printf("0x%8.8llx %-14s ", GetID(), GetSectionTypeAsCString (m_type)); bool resolved = true; addr_t addr = LLDB_INVALID_ADDRESS; Modified: lldb/trunk/source/Core/UserID.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserID.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Core/UserID.cpp (original) +++ lldb/trunk/source/Core/UserID.cpp Wed Oct 19 13:09:39 2011 @@ -20,6 +20,6 @@ Stream& lldb_private::operator << (Stream& strm, const UserID& uid) { - strm.Printf("{0x%8.8x}", uid.GetID()); + strm.Printf("{0x%8.8llx}", uid.GetID()); return strm; } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Oct 19 13:09:39 2011 @@ -204,7 +204,7 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %d')", m_dictionary_name.c_str(), + run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %llu')", m_dictionary_name.c_str(), interpreter.GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); @@ -306,13 +306,13 @@ StreamString run_string; - run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %d')", m_dictionary_name.c_str(), + run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %llu')", m_dictionary_name.c_str(), GetCommandInterpreter().GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%d)')", + run_string.Printf ("run_one_line (%s, 'lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%llu)')", m_dictionary_name.c_str(), GetCommandInterpreter().GetDebugger().GetID()); PyRun_SimpleString (run_string.GetData()); Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Wed Oct 19 13:09:39 2011 @@ -294,7 +294,7 @@ // locker will keep a mutex locked until it goes out of scope LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD)); if (log && log->GetMask().Test(KDP_LOG_VERBOSE)) - log->Printf ("ProcessKDP::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessKDP::%s (pid = %llu)", __FUNCTION__, GetID()); // We currently are making only one thread per core and we // actually don't know about actual threads. Eventually we @@ -698,7 +698,7 @@ LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_PROCESS)); if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) thread starting...", __FUNCTION__, arg, process->GetID()); Listener listener ("ProcessKDP::AsyncThread"); EventSP event_sp; @@ -713,14 +713,14 @@ while (!done) { if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); if (listener.WaitForEvent (NULL, event_sp)) { const uint32_t event_type = event_sp->GetType(); if (event_sp->BroadcasterIs (&process->m_async_broadcaster)) { if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type); switch (event_type) { @@ -772,13 +772,13 @@ case eBroadcastBitAsyncThreadShouldExit: if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID()); done = true; break; default: if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type); done = true; break; } @@ -795,14 +795,14 @@ else { if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID()); done = true; } } } if (log) - log->Printf ("ProcessKDP::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessKDP::%s (arg = %p, pid = %llu) thread exiting...", __FUNCTION__, arg, process->GetID()); process->m_async_thread = LLDB_INVALID_HOST_THREAD; return NULL; Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp Wed Oct 19 13:09:39 2011 @@ -76,7 +76,7 @@ lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP)); if (log) - log->Printf ("Resuming thread: %4.4x with state: %s.", GetID(), StateAsCString(resume_state)); + log->Printf ("Resuming thread: %4.4llx with state: %s.", GetID(), StateAsCString(resume_state)); // ProcessKDP &process = GetKDPProcess(); // switch (resume_state) Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Wed Oct 19 13:09:39 2011 @@ -179,7 +179,7 @@ { // Get all registers in one packet if (thread_suffix_supported) - packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4x;", m_thread.GetID()); + packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4llx;", m_thread.GetID()); else packet_len = ::snprintf (packet, sizeof(packet), "g"); assert (packet_len < (sizeof(packet) - 1)); @@ -195,7 +195,7 @@ // Get each register individually if (thread_suffix_supported) - packet_len = ::snprintf (packet, sizeof(packet), "p%x;thread:%4.4x;", reg, m_thread.GetID()); + packet_len = ::snprintf (packet, sizeof(packet), "p%x;thread:%4.4llx;", reg, m_thread.GetID()); else packet_len = ::snprintf (packet, sizeof(packet), "p%x", reg); assert (packet_len < (sizeof(packet) - 1)); @@ -282,7 +282,7 @@ lldb::endian::InlHostByteOrder()); if (thread_suffix_supported) - packet.Printf (";thread:%4.4x;", m_thread.GetID()); + packet.Printf (";thread:%4.4llx;", m_thread.GetID()); // Invalidate all register values InvalidateIfNeeded (true); @@ -309,7 +309,7 @@ lldb::endian::InlHostByteOrder()); if (thread_suffix_supported) - packet.Printf (";thread:%4.4x;", m_thread.GetID()); + packet.Printf (";thread:%4.4llx;", m_thread.GetID()); // Invalidate just this register m_reg_valid[reg] = false; @@ -346,7 +346,7 @@ { int packet_len = 0; if (thread_suffix_supported) - packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4x", m_thread.GetID()); + packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4llx", m_thread.GetID()); else packet_len = ::snprintf (packet, sizeof(packet), "g"); assert (packet_len < (sizeof(packet) - 1)); @@ -363,7 +363,7 @@ if (thread_suffix_supported) { char thread_id_cstr[64]; - ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID()); + ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4llx;", m_thread.GetID()); response_str.append (thread_id_cstr); } data_sp.reset (new DataBufferHeap (response_str.c_str(), response_str.size())); @@ -457,7 +457,7 @@ lldb::endian::InlHostByteOrder()); if (thread_suffix_supported) - packet.Printf (";thread:%4.4x;", m_thread.GetID()); + packet.Printf (";thread:%4.4llx;", m_thread.GetID()); m_reg_valid[reg] = false; if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(), Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct 19 13:09:39 2011 @@ -1082,7 +1082,7 @@ // locker will keep a mutex locked until it goes out of scope LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD)); if (log && log->GetMask().Test(GDBR_LOG_VERBOSE)) - log->Printf ("ProcessGDBRemote::%s (pid = %i)", __FUNCTION__, GetID()); + log->Printf ("ProcessGDBRemote::%s (pid = %llu)", __FUNCTION__, GetID()); // Update the thread list's stop id immediately so we don't recurse into this function. std::vector thread_ids; @@ -1798,12 +1798,12 @@ user_id_t site_id = bp_site->GetID(); const addr_t addr = bp_site->GetLoadAddress(); if (log) - log->Printf ("ProcessGDBRemote::EnableBreakpoint (size_id = %d) address = 0x%llx", site_id, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::EnableBreakpoint (size_id = %llu) address = 0x%llx", site_id, (uint64_t)addr); if (bp_site->IsEnabled()) { if (log) - log->Printf ("ProcessGDBRemote::EnableBreakpoint (size_id = %d) address = 0x%llx -- SUCCESS (already enabled)", site_id, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::EnableBreakpoint (size_id = %llu) address = 0x%llx -- SUCCESS (already enabled)", site_id, (uint64_t)addr); return error; } else @@ -1860,7 +1860,7 @@ user_id_t site_id = bp_site->GetID(); LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS)); if (log) - log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %d) addr = 0x%8.8llx", site_id, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %llu) addr = 0x%8.8llx", site_id, (uint64_t)addr); if (bp_site->IsEnabled()) { @@ -1889,7 +1889,7 @@ else { if (log) - log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %d) addr = 0x%8.8llx -- SUCCESS (already disabled)", site_id, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::DisableBreakpoint (site_id = %llu) addr = 0x%8.8llx -- SUCCESS (already disabled)", site_id, (uint64_t)addr); return error; } @@ -1926,11 +1926,11 @@ addr_t addr = wp->GetLoadAddress(); LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_WATCHPOINTS)); if (log) - log->Printf ("ProcessGDBRemote::EnableWatchpoint(watchID = %d)", watchID); + log->Printf ("ProcessGDBRemote::EnableWatchpoint(watchID = %llu)", watchID); if (wp->IsEnabled()) { if (log) - log->Printf("ProcessGDBRemote::EnableWatchpoint(watchID = %d) addr = 0x%8.8llx: watchpoint already enabled.", watchID, (uint64_t)addr); + log->Printf("ProcessGDBRemote::EnableWatchpoint(watchID = %llu) addr = 0x%8.8llx: watchpoint already enabled.", watchID, (uint64_t)addr); return error; } @@ -1970,12 +1970,12 @@ addr_t addr = wp->GetLoadAddress(); if (log) - log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %d) addr = 0x%8.8llx", watchID, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %llu) addr = 0x%8.8llx", watchID, (uint64_t)addr); if (!wp->IsEnabled()) { if (log) - log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %d) addr = 0x%8.8llx -- SUCCESS (already disabled)", watchID, (uint64_t)addr); + log->Printf ("ProcessGDBRemote::DisableWatchpoint (watchID = %llu) addr = 0x%8.8llx -- SUCCESS (already disabled)", watchID, (uint64_t)addr); return error; } @@ -2307,7 +2307,7 @@ LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) thread starting...", __FUNCTION__, arg, process->GetID()); Listener listener ("ProcessGDBRemote::AsyncThread"); EventSP event_sp; @@ -2322,14 +2322,14 @@ while (!done) { if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) listener.WaitForEvent (NULL, event_sp)...", __FUNCTION__, arg, process->GetID()); if (listener.WaitForEvent (NULL, event_sp)) { const uint32_t event_type = event_sp->GetType(); if (event_sp->BroadcasterIs (&process->m_async_broadcaster)) { if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) Got an event of type: %d...", __FUNCTION__, arg, process->GetID(), event_type); switch (event_type) { @@ -2342,7 +2342,7 @@ const char *continue_cstr = (const char *)continue_packet->GetBytes (); const size_t continue_cstr_len = continue_packet->GetByteSize (); if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) got eBroadcastBitAsyncContinue: %s", __FUNCTION__, arg, process->GetID(), continue_cstr); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) got eBroadcastBitAsyncContinue: %s", __FUNCTION__, arg, process->GetID(), continue_cstr); if (::strstr (continue_cstr, "vAttach") == NULL) process->SetPrivateState(eStateRunning); @@ -2379,13 +2379,13 @@ case eBroadcastBitAsyncThreadShouldExit: if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) got eBroadcastBitAsyncThreadShouldExit...", __FUNCTION__, arg, process->GetID()); done = true; break; default: if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) got unknown event 0x%8.8x", __FUNCTION__, arg, process->GetID(), event_type); done = true; break; } @@ -2402,14 +2402,14 @@ else { if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) listener.WaitForEvent (NULL, event_sp) => false", __FUNCTION__, arg, process->GetID()); done = true; } } } if (log) - log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, arg, process->GetID()); + log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %llu) thread exiting...", __FUNCTION__, arg, process->GetID()); process->m_async_thread = LLDB_INVALID_HOST_THREAD; return NULL; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Wed Oct 19 13:09:39 2011 @@ -77,7 +77,7 @@ int signo = GetResumeSignal(); lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (GDBR_LOG_THREAD)); if (log) - log->Printf ("Resuming thread: %4.4x with state: %s.", GetID(), StateAsCString(resume_state)); + log->Printf ("Resuming thread: %4.4llx with state: %s.", GetID(), StateAsCString(resume_state)); ProcessGDBRemote &process = GetGDBProcess(); switch (resume_state) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Oct 19 13:09:39 2011 @@ -163,6 +163,7 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) : SymbolFile (objfile), + UserID (0), // Used by SymbolFileDWARFDebugMap to when this class parses .o files to contain the .o file index/ID m_debug_map_symfile (NULL), m_clang_tu_decl (NULL), m_flags(), @@ -551,8 +552,8 @@ SymbolFileDWARF::GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid) { DWARFDebugInfo* info = DebugInfo(); - if (info) - return info->GetCompileUnit(cu_uid).get(); + if (info && UserIDMatches(cu_uid)) + return info->GetCompileUnit((dw_offset_t)cu_uid).get(); return NULL; } @@ -609,7 +610,11 @@ cu_file_spec.SetFile (fullpath.c_str(), false); } - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), curr_cu, cu_file_spec, curr_cu->GetOffset(), cu_language)); + compile_unit_sp.reset(new CompileUnit (m_obj_file->GetModule(), + curr_cu, + cu_file_spec, + MakeUserID(curr_cu->GetOffset()), + cu_language)); if (compile_unit_sp.get()) { curr_cu->SetUserData(compile_unit_sp.get()); @@ -722,9 +727,10 @@ func_range.GetBaseAddress().ResolveLinkedAddress(); + const user_id_t func_user_id = MakeUserID(die->GetOffset()); func_sp.reset(new Function (sc.comp_unit, - die->GetOffset(), // UserID is the DIE offset - die->GetOffset(), + func_user_id, // UserID is the DIE offset + func_user_id, func_name, func_type, func_range)); // first address range @@ -755,7 +761,7 @@ for (func_idx = 0; func_idx < num_funtions; ++func_idx) { const DWARFDebugInfoEntry *die = function_dies.GetDIEPtrAtIndex(func_idx); - if (sc.comp_unit->FindFunctionByUID (die->GetOffset()).get() == NULL) + if (sc.comp_unit->FindFunctionByUID (MakeUserID(die->GetOffset())).get() == NULL) { if (ParseCompileUnitFunction(sc, dwarf_cu, die)) ++functions_added; @@ -1030,7 +1036,7 @@ } else { - BlockSP block_sp(new Block (die->GetOffset())); + BlockSP block_sp(new Block (MakeUserID(die->GetOffset()))); parent_block->AddChild(block_sp); block = block_sp.get(); } @@ -1248,13 +1254,13 @@ else { if (name) - ReportError ("0x%8.8x: DW_TAG_member '%s' refers to type 0x%8.8x which was unable to be parsed", - die->GetOffset(), + ReportError ("0x%8.8llx: DW_TAG_member '%s' refers to type 0x%8.8llx which was unable to be parsed", + MakeUserID(die->GetOffset()), name, encoding_uid); else - ReportError ("0x%8.8x: DW_TAG_member refers to type 0x%8.8x which was unable to be parsed", - die->GetOffset(), + ReportError ("0x%8.8llx: DW_TAG_member refers to type 0x%8.8llx which was unable to be parsed", + MakeUserID(die->GetOffset()), encoding_uid); } } @@ -1371,7 +1377,7 @@ SymbolFileDWARF::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { DWARFDebugInfo* debug_info = DebugInfo(); - if (debug_info) + if (debug_info && UserIDMatches(type_uid)) { DWARFCompileUnitSP cu_sp; const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); @@ -1384,32 +1390,37 @@ clang::DeclContext* SymbolFileDWARF::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { - return GetClangDeclContextForDIEOffset (sc, type_uid); + if (UserIDMatches(type_uid)) + return GetClangDeclContextForDIEOffset (sc, type_uid); + return NULL; } Type* SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) { - DWARFDebugInfo* debug_info = DebugInfo(); - if (debug_info) + if (UserIDMatches(type_uid)) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); - if (type_die != NULL) + DWARFDebugInfo* debug_info = DebugInfo(); + if (debug_info) { - // We might be coming in in the middle of a type tree (a class - // withing a class, an enum within a class), so parse any needed - // parent DIEs before we get to this one... - const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu_sp.get(), type_die); - switch (decl_ctx_die->Tag()) + DWARFCompileUnitSP cu_sp; + const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); + if (type_die != NULL) { - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: - ResolveType(cu_sp.get(), decl_ctx_die); - break; + // We might be coming in in the middle of a type tree (a class + // withing a class, an enum within a class), so parse any needed + // parent DIEs before we get to this one... + const DWARFDebugInfoEntry *decl_ctx_die = GetDeclContextDIEContainingDIE (cu_sp.get(), type_die); + switch (decl_ctx_die->Tag()) + { + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + ResolveType(cu_sp.get(), decl_ctx_die); + break; + } + return ResolveType (cu_sp.get(), type_die); } - return ResolveType (cu_sp.get(), type_die); } } return NULL; @@ -1456,8 +1467,8 @@ const dw_tag_t tag = die->Tag(); - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", - die->GetOffset(), + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\") - resolve forward declaration...\n", + MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type->GetName().AsCString()); assert (clang_type); @@ -1657,7 +1668,7 @@ // Check if the symbol vendor already knows about this compile unit? sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX); - sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); + sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(func_die->GetOffset())).get(); if (sc.function == NULL) sc.function = ParseCompileUnitFunction(sc, curr_cu, func_die); @@ -1741,7 +1752,7 @@ if (function_die != NULL) { - sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); + sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get(); if (sc.function == NULL) sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die); } @@ -1755,9 +1766,9 @@ Block& block = sc.function->GetBlock (true); if (block_die != NULL) - sc.block = block.FindBlockByID (block_die->GetOffset()); + sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset())); else - sc.block = block.FindBlockByID (function_die->GetOffset()); + sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset())); if (sc.block) resolved |= eSymbolContextBlock; } @@ -1837,7 +1848,7 @@ if (function_die != NULL) { - sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); + sc.function = sc.comp_unit->FindFunctionByUID (MakeUserID(function_die->GetOffset())).get(); if (sc.function == NULL) sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die); } @@ -1847,9 +1858,9 @@ Block& block = sc.function->GetBlock (true); if (block_die != NULL) - sc.block = block.FindBlockByID (block_die->GetOffset()); + sc.block = block.FindBlockByID (MakeUserID(block_die->GetOffset())); else - sc.block = block.FindBlockByID (function_die->GetOffset()); + sc.block = block.FindBlockByID (MakeUserID(function_die->GetOffset())); } } } @@ -2219,7 +2230,7 @@ // Parse all blocks if needed if (inlined_die) { - sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); + sc.block = sc.function->GetBlock (true).FindBlockByID (MakeUserID(inlined_die->GetOffset())); assert (sc.block != NULL); if (sc.block->GetStartAddress (addr) == false) addr.Clear(); @@ -3319,9 +3330,9 @@ if (log) { const char *object_name = m_obj_file->GetModule()->GetObjectName().GetCString(); - log->Printf ("ASTContext => %p: 0x%8.8x: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", + log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", GetClangASTContext().getASTContext(), - die->GetOffset(), + MakeUserID(die->GetOffset()), namespace_name, namespace_decl, m_obj_file->GetFileSpec().GetDirectory().GetCString(), @@ -3529,12 +3540,12 @@ Type *resolved_type = ResolveType (type_cu, type_die, false); if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) { - DEBUG_PRINTF ("resolved 0x%8.8x (cu 0x%8.8x) from %s to 0x%8.8x (cu 0x%8.8x)\n", - die->GetOffset(), - curr_cu->GetOffset(), + DEBUG_PRINTF ("resolved 0x%8.8llx (cu 0x%8.8llx) from %s to 0x%8.8llx (cu 0x%8.8llx)\n", + MakeUserID(die->GetOffset()), + MakeUserID(curr_cu->GetOffset()), m_obj_file->GetFileSpec().GetFilename().AsCString(), - type_die->GetOffset(), - type_cu->GetOffset()); + MakeUserID(type_die->GetOffset()), + MakeUserID(type_cu->GetOffset())); m_die_to_type[die] = resolved_type; type_sp = resolved_type; @@ -3646,7 +3657,7 @@ } } - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") type => 0x%8.8x\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid); + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\") type => 0x%8.8x\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid); switch (tag) { @@ -3693,7 +3704,7 @@ } } - type_sp.reset( new Type (die->GetOffset(), + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, byte_size, @@ -3811,7 +3822,7 @@ } } - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); int tag_decl_kind = -1; AccessType default_accessibility = eAccessNone; @@ -3875,7 +3886,7 @@ // parameters in any class methods need it for the clang // types for function prototypes. LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die); - type_sp.reset (new Type (die->GetOffset(), + type_sp.reset (new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, byte_size, @@ -3965,7 +3976,7 @@ } } - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); clang_type_t enumerator_clang_type = NULL; clang_type = m_forward_decl_die_to_clang_type.lookup (die); @@ -3987,7 +3998,7 @@ LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die); - type_sp.reset( new Type (die->GetOffset(), + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, byte_size, @@ -4108,7 +4119,7 @@ } } - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); clang_type_t return_clang_type = NULL; Type *func_type = NULL; @@ -4236,8 +4247,8 @@ } else { - ReportWarning ("0x%8.8x: DW_AT_specification(0x%8.8x) has no decl\n", - die->GetOffset(), + ReportWarning ("0x%8.8llx: DW_AT_specification(0x%8.8x) has no decl\n", + MakeUserID(die->GetOffset()), specification_die_offset); } type_handled = true; @@ -4259,8 +4270,8 @@ } else { - ReportWarning ("0x%8.8x: DW_AT_abstract_origin(0x%8.8x) has no decl\n", - die->GetOffset(), + ReportWarning ("0x%8.8llx: DW_AT_abstract_origin(0x%8.8x) has no decl\n", + MakeUserID(die->GetOffset()), abstract_origin_die_offset); } type_handled = true; @@ -4288,10 +4299,10 @@ { clang::CXXMethodDecl *cxx_method_decl; // REMOVE THE CRASH DESCRIPTION BELOW - Host::SetCrashDescriptionWithFormat ("SymbolFileDWARF::ParseType() is adding a method %s to class %s in DIE 0x%8.8x from %s/%s", + Host::SetCrashDescriptionWithFormat ("SymbolFileDWARF::ParseType() is adding a method %s to class %s in DIE 0x%8.8llx from %s/%s", type_name_cstr, class_type->GetName().GetCString(), - die->GetOffset(), + MakeUserID(die->GetOffset()), m_obj_file->GetFileSpec().GetDirectory().GetCString(), m_obj_file->GetFileSpec().GetFilename().GetCString()); @@ -4356,7 +4367,7 @@ function_param_decls.size()); } } - type_sp.reset( new Type (die->GetOffset(), + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, 0, @@ -4421,7 +4432,7 @@ } } - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr); + DEBUG_PRINTF ("0x%8.8llx: %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr); Type *element_type = ResolveTypeUID(type_die_offset); @@ -4449,7 +4460,7 @@ array_element_bit_stride = array_element_bit_stride * num_elements; } ConstString empty_name; - type_sp.reset( new Type (die->GetOffset(), + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, empty_name, array_element_bit_stride / 8, @@ -4502,7 +4513,7 @@ byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(), clang_type) / 8; - type_sp.reset( new Type (die->GetOffset(), + type_sp.reset( new Type (MakeUserID(die->GetOffset()), this, type_name_const_str, byte_size, @@ -4533,7 +4544,7 @@ } else if (sc.function != NULL) { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset())); if (symbol_context_scope == NULL) symbol_context_scope = sc.function; } @@ -4582,7 +4593,7 @@ if (die->Tag() == DW_TAG_subprogram) { SymbolContext child_sc(sc); - child_sc.function = sc.comp_unit->FindFunctionByUID(die->GetOffset()).get(); + child_sc.function = sc.comp_unit->FindFunctionByUID(MakeUserID(die->GetOffset())).get(); types_added += ParseTypes(child_sc, dwarf_cu, die->GetFirstChild(), true, true); } else @@ -4854,7 +4865,7 @@ case DW_TAG_lexical_block: if (sc.function) { - symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset())); if (symbol_context_scope == NULL) symbol_context_scope = sc.function; } @@ -4867,16 +4878,16 @@ if (symbol_context_scope) { - var_sp.reset (new Variable(die->GetOffset(), - name, - mangled, - var_type, - scope, - symbol_context_scope, - &decl, - location, - is_external, - is_artificial)); + var_sp.reset (new Variable (MakeUserID(die->GetOffset()), + name, + mangled, + var_type, + scope, + symbol_context_scope, + &decl, + location, + is_external, + is_artificial)); var_sp->SetLocationIsConstantValueData (location_is_const_value_data); } @@ -5020,11 +5031,11 @@ } else { - ReportError ("parent 0x%8.8x %s with no valid compile unit in symbol context for 0x%8.8x %s.\n", - sc_parent_die->GetOffset(), - DW_TAG_value_to_name (parent_tag), - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); + ReportError ("parent 0x%8.8llx %s with no valid compile unit in symbol context for 0x%8.8llx %s.\n", + MakeUserID(sc_parent_die->GetOffset()), + DW_TAG_value_to_name (parent_tag), + MakeUserID(orig_die->GetOffset()), + DW_TAG_value_to_name (orig_die->Tag())); } break; @@ -5035,7 +5046,7 @@ { // Check to see if we already have parsed the variables for the given scope - Block *block = sc.function->GetBlock(true).FindBlockByID(sc_parent_die->GetOffset()); + Block *block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(sc_parent_die->GetOffset())); if (block == NULL) { // This must be a specification or abstract origin with @@ -5047,7 +5058,7 @@ sc_parent_die->GetOffset(), &concrete_block_die_cu); if (concrete_block_die) - block = sc.function->GetBlock(true).FindBlockByID(concrete_block_die->GetOffset()); + block = sc.function->GetBlock(true).FindBlockByID(MakeUserID(concrete_block_die->GetOffset())); } if (block != NULL) @@ -5064,9 +5075,9 @@ break; default: - ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8x %s.\n", - orig_die->GetOffset(), - DW_TAG_value_to_name (orig_die->Tag())); + ReportError ("didn't find appropriate parent DIE for variable list for 0x%8.8llx %s.\n", + MakeUserID(orig_die->GetOffset()), + DW_TAG_value_to_name (orig_die->Tag())); break; } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Oct 19 13:09:39 2011 @@ -55,7 +55,7 @@ class DWARFFormValue; class SymbolFileDWARFDebugMap; -class SymbolFileDWARF : public lldb_private::SymbolFile +class SymbolFileDWARF : public lldb_private::SymbolFile, public lldb_private::UserID { public: friend class SymbolFileDWARFDebugMap; @@ -411,6 +411,21 @@ m_decl_ctx_to_die[decl_ctx].insert(die); } + bool + UserIDMatches (lldb::user_id_t uid) const + { + const lldb::user_id_t high_uid = uid & 0xffffffff00000000ull; + if (high_uid) + return high_uid == GetID(); + return true; + } + + lldb::user_id_t + MakeUserID (dw_offset_t die_offset) const + { + return GetID() | die_offset; + } + void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Oct 19 13:09:39 2011 @@ -231,6 +231,20 @@ return NULL; } + +uint32_t +SymbolFileDWARFDebugMap::GetCompUnitInfoIndex (const CompileUnitInfo *comp_unit_info) +{ + if (!m_compile_unit_infos.empty()) + { + const CompileUnitInfo *first_comp_unit_info = &m_compile_unit_infos.front(); + const CompileUnitInfo *last_comp_unit_info = &m_compile_unit_infos.back(); + if (first_comp_unit_info <= comp_unit_info && comp_unit_info <= last_comp_unit_info) + return comp_unit_info - first_comp_unit_info; + } + return UINT32_MAX; +} + SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFileByOSOIndex (uint32_t oso_idx) { @@ -256,7 +270,12 @@ // Set a a pointer to this class to set our OSO DWARF file know // that the DWARF is being used along with a debug map and that // it will have the remapped sections that we do below. - ((SymbolFileDWARF *)comp_unit_info->oso_symbol_vendor->GetSymbolFile())->SetDebugMapSymfile(this); + SymbolFileDWARF *oso_symfile = (SymbolFileDWARF *)comp_unit_info->oso_symbol_vendor->GetSymbolFile(); + oso_symfile->SetDebugMapSymfile(this); + // Set the ID of the symbol file DWARF to the index of the OSO + // shifted left by 32 bits to provide a unique prefix for any + // UserID's that get created in the symbol file. + oso_symfile->SetID (((uint64_t)GetCompUnitInfoIndex(comp_unit_info) + 1ull) << 32ull); comp_unit_info->debug_map_sections_sp.reset(new SectionList); Symtab *exe_symtab = m_obj_file->GetSymtab(); @@ -622,11 +641,15 @@ Type* SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) { + const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); + SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); + if (oso_dwarf) + oso_dwarf->ResolveTypeUID (type_uid); return NULL; } lldb::clang_type_t -SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type) +SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type) { // We have a struct/union/class/enum that needs to be fully resolved. return NULL; @@ -1149,3 +1172,24 @@ } } +clang::DeclContext* +SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) +{ + const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); + SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); + if (oso_dwarf) + return oso_dwarf->GetClangDeclContextContainingTypeUID (type_uid); + return NULL; +} + +clang::DeclContext* +SymbolFileDWARFDebugMap::GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) +{ + const uint64_t oso_idx = GetOSOIndexFromUserID (type_uid); + SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx); + if (oso_dwarf) + return oso_dwarf->GetClangDeclContextForTypeUID (sc, type_uid); + return NULL; +} + + Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Wed Oct 19 13:09:39 2011 @@ -66,6 +66,8 @@ virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); + virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid); + virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid); virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); @@ -151,6 +153,11 @@ void InitOSO (); + static uint32_t + GetOSOIndexFromUserID (lldb::user_id_t uid) + { + return (uint32_t)((uid >> 32ull) - 1ull); + } bool GetFileSpecForSO (uint32_t oso_idx, lldb_private::FileSpec &file_spec); @@ -169,6 +176,9 @@ lldb_private::ObjectFile * GetObjectFileByOSOIndex (uint32_t oso_idx); + uint32_t + GetCompUnitInfoIndex (const CompileUnitInfo *comp_unit_info); + SymbolFileDWARF * GetSymbolFile (const lldb_private::SymbolContext& sc); Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Wed Oct 19 13:09:39 2011 @@ -89,7 +89,7 @@ const Block* parent_block = GetParent(); if (parent_block) { - s->Printf(", parent = {0x%8.8x}", parent_block->GetID()); + s->Printf(", parent = {0x%8.8llx}", parent_block->GetID()); } if (m_inlineInfoSP.get() != NULL) { @@ -194,7 +194,7 @@ Function *function = CalculateSymbolContextFunction(); if (function) function->DumpSymbolContext(s); - s->Printf(", Block{0x%8.8x}", GetID()); + s->Printf(", Block{0x%8.8llx}", GetID()); } void @@ -398,7 +398,7 @@ const Declaration &func_decl = func_type->GetDeclaration(); if (func_decl.GetLine()) { - log->Printf ("warning: %s/%s:%u block {0x%8.8x} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8x} in function {0x%8.8x} from %s/%s", + log->Printf ("warning: %s/%s:%u block {0x%8.8llx} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8llx} in function {0x%8.8llx} from %s/%s", func_decl.GetFile().GetDirectory().GetCString(), func_decl.GetFile().GetFilename().GetCString(), func_decl.GetLine(), @@ -413,7 +413,7 @@ } else { - log->Printf ("warning: block {0x%8.8x} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8x} in function {0x%8.8x} from %s/%s", + log->Printf ("warning: block {0x%8.8llx} has range[%u] [0x%llx - 0x%llx) which is not contained in parent block {0x%8.8llx} in function {0x%8.8llx} from %s/%s", GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr, Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Wed Oct 19 13:09:39 2011 @@ -73,7 +73,7 @@ CompileUnit::DumpSymbolContext(Stream *s) { GetModule()->DumpSymbolContext(s); - s->Printf(", CompileUnit{0x%8.8x}", GetID()); + s->Printf(", CompileUnit{0x%8.8llx}", GetID()); } Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Wed Oct 19 13:09:39 2011 @@ -367,7 +367,7 @@ } else if (m_type_uid != LLDB_INVALID_UID) { - s->Printf(", type_uid = 0x%8.8x", m_type_uid); + s->Printf(", type_uid = 0x%8.8llx", m_type_uid); } s->EOL(); @@ -423,7 +423,7 @@ Function::DumpSymbolContext(Stream *s) { m_comp_unit->DumpSymbolContext(s); - s->Printf(", Function{0x%8.8x}", GetID()); + s->Printf(", Function{0x%8.8llx}", GetID()); } size_t Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Wed Oct 19 13:09:39 2011 @@ -20,8 +20,8 @@ Symbol::Symbol() : - UserID (), SymbolContextScope (), + m_uid (UINT32_MAX), m_mangled (), m_type (eSymbolTypeInvalid), m_type_data (0), @@ -39,7 +39,7 @@ Symbol::Symbol ( - user_id_t symID, + uint32_t symID, const char *name, bool name_is_mangled, SymbolType type, @@ -52,8 +52,8 @@ uint32_t size, uint32_t flags ) : - UserID (symID), SymbolContextScope (), + m_uid (symID), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -71,7 +71,7 @@ Symbol::Symbol ( - user_id_t symID, + uint32_t symID, const char *name, bool name_is_mangled, SymbolType type, @@ -82,8 +82,8 @@ const AddressRange &range, uint32_t flags ) : - UserID (symID), SymbolContextScope (), + m_uid (symID), m_mangled (name, name_is_mangled), m_type (type), m_type_data (0), @@ -100,8 +100,8 @@ } Symbol::Symbol(const Symbol& rhs): - UserID (rhs), SymbolContextScope (rhs), + m_uid (rhs.m_uid), m_mangled (rhs.m_mangled), m_type (rhs.m_type), m_type_data (rhs.m_type_data), @@ -123,7 +123,7 @@ if (this != &rhs) { SymbolContextScope::operator= (rhs); - UserID::operator= (rhs); + m_uid = rhs.m_uid; m_mangled = rhs.m_mangled; m_type = rhs.m_type; m_type_data = rhs.m_type_data; @@ -140,6 +140,24 @@ return *this; } +void +Symbol::Clear() +{ + m_uid = UINT32_MAX; + m_mangled.Clear(); + m_type = eSymbolTypeInvalid; + m_type_data = 0; + m_type_data_resolved = false; + m_is_synthetic = false; + m_is_debug = false; + m_is_external = false; + m_size_is_sibling = false; + m_size_is_synthesized = false; + m_searched_for_function = false; + m_addr_range.Clear(); + m_flags = 0; +} + AddressRange * Symbol::GetAddressRangePtr() { Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Wed Oct 19 13:09:39 2011 @@ -500,7 +500,7 @@ if (log) { - log->Printf ("warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx", + log->Printf ("warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx", curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); } #ifdef LLDB_CONFIGURATION_DEBUG @@ -519,7 +519,7 @@ } if (objfile) { - fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx in %s/%s\n", + fprintf (stderr, "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx in %s/%s\n", curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress(), objfile->GetFileSpec().GetDirectory().GetCString(), @@ -527,7 +527,7 @@ } else { - fprintf (stderr, "warning: inlined block 0x%8.8x doesn't have a range that contains file address 0x%llx\n", + fprintf (stderr, "warning: inlined block 0x%8.8llx doesn't have a range that contains file address 0x%llx\n", curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); } } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Wed Oct 19 13:09:39 2011 @@ -228,7 +228,7 @@ { s->PutChar('('); if (verbose) - s->Printf("Type{0x%8.8x} ", GetID()); + s->Printf("Type{0x%8.8llx} ", GetID()); DumpTypeName (s); s->PutCString(") "); } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Oct 19 13:09:39 2011 @@ -1340,7 +1340,7 @@ } else { - error.SetErrorStringWithFormat("invalid breakpoint site ID: %i", break_id); + error.SetErrorStringWithFormat("invalid breakpoint site ID: %llu", break_id); } return error; @@ -1358,7 +1358,7 @@ } else { - error.SetErrorStringWithFormat("invalid breakpoint site ID: %i", break_id); + error.SetErrorStringWithFormat("invalid breakpoint site ID: %llu", break_id); } return error; } @@ -1540,7 +1540,7 @@ addr_t bp_addr = bp_site->GetLoadAddress(); lldb::user_id_t breakID = bp_site->GetID(); if (log) - log->Printf ("Process::DisableBreakpoint (breakID = %d) addr = 0x%llx", breakID, (uint64_t)bp_addr); + log->Printf ("Process::DisableBreakpoint (breakID = %llu) addr = 0x%llx", breakID, (uint64_t)bp_addr); if (bp_site->IsHardware()) { @@ -2718,7 +2718,7 @@ // Create a thread that watches our internal state and controls which // events make it to clients (into the DCProcess event queue). char thread_name[1024]; - snprintf(thread_name, sizeof(thread_name), "", GetID()); + snprintf(thread_name, sizeof(thread_name), "", GetID()); m_private_state_thread = Host::ThreadCreate (thread_name, Process::PrivateStateThread, this, NULL); return IS_VALID_LLDB_HOST_THREAD(m_private_state_thread); } @@ -2823,7 +2823,7 @@ { if (log) { - log->Printf ("Process::%s (pid = %i) broadcasting new state %s (old state %s) to %s", + log->Printf ("Process::%s (pid = %llu) broadcasting new state %s (old state %s) to %s", __FUNCTION__, GetID(), StateAsCString(new_state), @@ -2842,7 +2842,7 @@ { if (log) { - log->Printf ("Process::%s (pid = %i) suppressing state %s (old state %s): should_broadcast == false", + log->Printf ("Process::%s (pid = %llu) suppressing state %s (old state %s): should_broadcast == false", __FUNCTION__, GetID(), StateAsCString(new_state), @@ -2867,7 +2867,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) - log->Printf ("Process::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, this, GetID()); + log->Printf ("Process::%s (arg = %p, pid = %llu) thread starting...", __FUNCTION__, this, GetID()); bool exit_now = false; while (!exit_now) @@ -2893,7 +2893,7 @@ } if (log) - log->Printf ("Process::%s (arg = %p, pid = %i) got a control event: %d", __FUNCTION__, this, GetID(), event_sp->GetType()); + log->Printf ("Process::%s (arg = %p, pid = %llu) got a control event: %d", __FUNCTION__, this, GetID(), event_sp->GetType()); m_private_state_control_wait.SetValue (true, eBroadcastAlways); continue; @@ -2912,7 +2912,7 @@ internal_state == eStateDetached ) { if (log) - log->Printf ("Process::%s (arg = %p, pid = %i) about to exit with internal state %s...", __FUNCTION__, this, GetID(), StateAsCString(internal_state)); + log->Printf ("Process::%s (arg = %p, pid = %llu) about to exit with internal state %s...", __FUNCTION__, this, GetID(), StateAsCString(internal_state)); break; } @@ -2920,7 +2920,7 @@ // Verify log is still enabled before attempting to write to it... if (log) - log->Printf ("Process::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, this, GetID()); + log->Printf ("Process::%s (arg = %p, pid = %llu) thread exiting...", __FUNCTION__, this, GetID()); m_private_state_control_wait.SetValue (true, eBroadcastAlways); m_private_state_thread = LLDB_INVALID_HOST_THREAD; @@ -3043,7 +3043,7 @@ Process::ProcessEventData::Dump (Stream *s) const { if (m_process_sp) - s->Printf(" process = %p (pid = %u), ", m_process_sp.get(), m_process_sp->GetID()); + s->Printf(" process = %p (pid = %llu), ", m_process_sp.get(), m_process_sp->GetID()); s->Printf("state = %s", StateAsCString(GetState())); } @@ -3433,7 +3433,7 @@ { StreamString s; thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".", + log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4llx to run thread plan \"%s\".", thread->GetIndexID(), thread->GetID(), s.GetData()); @@ -3830,7 +3830,7 @@ continue; } - ts.Printf("<0x%4.4x ", thread->GetID()); + ts.Printf("<0x%4.4llx ", thread->GetID()); RegisterContext *register_context = thread->GetRegisterContext().get(); if (register_context) @@ -3967,7 +3967,7 @@ { int exit_status = GetExitStatus(); const char *exit_description = GetExitDescription(); - strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + strm.Printf ("Process %llu exited with status = %i (0x%8.8x) %s\n", GetID(), exit_status, exit_status, @@ -3978,12 +3978,12 @@ if (state == eStateConnected) strm.Printf ("Connected to remote target.\n"); else - strm.Printf ("Process %d %s\n", GetID(), StateAsCString (state)); + strm.Printf ("Process %llu %s\n", GetID(), StateAsCString (state)); } } else { - strm.Printf ("Process %d is running.\n", GetID()); + strm.Printf ("Process %llu is running.\n", GetID()); } } Modified: lldb/trunk/source/Target/StackID.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackID.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/StackID.cpp (original) +++ lldb/trunk/source/Target/StackID.cpp Wed Oct 19 13:09:39 2011 @@ -31,7 +31,7 @@ m_symbol_scope->CalculateSymbolContext (&sc); if (sc.block) - s->Printf(" (Block {0x%8.8x})", sc.block->GetID()); + s->Printf(" (Block {0x%8.8llx})", sc.block->GetID()); else if (sc.symbol) s->Printf(" (Symbol{0x%8.8x})", sc.symbol->GetID()); } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Oct 19 13:09:39 2011 @@ -1736,7 +1736,7 @@ } if (print_hook_header && !any_thread_matched) { - result.AppendMessageWithFormat("\n- Hook %d\n", cur_hook_sp->GetID()); + result.AppendMessageWithFormat("\n- Hook %llu\n", cur_hook_sp->GetID()); any_thread_matched = true; } @@ -1760,7 +1760,7 @@ if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) || (result.GetStatus() == eReturnStatusSuccessContinuingResult)) { - result.AppendMessageWithFormat ("Aborting stop hooks, hook %d set the program running.", cur_hook_sp->GetID()); + result.AppendMessageWithFormat ("Aborting stop hooks, hook %llu set the program running.", cur_hook_sp->GetID()); keep_going = false; } } @@ -1857,7 +1857,7 @@ s->SetIndentLevel(indent_level + 2); - s->Printf ("Hook: %d\n", GetID()); + s->Printf ("Hook: %llu\n", GetID()); if (m_active) s->Indent ("State: enabled\n"); else Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Wed Oct 19 13:09:39 2011 @@ -65,7 +65,7 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Thread::Thread(tid = 0x%4.4x)", this, GetID()); + log->Printf ("%p Thread::Thread(tid = 0x%4.4llx)", this, GetID()); QueueFundamentalPlan(true); UpdateInstanceName(); @@ -76,7 +76,7 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) - log->Printf ("%p Thread::~Thread(tid = 0x%4.4x)", this, GetID()); + log->Printf ("%p Thread::~Thread(tid = 0x%4.4llx)", this, GetID()); /// If you hit this assert, it means your derived class forgot to call DoDestroy in its destructor. assert (m_destroy_called); } @@ -373,7 +373,7 @@ if (thread_state == eStateSuspended || thread_state == eStateInvalid) { if (log) - log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote %i (state was suspended or invalid)\n", GetID(), eVoteNoOpinion); + log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4llx: returning vote %i (state was suspended or invalid)\n", GetID(), eVoteNoOpinion); return eVoteNoOpinion; } @@ -381,13 +381,13 @@ { // Don't use GetCompletedPlan here, since that suppresses private plans. if (log) - log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote for complete stack's back plan\n", GetID()); + log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4llx: returning vote for complete stack's back plan\n", GetID()); return m_completed_plan_stack.back()->ShouldReportStop (event_ptr); } else { if (log) - log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4x: returning vote for current plan\n", GetID()); + log->Printf ("Thread::ShouldReportStop() tid = 0x%4.4llx: returning vote for current plan\n", GetID()); return GetCurrentPlan()->ShouldReportStop (event_ptr); } } @@ -408,7 +408,7 @@ { // Don't use GetCompletedPlan here, since that suppresses private plans. if (log) - log->Printf ("Current Plan for thread %d (0x%4.4x): %s being asked whether we should report run.", + log->Printf ("Current Plan for thread %d (0x%4.4llx): %s being asked whether we should report run.", GetIndexID(), GetID(), m_completed_plan_stack.back()->GetName()); @@ -418,7 +418,7 @@ else { if (log) - log->Printf ("Current Plan for thread %d (0x%4.4x): %s being asked whether we should report run.", + log->Printf ("Current Plan for thread %d (0x%4.4llx): %s being asked whether we should report run.", GetIndexID(), GetID(), GetCurrentPlan()->GetName()); @@ -453,7 +453,7 @@ { StreamString s; thread_plan_sp->GetDescription (&s, lldb::eDescriptionLevelFull); - log->Printf("Pushing plan: \"%s\", tid = 0x%4.4x.", + log->Printf("Pushing plan: \"%s\", tid = 0x%4.4llx.", s.GetData(), thread_plan_sp->GetThread().GetID()); } @@ -472,7 +472,7 @@ ThreadPlanSP &plan = m_plan_stack.back(); if (log) { - log->Printf("Popping plan: \"%s\", tid = 0x%4.4x.", plan->GetName(), plan->GetThread().GetID()); + log->Printf("Popping plan: \"%s\", tid = 0x%4.4llx.", plan->GetName(), plan->GetThread().GetID()); } m_completed_plan_stack.push_back (plan); plan->WillPop(); @@ -614,7 +614,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (log) { - log->Printf("Discarding thread plans for thread tid = 0x%4.4x, up to %p", GetID(), up_to_plan_sp.get()); + log->Printf("Discarding thread plans for thread tid = 0x%4.4llx, up to %p", GetID(), up_to_plan_sp.get()); } int stack_size = m_plan_stack.size(); @@ -655,7 +655,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (log) { - log->Printf("Discarding thread plans for thread (tid = 0x%4.4x, force %d)", GetID(), force); + log->Printf("Discarding thread plans for thread (tid = 0x%4.4llx, force %d)", GetID(), force); } if (force) @@ -864,7 +864,7 @@ uint32_t stack_size = m_plan_stack.size(); int i; s->Indent(); - s->Printf ("Plan Stack for thread #%u: tid = 0x%4.4x, stack_size = %d\n", GetIndexID(), GetID(), stack_size); + s->Printf ("Plan Stack for thread #%u: tid = 0x%4.4llx, stack_size = %d\n", GetIndexID(), GetID(), stack_size); for (i = stack_size - 1; i >= 0; i--) { s->IndentMore(); Modified: lldb/trunk/source/Target/ThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadList.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadList.cpp (original) +++ lldb/trunk/source/Target/ThreadList.cpp Wed Oct 19 13:09:39 2011 @@ -202,7 +202,7 @@ if (thread_sp->GetResumeState () == eStateSuspended) { if (log) - log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since thread was suspended)", + log->Printf ("ThreadList::%s for tid = 0x%4.4llx, pc = 0x%16.16llx, should_stop = 0 (ignore since thread was suspended)", __FUNCTION__, thread_sp->GetID (), thread_sp->GetRegisterContext()->GetPC()); @@ -212,7 +212,7 @@ if (thread_sp->ThreadStoppedForAReason() == false) { if (log) - log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx, should_stop = 0 (ignore since no stop reason)", + log->Printf ("ThreadList::%s for tid = 0x%4.4llx, pc = 0x%16.16llx, should_stop = 0 (ignore since no stop reason)", __FUNCTION__, thread_sp->GetID (), thread_sp->GetRegisterContext()->GetPC()); @@ -220,7 +220,7 @@ } if (log) - log->Printf ("ThreadList::%s for tid = 0x%4.4x, pc = 0x%16.16llx", + log->Printf ("ThreadList::%s for tid = 0x%4.4llx, pc = 0x%16.16llx", __FUNCTION__, thread_sp->GetID (), thread_sp->GetRegisterContext()->GetPC()); @@ -267,7 +267,7 @@ { const Vote vote = thread_sp->ShouldReportStop (event_ptr); if (log) - log->Printf ("ThreadList::%s thread 0x%4.4x: pc = 0x%16.16llx, vote = %s", + log->Printf ("ThreadList::%s thread 0x%4.4llx: pc = 0x%16.16llx, vote = %s", __FUNCTION__, thread_sp->GetID (), thread_sp->GetRegisterContext()->GetPC(), @@ -289,7 +289,7 @@ else { if (log) - log->Printf ("ThreadList::%s thread 0x%4.4x: pc = 0x%16.16llx voted %s, but lost out because result was %s", + log->Printf ("ThreadList::%s thread 0x%4.4llx: pc = 0x%16.16llx voted %s, but lost out because result was %s", __FUNCTION__, thread_sp->GetID (), thread_sp->GetRegisterContext()->GetPC(), @@ -334,7 +334,7 @@ break; case eVoteNo: if (log) - log->Printf ("ThreadList::ShouldReportRun() thread %d (0x%4.4x) says don't report.", + log->Printf ("ThreadList::ShouldReportRun() thread %d (0x%4.4llx) says don't report.", (*pos)->GetIndexID(), (*pos)->GetID()); result = eVoteNo; Modified: lldb/trunk/source/Target/ThreadPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlan.cpp (original) +++ lldb/trunk/source/Target/ThreadPlan.cpp Wed Oct 19 13:09:39 2011 @@ -153,7 +153,7 @@ addr_t pc = reg_ctx->GetPC(); addr_t sp = reg_ctx->GetSP(); addr_t fp = reg_ctx->GetFP(); - log->Printf("%s Thread #%u: tid = 0x%4.4x, pc = 0x%8.8llx, sp = 0x%8.8llx, fp = 0x%8.8llx, plan = '%s', state = %s, stop others = %d", + log->Printf("%s Thread #%u: tid = 0x%4.4llx, pc = 0x%8.8llx, sp = 0x%8.8llx, fp = 0x%8.8llx, plan = '%s', state = %s, stop others = %d", __FUNCTION__, m_thread.GetIndexID(), m_thread.GetID(), Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanBase.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanBase.cpp Wed Oct 19 13:09:39 2011 @@ -106,7 +106,7 @@ // at this point. Don't force the discard, however, so Master plans can stay // in place if they want to. if (log) - log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (breakpoint hit.)", m_thread.GetID()); + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4llx (breakpoint hit.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; } @@ -134,7 +134,7 @@ // If we crashed, discard thread plans and stop. Don't force the discard, however, // since on rerun the target may clean up this exception and continue normally from there. if (log) - log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (exception.)", m_thread.GetID()); + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4llx (exception.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; @@ -142,7 +142,7 @@ if (stop_info_sp->ShouldStop(event_ptr)) { if (log) - log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4x (signal.)", m_thread.GetID()); + log->Printf("Base plan discarding thread plans for thread tid = 0x%4.4llx (signal.)", m_thread.GetID()); m_thread.DiscardThreadPlans(false); return true; } Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Oct 19 13:09:39 2011 @@ -292,7 +292,7 @@ abi->GetReturnValue(m_thread, *m_return_value_sp); } if (log) - log->Printf ("DoTakedown called for thread 0x%4.4x, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); + log->Printf ("DoTakedown called for thread 0x%4.4llx, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); m_takedown_done = true; m_real_stop_info_sp = GetPrivateStopReason(); m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state); @@ -305,7 +305,7 @@ else { if (log) - log->Printf ("DoTakedown called as no-op for thread 0x%4.4x, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); + log->Printf ("DoTakedown called as no-op for thread 0x%4.4llx, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); } } Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Wed Oct 19 13:09:39 2011 @@ -152,7 +152,7 @@ } s->Address(m_addresses[i], sizeof (addr_t)); - s->Printf (" using breakpoint: %d - ", m_break_ids[i]); + s->Printf (" using breakpoint: %llu - ", m_break_ids[i]); Breakpoint *breakpoint = m_thread.GetProcess().GetTarget().GetBreakpointByID (m_break_ids[i]).get(); if (breakpoint) breakpoint->Dump (s); Modified: lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp?rev=142534&r1=142533&r2=142534&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp Wed Oct 19 13:09:39 2011 @@ -48,7 +48,7 @@ void ThreadPlanStepOverBreakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level) { - s->Printf("Single stepping past breakpoint site %d at 0x%llx", m_breakpoint_site_id, (uint64_t)m_breakpoint_addr); + s->Printf("Single stepping past breakpoint site %llu at 0x%llx", m_breakpoint_site_id, (uint64_t)m_breakpoint_addr); } bool From johnny.chen at apple.com Wed Oct 19 15:51:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 19 Oct 2011 20:51:28 -0000 Subject: [Lldb-commits] [lldb] r142543 - in /lldb/trunk/test/functionalities/watchpoint: hello_watchpoint/TestMyFirstWatchpoint.py watchpoint_commands/TestWatchpointCommands.py Message-ID: <20111019205129.055F53128018@llvm.org> Author: johnny Date: Wed Oct 19 15:51:28 2011 New Revision: 142543 URL: http://llvm.org/viewvc/llvm-project?rev=142543&view=rev Log: Temporarily relax the expected substrings for watchpoint creation output due a bug in the decl file info of a global variable emitted by clang. Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py Modified: lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py?rev=142543&r1=142542&r2=142543&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py (original) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py Wed Oct 19 15:51:28 2011 @@ -60,7 +60,8 @@ # There should be only one watchpoint hit (see main.c). self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py?rev=142543&r1=142542&r2=142543&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py Wed Oct 19 15:51:28 2011 @@ -113,7 +113,8 @@ # There should be two watchpoint hits (see main.c). self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. @@ -169,7 +170,8 @@ # There should be two watchpoint hits (see main.c). self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Delete the watchpoint immediately, but set auto-confirm to true first. self.runCmd("settings set auto-confirm true") @@ -211,7 +213,8 @@ # There should be two watchpoint hits (see main.c). self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Set the ignore count of the watchpoint immediately. self.expect("watchpoint ignore -i 2", @@ -257,7 +260,8 @@ # There should be two watchpoint hits (see main.c). self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Use the '-v' option to do verbose listing of the watchpoint. # The hit count should be 0 initially. @@ -316,7 +320,8 @@ # There should be two watchpoint hits (see main.c). self.expect("frame variable -w read_write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = rw', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) # Immediately, we disable the watchpoint. We won't be stopping due to a # watchpoint after this. From johnny.chen at apple.com Wed Oct 19 17:17:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 19 Oct 2011 22:17:06 -0000 Subject: [Lldb-commits] [lldb] r142549 - /lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py Message-ID: <20111019221706.EF2D72A6C12C@llvm.org> Author: johnny Date: Wed Oct 19 17:17:06 2011 New Revision: 142549 URL: http://llvm.org/viewvc/llvm-project?rev=142549&view=rev Log: Missed this file when doing r142543 to temporarily relax the expected substrings for watchpoint creation output. Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py Modified: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py?rev=142549&r1=142548&r2=142549&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py (original) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/condition/TestWatchpointConditionCmd.py Wed Oct 19 17:17:06 2011 @@ -60,7 +60,8 @@ # With a condition of 'global==5'. self.expect("frame variable -w write -g -L global", WATCHPOINT_CREATED, substrs = ['Watchpoint created', 'size = 4', 'type = w', - '%s:%d' % (self.source, self.decl)]) + #'%s:%d' % (self.source, self.decl)]) + ':%d' % (self.decl)]) self.runCmd("watchpoint modify -c 'global==5'") From gclayton at apple.com Wed Oct 19 19:47:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 20 Oct 2011 00:47:21 -0000 Subject: [Lldb-commits] [lldb] r142561 - in /lldb/trunk: include/lldb/Expression/ASTDumper.h source/Expression/ASTDumper.cpp source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111020004721.44F8F2A6C12C@llvm.org> Author: gclayton Date: Wed Oct 19 19:47:21 2011 New Revision: 142561 URL: http://llvm.org/viewvc/llvm-project?rev=142561&view=rev Log: Modified the ASTDumper to return a "const char *" instead of a copy of the std::string and modified all places that used the std::string it returned to use the "const char *". Also modified the expression parser to not crash when a function type fails to copy into the expression AST context. Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h lldb/trunk/source/Expression/ASTDumper.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ASTDumper.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTDumper.h?rev=142561&r1=142560&r2=142561&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTDumper.h (original) +++ lldb/trunk/include/lldb/Expression/ASTDumper.h Wed Oct 19 19:47:21 2011 @@ -26,7 +26,7 @@ ASTDumper (clang::QualType type); ASTDumper (lldb::clang_type_t type); - std::string AsString(); + const char *GetCString(); void ToSTDERR(); void ToLog(lldb::LogSP &log, const char *prefix); void ToStream(lldb::StreamSP &stream); Modified: lldb/trunk/source/Expression/ASTDumper.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTDumper.cpp?rev=142561&r1=142560&r2=142561&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTDumper.cpp (original) +++ lldb/trunk/source/Expression/ASTDumper.cpp Wed Oct 19 19:47:21 2011 @@ -78,9 +78,10 @@ m_dump = clang::QualType::getFromOpaquePtr(type).getAsString(); } -std::string ASTDumper::AsString() +const char * +ASTDumper::GetCString() { - return m_dump; + return m_dump.c_str(); } void ASTDumper::ToSTDERR() Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142561&r1=142560&r2=142561&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Oct 19 19:47:21 2011 @@ -2180,8 +2180,8 @@ if (log) { - std::string type_string = ASTDumper(pointer_target_qual_type).AsString(); - log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, type_string.c_str()); + ASTDumper ast_dumper(pointer_target_qual_type); + log->Printf(" FEVD[%u] Adding type for $__lldb_class: %s", current_id, ast_dumper.GetCString()); } AddOneType(context, class_user_type, current_id, true); @@ -2231,8 +2231,8 @@ if (log) { - std::string type_string = ASTDumper(pointer_target_type).AsString(); - log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, type_string.c_str()); + ASTDumper ast_dumper(pointer_target_type); + log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", current_id, ast_dumper.GetCString()); } AddOneType(context, class_user_type, current_id, false); @@ -2591,12 +2591,11 @@ { if (log) { - std::string decl_print_string = ASTDumper(decl).AsString(); - + ASTDumper ast_dumper(decl); if (const NamedDecl *context_named_decl = dyn_cast(context_decl)) - log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), decl_print_string.c_str()); + log->Printf(" FELD[%d] Adding [to %s] lexical decl %s", current_id, context_named_decl->getNameAsString().c_str(), ast_dumper.GetCString()); else - log->Printf(" FELD[%d] Adding lexical decl %s", current_id, decl_print_string.c_str()); + log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString()); } Decl *copied_decl = ast_importer->CopyDecl(original_ctx, decl); @@ -2776,9 +2775,8 @@ if (log) { - std::string var_decl_print_string = ASTDumper(var_decl).AsString(); - - log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), var_decl_print_string.c_str()); + ASTDumper ast_dumper(var_decl); + log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString()); } } @@ -2806,9 +2804,8 @@ if (log) { - std::string var_decl_print_string = ASTDumper(var_decl).AsString(); - - log->Printf(" FEVD[%u] Added pvar %s, returned %s", current_id, pvar_sp->GetName().GetCString(), var_decl_print_string.c_str()); + ASTDumper ast_dumper(var_decl); + log->Printf(" FEVD[%u] Added pvar %s, returned %s", current_id, pvar_sp->GetName().GetCString(), ast_dumper.GetCString()); } } @@ -2865,9 +2862,9 @@ if (log) { - std::string var_decl_print_string = ASTDumper(var_decl).AsString(); + ASTDumper ast_dumper(var_decl); - log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), var_decl_print_string.c_str()); + log->Printf(" FEVD[%u] Found variable %s, returned %s", current_id, decl_name.c_str(), ast_dumper.GetCString()); } } @@ -2899,9 +2896,8 @@ if (log) { - std::string var_decl_print_string = ASTDumper((clang::Decl*)var_decl).AsString(); - - log->Printf("Variable of unknown type now has Decl %s", var_decl_print_string.c_str()); + ASTDumper ast_dumper(const_cast(var_decl)); + log->Printf("Variable of unknown type now has Decl %s", ast_dumper.GetCString()); } QualType var_type = var_decl->getType(); @@ -2962,9 +2958,8 @@ if (log && log->GetVerbose()) { - std::string var_decl_print_string = ASTDumper(var_decl).AsString(); - - log->Printf(" FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), var_decl_print_string.c_str()); + ASTDumper ast_dumper(var_decl); + log->Printf(" FEVD[%d] Added register %s, returned %s", current_id, context.m_decl_name.getAsString().c_str(), ast_dumper.GetCString()); } } @@ -3032,8 +3027,20 @@ fun_ast_context = fun_type->GetClangASTContext().getASTContext(); void *copied_type = GuardedCopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type); - - fun_decl = context.AddFunDecl(copied_type); + if (copied_type) + { + fun_decl = context.AddFunDecl(copied_type); + } + else + { + // We failed to copy the type we found + if (log) + { + log->Printf (" Failed to import the function type '%s' {0x%8.8llx} into the expression parser AST contenxt", + fun_type->GetName().GetCString(), + fun_type->GetID()); + } + } } else if (symbol) { @@ -3070,13 +3077,13 @@ if (log) { - std::string fun_decl_print_string = ASTDumper(fun_decl).AsString(); + ASTDumper ast_dumper(fun_decl); log->Printf(" FEVD[%u] Found %s function %s, returned %s", current_id, (fun ? "specific" : "generic"), decl_name.c_str(), - fun_decl_print_string.c_str()); + ast_dumper.GetCString()); } } From johnny.chen at apple.com Wed Oct 19 20:35:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 01:35:57 -0000 Subject: [Lldb-commits] [lldb] r142562 - /lldb/trunk/test/lldbbench.py Message-ID: <20111020013557.B85B22A6C12C@llvm.org> Author: johnny Date: Wed Oct 19 20:35:57 2011 New Revision: 142562 URL: http://llvm.org/viewvc/llvm-project?rev=142562&view=rev Log: Up until now, we have been using pexpect to spawn an lldb process and use lldb commands to bring the debugger to the desired state. This patch makes BenchBase inherit from TestBase, instead of Base (which is a parent class of TestBase). This is so that we can also enjoy the Pythonic way of bringing the lldb debugger to a desired state before running the benchmark and collect statistics. Modified: lldb/trunk/test/lldbbench.py Modified: lldb/trunk/test/lldbbench.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbbench.py?rev=142562&r1=142561&r2=142562&view=diff ============================================================================== --- lldb/trunk/test/lldbbench.py (original) +++ lldb/trunk/test/lldbbench.py Wed Oct 19 20:35:57 2011 @@ -1,7 +1,5 @@ import time -from lldbtest import Base -from lldbtest import benchmarks_test -from lldbtest import line_number +from lldbtest import * class Stopwatch(object): """Stopwatch provides a simple utility to start/stop your stopwatch multiple @@ -85,17 +83,19 @@ self.__laps__, self.__total_elapsed__) -class BenchBase(Base): +class BenchBase(TestBase): """ Abstract base class for benchmark tests. """ def setUp(self): """Fixture for unittest test case setup.""" - Base.setUp(self) + super(BenchBase, self).setUp() + #TestBase.setUp(self) self.stopwatch = Stopwatch() def tearDown(self): """Fixture for unittest test case teardown.""" - Base.tearDown(self) + super(BenchBase, self).setUp() + #TestBase.tearDown(self) del self.stopwatch From johnny.chen at apple.com Thu Oct 20 12:45:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 17:45:39 -0000 Subject: [Lldb-commits] [lldb] r142594 - /lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py Message-ID: <20111020174539.5EDFB3128026@llvm.org> Author: johnny Date: Thu Oct 20 12:45:39 2011 New Revision: 142594 URL: http://llvm.org/viewvc/llvm-project?rev=142594&view=rev Log: Remove stale code. Modified: lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py Modified: lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py?rev=142594&r1=142593&r2=142594&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py Thu Oct 20 12:45:39 2011 @@ -25,7 +25,7 @@ self.break_spec = '-F Driver::MainLoop()' else: self.break_spec = '-n main' - self.stepping_avg = None + #print "self.exe=%s" % self.exe #print "self.break_spec=%s" % self.break_spec @@ -69,9 +69,6 @@ except: pass - self.stepping_avg = self.stopwatch.avg() - if self.TraceOn(): - print "lldb stepping benchmark:", str(self.stopwatch) self.child = None From johnny.chen at apple.com Thu Oct 20 12:49:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 17:49:45 -0000 Subject: [Lldb-commits] [lldb] r142595 - /lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Message-ID: <20111020174945.186E33128026@llvm.org> Author: johnny Date: Thu Oct 20 12:49:44 2011 New Revision: 142595 URL: http://llvm.org/viewvc/llvm-project?rev=142595&view=rev Log: Remove stale code. Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py?rev=142595&r1=142594&r2=142595&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Thu Oct 20 12:49:44 2011 @@ -12,7 +12,6 @@ def setUp(self): BenchBase.setUp(self) - self.stepping_avg = None @benchmarks_test def test_lldb_runhooks_then_steppings(self): @@ -54,9 +53,6 @@ except: pass - self.stepping_avg = self.stopwatch.avg() - if self.TraceOn(): - print "lldb stepping benchmark:", str(self.stopwatch) self.child = None From johnny.chen at apple.com Thu Oct 20 13:43:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 18:43:28 -0000 Subject: [Lldb-commits] [lldb] r142598 - in /lldb/trunk/test: benchmarks/disassembly/TestDisassembly.py benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py benchmarks/example/TestRepeatedExprs.py benchmarks/stepping/TestRunHooksThenSteppings.py benchmarks/stepping/TestSteppingSpeed.py dotest.py Message-ID: <20111020184328.E22273128026@llvm.org> Author: johnny Date: Thu Oct 20 13:43:28 2011 New Revision: 142598 URL: http://llvm.org/viewvc/llvm-project?rev=142598&view=rev Log: Parameterize the iteration count used when running benchmarks, instead of hard-coded inside the test case. Add a '-y count' option to the test driver for this purpose. An example: $ ./dotest.py -v -y 25 +b -p TestDisassembly.py ... ---------------------------------------------------------------------- Collected 2 tests 1: test_run_gdb_then_lldb (TestDisassembly.DisassembleDriverMainLoop) Test disassembly on a large function with lldb vs. gdb. ... gdb benchmark: Avg: 0.226305 (Laps: 25, Total Elapsed Time: 5.657614) lldb benchmark: Avg: 0.113864 (Laps: 25, Total Elapsed Time: 2.846606) lldb_avg/gdb_avg: 0.503146 ok 2: test_run_lldb_then_gdb (TestDisassembly.DisassembleDriverMainLoop) Test disassembly on a large function with lldb vs. gdb. ... lldb benchmark: Avg: 0.113008 (Laps: 25, Total Elapsed Time: 2.825201) gdb benchmark: Avg: 0.225240 (Laps: 25, Total Elapsed Time: 5.631001) lldb_avg/gdb_avg: 0.501723 ok ---------------------------------------------------------------------- Ran 2 tests in 41.346s OK Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py lldb/trunk/test/dotest.py Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py Thu Oct 20 13:43:28 2011 @@ -16,14 +16,17 @@ self.function = 'Driver::MainLoop()' self.lldb_avg = None self.gdb_avg = None + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 5 @benchmarks_test def test_run_lldb_then_gdb(self): """Test disassembly on a large function with lldb vs. gdb.""" print - self.run_lldb_disassembly(self.exe, self.function, 5) + self.run_lldb_disassembly(self.exe, self.function, self.count) print "lldb benchmark:", self.stopwatch - self.run_gdb_disassembly(self.exe, self.function, 5) + self.run_gdb_disassembly(self.exe, self.function, self.count) print "gdb benchmark:", self.stopwatch print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg) @@ -31,9 +34,9 @@ def test_run_gdb_then_lldb(self): """Test disassembly on a large function with lldb vs. gdb.""" print - self.run_gdb_disassembly(self.exe, self.function, 5) + self.run_gdb_disassembly(self.exe, self.function, self.count) print "gdb benchmark:", self.stopwatch - self.run_lldb_disassembly(self.exe, self.function, 5) + self.run_lldb_disassembly(self.exe, self.function, self.count) print "lldb benchmark:", self.stopwatch print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg) Modified: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Thu Oct 20 13:43:28 2011 @@ -18,15 +18,18 @@ self.function = 'Driver::MainLoop()' self.gdb_41_avg = None self.gdb_42_avg = None + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 5 @benchmarks_test def test_run_41_then_42(self): """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" print - self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, 5) + self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, self.count) print "4.1 gdb benchmark:", self.stopwatch self.gdb_41_avg = self.stopwatch.avg() - self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, 5) + self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, self.count) print "4.2 gdb benchmark:", self.stopwatch self.gdb_42_avg = self.stopwatch.avg() print "gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg) @@ -35,10 +38,10 @@ def test_run_42_then_41(self): """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" print - self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, 5) + self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, self.count) print "4.2 gdb benchmark:", self.stopwatch self.gdb_42_avg = self.stopwatch.avg() - self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, 5) + self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, self.count) print "4.1 gdb benchmark:", self.stopwatch self.gdb_41_avg = self.stopwatch.avg() print "gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg) Modified: lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (original) +++ lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py Thu Oct 20 13:43:28 2011 @@ -16,6 +16,9 @@ self.line_to_break = line_number(self.source, '// Set breakpoint here.') self.lldb_avg = None self.gdb_avg = None + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 100 @benchmarks_test def test_compare_lldb_to_gdb(self): @@ -24,9 +27,9 @@ self.exe_name = 'a.out' print - self.run_lldb_repeated_exprs(self.exe_name, 100) + self.run_lldb_repeated_exprs(self.exe_name, self.count) print "lldb benchmark:", self.stopwatch - self.run_gdb_repeated_exprs(self.exe_name, 100) + self.run_gdb_repeated_exprs(self.exe_name, self.count) print "gdb benchmark:", self.stopwatch print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg) Modified: lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestRunHooksThenSteppings.py Thu Oct 20 13:43:28 2011 @@ -12,12 +12,15 @@ def setUp(self): BenchBase.setUp(self) + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 50 @benchmarks_test def test_lldb_runhooks_then_steppings(self): """Test lldb steppings on a large executable.""" print - self.run_lldb_runhooks_then_steppings(50) + self.run_lldb_runhooks_then_steppings(self.count) print "lldb stepping benchmark:", self.stopwatch def run_lldb_runhooks_then_steppings(self, count): Modified: lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py (original) +++ lldb/trunk/test/benchmarks/stepping/TestSteppingSpeed.py Thu Oct 20 13:43:28 2011 @@ -26,6 +26,10 @@ else: self.break_spec = '-n main' + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 50 + #print "self.exe=%s" % self.exe #print "self.break_spec=%s" % self.break_spec @@ -33,7 +37,7 @@ def test_run_lldb_steppings(self): """Test lldb steppings on a large executable.""" print - self.run_lldb_steppings(self.exe, self.break_spec, 50) + self.run_lldb_steppings(self.exe, self.break_spec, self.count) print "lldb stepping benchmark:", self.stopwatch def run_lldb_steppings(self, exe, break_spec, count): Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=142598&r1=142597&r2=142598&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Oct 20 13:43:28 2011 @@ -107,6 +107,8 @@ bmExecutable = None # The breakpoint specification of bmExecutable, as specified by the '-x' option. bmBreakpointSpec = None +# The benchamrk iteration count, as specified by the '-y' option. +bmIterationCount = -1 # By default, failfast is False. Use '-F' to overwrite it. failfast = False @@ -210,6 +212,9 @@ -v : do verbose mode of unittest framework (print out each test case invocation) -x : specify the breakpoint specification for the benchmark executable; see also '-e', which provides the full path of the executable +-y : specify the iteration count used to collect our benchmarks; an example is + the number of times to do 'thread step-over' to measure stepping speed + see also '-e' and '-x' options -w : insert some wait time (currently 0.5 sec) between consecutive test cases -# : Repeat the test suite for a specified number of times @@ -321,6 +326,7 @@ global dumpSysPath global bmExecutable global bmBreakpointSpec + global bmIterationCount global failfast global filters global fs4all @@ -478,6 +484,13 @@ usage() bmBreakpointSpec = sys.argv[index] index += 1 + elif sys.argv[index].startswith('-y'): + # Increment by 1 to fetch the the benchmark iteration count. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + bmIterationCount = int(sys.argv[index]) + index += 1 elif sys.argv[index].startswith('-#'): # Increment by 1 to fetch the repeat count argument. index += 1 @@ -902,9 +915,10 @@ lldb.just_do_python_api_test = just_do_python_api_test lldb.just_do_benchmarks_test = just_do_benchmarks_test -# Put bmExecutable and bmBreakpointSpec into the lldb namespace, too. +# Put bmExecutable, bmBreakpointSpec, and bmIterationCount into the lldb namespace, too. lldb.bmExecutable = bmExecutable lldb.bmBreakpointSpec = bmBreakpointSpec +lldb.bmIterationCount = bmIterationCount # And don't forget the runHooks! lldb.runHooks = runHooks From johnny.chen at apple.com Thu Oct 20 13:57:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 18:57:05 -0000 Subject: [Lldb-commits] [lldb] r142601 - in /lldb/trunk/test/benchmarks/example: Makefile TestRepeatedExprs.py main.cpp Message-ID: <20111020185705.133513128026@llvm.org> Author: johnny Date: Thu Oct 20 13:57:04 2011 New Revision: 142601 URL: http://llvm.org/viewvc/llvm-project?rev=142601&view=rev Log: Directory renaming: example -> expression. Removed: lldb/trunk/test/benchmarks/example/Makefile lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py lldb/trunk/test/benchmarks/example/main.cpp Removed: lldb/trunk/test/benchmarks/example/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/Makefile?rev=142600&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/Makefile (original) +++ lldb/trunk/test/benchmarks/example/Makefile (removed) @@ -1,5 +0,0 @@ -LEVEL = ../../make - -CXX_SOURCES := main.cpp - -include $(LEVEL)/Makefile.rules Removed: lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py?rev=142600&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (original) +++ lldb/trunk/test/benchmarks/example/TestRepeatedExprs.py (removed) @@ -1,133 +0,0 @@ -"""Test evaluating expressions repeatedly comparing lldb against gdb.""" - -import os, sys -import unittest2 -import lldb -import pexpect -from lldbbench import * - -class RepeatedExprsCase(BenchBase): - - mydir = os.path.join("benchmarks", "example") - - def setUp(self): - BenchBase.setUp(self) - self.source = 'main.cpp' - self.line_to_break = line_number(self.source, '// Set breakpoint here.') - self.lldb_avg = None - self.gdb_avg = None - self.count = lldb.bmIterationCount - if self.count <= 0: - self.count = 100 - - @benchmarks_test - def test_compare_lldb_to_gdb(self): - """Test repeated expressions with lldb vs. gdb.""" - self.buildDefault() - self.exe_name = 'a.out' - - print - self.run_lldb_repeated_exprs(self.exe_name, self.count) - print "lldb benchmark:", self.stopwatch - self.run_gdb_repeated_exprs(self.exe_name, self.count) - print "gdb benchmark:", self.stopwatch - print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg) - - def run_lldb_repeated_exprs(self, exe_name, count): - exe = os.path.join(os.getcwd(), exe_name) - - # Set self.child_prompt, which is "(lldb) ". - self.child_prompt = '(lldb) ' - prompt = self.child_prompt - - # So that the child gets torn down after the test. - self.child = pexpect.spawn('%s %s %s' % (self.lldbExec, self.lldbOption, exe)) - child = self.child - - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - child.expect_exact(prompt) - child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break)) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact(prompt) - expr_cmd1 = 'expr ptr[j]->point.x' - expr_cmd2 = 'expr ptr[j]->point.y' - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - child.sendline(expr_cmd1) - child.expect_exact(prompt) - child.sendline(expr_cmd2) - child.expect_exact(prompt) - child.sendline('process continue') - child.expect_exact(prompt) - - child.sendline('quit') - try: - self.child.expect(pexpect.EOF) - except: - pass - - self.lldb_avg = self.stopwatch.avg() - if self.TraceOn(): - print "lldb expression benchmark:", str(self.stopwatch) - self.child = None - - def run_gdb_repeated_exprs(self, exe_name, count): - exe = os.path.join(os.getcwd(), exe_name) - - # Set self.child_prompt, which is "(gdb) ". - self.child_prompt = '(gdb) ' - prompt = self.child_prompt - - # So that the child gets torn down after the test. - self.child = pexpect.spawn('gdb --nx %s' % exe) - child = self.child - - # Turn on logging for what the child sends back. - if self.TraceOn(): - child.logfile_read = sys.stdout - - child.expect_exact(prompt) - child.sendline('break %s:%d' % (self.source, self.line_to_break)) - child.expect_exact(prompt) - child.sendline('run') - child.expect_exact(prompt) - expr_cmd1 = 'print ptr[j]->point.x' - expr_cmd2 = 'print ptr[j]->point.y' - - # Reset the stopwatch now. - self.stopwatch.reset() - for i in range(count): - with self.stopwatch: - child.sendline(expr_cmd1) - child.expect_exact(prompt) - child.sendline(expr_cmd2) - child.expect_exact(prompt) - child.sendline('continue') - child.expect_exact(prompt) - - child.sendline('quit') - child.expect_exact('The program is running. Exit anyway?') - child.sendline('y') - try: - self.child.expect(pexpect.EOF) - except: - pass - - self.gdb_avg = self.stopwatch.avg() - if self.TraceOn(): - print "gdb expression benchmark:", str(self.stopwatch) - self.child = None - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Removed: lldb/trunk/test/benchmarks/example/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/example/main.cpp?rev=142600&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/example/main.cpp (original) +++ lldb/trunk/test/benchmarks/example/main.cpp (removed) @@ -1,51 +0,0 @@ -//===-- main.cpp ------------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include - -class Point { -public: - int x; - int y; - Point(int a, int b): - x(a), - y(b) - {} -}; - -class Data { -public: - int id; - Point point; - Data(int i): - id(i), - point(0, 0) - {} -}; - -int main(int argc, char const *argv[]) { - Data *data[1000]; - Data **ptr = data; - for (int i = 0; i < 1000; ++i) { - ptr[i] = new Data(i); - ptr[i]->point.x = i; - ptr[i]->point.y = i+1; - } - - printf("Finished populating data.\n"); - for (int j = 0; j < 1000; ++j) { - bool dump = argc > 1; // Set breakpoint here. - // Evaluate a couple of expressions (2*1000 = 2000 exprs): - // expr ptr[j]->point.x - // expr ptr[j]->point.y - if (dump) { - printf("data[%d] = %d (%d, %d)\n", j, ptr[j]->id, ptr[j]->point.x, ptr[j]->point.y); - } - } - return 0; -} From johnny.chen at apple.com Thu Oct 20 13:58:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 18:58:28 -0000 Subject: [Lldb-commits] [lldb] r142602 - in /lldb/trunk/test/benchmarks/expression: ./ Makefile TestRepeatedExprs.py main.cpp Message-ID: <20111020185828.2D8063128026@llvm.org> Author: johnny Date: Thu Oct 20 13:58:28 2011 New Revision: 142602 URL: http://llvm.org/viewvc/llvm-project?rev=142602&view=rev Log: Directory renaming: example -> expression. Added: lldb/trunk/test/benchmarks/expression/ lldb/trunk/test/benchmarks/expression/Makefile lldb/trunk/test/benchmarks/expression/TestRepeatedExprs.py lldb/trunk/test/benchmarks/expression/main.cpp Added: lldb/trunk/test/benchmarks/expression/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/expression/Makefile?rev=142602&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/expression/Makefile (added) +++ lldb/trunk/test/benchmarks/expression/Makefile Thu Oct 20 13:58:28 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/benchmarks/expression/TestRepeatedExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/expression/TestRepeatedExprs.py?rev=142602&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/expression/TestRepeatedExprs.py (added) +++ lldb/trunk/test/benchmarks/expression/TestRepeatedExprs.py Thu Oct 20 13:58:28 2011 @@ -0,0 +1,133 @@ +"""Test evaluating expressions repeatedly comparing lldb against gdb.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class RepeatedExprsCase(BenchBase): + + mydir = os.path.join("benchmarks", "expression") + + def setUp(self): + BenchBase.setUp(self) + self.source = 'main.cpp' + self.line_to_break = line_number(self.source, '// Set breakpoint here.') + self.lldb_avg = None + self.gdb_avg = None + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 100 + + @benchmarks_test + def test_compare_lldb_to_gdb(self): + """Test repeated expressions with lldb vs. gdb.""" + self.buildDefault() + self.exe_name = 'a.out' + + print + self.run_lldb_repeated_exprs(self.exe_name, self.count) + print "lldb benchmark:", self.stopwatch + self.run_gdb_repeated_exprs(self.exe_name, self.count) + print "gdb benchmark:", self.stopwatch + print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg) + + def run_lldb_repeated_exprs(self, exe_name, count): + exe = os.path.join(os.getcwd(), exe_name) + + # Set self.child_prompt, which is "(lldb) ". + self.child_prompt = '(lldb) ' + prompt = self.child_prompt + + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s %s' % (self.lldbExec, self.lldbOption, exe)) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + child.expect_exact(prompt) + child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break)) + child.expect_exact(prompt) + child.sendline('run') + child.expect_exact(prompt) + expr_cmd1 = 'expr ptr[j]->point.x' + expr_cmd2 = 'expr ptr[j]->point.y' + + # Reset the stopwatch now. + self.stopwatch.reset() + for i in range(count): + with self.stopwatch: + child.sendline(expr_cmd1) + child.expect_exact(prompt) + child.sendline(expr_cmd2) + child.expect_exact(prompt) + child.sendline('process continue') + child.expect_exact(prompt) + + child.sendline('quit') + try: + self.child.expect(pexpect.EOF) + except: + pass + + self.lldb_avg = self.stopwatch.avg() + if self.TraceOn(): + print "lldb expression benchmark:", str(self.stopwatch) + self.child = None + + def run_gdb_repeated_exprs(self, exe_name, count): + exe = os.path.join(os.getcwd(), exe_name) + + # Set self.child_prompt, which is "(gdb) ". + self.child_prompt = '(gdb) ' + prompt = self.child_prompt + + # So that the child gets torn down after the test. + self.child = pexpect.spawn('gdb --nx %s' % exe) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + child.expect_exact(prompt) + child.sendline('break %s:%d' % (self.source, self.line_to_break)) + child.expect_exact(prompt) + child.sendline('run') + child.expect_exact(prompt) + expr_cmd1 = 'print ptr[j]->point.x' + expr_cmd2 = 'print ptr[j]->point.y' + + # Reset the stopwatch now. + self.stopwatch.reset() + for i in range(count): + with self.stopwatch: + child.sendline(expr_cmd1) + child.expect_exact(prompt) + child.sendline(expr_cmd2) + child.expect_exact(prompt) + child.sendline('continue') + child.expect_exact(prompt) + + child.sendline('quit') + child.expect_exact('The program is running. Exit anyway?') + child.sendline('y') + try: + self.child.expect(pexpect.EOF) + except: + pass + + self.gdb_avg = self.stopwatch.avg() + if self.TraceOn(): + print "gdb expression benchmark:", str(self.stopwatch) + self.child = None + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/benchmarks/expression/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/expression/main.cpp?rev=142602&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/expression/main.cpp (added) +++ lldb/trunk/test/benchmarks/expression/main.cpp Thu Oct 20 13:58:28 2011 @@ -0,0 +1,51 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +class Point { +public: + int x; + int y; + Point(int a, int b): + x(a), + y(b) + {} +}; + +class Data { +public: + int id; + Point point; + Data(int i): + id(i), + point(0, 0) + {} +}; + +int main(int argc, char const *argv[]) { + Data *data[1000]; + Data **ptr = data; + for (int i = 0; i < 1000; ++i) { + ptr[i] = new Data(i); + ptr[i]->point.x = i; + ptr[i]->point.y = i+1; + } + + printf("Finished populating data.\n"); + for (int j = 0; j < 1000; ++j) { + bool dump = argc > 1; // Set breakpoint here. + // Evaluate a couple of expressions (2*1000 = 2000 exprs): + // expr ptr[j]->point.x + // expr ptr[j]->point.y + if (dump) { + printf("data[%d] = %d (%d, %d)\n", j, ptr[j]->id, ptr[j]->point.x, ptr[j]->point.y); + } + } + return 0; +} From johnny.chen at apple.com Thu Oct 20 14:13:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 19:13:51 -0000 Subject: [Lldb-commits] [lldb] r142603 - /lldb/trunk/test/benchmarks/example/ Message-ID: <20111020191351.DD6023128026@llvm.org> Author: johnny Date: Thu Oct 20 14:13:51 2011 New Revision: 142603 URL: http://llvm.org/viewvc/llvm-project?rev=142603&view=rev Log: Really delete it this time. Removed: lldb/trunk/test/benchmarks/example/ From johnny.chen at apple.com Thu Oct 20 17:16:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 22:16:24 -0000 Subject: [Lldb-commits] [lldb] r142625 - /lldb/trunk/test/dotest.py Message-ID: <20111020221624.B48423128026@llvm.org> Author: johnny Date: Thu Oct 20 17:16:24 2011 New Revision: 142625 URL: http://llvm.org/viewvc/llvm-project?rev=142625&view=rev Log: Breakpoint specification can have the form '-n main', so it's not a good idea to check that the option arg in '-x opt_arg' does not start with a '-' char. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=142625&r1=142624&r2=142625&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Oct 20 17:16:24 2011 @@ -480,7 +480,7 @@ elif sys.argv[index].startswith('-x'): # Increment by 1 to fetch the breakpoint specification of the benchmark executable. index += 1 - if index >= len(sys.argv) or sys.argv[index].startswith('-'): + if index >= len(sys.argv): usage() bmBreakpointSpec = sys.argv[index] index += 1 From gclayton at apple.com Thu Oct 20 17:30:33 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 20 Oct 2011 22:30:33 -0000 Subject: [Lldb-commits] [lldb] r142627 - in /lldb/trunk: include/lldb/Core/MappedHash.h lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Message-ID: <20111020223033.CEC6B3128026@llvm.org> Author: gclayton Date: Thu Oct 20 17:30:33 2011 New Revision: 142627 URL: http://llvm.org/viewvc/llvm-project?rev=142627&view=rev Log: Fixed some issues where we might not have one of the new apple accelerator tables (like the .apple_namespaces) and it would cause us to index DWARF that didn't need to be indexed. Updated the MappedHash.h (generic Apple accelerator table) and the DWARF specific one (HashedNameToDIE.h) to be up to date with the latest and greatest hash table format. Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Modified: lldb/trunk/include/lldb/Core/MappedHash.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/include/lldb/Core/MappedHash.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/MappedHash.h?rev=142627&r1=142626&r2=142627&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/MappedHash.h (original) +++ lldb/trunk/include/lldb/Core/MappedHash.h Thu Oct 20 17:30:33 2011 @@ -61,8 +61,7 @@ uint32_t magic; // HASH_MAGIC or HASH_CIGAM magic value to allow endian detection uint16_t version; // Version number - uint8_t addr_bytesize; // Size in bytes of an address - uint8_t hash_function; // The hash function enumeration that was used + uint16_t hash_function; // The hash function enumeration that was used uint32_t bucket_count; // The number of buckets in this hash table uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table uint32_t header_data_len; // The size in bytes of the "header_data" template member below @@ -71,7 +70,6 @@ Header () : magic (HASH_MAGIC), version (1), - addr_bytesize (4), hash_function (eHashFunctionDJB), bucket_count (0), hashes_count (0), @@ -90,7 +88,6 @@ { return sizeof(magic) + sizeof(version) + - sizeof(addr_bytesize) + sizeof(hash_function) + sizeof(bucket_count) + sizeof(hashes_count) + @@ -112,8 +109,7 @@ { s.Printf ("header.magic = 0x%8.8x\n", magic); s.Printf ("header.version = 0x%4.4x\n", version); - s.Printf ("header.addr_bytesize = 0x%2.2x\n", addr_bytesize); - s.Printf ("header.hash_function = 0x%2.2x\n", hash_function); + s.Printf ("header.hash_function = 0x%4.4x\n", hash_function); s.Printf ("header.bucket_count = 0x%8.8x %u\n", bucket_count, bucket_count); s.Printf ("header.hashes_count = 0x%8.8x %u\n", hashes_count, hashes_count); s.Printf ("header.header_data_len = 0x%8.8x %u\n", header_data_len, header_data_len); @@ -125,7 +121,6 @@ if (data.ValidOffsetForDataOfSize (offset, sizeof (magic) + sizeof (version) + - sizeof (addr_bytesize) + sizeof (hash_function) + sizeof (bucket_count) + sizeof (hashes_count) + @@ -162,8 +157,9 @@ // Unsupported version return UINT32_MAX; } - addr_bytesize = data.GetU8 (&offset); - hash_function = data.GetU8 (&offset); + hash_function = data.GetU16 (&offset); + if (hash_function == 4) + hash_function = 0; // Deal with pre-release version of this table... bucket_count = data.GetU32 (&offset); hashes_count = data.GetU32 (&offset); header_data_len = data.GetU32 (&offset); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=142627&r1=142626&r2=142627&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Oct 20 17:30:33 2011 @@ -340,7 +340,6 @@ 26957D9A13D381C900670048 /* RegisterContextDarwin_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9413D381C900670048 /* RegisterContextDarwin_i386.cpp */; }; 26957D9C13D381C900670048 /* RegisterContextDarwin_x86_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26957D9613D381C900670048 /* RegisterContextDarwin_x86_64.cpp */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; - 26A0DA4E140F7226006DA411 /* HashedNameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A0DA4C140F721D006DA411 /* HashedNameToDIE.cpp */; }; 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; 26A7A035135E6E4200FB369E /* NamedOptionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */; }; 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */; }; @@ -790,7 +789,6 @@ 269FF08112494FC200225026 /* UnwindTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindTable.h; path = include/lldb/Symbol/UnwindTable.h; sourceTree = ""; }; 26A0604711A5BC7A00F75969 /* Baton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Baton.h; path = include/lldb/Core/Baton.h; sourceTree = ""; }; 26A0604811A5D03C00F75969 /* Baton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Baton.cpp; path = source/Core/Baton.cpp; sourceTree = ""; }; - 26A0DA4C140F721D006DA411 /* HashedNameToDIE.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HashedNameToDIE.cpp; sourceTree = ""; }; 26A0DA4D140F721D006DA411 /* HashedNameToDIE.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HashedNameToDIE.h; sourceTree = ""; }; 26A3B4AC1181454800381BC2 /* ObjectContainerBSDArchive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectContainerBSDArchive.cpp; sourceTree = ""; }; 26A3B4AD1181454800381BC2 /* ObjectContainerBSDArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectContainerBSDArchive.h; sourceTree = ""; }; @@ -1652,7 +1650,6 @@ 260C89D610F57C5600BB2B04 /* DWARFLocationDescription.h */, 260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */, 260C89D810F57C5600BB2B04 /* DWARFLocationList.h */, - 26A0DA4C140F721D006DA411 /* HashedNameToDIE.cpp */, 26A0DA4D140F721D006DA411 /* HashedNameToDIE.h */, 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */, 2618D957124056C700F2B8FE /* NameToDIE.h */, @@ -3501,7 +3498,6 @@ 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */, 94FA3DE01405D50400833217 /* ValueObjectConstResultChild.cpp in Sources */, 949ADF031406F648004833E1 /* ValueObjectConstResultImpl.cpp in Sources */, - 26A0DA4E140F7226006DA411 /* HashedNameToDIE.cpp in Sources */, B27318421416AC12006039C8 /* WatchpointList.cpp in Sources */, 26E152261419CAD4007967D0 /* ObjectFilePECOFF.cpp in Sources */, B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */, Removed: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=142626&view=auto ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (removed) @@ -1,298 +0,0 @@ -//===-- HashedNameToDIE.cpp -------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "HashedNameToDIE.h" -#include "lldb/Core/ConstString.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Core/Stream.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Symbol/ObjectFile.h" - -#include "DWARFCompileUnit.h" -#include "DWARFDebugInfo.h" -#include "DWARFDebugInfoEntry.h" -#include "DWARFDefines.h" -#include "SymbolFileDWARF.h" -using namespace lldb; -using namespace lldb_private; - -static uint32_t -dl_new_hash (const char *s) -{ - uint32_t h = 5381; - - for (unsigned char c = *s; c; c = *++s) - h = ((h << 5) + h) + c; - - return h; -} - - -void -HashedNameToDIE::Header::Dump (Stream &s) -{ - s.Printf ("header.magic = 0x%8.8x", magic); - s.Printf ("header.version = 0x%4.4x", version); - s.Printf ("header.addr_bytesize = 0x%2.2x", addr_bytesize); - s.Printf ("header.hash_function = 0x%2.2x", hash_function); - s.Printf ("header.bucket_count = 0x%8.8x %u", bucket_count, bucket_count); - s.Printf ("header.hashes_count = 0x%8.8x %u", hashes_count, hashes_count); - s.Printf ("header.prologue_length = 0x%8.8x %u", prologue_length, prologue_length); -} - -uint32_t -HashedNameToDIE::Header::Read (const DataExtractor &data, uint32_t offset) -{ - magic = data.GetU32 (&offset); - if (magic != HASH_MAGIC) - { - // Magic bytes didn't match - version = 0; - return UINT32_MAX; - } - - version = data.GetU16 (&offset); - if (version != 1) - { - // Unsupported version - return UINT32_MAX; - } - addr_bytesize = data.GetU8 (&offset); - hash_function = data.GetU8 (&offset); - bucket_count = data.GetU32 (&offset); - hashes_count = data.GetU32 (&offset); - prologue_length = data.GetU32 (&offset); - return offset; -} - -void -HashedNameToDIE::DWARF::Header::Dump (Stream &s) -{ - HashedNameToDIE::Header::Dump (s); - dwarf_prologue.Dump (s); -} - -uint32_t -HashedNameToDIE::DWARF::Header::Read (const DataExtractor &data, uint32_t offset) -{ - offset = HashedNameToDIE::Header::Read (data, offset); - if (offset != UINT32_MAX) - offset = dwarf_prologue.Read (data, offset); - else - dwarf_prologue.Clear(); - return offset; -} - -void -HashedNameToDIE::DWARF::Prologue::Dump (Stream &s) -{ - s.Printf ("dwarf_prologue.die_base_offset = 0x%8.8x\n", die_base_offset); - const size_t num_atoms = atoms.size(); - for (size_t i = 0; i < num_atoms; ++i) - { - s.Printf ("dwarf_prologue.atom[%zi] = %17s %s\n", - i, - GetAtomTypeName (atoms[i].type), - DW_FORM_value_to_name(atoms[i].form)); - } -} - -uint32_t -HashedNameToDIE::DWARF::Prologue::Read (const DataExtractor &data, uint32_t offset) -{ - Clear(); - die_base_offset = data.GetU32 (&offset); - Atom atom; - while (offset != UINT32_MAX) - { - atom.type = data.GetU16 (&offset); - atom.form = data.GetU16 (&offset); - if (atom.type == eAtomTypeNULL) - break; - atoms.push_back(atom); - } - return offset; -} - - -HashedNameToDIE::MemoryTable::MemoryTable (SymbolFileDWARF *dwarf, - const lldb_private::DataExtractor &data, - bool is_apple_names) : - m_data (data), - m_string_table (dwarf->get_debug_str_data ()), - m_is_apple_names (is_apple_names), - m_header () -{ -} - -bool -HashedNameToDIE::MemoryTable::Initialize () -{ - uint32_t offset = 0; - offset = m_header.Read (m_data, offset); - return m_header.version == 1; -} - - -size_t -HashedNameToDIE::MemoryTable::Find (const char *name_cstr, DIEArray &die_ofsets) const -{ - if (m_header.version == 1) - { - if (name_cstr && name_cstr[0]) - { - // Hash the C string - const uint32_t name_hash = dl_new_hash (name_cstr); - - const uint32_t bucket_count = m_header.bucket_count; - const uint32_t hashes_count = m_header.bucket_count; - // Find the correct bucket for the using the hash value - const uint32_t bucket_idx = name_hash % bucket_count; - - // Calculate the offset for the bucket entry for the bucket index - uint32_t offset = GetOffsetOfBucketEntry (bucket_idx); - - // Extract the bucket entry which is a hash index. If the hash index - // is UINT32_MAX, then the bucket is empty. If it isn't, it is the - // index of the hash in the hashes array. We will then iterate through - // all hashes as long as they match "bucket_idx" which was calculated - // above - uint32_t hash_idx = m_data.GetU32 (&offset); - if (hash_idx != UINT32_MAX) - { - uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); - - const size_t initial_size = die_ofsets.size(); - uint32_t hash; - while (((hash = m_data.GetU32 (&hash_offset)) % bucket_count) == bucket_idx) - { - if (hash_idx >= hashes_count) - break; - - if (hash == name_hash) - { - // The hash matches, but we still need to verify that the - // C string matches in case we have a hash collision. Figure - // out the offset for the data associated with this hash entry - offset = GetOffsetOfHashDataOffset (hash_idx); - uint32_t hash_data_offset = m_data.GetU32 (&offset); - uint32_t str_offset; - // Now we have the offset to the data for all strings that match - // our 32 bit hash. The format of the hash bucket is: - // - // uint32_t stroff; // string offset in .debug_str table - // uint32_t num_dies; // Number of DIEs in debug info that match the string that follow this - // uint32_t die_offsets[num_dies]; // An array of DIE offsets - // - // When a "stroff" is read and it is zero, then the data for this - // hash is terminated. - while ((str_offset = m_data.GetU32 (&hash_data_offset)) != 0) - { - // Extract the C string and comapare it - const char *cstr_name = m_string_table.PeekCStr(str_offset); - if (cstr_name) - { - if (strcmp(name_cstr, cstr_name) == 0) - { - // We have a match, now extract the DIE count - const uint32_t die_count = m_data.GetU32 (&hash_data_offset); - // Now extract "die_count" DIE offsets and put them into the - // results - for (uint32_t die_idx = 0; die_idx < die_count; ++die_idx) - die_ofsets.push_back(m_data.GetU32 (&hash_data_offset)); - } - } - } - } - ++hash_idx; - } - - return die_ofsets.size() - initial_size; - } - } - } - return 0; -} - -void -HashedNameToDIE::MemoryTable::Dump (Stream &s) -{ - if (m_header.version == 1) - { - if (m_is_apple_names) - s.PutCString (".apple_names contents:\n"); - else - s.PutCString (".apple_types contents:\n"); - - m_header.Dump (s); - uint32_t empty_bucket_count = 0; - uint32_t hash_collisions = 0; - uint32_t hash_idx_offset = GetOffsetOfBucketEntry (0); - const uint32_t bucket_count = m_header.bucket_count; - const uint32_t hashes_count = m_header.hashes_count; - for (uint32_t bucket_idx=0; bucket_idx hash[%u]\n", hash_idx); - - uint32_t hash_offset = GetOffsetOfHashValue (hash_idx); - uint32_t data_offset = GetOffsetOfHashDataOffset (hash_idx); - - uint32_t hash; - while (((hash = m_data.GetU32 (&hash_offset)) % bucket_count) == bucket_idx) - { - if (hash_idx >= hashes_count) - break; - - uint32_t hash_data_offset = m_data.GetU32 (&data_offset); - s.Printf(" hash[%u] = 0x%8.8x\n", hash_idx, hash); - - uint32_t string_count = 0; - uint32_t strp_offset; - while ((strp_offset = m_data.GetU32 (&hash_data_offset)) != 0) - { - const uint32_t num_die_offsets = m_data.GetU32 (&hash_data_offset); - s.Printf(" str[%u] = 0x%8.8x \"%s\", dies[%u] = {", - string_count, - strp_offset, - m_string_table.PeekCStr(strp_offset), - num_die_offsets); - ++string_count; - - for (uint32_t die_idx=0; die_idx 1) - ++hash_collisions; - } - } - else - { - s.PutCString(" EMPTY\n"); - ++empty_bucket_count; - } - s.EOL(); - } - s.EOL(); - s.Printf ("%u of %u buckets empty (%2.1f%%)\n", empty_bucket_count, bucket_count, (((float)empty_bucket_count/(float)m_header.bucket_count)*100.0f)); - s.Printf ("Average hashes/non-empty bucket = %2.1f%%\n", ((float)m_header.hashes_count/(float)(m_header.bucket_count - empty_bucket_count))); - s.Printf ("Hash collisions = %u\n", hash_collisions); - } -} - - Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=142627&r1=142626&r2=142627&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Thu Oct 20 17:30:33 2011 @@ -14,262 +14,10 @@ #include "lldb/lldb-defines.h" #include "lldb/Core/dwarf.h" #include "lldb/Core/RegularExpression.h" +#include "lldb/Core/MappedHash.h" class SymbolFileDWARF; -typedef std::vector DIEArray; - -class HashedNameToDIE -{ -public: - enum NameFlags - { - eNameFlagIsExternal = (1u << 0), - eNameFlagIsClassCXX = (1u << 1), - eNameFlagIsClassObjC = (1u << 2), - eNameFlagIsClassObjCMaster = (1u << 3) - }; - - enum TypeFlags - { - eTypeFlagIsExternal = (1u << 0) - }; - - enum HashFunctionType - { - eHashFunctionDJB = 0u, // Daniel J Bernstein hash function that is also used by the ELF GNU_HASH sections - }; - - static const uint32_t HASH_MAGIC = 0x48415348u; - - struct Header - { - uint32_t magic; // 'HASH' magic value to allow endian detection - uint16_t version; // Version number - uint8_t addr_bytesize; // Size in bytes of an address - uint8_t hash_function; // The hash function enumeration that was used - uint32_t bucket_count; // The number of buckets in this hash table - uint32_t hashes_count; // The total number of unique hash values and hash data offsets in this table - uint32_t prologue_length; // The length of the prologue - - Header (uint32_t _prologue_length) : - magic (HASH_MAGIC), - version (1), - addr_bytesize (4), - hash_function (eHashFunctionDJB), - bucket_count (0), - hashes_count (0), - prologue_length (_prologue_length) - { - } - - virtual - ~Header () - { - } - - virtual size_t - GetByteSize() const - { - return sizeof(magic) + - sizeof(version) + - sizeof(addr_bytesize) + - sizeof(hash_function) + - sizeof(bucket_count) + - sizeof(hashes_count) + - sizeof(prologue_length) + - prologue_length; - } - - virtual void - Dump (lldb_private::Stream &s); - - virtual uint32_t - Read (const lldb_private::DataExtractor &data, uint32_t offset); - }; - - struct DWARF - { - enum AtomType - { - eAtomTypeNULL = 0u, - eAtomTypeHashString = 1u, // String value for hash, use DW_FORM_strp (preferred) or DW_FORM_string - eAtomTypeHashLength = 2u, // Length of data for the previous string refered by the last eAtomTypeHashString atom - eAtomTypeArraySize = 3u, // A count that specifies a number of atoms that follow this entry, the next atom defines what the atom type for the array is - eAtomTypeDIEOffset = 4u, // DIE offset, check form for encoding. If DW_FORM_ref1,2,4,8 or DW_FORM_ref_udata, then this value is added to the prologue - eAtomTypeTag = 5u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2 - eAtomTypeNameFlags = 6u, // Flags from enum NameFlags - eAtomTypeTypeFlags = 7u, // Flags from enum TypeFlags - }; - - struct Atom - { - uint16_t type; - dw_form_t form; - - Atom (uint16_t t = eAtomTypeNULL, dw_form_t f = 0) : - type (t), - form (f) - { - } - }; - - typedef std::vector AtomArray; - - - static const char * - GetAtomTypeName (uint16_t atom) - { - switch (atom) - { - case eAtomTypeNULL: return "NULL"; - case eAtomTypeHashString: return "hash-string"; - case eAtomTypeHashLength: return "hash-data-length"; - case eAtomTypeArraySize: return "array-size"; - case eAtomTypeDIEOffset: return "die-offset"; - case eAtomTypeTag: return "die-tag"; - case eAtomTypeNameFlags: return "name-flags"; - case eAtomTypeTypeFlags: return "type-flags"; - } - return ""; - } - struct Prologue - { - // DIE offset base so die offsets in hash_data can be CU relative - dw_offset_t die_base_offset; - AtomArray atoms; - - Prologue (dw_offset_t _die_base_offset = 0) : - die_base_offset (_die_base_offset) - { - // Define an array of DIE offsets by first defining an array, - // and then define the atom type for the array, in this case - // we have an array of DIE offsets - atoms.push_back (Atom(eAtomTypeArraySize, DW_FORM_data4)); - atoms.push_back (Atom(eAtomTypeDIEOffset, DW_FORM_data4)); - } - - virtual - ~Prologue () - { - } - - - virtual void - Clear () - { - die_base_offset = 0; - atoms.clear(); - } - - virtual void - Dump (lldb_private::Stream &s); - - virtual uint32_t - Read (const lldb_private::DataExtractor &data, uint32_t offset); - - size_t - GetByteSize () const - { - // Add an extra count to the atoms size for the zero termination Atom that gets - // written to disk - return sizeof(die_base_offset) + ((atoms.size() + 1) * sizeof(Atom)); - } - }; - - struct Header : public HashedNameToDIE::Header - { - Header (dw_offset_t _die_base_offset = 0) : - HashedNameToDIE::Header (sizeof(Prologue)), - dwarf_prologue (_die_base_offset) - { - } - - virtual - ~Header () - { - } - - Prologue dwarf_prologue; - - virtual void - Dump (lldb_private::Stream &s); - - virtual uint32_t - Read (const lldb_private::DataExtractor &data, uint32_t offset); - }; - - }; - - - class MemoryTable - { - public: - - MemoryTable (SymbolFileDWARF *dwarf, - const lldb_private::DataExtractor &data, - bool is_apple_names); - - ~MemoryTable () - { - } - - bool - Initialize (); - - bool - IsValid () const - { - return m_header.version > 0; - } - - uint32_t - GetOffsetOfBucketEntry (uint32_t idx) const - { - if (idx < m_header.bucket_count) - return m_header.GetByteSize() + 4 * idx; - return UINT32_MAX; - } - - uint32_t - GetOffsetOfHashValue (uint32_t idx) const - { - if (idx < m_header.hashes_count) - return m_header.GetByteSize() + - 4 * m_header.bucket_count + - 4 * idx; - return UINT32_MAX; - } - - uint32_t - GetOffsetOfHashDataOffset (uint32_t idx) const - { - if (idx < m_header.hashes_count) - { - return m_header.GetByteSize() + - 4 * m_header.bucket_count + - 4 * m_header.hashes_count + - 4 * idx; - } - return UINT32_MAX; - } - - void - Dump (lldb_private::Stream &s); - - size_t - Find (const char *name, DIEArray &die_ofsets) const; - - protected: - const lldb_private::DataExtractor &m_data; - const lldb_private::DataExtractor &m_string_table; - bool m_is_apple_names; // true => .apple_names, false => .apple_types - DWARF::Header m_header; - }; -}; - -#include "lldb/Core/MappedHash.h" - struct DWARFMappedHash { typedef std::vector DIEArray; @@ -277,23 +25,21 @@ enum AtomType { eAtomTypeNULL = 0u, - eAtomTypeHashString = 1u, // String value for hash, use DW_FORM_strp (preferred) or DW_FORM_string - eAtomTypeHashLength = 2u, // Length of data for the previous string refered by the last eAtomTypeHashString atom - eAtomTypeArraySize = 3u, // A count that specifies a number of atoms that follow this entry, the next atom defines what the atom type for the array is - eAtomTypeDIEOffset = 4u, // DIE offset, check form for encoding. If DW_FORM_ref1,2,4,8 or DW_FORM_ref_udata, then this value is added to the prologue - eAtomTypeTag = 5u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2 - eAtomTypeNameFlags = 6u, // Flags from enum NameFlags - eAtomTypeTypeFlags = 7u, // Flags from enum TypeFlags + eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding + eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that contains the item in question + eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2 + eAtomTypeNameFlags = 4u, // Flags from enum NameFlags + eAtomTypeTypeFlags = 5u, // Flags from enum TypeFlags }; - + struct Atom { uint16_t type; dw_form_t form; Atom (uint16_t t = eAtomTypeNULL, dw_form_t f = 0) : - type (t), - form (f) + type (t), + form (f) { } }; @@ -307,10 +53,8 @@ switch (atom) { case eAtomTypeNULL: return "NULL"; - case eAtomTypeHashString: return "hash-string"; - case eAtomTypeHashLength: return "hash-data-length"; - case eAtomTypeArraySize: return "array-size"; case eAtomTypeDIEOffset: return "die-offset"; + case eAtomTypeCUOffset: return "cu-offset"; case eAtomTypeTag: return "die-tag"; case eAtomTypeNameFlags: return "name-flags"; case eAtomTypeTypeFlags: return "type-flags"; @@ -329,7 +73,6 @@ // Define an array of DIE offsets by first defining an array, // and then define the atom type for the array, in this case // we have an array of DIE offsets - atoms.push_back (Atom(eAtomTypeArraySize, DW_FORM_data4)); atoms.push_back (Atom(eAtomTypeDIEOffset, DW_FORM_data4)); } @@ -351,14 +94,26 @@ Read (const lldb_private::DataExtractor &data, uint32_t offset) { die_base_offset = data.GetU32 (&offset); - Atom atom; - while (offset != UINT32_MAX) + + const uint32_t atom_count = data.GetU32 (&offset); + if (atom_count == 0x00060003u) { - atom.type = data.GetU16 (&offset); - atom.form = data.GetU16 (&offset); - if (atom.type == eAtomTypeNULL) - break; - atoms.push_back(atom); + // Old format, deal with contents of old pre-release format + while (data.GetU32(&offset)) + /* do nothing */; + + // Hardcode to the only know value for now. + atoms.push_back (Atom(eAtomTypeDIEOffset, DW_FORM_data4)); + } + else + { + Atom atom; + for (uint32_t i=0; i (table_data), m_data (table_data), m_string_table (string_table), - m_is_apple_names (is_apple_names) + m_name (name) { } @@ -668,7 +423,7 @@ protected: const lldb_private::DataExtractor &m_data; const lldb_private::DataExtractor &m_string_table; - bool m_is_apple_names; // true => .apple_names, false => .apple_types + std::string m_name; }; }; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=142627&r1=142626&r2=142627&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Oct 20 17:30:33 2011 @@ -194,6 +194,7 @@ m_namespace_index(), m_indexed (false), m_is_external_ast_source (false), + m_using_apple_tables (false), m_ranges(), m_unique_ast_type_map () { @@ -260,23 +261,29 @@ get_apple_names_data(); if (m_data_apple_names.GetByteSize() > 0) { - m_apple_names_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_names, get_debug_str_data(), true)); - if (!m_apple_names_ap->IsValid()) + m_apple_names_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_names, get_debug_str_data(), ".apple_names")); + if (m_apple_names_ap->IsValid()) + m_using_apple_tables = true; + else m_apple_names_ap.reset(); } get_apple_types_data(); if (m_data_apple_types.GetByteSize() > 0) { - m_apple_types_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_types, get_debug_str_data(), false)); - if (!m_apple_types_ap->IsValid()) + m_apple_types_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_types, get_debug_str_data(), ".apple_types")); + if (m_apple_types_ap->IsValid()) + m_using_apple_tables = true; + else m_apple_types_ap.reset(); } get_apple_namespaces_data(); if (m_data_apple_namespaces.GetByteSize() > 0) { - m_apple_namespaces_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_namespaces, get_debug_str_data(), false)); - if (!m_apple_namespaces_ap->IsValid()) + m_apple_namespaces_ap.reset (new DWARFMappedHash::MemoryTable (m_data_apple_namespaces, get_debug_str_data(), ".apple_namespaces")); + if (m_apple_namespaces_ap->IsValid()) + m_using_apple_tables = true; + else m_apple_namespaces_ap.reset(); } @@ -2068,16 +2075,19 @@ DIEArray die_offsets; - if (m_apple_names_ap.get()) + if (m_using_apple_tables) { - const char *name_cstr = name.GetCString(); - const char *base_name_start; - const char *base_name_end = NULL; - - if (!CPPLanguageRuntime::StripNamespacesFromVariableName(name_cstr, base_name_start, base_name_end)) - base_name_start = name_cstr; + if (m_apple_names_ap.get()) + { + const char *name_cstr = name.GetCString(); + const char *base_name_start; + const char *base_name_end = NULL; - m_apple_names_ap->FindByName (base_name_start, die_offsets); + if (!CPPLanguageRuntime::StripNamespacesFromVariableName(name_cstr, base_name_start, base_name_end)) + base_name_start = name_cstr; + + m_apple_names_ap->FindByName (base_name_start, die_offsets); + } } else { @@ -2147,9 +2157,10 @@ DIEArray die_offsets; - if (m_apple_names_ap.get()) + if (m_using_apple_tables) { - m_apple_names_ap->AppendAllDIEsThatMatchingRegex (regex, die_offsets); + if (m_apple_names_ap.get()) + m_apple_names_ap->AppendAllDIEsThatMatchingRegex (regex, die_offsets); } else { @@ -2467,90 +2478,94 @@ return 0; DWARFCompileUnit *dwarf_cu = NULL; - if (m_apple_names_ap.get()) + if (m_using_apple_tables) { - DIEArray die_offsets; - - uint32_t num_matches = 0; - - if (effective_name_type_mask & eFunctionNameTypeFull) + if (m_apple_names_ap.get()) { - // If they asked for the full name, match what they typed. At some point we may - // want to canonicalize this (strip double spaces, etc. For now, we just add all the - // dies that we find by exact match. - num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); - for (uint32_t i = 0; i < num_matches; i++) - { - const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); - if (die) - { - if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) - continue; - - ResolveFunction (dwarf_cu, die, sc_list); - } - } - } - else - { - if (effective_name_type_mask & eFunctionNameTypeSelector) + + DIEArray die_offsets; + + uint32_t num_matches = 0; + + if (effective_name_type_mask & eFunctionNameTypeFull) { - if (namespace_decl && *namespace_decl) - return 0; // no selectors in namespaces - + // If they asked for the full name, match what they typed. At some point we may + // want to canonicalize this (strip double spaces, etc. For now, we just add all the + // dies that we find by exact match. num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); - // Now make sure these are actually ObjC methods. In this case we can simply look up the name, - // and if it is an ObjC method name, we're good. - for (uint32_t i = 0; i < num_matches; i++) { - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); if (die) { - const char *die_name = die->GetName(this, dwarf_cu); - if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name)) - ResolveFunction (dwarf_cu, die, sc_list); + if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) + continue; + + ResolveFunction (dwarf_cu, die, sc_list); } } - die_offsets.clear(); } - - if (effective_name_type_mask & eFunctionNameTypeMethod - || effective_name_type_mask & eFunctionNameTypeBase) - { - if ((effective_name_type_mask & eFunctionNameTypeMethod) && - (namespace_decl && *namespace_decl)) - return 0; // no methods in namespaces - - // The apple_names table stores just the "base name" of C++ methods in the table. So we have to - // extract the base name, look that up, and if there is any other information in the name we were - // passed in we have to post-filter based on that. - - // FIXME: Arrange the logic above so that we don't calculate the base name twice: - std::string base_name(base_name_start, base_name_end - base_name_start); - num_matches = m_apple_names_ap->FindByName (base_name.c_str(), die_offsets); + else + { + if (effective_name_type_mask & eFunctionNameTypeSelector) + { + if (namespace_decl && *namespace_decl) + return 0; // no selectors in namespaces + + num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets); + // Now make sure these are actually ObjC methods. In this case we can simply look up the name, + // and if it is an ObjC method name, we're good. + + for (uint32_t i = 0; i < num_matches; i++) + { + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + if (die) + { + const char *die_name = die->GetName(this, dwarf_cu); + if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name)) + ResolveFunction (dwarf_cu, die, sc_list); + } + } + die_offsets.clear(); + } - for (uint32_t i = 0; i < num_matches; i++) + if (effective_name_type_mask & eFunctionNameTypeMethod + || effective_name_type_mask & eFunctionNameTypeBase) { - const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); - if (die) + if ((effective_name_type_mask & eFunctionNameTypeMethod) && + (namespace_decl && *namespace_decl)) + return 0; // no methods in namespaces + + // The apple_names table stores just the "base name" of C++ methods in the table. So we have to + // extract the base name, look that up, and if there is any other information in the name we were + // passed in we have to post-filter based on that. + + // FIXME: Arrange the logic above so that we don't calculate the base name twice: + std::string base_name(base_name_start, base_name_end - base_name_start); + num_matches = m_apple_names_ap->FindByName (base_name.c_str(), die_offsets); + + for (uint32_t i = 0; i < num_matches; i++) { - if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) - continue; - - if (!FunctionDieMatchesPartialName(die, - dwarf_cu, - effective_name_type_mask, - name_cstr, - base_name_start, - base_name_end)) - continue; + const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu); + if (die) + { + if (namespace_decl && !DIEIsInNamespace (namespace_decl, dwarf_cu, die)) + continue; - // If we get to here, the die is good, and we should add it: - ResolveFunction (dwarf_cu, die, sc_list); + if (!FunctionDieMatchesPartialName(die, + dwarf_cu, + effective_name_type_mask, + name_cstr, + base_name_start, + base_name_end)) + continue; + + // If we get to here, the die is good, and we should add it: + ResolveFunction (dwarf_cu, die, sc_list); + } } + die_offsets.clear(); } - die_offsets.clear(); } } } @@ -2660,9 +2675,10 @@ // we are appending the results to a variable list. uint32_t original_size = sc_list.GetSize(); - if (m_apple_names_ap.get()) + if (m_using_apple_tables) { - FindFunctions (regex, *m_apple_names_ap, sc_list); + if (m_apple_names_ap.get()) + FindFunctions (regex, *m_apple_names_ap, sc_list); } else { @@ -2739,10 +2755,13 @@ DIEArray die_offsets; - if (m_apple_types_ap.get()) + if (m_using_apple_tables) { - const char *name_cstr = name.GetCString(); - m_apple_types_ap->FindByName (name_cstr, die_offsets); + if (m_apple_types_ap.get()) + { + const char *name_cstr = name.GetCString(); + m_apple_types_ap->FindByName (name_cstr, die_offsets); + } } else { @@ -2810,10 +2829,13 @@ // Index if we already haven't to make sure the compile units // get indexed and make their global DIE index list - if (m_apple_namespaces_ap.get()) + if (m_using_apple_tables) { - const char *name_cstr = name.GetCString(); - m_apple_namespaces_ap->FindByName (name_cstr, die_offsets); + if (m_apple_namespaces_ap.get()) + { + const char *name_cstr = name.GetCString(); + m_apple_namespaces_ap->FindByName (name_cstr, die_offsets); + } } else { @@ -3500,10 +3522,13 @@ DIEArray die_offsets; - if (m_apple_types_ap.get()) + if (m_using_apple_tables) { - const char *name_cstr = type_name.GetCString(); - m_apple_types_ap->FindByName (name_cstr, die_offsets); + if (m_apple_types_ap.get()) + { + const char *name_cstr = type_name.GetCString(); + m_apple_types_ap->FindByName (name_cstr, die_offsets); + } } else { @@ -4702,12 +4727,12 @@ DWARFCompileUnit* match_dwarf_cu = NULL; const DWARFDebugInfoEntry* die = NULL; DIEArray die_offsets; - if (m_apple_names_ap.get()) + if (m_using_apple_tables) { - // TODO: implement finding all items in - m_apple_names_ap->AppendAllDIEsInRange (dwarf_cu->GetOffset(), - dwarf_cu->GetNextCompileUnitOffset(), - die_offsets); + if (m_apple_names_ap.get()) + m_apple_names_ap->AppendAllDIEsInRange (dwarf_cu->GetOffset(), + dwarf_cu->GetNextCompileUnitOffset(), + die_offsets); } else { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=142627&r1=142626&r2=142627&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Oct 20 17:30:33 2011 @@ -464,7 +464,8 @@ NameToDIE m_type_index; // All type DIE offsets NameToDIE m_namespace_index; // All type DIE offsets bool m_indexed:1, - m_is_external_ast_source:1; + m_is_external_ast_source:1, + m_using_apple_tables:1; std::auto_ptr m_ranges; UniqueDWARFASTTypeMap m_unique_ast_type_map; From johnny.chen at apple.com Thu Oct 20 17:37:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 20 Oct 2011 22:37:46 -0000 Subject: [Lldb-commits] [lldb] r142628 - in /lldb/trunk/test/benchmarks/startup: ./ TestStartupDelays.py Message-ID: <20111020223746.182943128026@llvm.org> Author: johnny Date: Thu Oct 20 17:37:45 2011 New Revision: 142628 URL: http://llvm.org/viewvc/llvm-project?rev=142628&view=rev Log: Add a benchmark for measuring start up delays of lldb, including: o create a fresh target; and o set the first breakpoint Example (using lldb to set a breakpoint on lldb's Driver::MainLoop function): ./dotest.py -v +b -x '-F Driver::MainLoop()' -p TestStartupDelays.py ... 1: test_startup_delay (TestStartupDelays.StartupDelaysBench) Test start up delays creating a target and setting a breakpoint. ... lldb startup delays benchmark: create fresh target: Avg: 0.106732 (Laps: 15, Total Elapsed Time: 1.600985) set first breakpoint: Avg: 0.102589 (Laps: 15, Total Elapsed Time: 1.538832) ok Added: lldb/trunk/test/benchmarks/startup/ lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Added: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/startup/TestStartupDelays.py?rev=142628&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/startup/TestStartupDelays.py (added) +++ lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Thu Oct 20 17:37:45 2011 @@ -0,0 +1,82 @@ +"""Test lldb's startup delays creating a target and setting a breakpoint.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class StartupDelaysBench(BenchBase): + + mydir = os.path.join("benchmarks", "startup") + + def setUp(self): + BenchBase.setUp(self) + # Create self.stopwatch2 for measuring "set first breakpoint". + # The default self.stopwatch is for "create fresh target". + self.stopwatch2 = Stopwatch() + if lldb.bmExecutable: + self.exe = lldb.bmExecutable + else: + self.exe = self.lldbHere + if lldb.bmBreakpointSpec: + self.break_spec = lldb.bmBreakpointSpec + else: + self.break_spec = '-n main' + + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 15 + + @benchmarks_test + def test_startup_delay(self): + """Test start up delays creating a target and setting a breakpoint.""" + print + self.run_startup_delays_bench(self.exe, self.break_spec, self.count) + print "lldb startup delays benchmark:" + print "create fresh target:", self.stopwatch + print "set first breakpoint:", self.stopwatch2 + + def run_startup_delays_bench(self, exe, break_spec, count): + # Set self.child_prompt, which is "(lldb) ". + self.child_prompt = '(lldb) ' + prompt = self.child_prompt + + # Reset the stopwatchs now. + self.stopwatch.reset() + self.stopwatch2.reset() + for i in range(count): + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s' % (self.lldbHere, self.lldbOption)) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + with self.stopwatch: + # Create a fresh target. + child.sendline('file %s' % exe) # Aka 'target create'. + child.expect_exact(prompt) + + with self.stopwatch2: + # Read debug info and set the first breakpoint. + child.sendline('breakpoint set %s' % break_spec) + child.expect_exact(prompt) + + child.sendline('quit') + try: + self.child.expect(pexpect.EOF) + except: + pass + + # The test is about to end and if we come to here, the child process has + # been terminated. Mark it so. + self.child = None + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From johnny.chen at apple.com Thu Oct 20 20:09:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 21 Oct 2011 01:09:29 -0000 Subject: [Lldb-commits] [lldb] r142629 - in /lldb/trunk/test/benchmarks/disassembly: TestDisassembly.py TestFlintVsSlateGDBDisassembly.py Message-ID: <20111021010929.A04DC3128026@llvm.org> Author: johnny Date: Thu Oct 20 20:09:29 2011 New Revision: 142629 URL: http://llvm.org/viewvc/llvm-project?rev=142629&view=rev Log: Fix wrong directory name. Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Modified: lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py?rev=142629&r1=142628&r2=142629&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestDisassembly.py Thu Oct 20 20:09:29 2011 @@ -8,7 +8,7 @@ class DisassembleDriverMainLoop(BenchBase): - mydir = os.path.join("benchmarks", "example") + mydir = os.path.join("benchmarks", "disassembly") def setUp(self): BenchBase.setUp(self) Modified: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py?rev=142629&r1=142628&r2=142629&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py (original) +++ lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Thu Oct 20 20:09:29 2011 @@ -8,7 +8,7 @@ class FlintVsSlateGDBDisassembly(BenchBase): - mydir = os.path.join("benchmarks", "example") + mydir = os.path.join("benchmarks", "disassembly") def setUp(self): BenchBase.setUp(self) From jingham at apple.com Thu Oct 20 20:49:48 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 21 Oct 2011 01:49:48 -0000 Subject: [Lldb-commits] [lldb] r142632 - in /lldb/trunk: include/lldb/Target/Unwind.h source/Plugins/Process/Utility/UnwindLLDB.cpp source/Plugins/Process/Utility/UnwindLLDB.h source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h Message-ID: <20111021014948.6CE523128026@llvm.org> Author: jingham Date: Thu Oct 20 20:49:48 2011 New Revision: 142632 URL: http://llvm.org/viewvc/llvm-project?rev=142632&view=rev Log: Lock the Unwinder before accessing it. Modified: lldb/trunk/include/lldb/Target/Unwind.h lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h Modified: lldb/trunk/include/lldb/Target/Unwind.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Unwind.h?rev=142632&r1=142631&r2=142632&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Unwind.h (original) +++ lldb/trunk/include/lldb/Target/Unwind.h Thu Oct 20 20:49:48 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/Host/Mutex.h" namespace lldb_private { @@ -25,7 +26,8 @@ // Classes that inherit from Unwind can see and modify these //------------------------------------------------------------------ Unwind(Thread &thread) : - m_thread (thread) + m_thread (thread), + m_unwind_mutex() { } @@ -35,20 +37,37 @@ { } - virtual void - Clear() = 0; + void + Clear() + { + Mutex::Locker locker(m_unwind_mutex); + DoClear(); + + } - virtual uint32_t - GetFrameCount() = 0; + uint32_t + GetFrameCount() + { + Mutex::Locker locker(m_unwind_mutex); + return DoGetFrameCount(); + } - virtual bool + bool GetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, - lldb::addr_t& pc) = 0; + lldb::addr_t& pc) + { + Mutex::Locker locker(m_unwind_mutex); + return DoGetFrameInfoAtIndex (frame_idx, cfa, pc); + } + + lldb::RegisterContextSP + CreateRegisterContextForFrame (StackFrame *frame) + { + Mutex::Locker locker(m_unwind_mutex); + return DoCreateRegisterContextForFrame (frame); + } - virtual lldb::RegisterContextSP - CreateRegisterContextForFrame (StackFrame *frame) = 0; - Thread & GetThread() { @@ -59,7 +78,22 @@ //------------------------------------------------------------------ // Classes that inherit from Unwind can see and modify these //------------------------------------------------------------------ + virtual void + DoClear() = 0; + + virtual uint32_t + DoGetFrameCount() = 0; + + virtual bool + DoGetFrameInfoAtIndex (uint32_t frame_idx, + lldb::addr_t& cfa, + lldb::addr_t& pc) = 0; + + virtual lldb::RegisterContextSP + DoCreateRegisterContextForFrame (StackFrame *frame) = 0; + Thread &m_thread; + Mutex m_unwind_mutex; private: DISALLOW_COPY_AND_ASSIGN (Unwind); }; Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=142632&r1=142631&r2=142632&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Thu Oct 20 20:49:48 2011 @@ -30,7 +30,7 @@ } uint32_t -UnwindLLDB::GetFrameCount() +UnwindLLDB::DoGetFrameCount() { if (m_frames.empty()) { @@ -177,7 +177,7 @@ } bool -UnwindLLDB::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) +UnwindLLDB::DoGetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) { if (m_frames.size() == 0) { @@ -200,7 +200,7 @@ } lldb::RegisterContextSP -UnwindLLDB::CreateRegisterContextForFrame (StackFrame *frame) +UnwindLLDB::DoCreateRegisterContextForFrame (StackFrame *frame) { lldb::RegisterContextSP reg_ctx_sp; uint32_t idx = frame->GetConcreteFrameIndex (); Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=142632&r1=142631&r2=142632&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Thu Oct 20 20:49:48 2011 @@ -30,22 +30,23 @@ virtual ~UnwindLLDB() { } +protected: void - Clear() + DoClear() { m_frames.clear(); } virtual uint32_t - GetFrameCount(); + DoGetFrameCount(); bool - GetFrameInfoAtIndex (uint32_t frame_idx, + DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& start_pc); lldb::RegisterContextSP - CreateRegisterContextForFrame (lldb_private::StackFrame *frame); + DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame); private: struct Cursor Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp?rev=142632&r1=142631&r2=142632&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp Thu Oct 20 20:49:48 2011 @@ -28,7 +28,7 @@ } uint32_t -UnwindMacOSXFrameBackchain::GetFrameCount() +UnwindMacOSXFrameBackchain::DoGetFrameCount() { if (m_cursors.empty()) { @@ -45,7 +45,7 @@ } bool -UnwindMacOSXFrameBackchain::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) +UnwindMacOSXFrameBackchain::DoGetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) { const uint32_t frame_count = GetFrameCount(); if (idx < frame_count) @@ -64,7 +64,7 @@ } lldb::RegisterContextSP -UnwindMacOSXFrameBackchain::CreateRegisterContextForFrame (StackFrame *frame) +UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame (StackFrame *frame) { lldb::RegisterContextSP reg_ctx_sp; uint32_t concrete_idx = frame->GetConcreteFrameIndex (); Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h?rev=142632&r1=142631&r2=142632&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h Thu Oct 20 20:49:48 2011 @@ -30,27 +30,24 @@ { } +protected: virtual void - Clear() + DoClear() { m_cursors.clear(); } virtual uint32_t - GetFrameCount(); + DoGetFrameCount(); bool - GetFrameInfoAtIndex (uint32_t frame_idx, + DoGetFrameInfoAtIndex (uint32_t frame_idx, lldb::addr_t& cfa, lldb::addr_t& pc); lldb::RegisterContextSP - CreateRegisterContextForFrame (lldb_private::StackFrame *frame); - - lldb_private::Thread & - GetThread(); + DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame); -protected: friend class RegisterContextMacOSXFrameBackchain; struct Cursor From scallanan at apple.com Fri Oct 21 00:18:02 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 21 Oct 2011 05:18:02 -0000 Subject: [Lldb-commits] [lldb] r142638 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp source/Expression/IRInterpreter.cpp Message-ID: <20111021051802.4D3EA3128026@llvm.org> Author: spyffe Date: Fri Oct 21 00:18:02 2011 New Revision: 142638 URL: http://llvm.org/viewvc/llvm-project?rev=142638&view=rev Log: Made the IR interpreter more robust in the presence of arbitrary pointers, allowing direct dereferences of literal addresses. Also disabled special-cased generation of certain expression results (especially casts), substituting the IR interpreter. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Expression/IRInterpreter.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=142638&r1=142637&r2=142638&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Oct 21 00:18:02 2011 @@ -381,12 +381,25 @@ TargetInfo GetTargetInfo(); //------------------------------------------------------------------ - /// [Used by IRInterpreter] Write to the target. + /// [Used by IRInterpreter] Promote an unknown address to a + /// LoadAddress or FileAddress depending on the presence of a + /// process. /// /// @param[in] addr + /// The address to promote. + /// + /// @return + /// The wrapped entity. + //------------------------------------------------------------------ + lldb_private::Value WrapBareAddress (lldb::addr_t addr); + + //------------------------------------------------------------------ + /// [Used by IRInterpreter] Write to the target. + /// + /// @param[in] value /// The address to write to. /// - /// @param[in] data + /// @param[in] addr /// The address of the data buffer to read from. /// /// @param[in] length @@ -406,7 +419,7 @@ /// @param[in] data /// The address of the data buffer to write to. /// - /// @param[in] addr + /// @param[in] value /// The address to read from. /// /// @param[in] length @@ -419,7 +432,7 @@ ReadTarget (uint8_t *data, lldb_private::Value &value, size_t length); - + //------------------------------------------------------------------ /// [Used by IRInterpreter] Get the Value for a NamedDecl. /// @@ -467,6 +480,10 @@ /// True if the data should be treated as disappearing after the /// expression completes. In that case, it gets no live data. /// + /// @param[in] maybe_make_load + /// True if the value is a file address but should be potentially + /// upgraded to a load address if a target is presence. + /// /// @return /// True on success; false otherwise. //------------------------------------------------------------------ @@ -475,7 +492,8 @@ lldb_private::Value &value, const ConstString &name, lldb_private::TypeFromParser type, - bool transient); + bool transient, + bool maybe_make_load); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Materialize the entire struct Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142638&r1=142637&r2=142638&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Oct 21 00:18:02 2011 @@ -350,7 +350,8 @@ lldb_private::Value &value, const ConstString &name, lldb_private::TypeFromParser type, - bool transient) + bool transient, + bool maybe_make_load) { assert (m_parser_vars.get()); @@ -358,6 +359,14 @@ if (!pvar_sp) return false; + + if (maybe_make_load && + value.GetValueType() == Value::eValueTypeFileAddress && + m_parser_vars->m_exe_ctx && + m_parser_vars->m_exe_ctx->GetProcessPtr()) + { + value.SetValueType(Value::eValueTypeLoadAddress); + } if (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && !pvar_sp->m_live_sp && @@ -782,6 +791,23 @@ // Interface for IRInterpreter +Value +ClangExpressionDeclMap::WrapBareAddress (lldb::addr_t addr) +{ + Value ret; + + ret.SetContext(Value::eContextTypeInvalid, NULL); + + if (m_parser_vars->m_exe_ctx && m_parser_vars->m_exe_ctx->GetProcessPtr()) + ret.SetValueType(Value::eValueTypeLoadAddress); + else + ret.SetValueType(Value::eValueTypeFileAddress); + + ret.GetScalar() = (unsigned long long)addr; + + return ret; +} + bool ClangExpressionDeclMap::WriteTarget (lldb_private::Value &value, const uint8_t *data, Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=142638&r1=142637&r2=142638&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Oct 21 00:18:02 2011 @@ -672,9 +672,9 @@ if (!m_has_side_effects) { - MaybeSetConstantResult (initializer, - m_result_name, - m_result_type); + //MaybeSetConstantResult (initializer, + // m_result_name, + // m_result_type); } StoreInst *synthesized_store = new StoreInst(initializer, @@ -688,7 +688,7 @@ { if (!m_has_side_effects && lldb_private::ClangASTContext::IsPointerType (m_result_type.GetOpaqueQualType())) { - MaybeSetCastResult (m_result_type); + //MaybeSetCastResult (m_result_type); } result_global->replaceAllUsesWith(new_result_global); Modified: lldb/trunk/source/Expression/IRInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=142638&r1=142637&r2=142638&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp (original) +++ lldb/trunk/source/Expression/IRInterpreter.cpp Fri Oct 21 00:18:02 2011 @@ -341,9 +341,23 @@ bool Read (uint8_t *data, lldb::addr_t addr, size_t length) { - lldb_private::Value target = GetAccessTarget(addr); + lldb_private::Value source = GetAccessTarget(addr); + + return m_decl_map.ReadTarget(data, source, length); + } + + bool WriteToRawPtr (lldb::addr_t addr, const uint8_t *data, size_t length) + { + lldb_private::Value target = m_decl_map.WrapBareAddress(addr); - return m_decl_map.ReadTarget(data, target, length); + return m_decl_map.WriteTarget(target, data, length); + } + + bool ReadFromRawPtr (uint8_t *data, lldb::addr_t addr, size_t length) + { + lldb_private::Value source = m_decl_map.WrapBareAddress(addr); + + return m_decl_map.ReadTarget(data, source, length); } std::string PrintData (lldb::addr_t addr, size_t length) @@ -533,11 +547,22 @@ const uint64_t *raw_data = constant_int->getValue().getRawData(); return m_memory.Write(region.m_base, (const uint8_t*)raw_data, constant_size); } - if (const ConstantFP *constant_fp = dyn_cast(constant)) + else if (const ConstantFP *constant_fp = dyn_cast(constant)) { const uint64_t *raw_data = constant_fp->getValueAPF().bitcastToAPInt().getRawData(); return m_memory.Write(region.m_base, (const uint8_t*)raw_data, constant_size); } + else if (const ConstantExpr *constant_expr = dyn_cast(constant)) + { + switch (constant_expr->getOpcode()) + { + default: + return false; + case Instruction::IntToPtr: + case Instruction::BitCast: + return ResolveConstant(region, constant_expr->getOperand(0)); + } + } return false; } @@ -718,6 +743,7 @@ lldb_private::Value base; bool transient = false; + bool maybe_make_load = false; if (m_decl_map.ResultIsReference(result_name)) { @@ -736,14 +762,25 @@ Memory::Region R_final = m_memory.Lookup(R_pointer, R_final_ty); - if (!R_final.m_allocation) - return false; - - if (R_final.m_allocation->m_data) - transient = true; // this is a stack allocation + if (R_final.m_allocation) + { + if (R_final.m_allocation->m_data) + transient = true; // this is a stack allocation - base = R_final.m_allocation->m_origin; - base.GetScalar() += (R_final.m_base - R_final.m_allocation->m_virtual_address); + base = R_final.m_allocation->m_origin; + base.GetScalar() += (R_final.m_base - R_final.m_allocation->m_virtual_address); + } + else + { + // We got a bare pointer. We are going to treat it as a load address + // or a file address, letting decl_map make the choice based on whether + // or not a process exists. + + base.SetContext(lldb_private::Value::eContextTypeInvalid, NULL); + base.SetValueType(lldb_private::Value::eValueTypeFileAddress); + base.GetScalar() = (unsigned long long)R_pointer; + maybe_make_load = true; + } } else { @@ -752,7 +789,7 @@ base.GetScalar() = (unsigned long long)R.m_allocation->m_data->GetBytes() + (R.m_base - R.m_allocation->m_virtual_address); } - return m_decl_map.CompleteResultVariable (result, base, result_name, result_type, transient); + return m_decl_map.CompleteResultVariable (result, base, result_name, result_type, transient, maybe_make_load); } }; @@ -829,6 +866,7 @@ } } break; + case Instruction::IntToPtr: case Instruction::Load: case Instruction::Mul: case Instruction::Ret: @@ -1236,6 +1274,35 @@ } } break; + case Instruction::IntToPtr: + { + const IntToPtrInst *int_to_ptr_inst = dyn_cast(inst); + + if (!int_to_ptr_inst) + { + if (log) + log->Printf("getOpcode() returns IntToPtr, but instruction is not an IntToPtrInst"); + + return false; + } + + Value *src_operand = int_to_ptr_inst->getOperand(0); + + lldb_private::Scalar I; + + if (!frame.EvaluateValue(I, src_operand, llvm_module)) + return false; + + frame.AssignValue(inst, I, llvm_module); + + if (log) + { + log->Printf("Interpreted an IntToPtr"); + log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str()); + log->Printf(" = : %s", frame.SummarizeValue(inst).c_str()); + } + } + break; case Instruction::Load: { const LoadInst *load_inst = dyn_cast(inst); @@ -1289,13 +1356,35 @@ Memory::Region R = memory.Lookup(pointer, target_ty); - memory.Read(D_encoder->GetDataStart(), R.m_base, target_data.getTypeStoreSize(target_ty)); + if (R.IsValid()) + { + if (!memory.Read(D_encoder->GetDataStart(), R.m_base, target_data.getTypeStoreSize(target_ty))) + { + if (log) + log->Printf("Couldn't read from a region on behalf of a LoadInst"); + + return false; + } + } + else + { + if (!memory.ReadFromRawPtr(D_encoder->GetDataStart(), pointer, target_data.getTypeStoreSize(target_ty))) + { + if (log) + log->Printf("Couldn't read from a raw pointer on behalf of a LoadInst"); + + return false; + } + } if (log) { log->Printf("Interpreted a LoadInst"); log->Printf(" P : %s", frame.SummarizeValue(pointer_operand).c_str()); - log->Printf(" R : %s", memory.SummarizeRegion(R).c_str()); + if (R.IsValid()) + log->Printf(" R : %s", memory.SummarizeRegion(R).c_str()); + else + log->Printf(" R : raw pointer 0x%llx", (unsigned long long)pointer); log->Printf(" D : %s", frame.SummarizeValue(load_inst).c_str()); } } @@ -1365,15 +1454,27 @@ Memory::Region R = memory.Lookup(pointer, target_ty); - if (R.IsInvalid()) + if (R.IsValid()) { - if (log) - log->Printf("StoreInst's pointer doesn't point to a valid target"); - - return false; + if (!memory.Write(R.m_base, D_extractor->GetDataStart(), target_data.getTypeStoreSize(target_ty))) + { + if (log) + log->Printf("Couldn't write to a region on behalf of a LoadInst"); + + return false; + } + } + else + { + if (!memory.WriteToRawPtr(pointer, D_extractor->GetDataStart(), target_data.getTypeStoreSize(target_ty))) + { + if (log) + log->Printf("Couldn't write to a raw pointer on behalf of a LoadInst"); + + return false; + } } - memory.Write(R.m_base, D_extractor->GetDataStart(), target_data.getTypeStoreSize(target_ty)); if (log) { From johnny.chen at apple.com Fri Oct 21 12:57:04 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 21 Oct 2011 17:57:04 -0000 Subject: [Lldb-commits] [lldb] r142663 - /lldb/trunk/test/api/check_public_api_headers/main.cpp.template Message-ID: <20111021175704.323682A6C12C@llvm.org> Author: johnny Date: Fri Oct 21 12:57:04 2011 New Revision: 142663 URL: http://llvm.org/viewvc/llvm-project?rev=142663&view=rev Log: Fix the compilation warning while running the test case. Modified: lldb/trunk/test/api/check_public_api_headers/main.cpp.template Modified: lldb/trunk/test/api/check_public_api_headers/main.cpp.template URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/api/check_public_api_headers/main.cpp.template?rev=142663&r1=142662&r2=142663&view=diff ============================================================================== --- lldb/trunk/test/api/check_public_api_headers/main.cpp.template (original) +++ lldb/trunk/test/api/check_public_api_headers/main.cpp.template Fri Oct 21 12:57:04 2011 @@ -17,7 +17,7 @@ SBDebugger::Initialize(); SBDebugger dbg = SBDebugger::Create(); - printf("Hello SBDebugger %d\n", dbg.GetID()); // Set breakpoint here. + printf("Hello SBDebugger %llu\n", dbg.GetID()); // Set breakpoint here. SBDebugger::Terminate(); return 0; From johnny.chen at apple.com Fri Oct 21 13:33:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 21 Oct 2011 18:33:27 -0000 Subject: [Lldb-commits] [lldb] r142668 - /lldb/trunk/test/dotest.py Message-ID: <20111021183327.D698F2A6C12C@llvm.org> Author: johnny Date: Fri Oct 21 13:33:27 2011 New Revision: 142668 URL: http://llvm.org/viewvc/llvm-project?rev=142668&view=rev Log: Add a '-n' option to turn off printings of build dir, lldb version, svn info, and other headers which happen before the listingings of test cases. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=142668&r1=142667&r2=142668&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Oct 21 13:33:27 2011 @@ -131,6 +131,10 @@ # By default, we skip long running test case. Use '-l' option to override. skipLongRunningTest = True +# By default, we print the build dir, lldb version, and svn info. Use '-n' option to +# turn it off. +noHeaders = False + # The regular expression pattern to match against eligible filenames as our test cases. regexp = None @@ -201,6 +205,7 @@ other to bring the debugger to a desired state, so that, for example, further benchmarking can be done -l : don't skip long running test +-n : don't print the headers like build dir, lldb version, and svn info at all -p : specify a regexp filename pattern for inclusion in the test suite -r : specify a dir to relocate the tests and their intermediate files to; the directory must not exist before running this test driver; @@ -333,6 +338,7 @@ global ignore global runHooks global skipLongRunningTest + global noHeaders global regexp global rdir global sdir_name @@ -444,6 +450,9 @@ elif sys.argv[index].startswith('-l'): skipLongRunningTest = False index += 1 + elif sys.argv[index].startswith('-n'): + noHeaders = True + index += 1 elif sys.argv[index].startswith('-p'): # Increment by 1 to fetch the reg exp pattern argument. index += 1 @@ -575,6 +584,7 @@ global rdir global testdirs global dumpSysPath + global noHeaders global svn_info # Get the directory containing the current script. @@ -659,7 +669,8 @@ if not lldbExec: lldbExec = lldbHere os.environ["LLDB_BUILD_DIR"] = os.path.split(lldbExec)[0] - print "LLDB build dir:", os.environ["LLDB_BUILD_DIR"] + if not noHeaders: + print "LLDB build dir:", os.environ["LLDB_BUILD_DIR"] # One last chance to locate the 'lldb' executable. if not lldbExec: @@ -673,7 +684,8 @@ else: os.environ["LLDB_EXEC"] = lldbExec #print "The 'lldb' executable path is", lldbExec - os.system('%s -v' % lldbExec) + if not noHeaders: + os.system('%s -v' % lldbExec) if os.path.isdir(os.path.join(base, '.svn')): pipe = subprocess.Popen(["svn", "info", base], stdout = subprocess.PIPE) @@ -681,7 +693,8 @@ elif os.path.isdir(os.path.join(base, '.git')): pipe = subprocess.Popen(["git", "svn", "info", base], stdout = subprocess.PIPE) svn_info = pipe.stdout.read() - print svn_info + if not noHeaders: + print svn_info global ignore @@ -942,9 +955,10 @@ sdir_name = timestamp os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(os.getcwd(), sdir_name) -sys.stderr.write("\nSession logs for test failures/errors/unexpected successes" - " will go into directory '%s'\n" % sdir_name) -sys.stderr.write("Command invoked: %s\n" % getMyCommandLine()) +if not noHeaders: + sys.stderr.write("\nSession logs for test failures/errors/unexpected successes" + " will go into directory '%s'\n" % sdir_name) + sys.stderr.write("Command invoked: %s\n" % getMyCommandLine()) if not os.path.isdir(sdir_name): os.mkdir(sdir_name) From johnny.chen at apple.com Fri Oct 21 15:11:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 21 Oct 2011 20:11:40 -0000 Subject: [Lldb-commits] [lldb] r142676 - /lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Message-ID: <20111021201140.4209F2A6C12C@llvm.org> Author: johnny Date: Fri Oct 21 15:11:40 2011 New Revision: 142676 URL: http://llvm.org/viewvc/llvm-project?rev=142676&view=rev Log: Rephrase benchmark output display. Modified: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Modified: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/startup/TestStartupDelays.py?rev=142676&r1=142675&r2=142676&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/startup/TestStartupDelays.py (original) +++ lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Fri Oct 21 15:11:40 2011 @@ -33,9 +33,8 @@ """Test start up delays creating a target and setting a breakpoint.""" print self.run_startup_delays_bench(self.exe, self.break_spec, self.count) - print "lldb startup delays benchmark:" - print "create fresh target:", self.stopwatch - print "set first breakpoint:", self.stopwatch2 + print "lldb startup delay (create fresh target) benchmark:", self.stopwatch + print "lldb startup delay (set first breakpoint) benchmark:", self.stopwatch2 def run_startup_delays_bench(self, exe, break_spec, count): # Set self.child_prompt, which is "(lldb) ". From johnny.chen at apple.com Fri Oct 21 15:19:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 21 Oct 2011 20:19:51 -0000 Subject: [Lldb-commits] [lldb] r142678 - in /lldb/trunk/test/benchmarks/frame_variable: ./ TestFrameVariableResponse.py Message-ID: <20111021201951.AF7672A6C12C@llvm.org> Author: johnny Date: Fri Oct 21 15:19:51 2011 New Revision: 142678 URL: http://llvm.org/viewvc/llvm-project?rev=142678&view=rev Log: Add a benchmark for measuring the response time of the 'frame variable' command. Example (start the lldb inferior, break at the Driver::MainLoop() function, and issue 'frame variable'): $ ./dotest.py -v +b -x '-F Driver::MainLoop()' -n -p TestFrameVariableResponse.py ---------------------------------------------------------------------- Collected 1 test 1: test_startup_delay (TestFrameVariableResponse.FrameVariableResponseBench) Test response time for the 'frame variable' command. ... lldb frame variable benchmark: Avg: 1.636897 (Laps: 20, Total Elapsed Time: 32.737944) ok ---------------------------------------------------------------------- Ran 1 test in 65.105s OK Added: lldb/trunk/test/benchmarks/frame_variable/ lldb/trunk/test/benchmarks/frame_variable/TestFrameVariableResponse.py Added: lldb/trunk/test/benchmarks/frame_variable/TestFrameVariableResponse.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/frame_variable/TestFrameVariableResponse.py?rev=142678&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/frame_variable/TestFrameVariableResponse.py (added) +++ lldb/trunk/test/benchmarks/frame_variable/TestFrameVariableResponse.py Fri Oct 21 15:19:51 2011 @@ -0,0 +1,79 @@ +"""Test lldb's response time for 'frame variable' command.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class FrameVariableResponseBench(BenchBase): + + mydir = os.path.join("benchmarks", "frame_variable") + + def setUp(self): + BenchBase.setUp(self) + if lldb.bmExecutable: + self.exe = lldb.bmExecutable + else: + self.exe = self.lldbHere + if lldb.bmBreakpointSpec: + self.break_spec = lldb.bmBreakpointSpec + else: + self.break_spec = '-n main' + + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 20 + + @benchmarks_test + def test_startup_delay(self): + """Test response time for the 'frame variable' command.""" + print + self.run_frame_variable_bench(self.exe, self.break_spec, self.count) + print "lldb frame variable benchmark:", self.stopwatch + + def run_frame_variable_bench(self, exe, break_spec, count): + # Set self.child_prompt, which is "(lldb) ". + self.child_prompt = '(lldb) ' + prompt = self.child_prompt + + # Reset the stopwatchs now. + self.stopwatch.reset() + for i in range(count): + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s %s' % (self.lldbHere, self.lldbOption, exe)) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + # Set our breakpoint. + child.sendline('breakpoint set %s' % break_spec) + child.expect_exact(prompt) + + # Run the target and expect it to be stopped due to breakpoint. + child.sendline('run') # Aka 'process launch'. + child.expect_exact(prompt) + + with self.stopwatch: + # Measure the 'frame variable' response time. + child.sendline('frame variable') + child.expect_exact(prompt) + + child.sendline('quit') + try: + self.child.expect(pexpect.EOF) + except: + pass + + # The test is about to end and if we come to here, the child process has + # been terminated. Mark it so. + self.child = None + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From gclayton at apple.com Fri Oct 21 16:41:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 21 Oct 2011 21:41:45 -0000 Subject: [Lldb-commits] [lldb] r142688 - in /lldb/trunk/source/Plugins/Process: MacOSX-Kernel/ProcessKDP.cpp gdb-remote/ProcessGDBRemote.cpp Message-ID: <20111021214145.44A973128042@llvm.org> Author: gclayton Date: Fri Oct 21 16:41:45 2011 New Revision: 142688 URL: http://llvm.org/viewvc/llvm-project?rev=142688&view=rev Log: If a process plug-in was specified by name, always let the plug-in get used. Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=142688&r1=142687&r2=142688&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Fri Oct 21 16:41:45 2011 @@ -58,6 +58,9 @@ bool ProcessKDP::CanDebug(Target &target, bool plugin_specified_by_name) { + if (plugin_specified_by_name) + return true; + // For now we are just making sure the file exists for a given module Module *exe_module = target.GetExecutableModulePointer(); if (exe_module) @@ -71,10 +74,8 @@ exe_objfile->GetStrata() == ObjectFile::eStrataKernel) return true; } - return false; } - // No target executable, assume we can debug if our plug-in was specified by name - return plugin_specified_by_name; + return false; } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=142688&r1=142687&r2=142688&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Oct 21 16:41:45 2011 @@ -103,6 +103,9 @@ bool ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name) { + if (plugin_specified_by_name) + return true; + // For now we are just making sure the file exists for a given module Module *exe_module = target.GetExecutableModulePointer(); if (exe_module) From scallanan at apple.com Fri Oct 21 17:18:07 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 21 Oct 2011 22:18:07 -0000 Subject: [Lldb-commits] [lldb] r142690 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Symbol/ClangASTImporter.h source/Expression/ClangExpressionDeclMap.cpp source/Symbol/ClangASTImporter.cpp Message-ID: <20111021221807.96C153128042@llvm.org> Author: spyffe Date: Fri Oct 21 17:18:07 2011 New Revision: 142690 URL: http://llvm.org/viewvc/llvm-project?rev=142690&view=rev Log: Implemented an extension to the namespace map that permits a namespace map to be created and populated when the namespace is imported, not just when it is requested via FindExternalVisibleDecls(). Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=142690&r1=142689&r2=142690&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Oct 21 17:18:07 2011 @@ -56,7 +56,7 @@ /// Fourth and finally, it "dematerializes" the struct after the JITted code has /// has executed, placing the new values back where it found the old ones. //---------------------------------------------------------------------- -class ClangExpressionDeclMap +class ClangExpressionDeclMap : public ClangASTImporter::NamespaceMapCompleter { public: //------------------------------------------------------------------ @@ -695,6 +695,25 @@ assert(m_parser_vars.get()); m_parser_vars->m_enable_lookups = true; } + + //------------------------------------------------------------------ + /// [Used by ClangASTImporter] Look up the modules containing a + /// given namespace and put the appropriate entries in the namespace + /// map. + /// + /// @param[in] namespace_map + /// The map to be completed. + /// + /// @param[in] name + /// The name of the namespace to be found. + /// + /// @param[in] parent_map + /// The map for the namespace's parent namespace, if there is + /// one. + //------------------------------------------------------------------ + void CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, + const ConstString &name, + ClangASTImporter::NamespaceMapSP &parent_map) const; private: ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser. @@ -707,7 +726,8 @@ class ParserVars { public: - ParserVars() : + ParserVars(ClangExpressionDeclMap &decl_map) : + m_decl_map(decl_map), m_exe_ctx(NULL), m_sym_ctx(), m_persistent_vars(NULL), @@ -734,6 +754,8 @@ if (m_ast_importer->TargetASTContext() != ast_context) return NULL; + m_ast_importer->InstallMapCompleter(m_decl_map); + return m_ast_importer.get(); } @@ -745,6 +767,7 @@ std::auto_ptr m_ast_importer; ///< The importer used to import types on the parser's behalf. TargetInfo m_target_info; ///< Basic information about the target. private: + ClangExpressionDeclMap &m_decl_map; DISALLOW_COPY_AND_ASSIGN (ParserVars); }; @@ -757,7 +780,7 @@ EnableParserVars() { if (!m_parser_vars.get()) - m_parser_vars.reset(new ParserVars); + m_parser_vars.reset(new ParserVars(*this)); } //---------------------------------------------------------------------- Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=142690&r1=142689&r2=142690&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Fri Oct 21 17:18:07 2011 @@ -71,10 +71,27 @@ typedef std::vector < std::pair > NamespaceMap; typedef lldb::SharedPtr::Type NamespaceMapSP; - void RegisterNamespaceMap(const clang::NamespaceDecl *decl, - NamespaceMapSP &namespace_map); + void RegisterNamespaceMap (const clang::NamespaceDecl *decl, + NamespaceMapSP &namespace_map); - NamespaceMapSP GetNamespaceMap(const clang::NamespaceDecl *decl); + class NamespaceMapCompleter + { + public: + virtual ~NamespaceMapCompleter (); + + virtual void CompleteNamespaceMap (NamespaceMapSP &namespace_map, + const ConstString &name, + NamespaceMapSP &parent_map) const = 0; + }; + + void InstallMapCompleter (NamespaceMapCompleter &completer) + { + m_map_completer = &completer; + } + + NamespaceMapSP GetNamespaceMap (const clang::NamespaceDecl *decl); + + void BuildNamespaceMap (const clang::NamespaceDecl *decl); private: struct DeclOrigin @@ -166,12 +183,13 @@ typedef std::map NamespaceMetaMap; - NamespaceMetaMap m_namespace_maps; - clang::FileManager m_file_manager; - clang::ASTContext *m_target_ctx; - MinionMap m_minions; - MinionMap m_minimal_minions; - OriginMap m_origins; + NamespaceMetaMap m_namespace_maps; + NamespaceMapCompleter *m_map_completer; + clang::FileManager m_file_manager; + clang::ASTContext *m_target_ctx; + MinionMap m_minions; + MinionMap m_minimal_minions; + OriginMap m_origins; }; } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142690&r1=142689&r2=142690&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Oct 21 17:18:07 2011 @@ -2036,6 +2036,103 @@ return VariableSP(); } +// Interface for ClangASTImporter + +void +ClangExpressionDeclMap::CompleteNamespaceMap (ClangASTImporter::NamespaceMapSP &namespace_map, + const ConstString &name, + ClangASTImporter::NamespaceMapSP &parent_map) const +{ + static unsigned int invocation_id = 0; + unsigned int current_id = invocation_id++; + + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (log) + { + if (parent_map && parent_map->size()) + log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s in namespace %s", + current_id, + name.GetCString(), + parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); + else + log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s", + current_id, + name.GetCString()); + } + + + if (parent_map) + { + for (ClangASTImporter::NamespaceMap::iterator i = parent_map->begin(), e = parent_map->end(); + i != e; + ++i) + { + ClangNamespaceDecl found_namespace_decl; + + ModuleSP module_sp = i->first; + ClangNamespaceDecl module_parent_namespace_decl = i->second; + + SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor(); + + if (!symbol_vendor) + continue; + + SymbolContext null_sc; + + found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &module_parent_namespace_decl); + + if (!found_namespace_decl) + continue; + + namespace_map->push_back(std::pair(module_sp, found_namespace_decl)); + + if (log) + log->Printf(" CMN[%u] Found namespace %s in module %s", + current_id, + name.GetCString(), + module_sp->GetFileSpec().GetFilename().GetCString()); + } + } + else + { + ModuleList &images = m_parser_vars->m_sym_ctx.target_sp->GetImages(); + ClangNamespaceDecl null_namespace_decl; + + for (uint32_t i = 0, e = images.GetSize(); + i != e; + ++i) + { + ModuleSP image = images.GetModuleAtIndex(i); + + if (!image) + continue; + + ClangNamespaceDecl found_namespace_decl; + + SymbolVendor *symbol_vendor = image->GetSymbolVendor(); + + if (!symbol_vendor) + continue; + + SymbolContext null_sc; + + found_namespace_decl = symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl); + + if (!found_namespace_decl) + continue; + + namespace_map->push_back(std::pair(image, found_namespace_decl)); + + if (log) + log->Printf(" CMN[%u] Found namespace %s in module %s", + current_id, + name.GetCString(), + image->GetFileSpec().GetFilename().GetCString()); + } + } +} + // Interface for ClangASTSource void @@ -2067,7 +2164,7 @@ if (const NamespaceDecl *namespace_context = dyn_cast(context.m_decl_context)) { - ClangASTImporter::NamespaceMapSP namespace_map = m_parser_vars->m_ast_importer->GetNamespaceMap(namespace_context); + ClangASTImporter::NamespaceMapSP namespace_map = m_parser_vars->GetASTImporter(context.GetASTContext())->GetNamespaceMap(namespace_context); if (log && log->GetVerbose()) log->Printf(" FEVD[%u] Inspecting namespace map %p (%d entries)", @@ -2075,6 +2172,9 @@ namespace_map.get(), (int)namespace_map->size()); + if (!namespace_map) + return; + for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(), e = namespace_map->end(); i != e; ++i) Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=142690&r1=142689&r2=142690&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Fri Oct 21 17:18:07 2011 @@ -10,8 +10,10 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" +#include "lldb/Symbol/ClangNamespaceDecl.h" using namespace lldb_private; using namespace clang; @@ -111,6 +113,35 @@ return NamespaceMapSP(); } +void +ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) +{ + const DeclContext *parent_context = decl->getDeclContext(); + const NamespaceDecl *parent_namespace = dyn_cast(parent_context); + NamespaceMapSP parent_map; + + if (parent_namespace) + parent_map = GetNamespaceMap(parent_namespace); + + NamespaceMapSP new_map; + + new_map.reset(new NamespaceMap); + + if (m_map_completer) + { + std::string namespace_string = decl->getDeclName().getAsString(); + + m_map_completer->CompleteNamespaceMap (new_map, ConstString(namespace_string.c_str()), parent_map); + } + + RegisterNamespaceMap (decl, new_map); +} + +ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter () +{ + return; +} + clang::Decl *ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) { @@ -131,6 +162,15 @@ (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : "")); } + if (isa(from)) + { + NamespaceDecl *to_namespace_decl = dyn_cast(to); + + m_master.BuildNamespaceMap(to_namespace_decl); + + to_namespace_decl->setHasExternalVisibleStorage(); + } + if (isa(from)) { ObjCInterfaceDecl *to_interface_decl = dyn_cast(to); From gclayton at apple.com Fri Oct 21 18:04:20 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 21 Oct 2011 23:04:20 -0000 Subject: [Lldb-commits] [lldb] r142698 - /lldb/trunk/source/Symbol/ClangASTImporter.cpp Message-ID: <20111021230420.EB8CD3128042@llvm.org> Author: gclayton Date: Fri Oct 21 18:04:20 2011 New Revision: 142698 URL: http://llvm.org/viewvc/llvm-project?rev=142698&view=rev Log: Fixed a missing quote. Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=142698&r1=142697&r2=142698&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Fri Oct 21 18:04:20 2011 @@ -10,7 +10,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclObjC.h" #include "lldb/Core/Log.h" -#include "lldb/Core/Module.h +#include "lldb/Core/Module.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Symbol/ClangNamespaceDecl.h" From scallanan at apple.com Fri Oct 21 18:40:00 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 21 Oct 2011 23:40:00 -0000 Subject: [Lldb-commits] [lldb] r142702 - /lldb/trunk/source/Expression/ClangExpressionParser.cpp Message-ID: <20111021234001.08A5D3128042@llvm.org> Author: spyffe Date: Fri Oct 21 18:40:00 2011 New Revision: 142702 URL: http://llvm.org/viewvc/llvm-project?rev=142702&view=rev Log: Enabled dedicated debugger support in Clang, meaning that Objective-C methods returning types incompatible with "id" can be properly cast. Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=142702&r1=142701&r2=142702&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Fri Oct 21 18:40:00 2011 @@ -231,7 +231,7 @@ m_compiler->getLangOpts().ThreadsafeStatics = false; m_compiler->getLangOpts().AccessControl = false; // Debuggers get universal access m_compiler->getLangOpts().DollarIdents = true; // $ indicates a persistent variable name - //m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients + m_compiler->getLangOpts().DebuggerSupport = true; // Features specifically for debugger clients // Set CodeGen options m_compiler->getCodeGenOpts().EmitDeclMetadata = true; From jmolenda at apple.com Fri Oct 21 19:47:42 2011 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 22 Oct 2011 00:47:42 -0000 Subject: [Lldb-commits] [lldb] r142707 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20111022004742.176412A6C12C@llvm.org> Author: jmolenda Date: Fri Oct 21 19:47:41 2011 New Revision: 142707 URL: http://llvm.org/viewvc/llvm-project?rev=142707&view=rev Log: Add "stepi" as an alias for thread step-inst in addition to "si". Add "nexti" an "ni" as aliases for thread step-inst-over. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=142707&r1=142706&r2=142707&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Oct 21 19:47:41 2011 @@ -122,7 +122,17 @@ cmd_obj_sp = GetCommandSPExact ("thread step-inst", false); if (cmd_obj_sp) + { + AddAlias ("stepi", cmd_obj_sp); AddAlias ("si", cmd_obj_sp); + } + + cmd_obj_sp = GetCommandSPExact ("thread step-inst-over", false); + if (cmd_obj_sp) + { + AddAlias ("nexti", cmd_obj_sp); + AddAlias ("ni", cmd_obj_sp); + } cmd_obj_sp = GetCommandSPExact ("thread step-in", false); if (cmd_obj_sp) From johnny.chen at apple.com Fri Oct 21 19:57:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 22 Oct 2011 00:57:05 -0000 Subject: [Lldb-commits] [lldb] r142708 - in /lldb/trunk/test: bench.py benchmarks/disassembly/TestDoAttachThenDisassembly.py benchmarks/expression/TestExpressionCmd.py benchmarks/startup/TestStartupDelays.py dotest.py Message-ID: <20111022005705.B83543128042@llvm.org> Author: johnny Date: Fri Oct 21 19:57:05 2011 New Revision: 142708 URL: http://llvm.org/viewvc/llvm-project?rev=142708&view=rev Log: Add bench.py as a driver script to run some benchmarks on lldb. Add benchmarks for expression evaluations (TestExpressionCmd.py) and disassembly (TestDoAttachThenDisassembly.py). An example: [17:45:55] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py 2>&1 | grep -P '^lldb.*benchmark:' lldb startup delay (create fresh target) benchmark: Avg: 0.104274 (Laps: 30, Total Elapsed Time: 3.128214) lldb startup delay (set first breakpoint) benchmark: Avg: 0.102216 (Laps: 30, Total Elapsed Time: 3.066470) lldb frame variable benchmark: Avg: 1.649162 (Laps: 20, Total Elapsed Time: 32.983245) lldb stepping benchmark: Avg: 0.104409 (Laps: 50, Total Elapsed Time: 5.220461) lldb expr cmd benchmark: Avg: 0.206774 (Laps: 25, Total Elapsed Time: 5.169350) lldb disassembly benchmark: Avg: 0.089086 (Laps: 10, Total Elapsed Time: 0.890859) Added: lldb/trunk/test/bench.py (with props) lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py lldb/trunk/test/benchmarks/expression/TestExpressionCmd.py Modified: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py lldb/trunk/test/dotest.py Added: lldb/trunk/test/bench.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bench.py?rev=142708&view=auto ============================================================================== --- lldb/trunk/test/bench.py (added) +++ lldb/trunk/test/bench.py Fri Oct 21 19:57:05 2011 @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +""" +A simple bench runner which delegates to the ./dotest.py test driver to run the +benchmarks defined in the list named 'benches'. + +You need to hand edit 'benches' to modify/change the command lines passed to the +test driver. + +Use the following to get only the benchmark results in your terminal output: + + ./bench.py 2>&1 | grep -P '^lldb.*benchmark:' +""" + +import os, sys +import re + +# dotest.py invocation with no '-e exe-path' uses lldb as the inferior program, +# unless there is a mentioning of custom executable program. +benches = [ + # Measure startup delays creating a target and setting a breakpoint at main. + './dotest.py -v +b -n -p TestStartupDelays.py', + + # Measure 'frame variable' response after stopping at Driver::MainLoop(). + './dotest.py -v +b -x "-F Driver::MainLoop()" -n -p TestFrameVariableResponse.py', + + # Measure stepping speed after stopping at Driver::MainLoop(). + './dotest.py -v +b -x "-F Driver::MainLoop()" -n -p TestSteppingSpeed.py', + + # Measure expression cmd response with a simple custom executable program. + './dotest.py +b -n -p TestExpressionCmd.py', + + # Attach to a spawned lldb process then run disassembly benchmarks. + './dotest.py -v +b -n -p TestDoAttachThenDisassembly.py' +] + +def main(): + """Read the items from 'benches' and run the command line one by one.""" + print "Starting bench runner...." + + for command in benches: + print "Running %s" % (command) + os.system(command) + + print "Bench runner done." + +if __name__ == '__main__': + main() Propchange: lldb/trunk/test/bench.py ------------------------------------------------------------------------------ svn:executable = * Added: lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py?rev=142708&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py (added) +++ lldb/trunk/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py Fri Oct 21 19:57:05 2011 @@ -0,0 +1,66 @@ +"""Test lldb's disassemblt speed.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class AttachThenDisassemblyBench(BenchBase): + + mydir = os.path.join("benchmarks", "disassembly") + + def setUp(self): + BenchBase.setUp(self) + + @benchmarks_test + def test_attach_then_disassembly(self): + """Attach to a spawned lldb process then run disassembly benchmarks.""" + print + self.run_lldb_attach_then_disassembly(10) + print "lldb disassembly benchmark:", self.stopwatch + + def run_lldb_attach_then_disassembly(self, count): + target = self.dbg.CreateTarget(self.lldbHere) + + # Spawn a new process and don't display the stdout if not in TraceOn() mode. + import subprocess + popen = subprocess.Popen([self.lldbHere, self.lldbOption], + stdout = open(os.devnull, 'w') if not self.TraceOn() else None) + if self.TraceOn(): + print "pid of spawned process: %d" % popen.pid + + # Attach to the launched lldb process. + listener = lldb.SBListener("my.attach.listener") + error = lldb.SBError() + process = target.AttachToProcessWithID(listener, popen.pid, error) + + # Set thread0 as the selected thread, followed by the 'MainLoop' frame + # as the selected frame. Then do disassembly on the function. + thread0 = process.GetThreadAtIndex(0) + process.SetSelectedThread(thread0) + i = 0 + found = False + for f in thread0: + #print "frame#%d %s" % (i, f.GetFunctionName()) + if "MainLoop" in f.GetFunctionName(): + found = True + thread0.SetSelectedFrame(i) + if self.TraceOn(): + print "Found frame#%d for function 'MainLoop'" % i + break + i += 1 + + # Reset the stopwatch now. + self.stopwatch.reset() + for i in range(count): + with self.stopwatch: + # Disassemble the function. + self.runCmd("disassemble -f") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/benchmarks/expression/TestExpressionCmd.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/expression/TestExpressionCmd.py?rev=142708&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/expression/TestExpressionCmd.py (added) +++ lldb/trunk/test/benchmarks/expression/TestExpressionCmd.py Fri Oct 21 19:57:05 2011 @@ -0,0 +1,76 @@ +"""Test lldb's expression evaluations and collect statistics.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class ExpressionEvaluationCase(BenchBase): + + mydir = os.path.join("benchmarks", "expression") + + def setUp(self): + BenchBase.setUp(self) + self.source = 'main.cpp' + self.line_to_break = line_number(self.source, '// Set breakpoint here.') + self.count = lldb.bmIterationCount + if self.count <= 0: + self.count = 25 + + @benchmarks_test + def test_expr_cmd(self): + """Test lldb's expression commands and collect statistics.""" + self.buildDefault() + self.exe_name = 'a.out' + + print + self.run_lldb_repeated_exprs(self.exe_name, self.count) + print "lldb expr cmd benchmark:", self.stopwatch + + def run_lldb_repeated_exprs(self, exe_name, count): + exe = os.path.join(os.getcwd(), exe_name) + + # Set self.child_prompt, which is "(lldb) ". + self.child_prompt = '(lldb) ' + prompt = self.child_prompt + + # Reset the stopwatch now. + self.stopwatch.reset() + for i in range(count): + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s %s' % (self.lldbExec, self.lldbOption, exe)) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + child.expect_exact(prompt) + child.sendline('breakpoint set -f %s -l %d' % (self.source, self.line_to_break)) + child.expect_exact(prompt) + child.sendline('run') + child.expect_exact(prompt) + expr_cmd1 = 'expr ptr[j]->point.x' + expr_cmd2 = 'expr ptr[j]->point.y' + + with self.stopwatch: + child.sendline(expr_cmd1) + child.expect_exact(prompt) + child.sendline(expr_cmd2) + child.expect_exact(prompt) + + child.sendline('quit') + try: + self.child.expect(pexpect.EOF) + except: + pass + + self.child = None + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Modified: lldb/trunk/test/benchmarks/startup/TestStartupDelays.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/startup/TestStartupDelays.py?rev=142708&r1=142707&r2=142708&view=diff ============================================================================== --- lldb/trunk/test/benchmarks/startup/TestStartupDelays.py (original) +++ lldb/trunk/test/benchmarks/startup/TestStartupDelays.py Fri Oct 21 19:57:05 2011 @@ -26,7 +26,7 @@ self.count = lldb.bmIterationCount if self.count <= 0: - self.count = 15 + self.count = 30 @benchmarks_test def test_startup_delay(self): Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=142708&r1=142707&r2=142708&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Oct 21 19:57:05 2011 @@ -1062,10 +1062,11 @@ #print "sys.stdout name is", sys.stdout.name # First, write out the number of collected test cases. - sys.stderr.write(separator + "\n") - sys.stderr.write("Collected %d test%s\n\n" - % (suite.countTestCases(), - suite.countTestCases() != 1 and "s" or "")) + if not noHeaders: + sys.stderr.write(separator + "\n") + sys.stderr.write("Collected %d test%s\n\n" + % (suite.countTestCases(), + suite.countTestCases() != 1 and "s" or "")) class LLDBTestResult(unittest2.TextTestResult): """ From jmolenda at apple.com Fri Oct 21 20:30:52 2011 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 22 Oct 2011 01:30:52 -0000 Subject: [Lldb-commits] [lldb] r142710 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20111022013052.A54EA2A6C12C@llvm.org> Author: jmolenda Date: Fri Oct 21 20:30:52 2011 New Revision: 142710 URL: http://llvm.org/viewvc/llvm-project?rev=142710&view=rev Log: Add "display" and "undisplay" aliases for target stop-hook add/delete. A patina of gdb's "display" command, intended mostly for simply monitoring a variable as you step through source code. Formatters do not work, e.g. display/x $pc does not work. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=142710&r1=142709&r2=142710&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Oct 21 20:30:52 2011 @@ -174,6 +174,14 @@ if (cmd_obj_sp) AddAlias ("down", cmd_obj_sp); + cmd_obj_sp = GetCommandSPExact ("_display", false); + if (cmd_obj_sp) + AddAlias ("display", cmd_obj_sp); + + cmd_obj_sp = GetCommandSPExact ("_undisplay", false); + if (cmd_obj_sp) + AddAlias ("undisplay", cmd_obj_sp); + cmd_obj_sp = GetCommandSPExact ("target create", false); if (cmd_obj_sp) AddAlias ("file", cmd_obj_sp); @@ -212,7 +220,6 @@ AddOrReplaceAliasOptions ("r", alias_arguments_vector_sp); AddOrReplaceAliasOptions ("run", alias_arguments_vector_sp); } - } const char * @@ -328,6 +335,35 @@ m_command_dict[up_regex_cmd_sp->GetCommandName ()] = up_regex_cmd_sp; } } + + std::auto_ptr + display_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "_display", + "Add an expression evaluation stop-hook.", + "_display expression", 2)); + if (display_regex_cmd_ap.get()) + { + if (display_regex_cmd_ap->AddRegexCommand("^(.+)$", "target stop-hook add -o \"expr -- %1\"")) + { + CommandObjectSP display_regex_cmd_sp(display_regex_cmd_ap.release()); + m_command_dict[display_regex_cmd_sp->GetCommandName ()] = display_regex_cmd_sp; + } + } + + std::auto_ptr + undisplay_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "_undisplay", + "Remove an expression evaluation stop-hook.", + "_undisplay stop-hook-number", 2)); + if (undisplay_regex_cmd_ap.get()) + { + if (undisplay_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "target stop-hook delete %1")) + { + CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_ap.release()); + m_command_dict[undisplay_regex_cmd_sp->GetCommandName ()] = undisplay_regex_cmd_sp; + } + } + } int From scallanan at apple.com Fri Oct 21 20:58:08 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 22 Oct 2011 01:58:08 -0000 Subject: [Lldb-commits] [lldb] r142712 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111022015808.E8B6F2A6C12C@llvm.org> Author: spyffe Date: Fri Oct 21 20:58:08 2011 New Revision: 142712 URL: http://llvm.org/viewvc/llvm-project?rev=142712&view=rev Log: Made the expression parser handle persistent variables correctly even after the process has quit. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=142712&r1=142711&r2=142712&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Oct 21 20:58:08 2011 @@ -972,9 +972,11 @@ { if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference || persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) && - persistent_var_sp->m_live_sp) + persistent_var_sp->m_live_sp && + m_parser_vars->m_exe_ctx->GetProcessSP() && + m_parser_vars->m_exe_ctx->GetProcessSP()->IsAlive()) { - return persistent_var_sp->m_live_sp->GetValue(); + return persistent_var_sp->m_live_sp->GetValue(); } else { From jmolenda at apple.com Fri Oct 21 21:31:42 2011 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 22 Oct 2011 02:31:42 -0000 Subject: [Lldb-commits] [lldb] r142715 - /lldb/trunk/www/lldb-gdb.html Message-ID: <20111022023142.9E4EE3128042@llvm.org> Author: jmolenda Date: Fri Oct 21 21:31:42 2011 New Revision: 142715 URL: http://llvm.org/viewvc/llvm-project?rev=142715&view=rev Log: Document nexti, show some shorter versions of long lldb commands. Modified: lldb/trunk/www/lldb-gdb.html Modified: lldb/trunk/www/lldb-gdb.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/lldb-gdb.html?rev=142715&r1=142714&r2=142715&view=diff ============================================================================== --- lldb/trunk/www/lldb-gdb.html (original) +++ lldb/trunk/www/lldb-gdb.html Fri Oct 21 21:31:42 2011 @@ -1,664 +1,667 @@ - - - - - -LLDB Goals - - - -
- The LLDB Debugger -
- -
-
- -
-
-

LLDB to GDB Command Map

-
- -

Below is a table of LLDB commands with the GDB counterparts. - The built in GDB compatability aliases in GDB are also - listed.

-
- - -

Execution Commands

-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LLDBGDB
Launch a process no arguments.
- (lldb) process launch
- (lldb) run
- (lldb) r -
- (gdb) run
- (gdb) r -
Launch a process with arguments <args>.
- (lldb) process launch -- <args>
- (lldb) run -- <args>
- (lldb) r <args> -
- (gdb) run <args>
- (gdb) r <args> -
Launch a process for with arguments a.out 1 2 3 without having to supply the args every time.
- % lldb -- a.out 1 2 3
- (lldb) run
- ...
- (lldb) run
- ...
-
- % gdb --args a.out 1 2 3
- (gdb) run
- ...
- (gdb) run
- ...
-
Launch a process with arguments in new terminal window (Mac OS X only).
- (lldb) process launch --tty -- <args>
- (lldb) process launch -t -- <args>
-
-
Launch a process with arguments in existing terminal /dev/ttys006 (Mac OS X only).
- (lldb) process launch --tty=/dev/ttys006 -- <args>
- (lldb) process launch -t/dev/ttys006 -- <args>
-
-
Attach to a process with process ID 123.
- (lldb) process attach --pid 123
- (lldb) attach -p 123 -
- (gdb) attach 123 -
Attach to a process named "a.out".
- (lldb) process attach --name a.out
- (lldb) process attach -n a.out -
- (gdb) attach a.out -
Wait for a process named "a.out" to launch and attach.
- (lldb) process attach --name a.out --waitfor
- (lldb) process attach -n a.out -w -
- (gdb) attach -waitfor a.out -
Do a source level single step in the currently selected thread.
- (lldb) thread step-in
- (lldb) step
- (lldb) s -
- (gdb) step
- (gdb) s -
Do a source level single step over in the currently selected thread.
- (lldb) thread step-over
- (lldb) next
- (lldb) n
-
- (gdb) next
- (gdb) n -
Do an instruction level single step in the currently selected thread.
- (lldb) thread step-inst
- (lldb) si
-
- (gdb) stepi
- (gdb) si -
Do an instruction level single step over in the currently selected thread.
- (lldb) thread step-inst-over
-
- (gdb) nexti
- (gdb) ni -
Step out of the currently selected frame.
- (lldb) thread step-out
- (lldb) finish
-
- (gdb) finish
-
Display a the variable "argc" and "argv" everytime you stop.
- (lldb) target stop-hook add --one-liner "frame variable argc argv"
-
- (gdb) display argc
- (gdb) display argv
-
Display a the variable "argc" and "argv" only when you stop in the function named main.
- (lldb) target stop-hook add --name main --one-liner "frame variable argc argv"
-
Display the variable "*this" only when you stop in c class named MyClass.
- (lldb) target stop-hook add --classname MyClass --one-liner "frame variable *this"
-
Backtrace and disassemble every time you stop.
- (lldb) target stop-hook add"
- Enter your stop hook command(s). Type 'DONE' to end.
- > bt
- > disassemble --pc
- > DONE
- Stop hook #1 added.
-
-

-

- - -

Breakpoint Commands

-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LLDBGDB
Set a breakpoint at all functions named main.
- (lldb) breakpoint set --name main
- (lldb) breakpoint set -n main
- (lldb) b main -
- (lldb) break main -
Set a breakpoint in file test.c at line 12.
- (lldb) breakpoint set --file test.c --line 12
- (lldb) breakpoint set -f test.c -l 12
- (lldb) b test.c:12 -
- (lldb) break test.c:12 -
Set a breakpoint at all C++ methods whose basename is main.
- (lldb) breakpoint set --method main
- (lldb) breakpoint set -M main
-
- (lldb) break main
- (Hope that there are no C funtions named main). -
Set a breakpoint at all Objective C methods whose selector is count.
- (lldb) breakpoint set --selector count
- (lldb) breakpoint set -S count
-
- (lldb) break count
- (Hope that there are no C or C++ funtions named count). -
-

-

- - -

Examining Thread State

-
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LLDBGDB
Show the arguments and local variables for the current frame.
- (lldb) frame variable
-
- (gdb) info args
- and
- (gdb) info locals
-
Show the stack backtrace for the current thread.
- (lldb) thread backtrace
- (lldb) bt
-
- (gdb) bt
-
Show the stack backtraces for all threads.
- (lldb) thread backtrace all
- (lldb) bt all -
- (gdb) thread apply all bt -
Select a different stack frame by index for the current thread.
- (lldb) frame select 12
-
- (gdb) frame 12 -
Select the stack frame that called the current stack frame.
- (lldb) up
- (lldb) frame select --relative=1
-
- (gdb) up -
Select the stack frame that is called by the current stack frame.
- (lldb) down
- (lldb) frame select --relative=-1
- (lldb) frame select -r-1
-
- (gdb) down -
Select a different stack frame using a relative offset.
- (lldb) frame select --relative 2
- (lldb) frame select -r2
-
- (lldb) frame select --relative -3
- (lldb) frame select -r-3
-
- (gdb) up 2
- (gdb) down 3
-
Show the general purpose registers for the current thread.
- (lldb) register read
-
- (gdb) info registers
-
Show the general purpose registers for the current thread formatted as unsigned decimal. LLDB tries to use - the same format characters as printf when possible.
- (lldb) register read --format i
- (lldb) register read -f i
-
-
Show all registers in all register sets for the current thread.
- (lldb) register read --all
- (lldb) register read -a
-
- (gdb) info all-registers
-
Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.
- (lldb) register read rax rsp rbp
-
- (gdb) info all-registers rax rsp rbp
-
Show the values for the register named "rax" in the current thread formatted as binary.
- (lldb) register read --format binary rax
- (lldb) register read -f b rax
-
- (gdb) p/t $rax
-
Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.
- (lldb) memory read --size 4 --format x --count 4 0xbffff3c0
- (lldb) memory read -s4 -fx -c4 0xbffff3c0
- (lldb) x -s4 -fx -c4 0xbffff3c0
-
- (gdb) x/4xw 0xbffff3c0
-
Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as text.
- (lldb) memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0
- (lldb) memory read -o/tmp/mem.txt -c512 0xbffff3c0
-
- (gdb) set logging on
- (gdb) set logging file /tmp/mem.txt
- (gdb) x/512bx 0xbffff3c0
- (gdb) set logging off
-
Save binary memory data starting at 0x1000 and ending at 0x2000 to a file.
- (lldb) memory read --outfile /tmp/mem.bin --binary 0x1000 0x1200
- (lldb) memory read -o /tmp/mem.bin -b 0x1000 0x1200
-
Disassemble the current function for the current frame.
- (lldb) disassemble --frame
- (lldb) disassemble -f -
- (gdb) disassemble -
Disassemble any functions named main.
- (lldb) disassemble --name main
- (lldb) disassemble -n main -
- (gdb) disassemble main -
Disassemble an address range.
- (lldb) disassemble --start-address 0x1eb8 --end-address 0x1ec3
- (lldb) disassemble -s 0x1eb8 -e 0x1ec3
-
- (gdb) disassemble 0x1eb8 0x1ec3 -
Disassemble 20 instructions from a given address.
- (lldb) disassemble --start-address 0x1eb8 --count 20
- (lldb) disassemble -s 0x1eb8 -c 20
-
- (gdb) x/20i 0x1eb8 -
Show mixed source and disassembly for the current function for the current frame.
- (lldb) disassemble --frame --mixed
- (lldb) disassemble -f -m -
- n/a -
Disassemble the current function for the current frame and show the opcode bytes.
- (lldb) disassemble --frame --bytes
- (lldb) disassemble -f -b -
- n/a -
Disassemble the current source line for the current frame.
- (lldb) disassemble --line
- (lldb) disassemble -l -
- n/a -
-

-

- - -

Executable and Shared Library Query Commands

-
- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LLDBGDB
List the main executable and all dependent shared libraries.
- (lldb) image list
-
- (gdb) info shared
-
Lookup information for a raw address in the executable or any shared libraries.
- (lldb) image lookup --address 0x1ec4
- (lldb) image lookup -a 0x1ec4
-
- (gdb) info symbol 0x1ec4
-
Lookup information for an address in a.out only.
- (lldb) image lookup --address 0x1ec4 a.out
- (lldb) image lookup -a 0x1ec4 a.out
-
-
Lookup information for for a type Point by name.
- (lldb) image lookup --type Point
- (lldb) image lookup -t Point
-
- (lldb) ptype Point
-
Dump all sections from the main executable and any shared libraries.
- (lldb) image dump sections
-
- (gdb) maintenance info sections
-
Dump all sections in the a.out module.
- (lldb) image dump sections a.out
-
-
Dump all symbols from the main executable and any shared libraries.
- (lldb) image dump symtab
-
-
Dump all symbols in a.out and liba.so.
- (lldb) image dump symtab a.out liba.so
-
-
-

-

- - -

- - -

-
-
-
- - + + + + + +LLDB Goals + + + +
+ The LLDB Debugger +
+ +
+
+ +
+
+

LLDB to GDB Command Map

+
+ +

Below is a table of LLDB commands with the GDB counterparts. + The built in GDB compatability aliases in GDB are also + listed.

+
+ + +

Execution Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
Launch a process no arguments.
+ (lldb) process launch
+ (lldb) run
+ (lldb) r +
+ (gdb) run
+ (gdb) r +
Launch a process with arguments <args>.
+ (lldb) process launch -- <args>
+ (lldb) run -- <args>
+ (lldb) r <args> +
+ (gdb) run <args>
+ (gdb) r <args> +
Launch a process for with arguments a.out 1 2 3 without having to supply the args every time.
+ % lldb -- a.out 1 2 3
+ (lldb) run
+ ...
+ (lldb) run
+ ...
+
+ % gdb --args a.out 1 2 3
+ (gdb) run
+ ...
+ (gdb) run
+ ...
+
Launch a process with arguments in new terminal window (Mac OS X only).
+ (lldb) process launch --tty -- <args>
+ (lldb) process launch -t -- <args>
+
+
Launch a process with arguments in existing terminal /dev/ttys006 (Mac OS X only).
+ (lldb) process launch --tty=/dev/ttys006 -- <args>
+ (lldb) process launch -t/dev/ttys006 -- <args>
+
+
Attach to a process with process ID 123.
+ (lldb) process attach --pid 123
+ (lldb) attach -p 123 +
+ (gdb) attach 123 +
Attach to a process named "a.out".
+ (lldb) process attach --name a.out
+ (lldb) process attach -n a.out +
+ (gdb) attach a.out +
Wait for a process named "a.out" to launch and attach.
+ (lldb) process attach --name a.out --waitfor
+ (lldb) process attach -n a.out -w +
+ (gdb) attach -waitfor a.out +
Do a source level single step in the currently selected thread.
+ (lldb) thread step-in
+ (lldb) step
+ (lldb) s +
+ (gdb) step
+ (gdb) s +
Do a source level single step over in the currently selected thread.
+ (lldb) thread step-over
+ (lldb) next
+ (lldb) n
+
+ (gdb) next
+ (gdb) n +
Do an instruction level single step in the currently selected thread.
+ (lldb) thread step-inst
+ (lldb) si
+
+ (gdb) stepi
+ (gdb) si +
Do an instruction level single step over in the currently selected thread.
+ (lldb) thread step-inst-over
+ (lldb) ni +
+ (gdb) nexti
+ (gdb) ni +
Step out of the currently selected frame.
+ (lldb) thread step-out
+ (lldb) finish
+
+ (gdb) finish
+
Display a the variable "argc" and "argv" everytime you stop.
+ (lldb) target stop-hook add --one-liner "frame variable argc argv"
+ (lldb) ta st a -o "fr v argc argv"
+
+ (gdb) display argc
+ (gdb) display argv
+
Display a the variable "argc" and "argv" only when you stop in the function named main.
+ (lldb) target stop-hook add --name main --one-liner "frame variable argc argv"
+ (lldb) ta st a -n main -o "fr v argc argv"
+
Display the variable "*this" only when you stop in c class named MyClass.
+ (lldb) target stop-hook add --classname MyClass --one-liner "frame variable *this"
+
Backtrace and disassemble every time you stop.
+ (lldb) target stop-hook add
+ Enter your stop hook command(s). Type 'DONE' to end.
+ > bt
+ > disassemble --pc
+ > DONE
+ Stop hook #1 added.
+
+

+

+ + +

Breakpoint Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
Set a breakpoint at all functions named main.
+ (lldb) breakpoint set --name main
+ (lldb) br s -n main
+ (lldb) b main +
+ (lldb) break main +
Set a breakpoint in file test.c at line 12.
+ (lldb) breakpoint set --file test.c --line 12
+ (lldb) breakpoint set -f test.c -l 12
+ (lldb) b test.c:12 +
+ (lldb) break test.c:12 +
Set a breakpoint at all C++ methods whose basename is main.
+ (lldb) breakpoint set --method main
+ (lldb) breakpoint set -M main
+
+ (lldb) break main
+ (Hope that there are no C funtions named main). +
Set a breakpoint at all Objective C methods whose selector is count.
+ (lldb) breakpoint set --selector count
+ (lldb) breakpoint set -S count
+
+ (lldb) break count
+ (Hope that there are no C or C++ funtions named count). +
+

+

+ + +

Examining Thread State

+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
Show the arguments and local variables for the current frame.
+ (lldb) frame variable
+
+ (gdb) info args
+ and
+ (gdb) info locals
+
Show the stack backtrace for the current thread.
+ (lldb) thread backtrace
+ (lldb) bt
+
+ (gdb) bt
+
Show the stack backtraces for all threads.
+ (lldb) thread backtrace all
+ (lldb) bt all +
+ (gdb) thread apply all bt +
Select a different stack frame by index for the current thread.
+ (lldb) frame select 12
+
+ (gdb) frame 12 +
Select the stack frame that called the current stack frame.
+ (lldb) up
+ (lldb) frame select --relative=1
+
+ (gdb) up +
Select the stack frame that is called by the current stack frame.
+ (lldb) down
+ (lldb) frame select --relative=-1
+ (lldb) frame select -r-1
+
+ (gdb) down +
Select a different stack frame using a relative offset.
+ (lldb) frame select --relative 2
+ (lldb) frame select -r2
+
+ (lldb) frame select --relative -3
+ (lldb) frame select -r-3
+
+ (gdb) up 2
+ (gdb) down 3
+
Show the general purpose registers for the current thread.
+ (lldb) register read
+
+ (gdb) info registers
+
Show the general purpose registers for the current thread formatted as unsigned decimal. LLDB tries to use + the same format characters as printf when possible.
+ (lldb) register read --format i
+ (lldb) register read -f i
+
+
Show all registers in all register sets for the current thread.
+ (lldb) register read --all
+ (lldb) register read -a
+
+ (gdb) info all-registers
+
Show the values for the registers named "rax", "rsp" and "rbp" in the current thread.
+ (lldb) register read rax rsp rbp
+
+ (gdb) info all-registers rax rsp rbp
+
Show the values for the register named "rax" in the current thread formatted as binary.
+ (lldb) register read --format binary rax
+ (lldb) register read -f b rax
+
+ (gdb) p/t $rax
+
Read memory from address 0xbffff3c0 and show 4 hex uint32_t values.
+ (lldb) memory read --size 4 --format x --count 4 0xbffff3c0
+ (lldb) memory read -s4 -fx -c4 0xbffff3c0
+ (lldb) x -s4 -fx -c4 0xbffff3c0
+
+ (gdb) x/4xw 0xbffff3c0
+
Read 512 bytes of memory from address 0xbffff3c0 and save results to a local file as text.
+ (lldb) memory read --outfile /tmp/mem.txt --count 512 0xbffff3c0
+ (lldb) memory read -o/tmp/mem.txt -c512 0xbffff3c0
+
+ (gdb) set logging on
+ (gdb) set logging file /tmp/mem.txt
+ (gdb) x/512bx 0xbffff3c0
+ (gdb) set logging off
+
Save binary memory data starting at 0x1000 and ending at 0x2000 to a file.
+ (lldb) memory read --outfile /tmp/mem.bin --binary 0x1000 0x1200
+ (lldb) memory read -o /tmp/mem.bin -b 0x1000 0x1200
+
Disassemble the current function for the current frame.
+ (lldb) disassemble --frame
+ (lldb) disassemble -f +
+ (gdb) disassemble +
Disassemble any functions named main.
+ (lldb) disassemble --name main
+ (lldb) disassemble -n main +
+ (gdb) disassemble main +
Disassemble an address range.
+ (lldb) disassemble --start-address 0x1eb8 --end-address 0x1ec3
+ (lldb) disassemble -s 0x1eb8 -e 0x1ec3
+
+ (gdb) disassemble 0x1eb8 0x1ec3 +
Disassemble 20 instructions from a given address.
+ (lldb) disassemble --start-address 0x1eb8 --count 20
+ (lldb) disassemble -s 0x1eb8 -c 20
+
+ (gdb) x/20i 0x1eb8 +
Show mixed source and disassembly for the current function for the current frame.
+ (lldb) disassemble --frame --mixed
+ (lldb) disassemble -f -m +
+ n/a +
Disassemble the current function for the current frame and show the opcode bytes.
+ (lldb) disassemble --frame --bytes
+ (lldb) disassemble -f -b +
+ n/a +
Disassemble the current source line for the current frame.
+ (lldb) disassemble --line
+ (lldb) disassemble -l +
+ n/a +
+

+

+ + +

Executable and Shared Library Query Commands

+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LLDBGDB
List the main executable and all dependent shared libraries.
+ (lldb) image list
+
+ (gdb) info shared
+
Lookup information for a raw address in the executable or any shared libraries.
+ (lldb) image lookup --address 0x1ec4
+ (lldb) image lookup -a 0x1ec4
+
+ (gdb) info symbol 0x1ec4
+
Lookup information for an address in a.out only.
+ (lldb) image lookup --address 0x1ec4 a.out
+ (lldb) image lookup -a 0x1ec4 a.out
+
+
Lookup information for for a type Point by name.
+ (lldb) image lookup --type Point
+ (lldb) image lookup -t Point
+
+ (lldb) ptype Point
+
Dump all sections from the main executable and any shared libraries.
+ (lldb) image dump sections
+
+ (gdb) maintenance info sections
+
Dump all sections in the a.out module.
+ (lldb) image dump sections a.out
+
+
Dump all symbols from the main executable and any shared libraries.
+ (lldb) image dump symtab
+
+
Dump all symbols in a.out and liba.so.
+ (lldb) image dump symtab a.out liba.so
+
+
+

+

+ + +

+ + +

+
+
+
+ + From gclayton at apple.com Fri Oct 21 22:33:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 22 Oct 2011 03:33:13 -0000 Subject: [Lldb-commits] [lldb] r142717 - in /lldb/trunk: include/lldb/Core/ClangForward.h include/lldb/Symbol/ClangASTContext.h source/Expression/IRForTarget.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp source/Symbol/ClangASTType.cpp Message-ID: <20111022033314.0EC182A6C12C@llvm.org> Author: gclayton Date: Fri Oct 21 22:33:13 2011 New Revision: 142717 URL: http://llvm.org/viewvc/llvm-project?rev=142717&view=rev Log: Added template support when parsing DWARF into types. We can now use STL classes in the expression parser. Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Fri Oct 21 22:33:13 2011 @@ -31,6 +31,8 @@ class AddrLabelExpr; class AnalyzerOptions; class BinaryOperator; + class ClassTemplateDecl; + class ClassTemplateSpecializationDecl; class CodeGenOptions; class CodeGenerator; class CompilerInstance; Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Oct 21 22:33:13 2011 @@ -19,6 +19,8 @@ // Other libraries and framework includes #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/SmallVector.h" +#include "clang/AST/TemplateBase.h" // Project includes #include "lldb/lldb-enumerations.h" @@ -55,7 +57,7 @@ typedef void (*CompleteTagDeclCallback)(void *baton, clang::TagDecl *); typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); - + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ @@ -300,6 +302,44 @@ is_explicit); } + class TemplateParameterInfos + { + public: + bool + IsValid() const + { + if (args.empty()) + return false; + return args.size() == names.size(); + } + + size_t + GetSize () const + { + if (IsValid()) + return args.size(); + return 0; + } + + llvm::SmallVector names; + llvm::SmallVector args; + }; + + clang::ClassTemplateDecl * + CreateClassTemplateDecl (clang::DeclContext *decl_ctx, + const char *class_name, + int kind, + const TemplateParameterInfos &infos); + + clang::ClassTemplateSpecializationDecl * + CreateClassTemplateSpecializationDecl (clang::DeclContext *decl_ctx, + clang::ClassTemplateDecl *class_template_decl, + int kind, + const TemplateParameterInfos &infos); + + lldb::clang_type_t + CreateClassTemplateSpecializationType (clang::ClassTemplateSpecializationDecl *class_template_specialization_decl); + static clang::DeclContext * GetAsDeclContext (clang::CXXMethodDecl *cxx_method_decl); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Oct 21 22:33:13 2011 @@ -224,16 +224,41 @@ { if (!m_decl_map->GetFunctionInfo (fun_decl, fun_value_ptr, fun_addr)) { - fun_value_ptr = NULL; + lldb_private::ConstString alternate_mangling_const_str; + bool found_it = m_decl_map->GetFunctionAddress (name, fun_addr); + if (!found_it) + { + // Check for an alternate mangling for "std::basic_string" + // that is part of the itanium C++ name mangling scheme + const char *name_cstr = name.GetCString(); + if (strncmp(name_cstr, "_ZNKSbIcE", strlen("_ZNKSbIcE")) == 0) + { + std::string alternate_mangling("_ZNKSs"); + alternate_mangling.append (name_cstr + strlen("_ZNKSbIcE")); + alternate_mangling_const_str.SetCString(alternate_mangling.c_str()); + found_it = m_decl_map->GetFunctionAddress (alternate_mangling_const_str, fun_addr); + } + } - if (!m_decl_map->GetFunctionAddress (name, fun_addr)) + if (!found_it) { + fun_value_ptr = NULL; + if (log) - log->Printf("Function \"%s\" had no address", name.GetCString()); + { + if (alternate_mangling_const_str) + log->Printf("Function \"%s\" (alternate name \"%s\") has no address", name.GetCString(), alternate_mangling_const_str.GetCString()); + else + log->Printf("Function \"%s\" had no address", name.GetCString()); + } if (m_error_stream) - m_error_stream->Printf("Error [IRForTarget]: Call to a function '%s' that is not present in the target\n", name.GetCString()); - + { + if (alternate_mangling_const_str) + m_error_stream->Printf("error: call to a function '%s' (alternate name '%s') that is not present in the target\n", name.GetCString(), alternate_mangling_const_str.GetCString()); + else + m_error_stream->Printf("error: call to a function '%s' that is not present in the target\n", name.GetCString()); + } return false; } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct 21 22:33:13 2011 @@ -1133,6 +1133,128 @@ return blocks_added; } +bool +SymbolFileDWARF::ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *parent_die, + ClangASTContext::TemplateParameterInfos &template_param_infos) +{ + + if (parent_die == NULL) + return NULL; + + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); + + Args template_parameter_names; + for (const DWARFDebugInfoEntry *die = parent_die->GetFirstChild(); + die != NULL; + die = die->GetSibling()) + { + const dw_tag_t tag = die->Tag(); + + switch (tag) + { + case DW_TAG_template_type_parameter: + case DW_TAG_template_value_parameter: + { + DWARFDebugInfoEntry::Attributes attributes; + const size_t num_attributes = die->GetAttributes (this, + dwarf_cu, + fixed_form_sizes, + attributes); + const char *name = NULL; + Type *lldb_type = NULL; + clang_type_t clang_type = NULL; + uint64_t uval64 = 0; + bool uval64_valid = false; + if (num_attributes > 0) + { + DWARFFormValue form_value; + for (size_t i=0; iGetClangForwardType(); + } + break; + + case DW_AT_const_value: + if (attributes.ExtractFormValueAtIndex(this, i, form_value)) + { + uval64_valid = true; + uval64 = form_value.Unsigned(); + } + break; + default: + break; + } + } + + if (name && lldb_type && clang_type) + { + bool is_signed = false; + template_param_infos.names.push_back(name); + clang::QualType clang_qual_type (clang::QualType::getFromOpaquePtr (clang_type)); + if (tag == DW_TAG_template_value_parameter && ClangASTContext::IsIntegerType (clang_type, is_signed) && uval64_valid) + { + llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed); + template_param_infos.args.push_back (clang::TemplateArgument (llvm::APSInt(apint), clang_qual_type)); + } + else + { + template_param_infos.args.push_back (clang::TemplateArgument (clang_qual_type)); + } + } + else + { + return false; + } + + } + } + break; + + default: + break; + } + } + if (template_param_infos.args.empty()) + return false; + return template_param_infos.args.size() == template_param_infos.names.size(); +} + +clang::ClassTemplateDecl * +SymbolFileDWARF::ParseClassTemplateDecl (clang::DeclContext *decl_ctx, + const char *parent_name, + int tag_decl_kind, + const ClangASTContext::TemplateParameterInfos &template_param_infos) +{ + if (template_param_infos.IsValid()) + { + std::string template_basename(parent_name); + template_basename.erase (template_basename.find('<')); + ClangASTContext &ast = GetClangASTContext(); + + return ast.CreateClassTemplateDecl (decl_ctx, + template_basename.c_str(), + tag_decl_kind, + template_param_infos); + } + return NULL; +} + size_t SymbolFileDWARF::ParseChildMembers ( @@ -2342,16 +2464,16 @@ if (name_type_mask == eFunctionNameTypeMethod || name_type_mask == eFunctionNameTypeBase) { - clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIEOffset(die->GetOffset()); - if (!containing_decl_ctx) - return false; - - bool is_cxx_method = (containing_decl_ctx->getDeclKind() == clang::Decl::CXXRecord); - - if (!is_cxx_method && name_type_mask == eFunctionNameTypeMethod) - return false; - if (is_cxx_method && name_type_mask == eFunctionNameTypeBase) - return false; + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIEOffset(die->GetOffset()); + if (!containing_decl_ctx) + return false; + + bool is_cxx_method = DeclKindIsCXXClass(containing_decl_ctx->getDeclKind()); + + if (!is_cxx_method && name_type_mask == eFunctionNameTypeMethod) + return false; + if (is_cxx_method && name_type_mask == eFunctionNameTypeBase) + return false; } // Now we need to check whether the name we got back for this type matches the extra specifications @@ -2989,7 +3111,7 @@ // Ugly, but that if (arg_idx == 0) { - if (containing_decl_ctx->getDeclKind() == clang::Decl::CXXRecord) + if (DeclKindIsCXXClass(containing_decl_ctx->getDeclKind())) { // Often times compilers omit the "this" name for the // specification DIEs, so we can't rely upon the name @@ -3900,11 +4022,34 @@ clang_type = m_forward_decl_die_to_clang_type.lookup (die); if (clang_type == NULL) { - clang_type_was_created = true; - clang_type = ast.CreateRecordType (type_name_cstr, - tag_decl_kind, - GetClangDeclContextContainingDIE (dwarf_cu, die, NULL), - class_language); + clang::DeclContext *decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, NULL); + if (type_name_cstr && strchr (type_name_cstr, '<')) + { + ClangASTContext::TemplateParameterInfos template_param_infos; + if (ParseTemplateParameterInfos (dwarf_cu, die, template_param_infos)) + { + clang::ClassTemplateDecl *class_template_decl = ParseClassTemplateDecl (decl_ctx, + type_name_cstr, + tag_decl_kind, + template_param_infos); + + clang::ClassTemplateSpecializationDecl *class_specialization_decl = ast.CreateClassTemplateSpecializationDecl (decl_ctx, + class_template_decl, + tag_decl_kind, + template_param_infos); + clang_type = ast.CreateClassTemplateSpecializationType (class_specialization_decl); + clang_type_was_created = true; + } + } + + if (!clang_type_was_created) + { + clang_type_was_created = true; + clang_type = ast.CreateRecordType (type_name_cstr, + tag_decl_kind, + decl_ctx, + class_language); + } } // Store a forward declaration to this class type in case any @@ -4167,7 +4312,7 @@ clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die, &decl_ctx_die); const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); - const bool is_cxx_method = containing_decl_kind == clang::Decl::CXXRecord; + const bool is_cxx_method = DeclKindIsCXXClass (containing_decl_kind); // Start off static. This will be set to false in ParseChildParameters(...) // if we find a "this" paramters as the first parameter if (is_cxx_method) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Oct 21 22:33:13 2011 @@ -28,6 +28,7 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Flags.h" #include "lldb/Core/UniqueCStringMap.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -58,7 +59,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile, public lldb_private::UserID { public: - friend class SymbolFileDWARFDebugMap; + friend class SymbolFileDWARFDebugMap; //------------------------------------------------------------------ // Static Functions @@ -426,6 +427,32 @@ return GetID() | die_offset; } + static bool + DeclKindIsCXXClass (clang::Decl::Kind decl_kind) + { + switch (decl_kind) + { + case clang::Decl::CXXRecord: + case clang::Decl::ClassTemplateSpecialization: + return true; + default: + break; + } + return false; + } + + bool + ParseTemplateParameterInfos (DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *parent_die, + lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); + + clang::ClassTemplateDecl * + ParseClassTemplateDecl (clang::DeclContext *decl_ctx, + const char *parent_name, + int tag_decl_kind, + const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); + + void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Oct 21 22:33:13 2011 @@ -36,6 +36,7 @@ #include "clang/AST/ASTImporter.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Type.h" #include "clang/Basic/Builtins.h" @@ -58,6 +59,8 @@ #include "lldb/Core/dwarf.h" #include "lldb/Core/Flags.h" #include "lldb/Core/Log.h" +#include "lldb/Core/RegularExpression.h" +#include "lldb/Expression/ASTDumper.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/ObjCLanguageRuntime.h" @@ -1085,16 +1088,138 @@ // the CXXRecordDecl class since we often don't know from debug information // if something is struct or a class, so we default to always use the more // complete definition just in case. - CXXRecordDecl *decl = CXXRecordDecl::Create(*ast, - (TagDecl::TagKind)kind, - decl_ctx, - SourceLocation(), - SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL); + CXXRecordDecl *decl = CXXRecordDecl::Create (*ast, + (TagDecl::TagKind)kind, + decl_ctx, + SourceLocation(), + SourceLocation(), + name && name[0] ? &ast->Idents.get(name) : NULL); return ast->getTagDeclType(decl).getAsOpaquePtr(); } +ClassTemplateDecl * +ClangASTContext::CreateClassTemplateDecl (DeclContext *decl_ctx, + const char *class_name, + int kind, + const TemplateParameterInfos &template_param_infos) +{ + ASTContext *ast = getASTContext(); + + ClassTemplateDecl *class_template_decl = NULL; + if (decl_ctx == NULL) + decl_ctx = ast->getTranslationUnitDecl(); + + IdentifierInfo &identifier_info = ast->Idents.get(class_name); + DeclarationName decl_name (&identifier_info); + + clang::DeclContext::lookup_result result = decl_ctx->lookup(decl_name); + for (clang::DeclContext::lookup_iterator pos = result.first, end = result.second; pos != end; ++pos) + { + class_template_decl = dyn_cast(*pos); + if (class_template_decl) + return class_template_decl; + } + + llvm::SmallVector template_param_decls; + const bool parameter_pack = false; + const bool is_typename = false; + const unsigned depth = 0; + const size_t num_template_params = template_param_infos.GetSize(); + for (size_t i=0; igetTranslationUnitDecl(), // Is this the right decl context?, SourceLocation StartLoc, + SourceLocation(), + SourceLocation(), + depth, + i, + &ast->Idents.get(name), + template_param_infos.args[i].getAsType(), + parameter_pack, + NULL)); + + } + else + { + template_param_decls.push_back (TemplateTypeParmDecl::Create (*ast, + ast->getTranslationUnitDecl(), // Is this the right decl context? + SourceLocation(), + SourceLocation(), + depth, + i, + &ast->Idents.get(name), + is_typename, + parameter_pack)); + } + } + + TemplateParameterList *template_param_list = TemplateParameterList::Create (*ast, + SourceLocation(), + SourceLocation(), + &template_param_decls.front(), + template_param_decls.size(), + SourceLocation()); + + + CXXRecordDecl *template_cxx_decl = CXXRecordDecl::Create (*ast, + (TagDecl::TagKind)kind, + decl_ctx, // What decl context do we use here? TU? The actual decl context? + SourceLocation(), + SourceLocation(), + &identifier_info); + + + class_template_decl = ClassTemplateDecl::Create (*ast, + decl_ctx, // What decl context do we use here? TU? The actual decl context? + SourceLocation(), + decl_name, + template_param_list, + template_cxx_decl, + NULL); + + if (class_template_decl) + decl_ctx->addDecl (class_template_decl); + + return class_template_decl; +} + + +ClassTemplateSpecializationDecl * +ClangASTContext::CreateClassTemplateSpecializationDecl (DeclContext *decl_ctx, + ClassTemplateDecl *class_template_decl, + int kind, + const TemplateParameterInfos &template_param_infos) +{ + ASTContext *ast = getASTContext(); + ClassTemplateSpecializationDecl *class_template_specialization_decl = ClassTemplateSpecializationDecl::Create (*ast, + (TagDecl::TagKind)kind, + decl_ctx, + SourceLocation(), + SourceLocation(), + class_template_decl, + &template_param_infos.args.front(), + template_param_infos.args.size(), + NULL); + + return class_template_specialization_decl; +} + +lldb::clang_type_t +ClangASTContext::CreateClassTemplateSpecializationType (ClassTemplateSpecializationDecl *class_template_specialization_decl) +{ + if (class_template_specialization_decl) + { + ASTContext *ast = getASTContext(); + if (ast) + return ast->getTagDeclType(class_template_specialization_decl).getAsOpaquePtr(); + } + return NULL; +} + bool ClangASTContext::SetHasExternalStorage (clang_type_t clang_type, bool has_extern) { @@ -2842,6 +2967,8 @@ case clang::BuiltinType::ObjCClass: case clang::BuiltinType::ObjCSel: case clang::BuiltinType::BoundMember: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: return 1; } break; @@ -4615,6 +4742,8 @@ case clang::BuiltinType::ObjCClass: case clang::BuiltinType::ObjCSel: case clang::BuiltinType::BoundMember: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: break; } break; @@ -4748,6 +4877,8 @@ case clang::BuiltinType::ObjCClass: case clang::BuiltinType::ObjCSel: case clang::BuiltinType::BoundMember: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: break; } break; Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=142717&r1=142716&r2=142717&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Oct 21 22:33:13 2011 @@ -569,7 +569,10 @@ case clang::BuiltinType::Dependent: case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCClass: - case clang::BuiltinType::ObjCSel: return lldb::eFormatHex; + case clang::BuiltinType::ObjCSel: + case clang::BuiltinType::Half: + case clang::BuiltinType::ARCUnbridgedCast: + return lldb::eFormatHex; } break; case clang::Type::ObjCObjectPointer: return lldb::eFormatHex; From gclayton at apple.com Fri Oct 21 22:38:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 22 Oct 2011 03:38:38 -0000 Subject: [Lldb-commits] [lldb] r142718 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111022033838.40C9B2A6C12C@llvm.org> Author: gclayton Date: Fri Oct 21 22:38:38 2011 New Revision: 142718 URL: http://llvm.org/viewvc/llvm-project?rev=142718&view=rev Log: Bumped versions for lldb-81 and debugserver-146. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=142718&r1=142717&r2=142718&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Oct 21 22:38:38 2011 @@ -3685,9 +3685,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 80; + DYLIB_CURRENT_VERSION = 81; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3735,10 +3735,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 80; + DYLIB_CURRENT_VERSION = 81; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3784,8 +3784,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; - DYLIB_CURRENT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; + DYLIB_CURRENT_VERSION = 81; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3822,8 +3822,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; - DYLIB_CURRENT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; + DYLIB_CURRENT_VERSION = 81; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3860,8 +3860,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; - DYLIB_CURRENT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; + DYLIB_CURRENT_VERSION = 81; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3933,7 +3933,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3962,10 +3962,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 80; + DYLIB_CURRENT_VERSION = 81; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4088,7 +4088,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4118,7 +4118,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 80; + CURRENT_PROJECT_VERSION = 81; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=142718&r1=142717&r2=142718&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Oct 21 22:38:38 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 80 + 81 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=142718&r1=142717&r2=142718&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Oct 21 22:38:38 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -496,7 +496,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -517,7 +517,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -535,7 +535,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -575,7 +575,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -615,7 +615,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 145; + CURRENT_PROJECT_VERSION = 146; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Fri Oct 21 22:39:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 22 Oct 2011 03:39:04 -0000 Subject: [Lldb-commits] [lldb] r142719 - /lldb/tags/lldb-81/ Message-ID: <20111022033904.6A3EF3128042@llvm.org> Author: gclayton Date: Fri Oct 21 22:39:04 2011 New Revision: 142719 URL: http://llvm.org/viewvc/llvm-project?rev=142719&view=rev Log: lldb-81 Added: lldb/tags/lldb-81/ - copied from r142718, lldb/trunk/ From benny.kra at googlemail.com Sun Oct 23 11:31:38 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 23 Oct 2011 16:31:38 -0000 Subject: [Lldb-commits] [lldb] r142753 - in /lldb/trunk: include/lldb/Core/FormatNavigator.h tools/debugserver/source/PseudoTerminal.cpp Message-ID: <20111023163138.47A9A3524006@llvm.org> Author: d0k Date: Sun Oct 23 11:31:38 2011 New Revision: 142753 URL: http://llvm.org/viewvc/llvm-project?rev=142753&view=rev Log: Remove unused include of deprecated header. Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h lldb/trunk/tools/debugserver/source/PseudoTerminal.cpp Modified: lldb/trunk/include/lldb/Core/FormatNavigator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatNavigator.h?rev=142753&r1=142752&r2=142753&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatNavigator.h (original) +++ lldb/trunk/include/lldb/Core/FormatNavigator.h Sun Oct 23 11:31:38 2011 @@ -16,19 +16,6 @@ #include // C++ Includes - -#ifdef __GNUC__ -#include - -namespace std -{ - using namespace __gnu_cxx; -} - -#else -#include -#endif - #include // Other libraries and framework includes Modified: lldb/trunk/tools/debugserver/source/PseudoTerminal.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/PseudoTerminal.cpp?rev=142753&r1=142752&r2=142753&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/PseudoTerminal.cpp (original) +++ lldb/trunk/tools/debugserver/source/PseudoTerminal.cpp Sun Oct 23 11:31:38 2011 @@ -14,6 +14,7 @@ #include "PseudoTerminal.h" #include #include +#include //---------------------------------------------------------------------- // PseudoTerminal constructor From benny.kra at googlemail.com Sun Oct 23 11:49:03 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 23 Oct 2011 16:49:03 -0000 Subject: [Lldb-commits] [lldb] r142754 - in /lldb/trunk: include/lldb/Core/FormatClasses.h include/lldb/Interpreter/ScriptInterpreterPython.h source/Core/FormatClasses.cpp source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20111023164903.63F883524006@llvm.org> Author: d0k Date: Sun Oct 23 11:49:03 2011 New Revision: 142754 URL: http://llvm.org/viewvc/llvm-project?rev=142754&view=rev Log: Move Python.h includes out of the headers into the .cpp file where it's actually used. Python.h includes a ton of macros that can cause weird behavior down the road. Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=142754&r1=142753&r2=142754&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Sun Oct 23 11:49:03 2011 @@ -11,13 +11,6 @@ #define lldb_FormatClasses_h_ // C Includes - -#if defined (__APPLE__) -#include -#else -#include -#endif - #include #include @@ -302,7 +295,7 @@ { private: std::string m_python_class; - PyObject* m_wrapper; + void *m_wrapper; // Wraps PyObject. ScriptInterpreter *m_interpreter; public: @@ -310,10 +303,7 @@ lldb::ValueObjectSP be); virtual - ~FrontEnd() - { - Py_XDECREF(m_wrapper); - } + ~FrontEnd(); virtual uint32_t CalculateNumChildren() Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=142754&r1=142753&r2=142754&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Sun Oct 23 11:49:03 2011 @@ -11,12 +11,6 @@ #ifndef liblldb_ScriptInterpreterPython_h_ #define liblldb_ScriptInterpreterPython_h_ -#if defined (__APPLE__) -#include -#else -#include -#endif - #include "lldb/lldb-private.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Core/InputReader.h" @@ -197,7 +191,7 @@ lldb_utility::PseudoTerminal m_embedded_python_pty; lldb::InputReaderSP m_embedded_thread_input_reader_sp; FILE *m_dbg_stdout; - PyObject *m_new_sysout; + void *m_new_sysout; // This is a PyObject. std::string m_dictionary_name; TerminalState m_terminal_state; bool m_session_is_active; Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=142754&r1=142753&r2=142754&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Sun Oct 23 11:49:03 2011 @@ -8,6 +8,11 @@ //===----------------------------------------------------------------------===// // C Includes +#if defined (__APPLE__) +#include +#else +#include +#endif // C++ Includes #include @@ -243,7 +248,12 @@ if (m_interpreter == NULL) m_wrapper = NULL; else - m_wrapper = (PyObject*)m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); + m_wrapper = m_interpreter->CreateSyntheticScriptedProvider(m_python_class, m_backend); +} + +SyntheticScriptProvider::FrontEnd::~FrontEnd() +{ + Py_XDECREF((PyObject*)m_wrapper); } lldb::ValueObjectSP Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=142754&r1=142753&r2=142754&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Sun Oct 23 11:49:03 2011 @@ -8,8 +8,13 @@ //===----------------------------------------------------------------------===// // In order to guarantee correct working with Python, Python.h *MUST* be -// the *FIRST* header file included in ScriptInterpreterPython.h, and that -// must be the *FIRST* header file included here. +// the *FIRST* header file included here. + +#if defined (__APPLE__) +#include +#else +#include +#endif #include "lldb/Interpreter/ScriptInterpreterPython.h" @@ -242,11 +247,11 @@ { while (!GetPythonLock (1)) fprintf (tmp_fh, "Python interpreter locked on another thread; waiting to acquire lock...\n"); - Py_DECREF (m_new_sysout); + Py_DECREF ((PyObject*)m_new_sysout); ReleasePythonLock (); } else - Py_DECREF (m_new_sysout); + Py_DECREF ((PyObject*)m_new_sysout); } } @@ -358,7 +363,7 @@ if ((m_new_sysout != NULL) && (sysmod != NULL) && (sysdict != NULL)) - PyDict_SetItemString (sysdict, "stdout", m_new_sysout); + PyDict_SetItemString (sysdict, "stdout", (PyObject*)m_new_sysout); if (PyErr_Occurred()) PyErr_Clear ();