From filcab+lldb-dev at gmail.com Mon Sep 19 13:39:49 2011 From: filcab+lldb-dev at gmail.com (Filipe Cabecinhas) Date: Mon, 19 Sep 2011 11:39:49 -0700 Subject: [Lldb-commits] [lldb] r139982 - in /lldb/trunk/tools/debugserver/source/MacOSX: i386/DNBArchImplI386.cpp i386/DNBArchImplI386.h x86_64/DNBArchImplX86_64.cpp x86_64/DNBArchImplX86_64.h In-Reply-To: <20110917055938.324D32A6C12C@llvm.org> References: <20110917055938.324D32A6C12C@llvm.org> Message-ID: That patch has a bug by using the constant "x86_AVX_STATE64" Here is a fix. Regards, Filipe On Fri, Sep 16, 2011 at 22:59, Greg Clayton wrote: > Author: gclayton > Date: Sat Sep 17 00:59:37 2011 > New Revision: 139982 > > URL: http://llvm.org/viewvc/llvm-project?rev=139982&view=rev > Log: > Added more logging, and renamed FPR to FPU in a the register set/flavor > enum. > > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp > lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139982&r1=139981&r2=139982&view=diff > > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp > (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Sat > Sep 17 00:59:37 2011 > @@ -463,12 +463,18 @@ > if (CPUHasAVX() || FORCE_AVX_REGS) > { > mach_msg_type_number_t count = e_regSetWordSizeAVX; > - m_state.SetError(e_regSetFPU, Read, > ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, > (thread_state_t)&m_state.context.fpu.avx, &count)); > + m_state.SetError (e_regSetFPU, Read, > ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, > (thread_state_t)&m_state.context.fpu.avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state > (0x%4.4x, %u, &avx, %u (%u passed in)) => 0x%8.8x", > + m_thread->ThreadID(), __i386_AVX_STATE, > count, e_regSetWordSizeAVX, > + m_state.GetError(e_regSetFPU, Read)); > } > else > { > - mach_msg_type_number_t count = e_regSetWordSizeFPR; > + mach_msg_type_number_t count = e_regSetWordSizeFPU; > m_state.SetError(e_regSetFPU, Read, > ::thread_get_state(m_thread->ThreadID(), __i386_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state > (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x", > + m_thread->ThreadID(), > __i386_FLOAT_STATE, count, e_regSetWordSizeFPU, > + m_state.GetError(e_regSetFPU, Read)); > } > } > } > @@ -506,7 +512,7 @@ > if (CPUHasAVX() || FORCE_AVX_REGS) > m_state.SetError(e_regSetFPU, Write, > ::thread_set_state(m_thread->ThreadID(), __i386_AVX_STATE, > (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX)); > else > - m_state.SetError(e_regSetFPU, Write, > ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); > + m_state.SetError(e_regSetFPU, Write, > ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU)); > return m_state.GetError(e_regSetFPU, Write); > } > } > @@ -1448,9 +1454,27 @@ > size = buf_len; > > bool force = false; > - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force)) > - return 0; > - ::memcpy (buf, &m_state.context, size); > + kern_return_t kret; > + if ((kret = GetGPRState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: GPR regs > failed to read: %u ", buf, buf_len, kret); > + size = 0; > + } > + else if ((kret = GetFPUState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: %s regs > failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + size = 0; > + } > + else if ((kret = GetEXCState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: EXC regs > failed to read: %u", buf, buf_len, kret); > + size = 0; > + } > + else > + { > + // Success > + ::memcpy (buf, &m_state.context, size); > + } > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf > = %p, len = %zu) => %zu", buf, buf_len, size); > // Return the size of the register context even if NULL was passed in > @@ -1470,9 +1494,13 @@ > size = buf_len; > > ::memcpy (&m_state.context, buf, size); > - SetGPRState(); > - SetFPUState(); > - SetEXCState(); > + kern_return_t kret; > + if ((kret = SetGPRState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: GPR regs > failed to write: %u", buf, buf_len, kret); > + if ((kret = SetFPUState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: %s regs > failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + if ((kret = SetEXCState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: EXP regs > failed to write: %u", buf, buf_len, kret); > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf > = %p, len = %zu) => %zu", buf, buf_len, size); > return size; > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=139982&r1=139981&r2=139982&view=diff > > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h > (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Sat > Sep 17 00:59:37 2011 > @@ -92,7 +92,7 @@ > typedef enum RegisterSetWordSizeTag > { > e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), > - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), > + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int), > e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), > e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int), > e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int) > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139982&r1=139981&r2=139982&view=diff > > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > Sat Sep 17 00:59:37 2011 > @@ -369,11 +369,17 @@ > { > mach_msg_type_number_t count = e_regSetWordSizeAVX; > m_state.SetError(e_regSetFPU, Read, > ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, > (thread_state_t)&m_state.context.fpu.avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state > (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x", > + m_thread->ThreadID(), x86_AVX_STATE64, > (uint32_t)count, > + e_regSetWordSizeAVX, > m_state.GetError(e_regSetFPU, Read)); > } > else > { > - mach_msg_type_number_t count = e_regSetWordSizeFPR; > + mach_msg_type_number_t count = e_regSetWordSizeFPU; > m_state.SetError(e_regSetFPU, Read, > ::thread_get_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state > (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x", > + m_thread->ThreadID(), > __x86_64_FLOAT_STATE, (uint32_t)count, > + e_regSetWordSizeFPU, > m_state.GetError(e_regSetFPU, Read)); > } > } > } > @@ -434,7 +440,7 @@ > } > else > { > - m_state.SetError(e_regSetFPU, Write, > ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); > + m_state.SetError(e_regSetFPU, Write, > ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, > (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU)); > return m_state.GetError(e_regSetFPU, Write); > } > } > @@ -1714,9 +1720,29 @@ > size = buf_len; > > bool force = false; > - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force)) > - return 0; > - ::memcpy (buf, &m_state.context, size); > + kern_return_t kret; > + if ((kret = GetGPRState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: GPR regs > failed to read: %u ", buf, buf_len, kret); > + size = 0; > + } > + else > + if ((kret = GetFPUState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: %s regs > failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + size = 0; > + } > + else > + if ((kret = GetEXCState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: EXC regs > failed to read: %u", buf, buf_len, kret); > + size = 0; > + } > + else > + { > + // Success > + ::memcpy (buf, &m_state.context, size); > + } > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext > (buf = %p, len = %zu) => %zu", buf, buf_len, size); > // Return the size of the register context even if NULL was passed in > @@ -1736,9 +1762,13 @@ > size = buf_len; > > ::memcpy (&m_state.context, buf, size); > - SetGPRState(); > - SetFPUState(); > - SetEXCState(); > + kern_return_t kret; > + if ((kret = SetGPRState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: GPR regs > failed to write: %u", buf, buf_len, kret); > + if ((kret = SetFPUState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: %s regs > failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + if ((kret = SetEXCState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, > "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: EXP regs > failed to write: %u", buf, buf_len, kret); > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext > (buf = %p, len = %zu) => %zu", buf, buf_len, size); > return size; > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > URL: > http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=139982&r1=139981&r2=139982&view=diff > > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > Sat Sep 17 00:59:37 2011 > @@ -91,7 +91,7 @@ > typedef enum RegisterSetWordSizeTag > { > e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), > - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), > + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int), > e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), > e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int), > e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int) > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listino/lldb-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110919/9e374f5f/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: fix-r139982.patch Type: application/octet-stream Size: 991 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110919/9e374f5f/attachment-0001.obj From johnny.chen at apple.com Mon Sep 19 13:54:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 19 Sep 2011 18:54:01 -0000 Subject: [Lldb-commits] [lldb] r140037 - /lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Message-ID: <20110919185401.6F0D02A6C12C@llvm.org> Author: johnny Date: Mon Sep 19 13:54:01 2011 New Revision: 140037 URL: http://llvm.org/viewvc/llvm-project?rev=140037&view=rev Log: The r139982 patch has a bug by using the constant "x86_AVX_STATE64". Patch by Filipe. Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=140037&r1=140036&r2=140037&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Mon Sep 19 13:54:01 2011 @@ -370,7 +370,7 @@ mach_msg_type_number_t count = e_regSetWordSizeAVX; m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x", - m_thread->ThreadID(), x86_AVX_STATE64, (uint32_t)count, + m_thread->ThreadID(), __x86_64_AVX_STATE, (uint32_t)count, e_regSetWordSizeAVX, m_state.GetError(e_regSetFPU, Read)); } else From johnny.chen at apple.com Mon Sep 19 13:56:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 19 Sep 2011 11:56:08 -0700 Subject: [Lldb-commits] [lldb] r139982 - in /lldb/trunk/tools/debugserver/source/MacOSX: i386/DNBArchImplI386.cpp i386/DNBArchImplI386.h x86_64/DNBArchImplX86_64.cpp x86_64/DNBArchImplX86_64.h In-Reply-To: References: <20110917055938.324D32A6C12C@llvm.org> Message-ID: <2079D435-8442-46D9-A019-DE7B7647F2F2@apple.com> Thanks. Patch checked in to ToT. On Sep 19, 2011, at 11:39 AM, Filipe Cabecinhas wrote: > That patch has a bug by using the constant "x86_AVX_STATE64" > Here is a fix. > > Regards, > > Filipe > > > > On Fri, Sep 16, 2011 at 22:59, Greg Clayton wrote: > Author: gclayton > Date: Sat Sep 17 00:59:37 2011 > New Revision: 139982 > > URL: http://llvm.org/viewvc/llvm-project?rev=139982&view=rev > Log: > Added more logging, and renamed FPR to FPU in a the register set/flavor enum. > > > Modified: > lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp > lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp?rev=139982&r1=139981&r2=139982&view=diff > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp Sat Sep 17 00:59:37 2011 > @@ -463,12 +463,18 @@ > if (CPUHasAVX() || FORCE_AVX_REGS) > { > mach_msg_type_number_t count = e_regSetWordSizeAVX; > - m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); > + m_state.SetError (e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in)) => 0x%8.8x", > + m_thread->ThreadID(), __i386_AVX_STATE, count, e_regSetWordSizeAVX, > + m_state.GetError(e_regSetFPU, Read)); > } > else > { > - mach_msg_type_number_t count = e_regSetWordSizeFPR; > + mach_msg_type_number_t count = e_regSetWordSizeFPU; > m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x", > + m_thread->ThreadID(), __i386_FLOAT_STATE, count, e_regSetWordSizeFPU, > + m_state.GetError(e_regSetFPU, Read)); > } > } > } > @@ -506,7 +512,7 @@ > if (CPUHasAVX() || FORCE_AVX_REGS) > m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, e_regSetWordSizeAVX)); > else > - m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); > + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __i386_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU)); > return m_state.GetError(e_regSetFPU, Write); > } > } > @@ -1448,9 +1454,27 @@ > size = buf_len; > > bool force = false; > - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force)) > - return 0; > - ::memcpy (buf, &m_state.context, size); > + kern_return_t kret; > + if ((kret = GetGPRState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret); > + size = 0; > + } > + else if ((kret = GetFPUState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + size = 0; > + } > + else if ((kret = GetEXCState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret); > + size = 0; > + } > + else > + { > + // Success > + ::memcpy (buf, &m_state.context, size); > + } > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); > // Return the size of the register context even if NULL was passed in > @@ -1470,9 +1494,13 @@ > size = buf_len; > > ::memcpy (&m_state.context, buf, size); > - SetGPRState(); > - SetFPUState(); > - SetEXCState(); > + kern_return_t kret; > + if ((kret = SetGPRState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret); > + if ((kret = SetFPUState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + if ((kret = SetEXCState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret); > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplI386::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); > return size; > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=139982&r1=139981&r2=139982&view=diff > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Sat Sep 17 00:59:37 2011 > @@ -92,7 +92,7 @@ > typedef enum RegisterSetWordSizeTag > { > e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), > - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), > + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int), > e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), > e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int), > e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int) > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139982&r1=139981&r2=139982&view=diff > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Sat Sep 17 00:59:37 2011 > @@ -369,11 +369,17 @@ > { > mach_msg_type_number_t count = e_regSetWordSizeAVX; > m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_AVX_STATE, (thread_state_t)&m_state.context.fpu.avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &avx, %u (%u passed in) carp) => 0x%8.8x", > + m_thread->ThreadID(), x86_AVX_STATE64, (uint32_t)count, > + e_regSetWordSizeAVX, m_state.GetError(e_regSetFPU, Read)); > } > else > { > - mach_msg_type_number_t count = e_regSetWordSizeFPR; > + mach_msg_type_number_t count = e_regSetWordSizeFPU; > m_state.SetError(e_regSetFPU, Read, ::thread_get_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, &count)); > + DNBLogThreadedIf (LOG_THREAD, "::thread_get_state (0x%4.4x, %u, &fpu, %u (%u passed in) => 0x%8.8x", > + m_thread->ThreadID(), __x86_64_FLOAT_STATE, (uint32_t)count, > + e_regSetWordSizeFPU, m_state.GetError(e_regSetFPU, Read)); > } > } > } > @@ -434,7 +440,7 @@ > } > else > { > - m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPR)); > + m_state.SetError(e_regSetFPU, Write, ::thread_set_state(m_thread->ThreadID(), __x86_64_FLOAT_STATE, (thread_state_t)&m_state.context.fpu.no_avx, e_regSetWordSizeFPU)); > return m_state.GetError(e_regSetFPU, Write); > } > } > @@ -1714,9 +1720,29 @@ > size = buf_len; > > bool force = false; > - if (GetGPRState(force) | GetFPUState(force) | GetEXCState(force)) > - return 0; > - ::memcpy (buf, &m_state.context, size); > + kern_return_t kret; > + if ((kret = GetGPRState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to read: %u ", buf, buf_len, kret); > + size = 0; > + } > + else > + if ((kret = GetFPUState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: %s regs failed to read: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + size = 0; > + } > + else > + if ((kret = GetEXCState(force)) != KERN_SUCCESS) > + { > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) error: EXC regs failed to read: %u", buf, buf_len, kret); > + size = 0; > + } > + else > + { > + // Success > + ::memcpy (buf, &m_state.context, size); > + } > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::GetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); > // Return the size of the register context even if NULL was passed in > @@ -1736,9 +1762,13 @@ > size = buf_len; > > ::memcpy (&m_state.context, buf, size); > - SetGPRState(); > - SetFPUState(); > - SetEXCState(); > + kern_return_t kret; > + if ((kret = SetGPRState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: GPR regs failed to write: %u", buf, buf_len, kret); > + if ((kret = SetFPUState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: %s regs failed to write: %u", buf, buf_len, CPUHasAVX() ? "AVX" : "FPU", kret); > + if ((kret = SetEXCState()) != KERN_SUCCESS) > + DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) error: EXP regs failed to write: %u", buf, buf_len, kret); > } > DNBLogThreadedIf (LOG_THREAD, "DNBArchImplX86_64::SetRegisterContext (buf = %p, len = %zu) => %zu", buf, buf_len, size); > return size; > > Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=139982&r1=139981&r2=139982&view=diff > ============================================================================== > --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) > +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Sat Sep 17 00:59:37 2011 > @@ -91,7 +91,7 @@ > typedef enum RegisterSetWordSizeTag > { > e_regSetWordSizeGPR = sizeof(GPR) / sizeof(int), > - e_regSetWordSizeFPR = sizeof(FPU) / sizeof(int), > + e_regSetWordSizeFPU = sizeof(FPU) / sizeof(int), > e_regSetWordSizeEXC = sizeof(EXC) / sizeof(int), > e_regSetWordSizeAVX = sizeof(AVX) / sizeof(int), > e_regSetWordSizeDBG = sizeof(DBG) / sizeof(int) > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listino/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/20110919/c6184d85/attachment-0001.html From johnny.chen at apple.com Mon Sep 19 16:53:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 19 Sep 2011 21:53:51 -0000 Subject: [Lldb-commits] [lldb] r140071 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocationList.h source/Breakpoint/WatchpointLocationList.cpp Message-ID: <20110919215351.81F102A6C12C@llvm.org> Author: johnny Date: Mon Sep 19 16:53:51 2011 New Revision: 140071 URL: http://llvm.org/viewvc/llvm-project?rev=140071&view=rev Log: Add GetByIndex() methods to the WatchpointLocationList class to facilitate iteration through the watchpoint locations by index. Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140071&r1=140070&r2=140071&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Mon Sep 19 16:53:51 2011 @@ -114,6 +114,34 @@ FindIDByAddress (lldb::addr_t addr); //------------------------------------------------------------------ + /// Returns a shared pointer to the watchpoint location with + /// index \a i. + /// + /// @param[in] i + /// The watchpoint location index to seek for. + /// + /// @result + /// A shared pointer to the watchpoint location. May contain a NULL + /// pointer if the watchpoint location doesn't exist. + //------------------------------------------------------------------ + lldb::WatchpointLocationSP + GetByIndex (uint32_t i); + + //------------------------------------------------------------------ + /// Returns a shared pointer to the watchpoint location with index + /// \a i, const version. + /// + /// @param[in] i + /// The watchpoint location index to seek for. + /// + /// @result + /// A shared pointer to the watchpoint location. May contain a NULL + /// pointer if the watchpoint location doesn't exist. + //------------------------------------------------------------------ + const lldb::WatchpointLocationSP + GetByIndex (uint32_t i) const; + + //------------------------------------------------------------------ /// Removes the watchpoint location given by \b watchID from this list. /// /// @param[in] watchID @@ -193,6 +221,7 @@ GetListMutex (lldb_private::Mutex::Locker &locker); protected: + typedef std::vector collection; typedef std::map addr_map; addr_map::iterator @@ -201,6 +230,7 @@ addr_map::const_iterator GetIDConstIterator(lldb::watch_id_t watchID) const; + collection m_locations; addr_map m_address_to_location; mutable Mutex m_mutex; }; Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140071&r1=140070&r2=140071&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Mon Sep 19 16:53:51 2011 @@ -14,13 +14,13 @@ // Project includes #include "lldb/Breakpoint/WatchpointLocationList.h" #include "lldb/Breakpoint/WatchpointLocation.h" -#include "lldb/Core/ModuleList.h" #include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; WatchpointLocationList::WatchpointLocationList() : + m_locations (), m_address_to_location (), m_mutex (Mutex::eMutexTypeRecursive) { @@ -47,7 +47,15 @@ else { m_address_to_location[wp_addr] = wp_loc_sp; + collection::iterator pos, end = m_locations.end(); + for (pos = m_locations.begin(); pos != end; ++pos) + if ((*pos)->GetLoadAddress() == wp_addr) + { + m_locations.erase(pos); + break; + } } + m_locations.push_back(wp_loc_sp); return wp_loc_sp->GetID(); } @@ -141,6 +149,28 @@ return LLDB_INVALID_WATCH_ID; } +WatchpointLocationSP +WatchpointLocationList::GetByIndex (uint32_t i) +{ + Mutex::Locker locker (m_mutex); + WatchpointLocationSP wp_loc_sp; + if (i < m_locations.size()) + wp_loc_sp = m_locations[i]; + + return wp_loc_sp; +} + +const WatchpointLocationSP +WatchpointLocationList::GetByIndex (uint32_t i) const +{ + Mutex::Locker locker (m_mutex); + WatchpointLocationSP wp_loc_sp; + if (i < m_locations.size()) + wp_loc_sp = m_locations[i]; + + return wp_loc_sp; +} + bool WatchpointLocationList::Remove (lldb::watch_id_t watch_id) { @@ -149,6 +179,13 @@ if (pos != m_address_to_location.end()) { m_address_to_location.erase(pos); + collection::iterator pos, end = m_locations.end(); + for (pos = m_locations.begin(); pos != end; ++pos) + if ((*pos)->GetID() == watch_id) + { + m_locations.erase(pos); + break; + } return true; } return false; From jmolenda at apple.com Mon Sep 19 19:26:08 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 20 Sep 2011 00:26:08 -0000 Subject: [Lldb-commits] [lldb] r140115 - in /lldb/trunk: include/lldb/Core/Error.h source/Commands/CommandObjectTarget.cpp source/Core/ModuleList.cpp source/Core/UserSettingsController.cpp source/Core/ValueObject.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/DWARFExpression.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Target/StackFrame.cpp source/Target/Target.cpp Message-ID: <20110920002608.A5D4C2A6C12C@llvm.org> Author: jmolenda Date: Mon Sep 19 19:26:08 2011 New Revision: 140115 URL: http://llvm.org/viewvc/llvm-project?rev=140115&view=rev Log: Change Error::SetErrorStringWithFormat() prototype to use an __attribute__ format so the compiler knows that this method takes printf style formatter arguments and checks that it's being used correctly. Fix a couple dozen incorrect SetErrorStringWithFormat() calls throughout the sources. Modified: lldb/trunk/include/lldb/Core/Error.h lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Core/Error.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Error.h?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Error.h (original) +++ lldb/trunk/include/lldb/Core/Error.h Mon Sep 19 19:26:08 2011 @@ -266,7 +266,7 @@ /// A printf style format string //------------------------------------------------------------------ int - SetErrorStringWithFormat (const char *format, ...); + SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); int SetErrorStringWithVarArg (const char *format, va_list args); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Sep 19 19:26:08 2011 @@ -3429,7 +3429,7 @@ m_one_liner = option_arg; break; default: - error.SetErrorStringWithFormat ("Unrecognized option %c."); + error.SetErrorStringWithFormat ("Unrecognized option %c.", short_option); break; } return error; Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Mon Sep 19 19:26:08 2011 @@ -865,7 +865,7 @@ if (arch.IsValid()) { if (uuid_cstr[0]) - error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.GetArchitectureName(), uuid_cstr[0]); + error.SetErrorStringWithFormat("'%s' does not contain the %s architecture and UUID %s.\n", path, arch.GetArchitectureName(), uuid_cstr); else error.SetErrorStringWithFormat("'%s' does not contain the %s architecture.\n", path, arch.GetArchitectureName()); } @@ -941,9 +941,9 @@ uuid_cstr[0] = '\0'; if (uuid_cstr[0]) - error.SetErrorStringWithFormat("Cannot locate a module for UUID '%s'.\n", uuid_cstr[0]); + error.SetErrorStringWithFormat("Cannot locate a module for UUID '%s'.\n", uuid_cstr); else - error.SetErrorStringWithFormat("Cannot locate a module.\n", path, arch.GetArchitectureName()); + error.SetErrorStringWithFormat("Cannot locate a module.\n"); } } } Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Mon Sep 19 19:26:08 2011 @@ -2134,9 +2134,9 @@ if (value_cstr == NULL) - err.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n", value_cstr); + err.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n"); else if (value_cstr[0] == '\0') - err.SetErrorStringWithFormat ("invalid boolean string value (empty)\n", value_cstr); + err.SetErrorStringWithFormat ("invalid boolean string value (empty)\n"); else { bool new_value = Args::StringToBoolean (value_cstr, false, &success); @@ -2180,9 +2180,9 @@ error = option_value.SetValueFromCString(value); if (value == NULL) - error.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n", value); + error.SetErrorStringWithFormat ("invalid boolean string value (NULL)\n"); else if (value[0] == '\0') - error.SetErrorStringWithFormat ("invalid boolean string value (empty)\n", value); + error.SetErrorStringWithFormat ("invalid boolean string value (empty)\n"); else { bool new_value = Args::StringToBoolean (value, false, &success); Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Sep 19 19:26:08 2011 @@ -1053,7 +1053,7 @@ m_value_str.swap(sstr.GetString()); else { - m_error.SetErrorStringWithFormat ("unsufficient data for value (only %u of %u bytes available)", + m_error.SetErrorStringWithFormat ("unsufficient data for value (only %lu of %lu bytes available)", m_data.GetByteSize(), GetByteSize()); m_value_str.clear(); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 19 19:26:08 2011 @@ -1854,7 +1854,7 @@ Error write_error (reg_ctx.WriteRegisterValueToMemory(®_info, addr, register_byte_size, reg_value)); if (write_error.Fail()) { - err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", write_error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", reg_info.name, write_error.AsCString()); return false; } } Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Sep 19 19:26:08 2011 @@ -2395,7 +2395,7 @@ if (member_bit_incr % 8) { if (error_ptr) - error_ptr->SetErrorStringWithFormat("Array increment is not byte aligned", index, size); + error_ptr->SetErrorStringWithFormat("Array increment is not byte aligned"); return false; } int64_t member_offset = (int64_t)(member_bit_incr / 8) * index; Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Sep 19 19:26:08 2011 @@ -96,7 +96,7 @@ if (resolved_exe_file.Exists()) error.Clear(); else - error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root."); + error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_exe_file.GetFilename().AsCString("")); } } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 19 19:26:08 2011 @@ -745,7 +745,7 @@ else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -756,7 +756,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -769,7 +769,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", + error.SetErrorStringWithFormat ("failed to use pointer as array for index %ld for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -784,7 +784,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -797,7 +797,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index, child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -818,7 +818,7 @@ else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -829,7 +829,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); @@ -930,7 +930,7 @@ if (!child_valobj_sp) { valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("bitfield range %i-%i is not valid for \"(%s) %s\"", + error.SetErrorStringWithFormat ("bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index, final_index, valobj_sp->GetTypeName().AsCString(""), var_expr_path_strm.GetString().c_str()); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140115&r1=140114&r2=140115&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Sep 19 19:26:08 2011 @@ -769,7 +769,8 @@ if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec()) error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n", resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(), - resolved_addr.GetFileAddress()); + resolved_addr.GetFileAddress(), + resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString()); else error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress()); } From johnny.chen at apple.com Tue Sep 20 12:31:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 20 Sep 2011 17:31:06 -0000 Subject: [Lldb-commits] [lldb] r140150 - in /lldb/trunk/test: expression_command/formatters/TestFormatters.py functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Message-ID: <20110920173106.10B3D2A6C12C@llvm.org> Author: johnny Date: Tue Sep 20 12:31:05 2011 New Revision: 140150 URL: http://llvm.org/viewvc/llvm-project?rev=140150&view=rev Log: Add four new expectedFailre decorators to new failures most likely due to r139772 check-in. Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/formatters/TestFormatters.py?rev=140150&r1=140149&r2=140150&view=diff ============================================================================== --- lldb/trunk/test/expression_command/formatters/TestFormatters.py (original) +++ lldb/trunk/test/expression_command/formatters/TestFormatters.py Tue Sep 20 12:31:05 2011 @@ -18,12 +18,16 @@ self.line = line_number('main.cpp', '// Stop here') + # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in + @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): """Test expr + formatters for good interoperability.""" self.buildDsym() self.do_my_test() + # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in + @unittest2.expectedFailure def test_with_dwarf_(self): """Test expr + formatters for good interoperability.""" self.buildDsym() Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=140150&r1=140149&r2=140150&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Tue Sep 20 12:31:05 2011 @@ -11,12 +11,16 @@ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc") + # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in + @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test data formatter commands.""" self.buildDsym() self.data_formatter_commands() + # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in + @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Test data formatter commands.""" self.buildDwarf() From jmolenda at apple.com Tue Sep 20 16:44:10 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 20 Sep 2011 21:44:10 -0000 Subject: [Lldb-commits] [lldb] r140185 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Host/ include/lldb/Interpreter/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/DynamicLoader/Darwin-Kernel/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/ObjectContainer/BSD-Archive/ source/Plugins/ObjectContainer/Universal-Mach-O/ source/Plugins/ObjectFile/ELF/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/ObjectFile/PECOFF/ source/Plugins/P... Message-ID: <20110920214411.701132A6C12C@llvm.org> Author: jmolenda Date: Tue Sep 20 16:44:10 2011 New Revision: 140185 URL: http://llvm.org/viewvc/llvm-project?rev=140185&view=rev Log: Update declarations for all functions/methods that accept printf-style stdarg formats to use __attribute__ format so the compiler can flag incorrect uses. Fix all incorrect uses. Most of these are innocuous, a few were resulting in crashes. Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/include/lldb/Core/Error.h lldb/trunk/include/lldb/Core/Log.h lldb/trunk/include/lldb/Core/Stream.h lldb/trunk/include/lldb/Core/Timer.h lldb/trunk/include/lldb/Host/File.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h lldb/trunk/source/API/SBData.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Breakpoint/BreakpointList.cpp lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Log.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Symbol/SymbolVendor.cpp lldb/trunk/source/Symbol/Symtab.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/UnwindPlan.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrameList.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanStepUntil.cpp lldb/trunk/source/Target/ThreadSpec.cpp Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Tue Sep 20 16:44:10 2011 @@ -87,7 +87,7 @@ PutCString(const char* string, int len = -1); size_t - Printf(const char* format, ...); + Printf(const char* format, ...) __attribute__ ((format (printf, 2, 3))); protected: friend class SBCommandInterpreter; Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Tue Sep 20 16:44:10 2011 @@ -60,7 +60,7 @@ SetErrorString (const char *err_str); int - SetErrorStringWithFormat (const char *format, ...); + SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); bool IsValid () const; Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Tue Sep 20 16:44:10 2011 @@ -39,7 +39,7 @@ GetSize(); void - Printf (const char *format, ...); + Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void RedirectToFile (const char *path, bool append); Modified: lldb/trunk/include/lldb/Core/Error.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Error.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Error.h (original) +++ lldb/trunk/include/lldb/Core/Error.h Tue Sep 20 16:44:10 2011 @@ -175,7 +175,7 @@ /// format string \a format. //------------------------------------------------------------------ void - PutToLog (Log *log, const char *format, ...); + PutToLog (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4))); //------------------------------------------------------------------ /// Log an error to Log() if the error value is an error. @@ -196,7 +196,7 @@ /// format string \a format. //------------------------------------------------------------------ void - LogIfError (Log *log, const char *format, ...); + LogIfError (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4))); //------------------------------------------------------------------ /// Set accessor from a kern_return_t. Modified: lldb/trunk/include/lldb/Core/Log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Log.h (original) +++ lldb/trunk/include/lldb/Core/Log.h Tue Sep 20 16:44:10 2011 @@ -126,37 +126,37 @@ PutCString (const char *cstr); void - Printf (const char *format, ...); + Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void VAPrintf (const char *format, va_list args); void - PrintfWithFlags( uint32_t flags, const char *format, ...); + PrintfWithFlags( uint32_t flags, const char *format, ...) __attribute__ ((format (printf, 3, 4))); void - LogIf (uint32_t mask, const char *fmt, ...); + LogIf (uint32_t mask, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); void - Debug (const char *fmt, ...); + Debug (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void - DebugVerbose (const char *fmt, ...); + DebugVerbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void - Error (const char *fmt, ...); + Error (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void - FatalError (int err, const char *fmt, ...); + FatalError (int err, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); void - Verbose (const char *fmt, ...); + Verbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void - Warning (const char *fmt, ...); + Warning (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void - WarningVerbose (const char *fmt, ...); + WarningVerbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); Flags & GetOptions(); Modified: lldb/trunk/include/lldb/Core/Stream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Stream.h (original) +++ lldb/trunk/include/lldb/Core/Stream.h Tue Sep 20 16:44:10 2011 @@ -126,7 +126,7 @@ /// The number of bytes that were appended to the stream. //------------------------------------------------------------------ int - PrintfAsRawHex8 (const char *format, ...); + PrintfAsRawHex8 (const char *format, ...) __attribute__ ((format (printf, 2, 3))); //------------------------------------------------------------------ /// Format a C string from a printf style format and variable @@ -519,7 +519,7 @@ /// format string \a format. //------------------------------------------------------------------ int - Printf (const char *format, ...); + Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); int PrintfVarArg(const char *format, va_list args); Modified: lldb/trunk/include/lldb/Core/Timer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Timer.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Timer.h (original) +++ lldb/trunk/include/lldb/Core/Timer.h Tue Sep 20 16:44:10 2011 @@ -39,7 +39,7 @@ //-------------------------------------------------------------- /// Default constructor. //-------------------------------------------------------------- - Timer(const char *category, const char *format, ...); + Timer(const char *category, const char *format, ...) __attribute__ ((format (printf, 3, 4))); //-------------------------------------------------------------- /// Desstructor Modified: lldb/trunk/include/lldb/Host/File.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/File.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/File.h (original) +++ lldb/trunk/include/lldb/Host/File.h Tue Sep 20 16:44:10 2011 @@ -422,7 +422,7 @@ /// format string \a format. //------------------------------------------------------------------ int - Printf (const char *format, ...); + Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); int PrintfVarArg(const char *format, va_list args); Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Sep 20 16:44:10 2011 @@ -337,7 +337,7 @@ /// description string. //------------------------------------------------------------------ static void - SetCrashDescriptionWithFormat (const char *format, ...); + SetCrashDescriptionWithFormat (const char *format, ...) __attribute__ ((format (printf, 1, 2))); static void SetCrashDescription (const char *description); Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Tue Sep 20 16:44:10 2011 @@ -121,7 +121,7 @@ AppendMessage (const char *in_string, int len = -1); void - AppendMessageWithFormat (const char *format, ...); + AppendMessageWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void AppendRawWarning (const char *in_string, int len = -1); @@ -130,7 +130,7 @@ AppendWarning (const char *in_string, int len = -1); void - AppendWarningWithFormat (const char *format, ...); + AppendWarningWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); void AppendError (const char *in_string, int len = -1); @@ -139,7 +139,7 @@ AppendRawError (const char *in_string, int len = -1); void - AppendErrorWithFormat (const char *format, ...); + AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); lldb::ReturnStatus GetStatus(); Modified: lldb/trunk/source/API/SBData.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBData.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/API/SBData.cpp (original) +++ lldb/trunk/source/API/SBData.cpp Tue Sep 20 16:44:10 2011 @@ -108,7 +108,7 @@ value = m_opaque_sp->GetByteSize(); if (log) log->Printf ("SBData::GetByteSize () => " - "(%i)", value); + "(%lu)", value); return value; } @@ -187,7 +187,7 @@ } if (log) log->Printf ("SBData::GetLongDouble (error=%p,offset=%d) => " - "(%lf)", error.get(), offset, value); + "(%Lf)", error.get(), offset, value); return value; } @@ -297,7 +297,7 @@ } if (log) log->Printf ("SBData::GetUnsignedInt64 (error=%p,offset=%d) => " - "(%q)", error.get(), offset, value); + "(%lld)", error.get(), offset, value); return value; } @@ -385,7 +385,7 @@ } if (log) log->Printf ("SBData::GetSignedInt64 (error=%p,offset=%d) => " - "(%q)", error.get(), offset, value); + "(%lld)", error.get(), offset, value); return value; } @@ -453,7 +453,7 @@ error.SetErrorString("unable to read data"); } if (log) - log->Printf ("SBData::ReadRawData (error=%p,offset=%d,buf=%p,size=%d) => " + log->Printf ("SBData::ReadRawData (error=%p,offset=%d,buf=%p,size=%lu) => " "(%p)", error.get(), offset, buf, size, ok); return ok ? size : 0; } @@ -471,7 +471,7 @@ else m_opaque_sp->SetData(buf, size, endian); if (log) - log->Printf ("SBData::SetData (error=%p,buf=%p,size=%d,endian=%d,addr_size=%c) => " + log->Printf ("SBData::SetData (error=%p,buf=%p,size=%lu,endian=%d,addr_size=%c) => " "(%p)", error.get(), buf, size, endian, addr_size, m_opaque_sp.get()); } Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Tue Sep 20 16:44:10 2011 @@ -246,7 +246,7 @@ } if (log) - log->Printf ("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%d) => %d", + log->Printf ("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%d) => %lu", m_opaque_sp.get(), src, (uint32_t) src_len, Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 20 16:44:10 2011 @@ -646,7 +646,7 @@ if (log) { - log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (%p, address=%p) => SBBreakpoint(%p)", m_opaque_sp.get(), address, sb_bp.get()); + log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", m_opaque_sp.get(), (uint64_t) address, sb_bp.get()); } return sb_bp; Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Tue Sep 20 16:44:10 2011 @@ -729,7 +729,7 @@ if (all_in_function) { step_file_spec.GetPath (path, sizeof(path)); - sb_error.SetErrorStringWithFormat("No line entries for %s:u", path, line); + sb_error.SetErrorStringWithFormat("No line entries for %s:%u", path, line); } else sb_error.SetErrorString ("Step until target not in current function.\n"); Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Tue Sep 20 16:44:10 2011 @@ -106,7 +106,7 @@ if (name) log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name); else - log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name); + log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get()); } return name; @@ -357,7 +357,7 @@ if (log) { if (result.IsValid()) - log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); else log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get()); } @@ -391,7 +391,7 @@ if (log) { if (result.IsValid()) - log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); else log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get()); } @@ -433,7 +433,7 @@ if (log) { if (result.IsValid()) - log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); else log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); } @@ -463,7 +463,7 @@ if (log) { if (result.IsValid()) - log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); + log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); else log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get()); } @@ -541,7 +541,7 @@ if (log) { if (idx == UINT32_MAX) - log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx); + log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name); else log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx); } Modified: lldb/trunk/source/Breakpoint/BreakpointList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointList.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointList.cpp Tue Sep 20 16:44:10 2011 @@ -154,7 +154,7 @@ BreakpointList::Dump (Stream *s) const { Mutex::Locker locker(m_mutex); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); s->Printf("BreakpointList with %u Breakpoints:\n", (uint32_t)m_breakpoints.size()); s->IndentMore(); Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Tue Sep 20 16:44:10 2011 @@ -123,7 +123,7 @@ void BreakpointLocationList::Dump (Stream *s) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); //s->Indent(); Mutex::Locker locker (m_mutex); s->Printf("BreakpointLocationList with %zu BreakpointLocations:\n", m_locations.size()); Modified: lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp Tue Sep 20 16:44:10 2011 @@ -167,7 +167,7 @@ void BreakpointSiteList::Dump (Stream *s) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); //s->Indent(); s->Printf("BreakpointSiteList with %u BreakpointSites:\n", (uint32_t)m_bp_site_list.size()); s->IndentMore(); Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Tue Sep 20 16:44:10 2011 @@ -69,7 +69,7 @@ WatchpointLocationList::DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const { Mutex::Locker locker (m_mutex); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); //s->Indent(); s->Printf("WatchpointLocationList with %zu WatchpointLocations:\n", m_address_to_location.size()); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Sep 20 16:44:10 2011 @@ -885,7 +885,7 @@ { // No breakpoint selected; enable all currently set breakpoints. target->EnableAllBreakpoints (); - result.AppendMessageWithFormat ("All breakpoints enabled. (%d breakpoints)\n", num_breakpoints); + result.AppendMessageWithFormat ("All breakpoints enabled. (%lu breakpoints)\n", num_breakpoints); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -998,7 +998,7 @@ { // No breakpoint selected; disable all currently set breakpoints. target->DisableAllBreakpoints (); - result.AppendMessageWithFormat ("All breakpoints disabled. (%d breakpoints)\n", num_breakpoints); + result.AppendMessageWithFormat ("All breakpoints disabled. (%lu breakpoints)\n", num_breakpoints); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -1301,7 +1301,7 @@ else { target->RemoveAllBreakpoints (); - result.AppendMessageWithFormat ("All breakpoints removed. (%d breakpoints)\n", num_breakpoints); + result.AppendMessageWithFormat ("All breakpoints removed. (%lu breakpoints)\n", num_breakpoints); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Sep 20 16:44:10 2011 @@ -547,7 +547,7 @@ } else if (m_memory_options.m_count.OptionWasSet()) { - result.AppendErrorWithFormat("specify either the end address (0x%llx) or the count (--count %u), not both.\n", end_addr, item_count); + result.AppendErrorWithFormat("specify either the end address (0x%llx) or the count (--count %lu), not both.\n", end_addr, item_count); result.SetStatus(eReturnStatusFailed); return false; } @@ -572,7 +572,7 @@ } if (bytes_read < total_byte_size) - result.AppendWarningWithFormat("Not all bytes (%u/%u) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr); + result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr); } StreamFile outfile_stream; @@ -1012,7 +1012,7 @@ } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %u byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1040,7 +1040,7 @@ } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %u byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value 0x%llx is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1080,7 +1080,7 @@ } else if (!SIntValueIsValidForSize (sval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %lli is too large or small to fit in a %u byte signed integer value.\n", sval64, item_byte_size); + result.AppendErrorWithFormat ("Value %lli is too large or small to fit in a %lu byte signed integer value.\n", sval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1097,7 +1097,7 @@ } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %llu is too large to fit in a %u byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value %llu is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1114,7 +1114,7 @@ } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %llo is too large to fit in a %u byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value %llo is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Sep 20 16:44:10 2011 @@ -610,7 +610,7 @@ if (command.GetArgumentCount()) { - result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: \n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); + result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); } else @@ -733,9 +733,7 @@ } else { - result.AppendErrorWithFormat ("No PID specified for attach\n", - attach_pid, - error.AsCString()); + result.AppendErrorWithFormat ("No PID specified for attach\n"); result.SetStatus (eReturnStatusFailed); } @@ -1081,15 +1079,14 @@ } else { - result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command: \n", - m_cmd_name.c_str(), - m_cmd_syntax.c_str()); + result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n", + m_cmd_name.c_str()); result.SetStatus (eReturnStatusFailed); } } else { - result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: \n", + result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); @@ -1317,7 +1314,7 @@ } else { - result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: \n", m_cmd_name.c_str(), + result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); } @@ -1380,7 +1377,7 @@ } else { - result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: \n", + result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); @@ -1438,7 +1435,7 @@ } else { - result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: \n", + result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Sep 20 16:44:10 2011 @@ -389,7 +389,7 @@ sc_list.GetContextAtIndex (i, scratch_sc); if (scratch_sc.function != NULL) { - s.Printf("\n%d: ", i); + s.Printf("\n%lu: ", i); scratch_sc.function->Dump (&s, true); } } Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Sep 20 16:44:10 2011 @@ -436,7 +436,7 @@ if (thread == NULL) { result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", - step_thread_idx, 0, num_threads); + step_thread_idx, num_threads); result.SetStatus (eReturnStatusFailed); return false; } @@ -944,7 +944,6 @@ const uint32_t num_threads = process->GetThreadList().GetSize(); result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", m_options.m_thread_idx, - 0, num_threads); result.SetStatus (eReturnStatusFailed); return false; @@ -1135,7 +1134,7 @@ } else if (command.GetArgumentCount() != 1) { - result.AppendErrorWithFormat("'%s' takes exactly one thread index argument:\nUsage: \n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); + result.AppendErrorWithFormat("'%s' takes exactly one thread index argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); result.SetStatus (eReturnStatusFailed); return false; } Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Sep 20 16:44:10 2011 @@ -557,7 +557,7 @@ &error); if (error.Fail()) { - out_stream->Printf (error.AsCString()); + out_stream->Printf ("%s", error.AsCString()); out_stream->Flush(); return; } @@ -574,14 +574,14 @@ &error); if (error.Fail()) { - out_stream->Printf (error.AsCString()); + out_stream->Printf ("%s", error.AsCString()); out_stream->Flush(); return; } } else { - out_stream->Printf (error.AsCString()); + out_stream->Printf ("%s", error.AsCString()); out_stream->Flush(); return; } Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue Sep 20 16:44:10 2011 @@ -384,7 +384,7 @@ break; case DumpStyleSectionPointerOffset: - s->Printf("(Section *)%.*p + ", (int)sizeof(void*) * 2, m_section); + s->Printf("(Section *)%p + ", m_section); s->Address(m_offset, addr_size); break; Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Tue Sep 20 16:44:10 2011 @@ -196,7 +196,7 @@ void AddressRange::DumpDebug (Stream *s) const { - s->Printf("%.*p: AddressRange section = %*p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", (int)sizeof(void*) * 2, this, (int)sizeof(void*) * 2, m_base_addr.GetSection(), m_base_addr.GetOffset(), GetByteSize()); + s->Printf("%p: AddressRange section = %p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", this, m_base_addr.GetSection(), m_base_addr.GetOffset(), GetByteSize()); } // //bool Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Tue Sep 20 16:44:10 2011 @@ -1414,15 +1414,15 @@ { switch (ch) { - case '\e': s->Printf ("\\e", (uint8_t)ch); break; - case '\a': s->Printf ("\\a", ch); break; - case '\b': s->Printf ("\\b", ch); break; - case '\f': s->Printf ("\\f", ch); break; - case '\n': s->Printf ("\\n", ch); break; - case '\r': s->Printf ("\\r", ch); break; - case '\t': s->Printf ("\\t", ch); break; - case '\v': s->Printf ("\\v", ch); break; - case '\0': s->Printf ("\\0", ch); break; + case '\e': s->Printf ("\\e"); break; + case '\a': s->Printf ("\\a"); break; + case '\b': s->Printf ("\\b"); break; + case '\f': s->Printf ("\\f"); break; + case '\n': s->Printf ("\\n"); break; + case '\r': s->Printf ("\\r"); break; + case '\t': s->Printf ("\\t"); break; + case '\v': s->Printf ("\\v"); break; + case '\0': s->Printf ("\\0"); break; default: if (item_byte_size == 1) s->Printf ("\\x%2.2x", ch); @@ -1492,15 +1492,15 @@ { switch (ch) { - case '\e': s->Printf ("\\e", (uint8_t)ch); break; - case '\a': s->Printf ("\\a", ch); break; - case '\b': s->Printf ("\\b", ch); break; - case '\f': s->Printf ("\\f", ch); break; - case '\n': s->Printf ("\\n", ch); break; - case '\r': s->Printf ("\\r", ch); break; - case '\t': s->Printf ("\\t", ch); break; - case '\v': s->Printf ("\\v", ch); break; - case '\0': s->Printf ("\\0", ch); break; + case '\e': s->Printf ("\\e"); break; + case '\a': s->Printf ("\\a"); break; + case '\b': s->Printf ("\\b"); break; + case '\f': s->Printf ("\\f"); break; + case '\n': s->Printf ("\\n"); break; + case '\r': s->Printf ("\\r"); break; + case '\t': s->Printf ("\\t"); break; + case '\v': s->Printf ("\\v"); break; + case '\0': s->Printf ("\\0"); break; default: s->Printf ("\\x%2.2x", ch); break; } } @@ -1521,7 +1521,7 @@ s->Printf("\"%s\"", cstr); else { - s->Printf("NULL", cstr); + s->Printf("NULL"); offset = UINT32_MAX; } } Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Sep 20 16:44:10 2011 @@ -790,7 +790,7 @@ *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_higher = *index_lower; if (log) - log->Printf("[%d] detected, high index is same", *index_lower); + log->Printf("[%lld] detected, high index is same", *index_lower); } else if (*close_bracket_position && *close_bracket_position < var_name_end) { @@ -798,7 +798,7 @@ *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_higher = ::strtoul (*separator_position+1, &end, 0); if (log) - log->Printf("[%d-%d] detected", *index_lower, *index_higher); + log->Printf("[%lld-%lld] detected", *index_lower, *index_higher); } else { @@ -1267,7 +1267,7 @@ if (!item) { if (log) - log->Printf("ERROR in getting child item at index %d", index_lower); + log->Printf("ERROR in getting child item at index %lld", index_lower); } else { Modified: lldb/trunk/source/Core/Log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/Log.cpp (original) +++ lldb/trunk/source/Core/Log.cpp Tue Sep 20 16:44:10 2011 @@ -100,7 +100,7 @@ if (m_options.Test (LLDB_LOG_OPTION_PREPEND_TIMESTAMP)) { struct timeval tv = TimeValue::Now().GetAsTimeVal(); - header.Printf ("%9llu.%6.6llu ", tv.tv_sec, tv.tv_usec); + header.Printf ("%9ld.%6.6d ", tv.tv_sec, tv.tv_usec); } // Add the process and thread if requested Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Sep 20 16:44:10 2011 @@ -217,7 +217,7 @@ void Module::DumpSymbolContext(Stream *s) { - s->Printf(", Module{0x%8.8x}", this); + s->Printf(", Module{%p}", this); } uint32_t Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Tue Sep 20 16:44:10 2011 @@ -859,9 +859,7 @@ StreamString value_str; - if (tmp_value.GetSize() == 0) - value_str.Printf (""); - else if (tmp_value.GetSize() == 1) + if (tmp_value.GetSize() == 1) value_str.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Sep 20 16:44:10 2011 @@ -176,7 +176,7 @@ } else { - errors.Printf("Could not determine type of input value %d.", i); + errors.Printf("Could not determine type of input value %lu.", i); return 1; } } @@ -335,7 +335,7 @@ size_t num_args = arg_values.GetSize(); if (num_args != m_arg_values.GetSize()) { - errors.Printf ("Wrong number of arguments - was: %d should be: %d", num_args, m_arg_values.GetSize()); + errors.Printf ("Wrong number of arguments - was: %lu should be: %lu", num_args, m_arg_values.GetSize()); return false; } Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Sep 20 16:44:10 2011 @@ -319,7 +319,7 @@ if (error_cstr && error_cstr[0]) error_stream.Printf ("error: %s\n", error_cstr); else - error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); + error_stream.Printf ("error: expression can't be interpreted or run\n"); return false; } } @@ -550,7 +550,7 @@ if (error_desc) error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc); else - error_stream.Printf ("Execution was interrupted.", error_desc); + error_stream.Printf ("Execution was interrupted."); if (discard_on_error) error_stream.Printf ("\nThe process has been returned to the state before execution."); Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Tue Sep 20 16:44:10 2011 @@ -173,7 +173,7 @@ if (error_cstr && error_cstr[0]) error_stream.Printf ("error: %s\n", error_cstr); else - error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); + error_stream.Printf ("error: expression can't be interpreted or run\n"); return false; } } Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Sep 20 16:44:10 2011 @@ -310,8 +310,8 @@ case DW_OP_const4s: s->Printf("DW_OP_const4s(0x%8.8x) ", m_data.GetU32(&offset)); break; // 0x0d 1 4-byte constant case DW_OP_const8u: s->Printf("DW_OP_const8u(0x%16.16llx) ", m_data.GetU64(&offset)); break; // 0x0e 1 8-byte constant case DW_OP_const8s: s->Printf("DW_OP_const8s(0x%16.16llx) ", m_data.GetU64(&offset)); break; // 0x0f 1 8-byte constant - case DW_OP_constu: s->Printf("DW_OP_constu(0x%x) ", m_data.GetULEB128(&offset)); break; // 0x10 1 ULEB128 constant - case DW_OP_consts: s->Printf("DW_OP_consts(0x%x) ", m_data.GetSLEB128(&offset)); break; // 0x11 1 SLEB128 constant + case DW_OP_constu: s->Printf("DW_OP_constu(0x%llx) ", m_data.GetULEB128(&offset)); break; // 0x10 1 ULEB128 constant + case DW_OP_consts: s->Printf("DW_OP_consts(0x%lld) ", m_data.GetSLEB128(&offset)); break; // 0x11 1 SLEB128 constant case DW_OP_dup: s->PutCString("DW_OP_dup"); break; // 0x12 case DW_OP_drop: s->PutCString("DW_OP_drop"); break; // 0x13 case DW_OP_over: s->PutCString("DW_OP_over"); break; // 0x14 @@ -330,7 +330,7 @@ case DW_OP_or: s->PutCString("DW_OP_or"); break; // 0x21 case DW_OP_plus: s->PutCString("DW_OP_plus"); break; // 0x22 case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend - s->Printf("DW_OP_plus_uconst(0x%x) ", m_data.GetULEB128(&offset)); + s->Printf("DW_OP_plus_uconst(0x%llx) ", m_data.GetULEB128(&offset)); break; case DW_OP_shl: s->PutCString("DW_OP_shl"); break; // 0x24 @@ -541,7 +541,7 @@ } break; case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed - s->Printf("DW_OP_piece(0x%x)", m_data.GetULEB128(&offset)); + s->Printf("DW_OP_piece(0x%llx)", m_data.GetULEB128(&offset)); break; case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved s->Printf("DW_OP_deref_size(0x%2.2x)", m_data.GetU8(&offset)); @@ -568,7 +568,7 @@ // case DW_OP_lo_user: s->PutCString("DW_OP_lo_user"); break; // 0xe0 // case DW_OP_hi_user: s->PutCString("DW_OP_hi_user"); break; // 0xff case DW_OP_APPLE_extern: - s->Printf("DW_OP_APPLE_extern(%u)", m_data.GetULEB128(&offset)); + s->Printf("DW_OP_APPLE_extern(%llu)", m_data.GetULEB128(&offset)); break; case DW_OP_APPLE_array_ref: s->PutCString("DW_OP_APPLE_array_ref"); @@ -589,7 +589,7 @@ s->PutCString("DW_OP_APPLE_deref_type"); break; case DW_OP_APPLE_expr_local: // 0xF5 - ULEB128 expression local index - s->Printf("DW_OP_APPLE_expr_local(%u)", m_data.GetULEB128(&offset)); + s->Printf("DW_OP_APPLE_expr_local(%llu)", m_data.GetULEB128(&offset)); break; case DW_OP_APPLE_constf: // 0xF6 - 1 byte float size, followed by constant float data { @@ -1029,7 +1029,7 @@ if (log) { size_t count = stack.size(); - log->Printf("Stack before operation has %d values:", count); + log->Printf("Stack before operation has %lu values:", count); for (size_t i=0; iPrintf("Stack after operation has %d values:", count); + log->Printf("Stack after operation has %lu values:", count); for (size_t i=0; igetTypeAlign(qual_type) + 7) / 8; if (log) - log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %d, align %d]", + log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %lu, align %lld]", name.c_str(), qual_type.getAsString().c_str(), PrintType(value_type).c_str(), @@ -1815,7 +1815,7 @@ } ss.flush(); - log->Printf("Found ConstantFP with size %d and raw data %s", operand_data_size, s.c_str()); + log->Printf("Found ConstantFP with size %lu and raw data %s", operand_data_size, s.c_str()); } lldb_private::DataBufferHeap data(operand_data_size, 0); @@ -2186,7 +2186,7 @@ } if (log) - log->Printf(" \"%s\" [\"%s\"] (\"%s\") placed at %d", + log->Printf(" \"%s\" [\"%s\"] (\"%s\") placed at %lld", value->getName().str().c_str(), name.GetCString(), PrintValue(value, true).c_str(), @@ -2225,7 +2225,7 @@ } if (log) - log->Printf("Total structure [align %d, size %d]", alignment, size); + log->Printf("Total structure [align %lld, size %lu]", alignment, size); return true; } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Sep 20 16:44:10 2011 @@ -600,7 +600,7 @@ str.Printf ("[<%s>]", names.GetData()); break; case eArgRepeatRange: - str.Printf ("<%s_1> .. <%s_n>", names.GetData()); + str.Printf ("<%s_1> .. <%s_n>", names.GetData(), names.GetData()); break; // Explicitly test for all the rest of the cases, so if new types get added we will notice the // missing case statement(s). Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 20 16:44:10 2011 @@ -204,8 +204,7 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - run_string.Printf ("run_one_line (%s, 'import gnu_libstdcpp')", m_dictionary_name.c_str(), - interpreter.GetDebugger().GetID()); + run_string.Printf ("run_one_line (%s, 'import gnu_libstdcpp')", m_dictionary_name.c_str()); PyRun_SimpleString (run_string.GetData()); if (m_dbg_stdout != NULL) @@ -629,7 +628,7 @@ if (script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor() != -1) { if (log) - log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %d", bytes, + log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %lu", bytes, bytes_len); if (bytes && bytes_len) { @@ -643,7 +642,7 @@ else { if (log) - log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %d, Master File Descriptor is bad.", + log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %lu, Master File Descriptor is bad.", bytes, bytes_len); reader.SetIsDone (true); Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Tue Sep 20 16:44:10 2011 @@ -493,7 +493,7 @@ OSKextLoadedKextSummary::collection kext_summaries; LogSP log(GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) - log->Printf ("Adding %d modules.\n"); + log->Printf ("Adding %d modules.\n", count); Mutex::Locker locker(m_mutex); Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Sep 20 16:44:10 2011 @@ -686,7 +686,7 @@ DYLDImageInfo::collection image_infos; LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER)); if (log) - log->Printf ("Adding %d modules.\n"); + log->Printf ("Adding %d modules.\n", image_infos_count); Mutex::Locker locker(m_mutex); if (m_process->GetStopID() == m_dyld_image_infos_stop_id) Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Tue Sep 20 16:44:10 2011 @@ -359,11 +359,11 @@ void ObjectContainerBSDArchive::Dump (Stream *s) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); const size_t num_archs = GetNumArchitectures(); const size_t num_objects = GetNumObjects(); - s->Printf("ObjectContainerBSDArchive, num_archs = %u, num_objects = %u", num_archs, num_objects); + s->Printf("ObjectContainerBSDArchive, num_archs = %lu, num_objects = %lu", num_archs, num_objects); uint32_t i; ArchSpec arch; s->IndentMore(); @@ -371,12 +371,12 @@ { s->Indent(); GetArchitectureAtIndex(i, arch); - s->Printf("arch[%u] = %s\n", arch.GetArchitectureName()); + s->Printf("arch[%u] = %s\n", i, arch.GetArchitectureName()); } for (i=0; iIndent(); - s->Printf("object[%u] = %s\n", GetObjectNameAtIndex (i)); + s->Printf("object[%u] = %s\n", i, GetObjectNameAtIndex (i)); } s->IndentLess(); s->EOL(); Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Tue Sep 20 16:44:10 2011 @@ -156,11 +156,11 @@ void ObjectContainerUniversalMachO::Dump (Stream *s) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); const size_t num_archs = GetNumArchitectures(); const size_t num_objects = GetNumObjects(); - s->Printf("ObjectContainerUniversalMachO, num_archs = %u, num_objects = %u", num_archs, num_objects); + s->Printf("ObjectContainerUniversalMachO, num_archs = %lu, num_objects = %lu", num_archs, num_objects); uint32_t i; ArchSpec arch; s->IndentMore(); @@ -168,12 +168,12 @@ { s->Indent(); GetArchitectureAtIndex(i, arch); - s->Printf("arch[%u] = %s\n", arch.GetArchitectureName()); + s->Printf("arch[%u] = %s\n", i, arch.GetArchitectureName()); } for (i=0; iIndent(); - s->Printf("object[%u] = %s\n", GetObjectNameAtIndex (i)); + s->Printf("object[%u] = %s\n", i, GetObjectNameAtIndex (i)); } s->IndentLess(); s->EOL(); Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Sep 20 16:44:10 2011 @@ -1161,9 +1161,9 @@ DumpELFHeader_e_type(s, header.e_type); s->Printf("\ne_machine = 0x%4.4x\n", header.e_machine); s->Printf("e_version = 0x%8.8x\n", header.e_version); - s->Printf("e_entry = 0x%8.8lx\n", header.e_entry); - s->Printf("e_phoff = 0x%8.8lx\n", header.e_phoff); - s->Printf("e_shoff = 0x%8.8lx\n", header.e_shoff); + s->Printf("e_entry = 0x%8.8llx\n", header.e_entry); + s->Printf("e_phoff = 0x%8.8llx\n", header.e_phoff); + s->Printf("e_shoff = 0x%8.8llx\n", header.e_shoff); s->Printf("e_flags = 0x%8.8x\n", header.e_flags); s->Printf("e_ehsize = 0x%4.4x\n", header.e_ehsize); s->Printf("e_phentsize = 0x%4.4x\n", header.e_phentsize); @@ -1221,11 +1221,11 @@ ObjectFileELF::DumpELFProgramHeader(Stream *s, const ELFProgramHeader &ph) { DumpELFProgramHeader_p_type(s, ph.p_type); - s->Printf(" %8.8lx %8.8lx %8.8lx", ph.p_offset, ph.p_vaddr, ph.p_paddr); - s->Printf(" %8.8lx %8.8lx %8.8lx (", ph.p_filesz, ph.p_memsz, ph.p_flags); + s->Printf(" %8.8llx %8.8llx %8.8llx", ph.p_offset, ph.p_vaddr, ph.p_paddr); + s->Printf(" %8.8llx %8.8llx %8.8x (", ph.p_filesz, ph.p_memsz, ph.p_flags); DumpELFProgramHeader_p_flags(s, ph.p_flags); - s->Printf(") %8.8x", ph.p_align); + s->Printf(") %8.8llx", ph.p_align); } //---------------------------------------------------------------------- @@ -1306,11 +1306,11 @@ { s->Printf("%8.8x ", sh.sh_name); DumpELFSectionHeader_sh_type(s, sh.sh_type); - s->Printf(" %8.8lx (", sh.sh_flags); + s->Printf(" %8.8llx (", sh.sh_flags); DumpELFSectionHeader_sh_flags(s, sh.sh_flags); - s->Printf(") %8.8lx %8.8lx %8.8lx", sh.sh_addr, sh.sh_offset, sh.sh_size); + s->Printf(") %8.8llx %8.8llx %8.8llx", sh.sh_addr, sh.sh_offset, sh.sh_size); s->Printf(" %8.8x %8.8x", sh.sh_link, sh.sh_info); - s->Printf(" %8.8lx %8.8lx", sh.sh_addralign, sh.sh_entsize); + s->Printf(" %8.8llx %8.8llx", sh.sh_addralign, sh.sh_entsize); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Sep 20 16:44:10 2011 @@ -1479,7 +1479,7 @@ ObjectFileMachO::Dump (Stream *s) { lldb_private::Mutex::Locker locker(m_mutex); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped) s->PutCString("ObjectFileMachO64"); Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Tue Sep 20 16:44:10 2011 @@ -656,7 +656,7 @@ ObjectFilePECOFF::Dump(Stream *s) { Mutex::Locker locker(m_mutex); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); s->PutCString("ObjectFilePECOFF"); Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp Tue Sep 20 16:44:10 2011 @@ -743,7 +743,7 @@ const addr_t region_addr = packet.GetPointer (&offset); const uint32_t region_size = packet.GetU32 (&offset); const uint32_t region_prot = packet.GetU32 (&offset); - s.Printf("\n\tregion[%i] = { range = [0x%16.16llx - 0x%16.16llx), size = 0x%8.8x, prot = %s }", region_addr, region_addr + region_size, region_size, GetPermissionsAsCString (region_prot)); + s.Printf("\n\tregion[%llu] = { range = [0x%16.16llx - 0x%16.16llx), size = 0x%8.8x, prot = %s }", region_addr, region_addr, region_addr + region_size, region_size, GetPermissionsAsCString (region_prot)); } } break; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Sep 20 16:44:10 2011 @@ -391,7 +391,7 @@ { success = false; if (log) - log->Printf ("error: invalid checksum in packet: '%s'\n", (int)(total_length), m_bytes.c_str()); + log->Printf ("error: invalid checksum in packet: '%s'\n", m_bytes.c_str()); } } m_bytes.erase(0, total_length); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Sep 20 16:44:10 2011 @@ -245,7 +245,7 @@ else { if (log) - log->Printf("error: failed to send '%*s'", payload_length, payload); + log->Printf("error: failed to send '%*s'", (int) payload_length, payload); } } else @@ -311,13 +311,13 @@ else { if (log) - log->Printf("error: packet mutex taken and send_async == false, not sending packet '%*s'", payload_length, payload); + log->Printf("error: packet mutex taken and send_async == false, not sending packet '%*s'", (int) payload_length, payload); } } if (response_len == 0) { if (log) - log->Printf("error: failed to get response for '%*s'", payload_length, payload); + log->Printf("error: failed to get response for '%*s'", (int) payload_length, payload); } return response_len; } @@ -385,7 +385,7 @@ got_stdout = false; if (log) - log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__); + log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%s)", __FUNCTION__, continue_packet.c_str()); if (WaitForPacketWithTimeoutMicroSeconds (response, UINT32_MAX)) { 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=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Sep 20 16:44:10 2011 @@ -1737,7 +1737,7 @@ { LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) - log->Printf ("ProcessGDBRemote::%s (&%p[%u]) ...", __FUNCTION__, buf, buf_size); + log->Printf ("ProcessGDBRemote::%s (&%p[%lu]) ...", __FUNCTION__, buf, buf_size); if (bytes_available > buf_size) { memcpy(buf, m_stdout_data.c_str(), buf_size); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Tue Sep 20 16:44:10 2011 @@ -885,7 +885,7 @@ } s->Printf("-------- -------- -------- -------------------------------------------\n"); - s->Printf("%7u %8u 100.00% Total for all DIEs\n", total_die_count, total_die_size); + s->Printf("%7u %8u 100.00%% Total for all DIEs\n", total_die_count, total_die_size); float total_category_percentages[kNumTagCategories] = { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Tue Sep 20 16:44:10 2011 @@ -1146,7 +1146,7 @@ if (obj_file) obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString(); const char *die_name = GetName (dwarf2Data, cu); - s.Printf ("CU: %s OBJFILE: %s DIE: %s (0x%llx).", + s.Printf ("CU: %s OBJFILE: %s DIE: %s (0x%x).", cu_name ? cu_name : "", obj_file_name ? obj_file_name : "", die_name ? die_name : "", @@ -1215,7 +1215,7 @@ { case DW_AT_stmt_list: if ( verbose ) s.PutCString(" ( "); - s.Printf( "0x%8.8x", form_value.Unsigned()); + s.Printf( "0x%8.8llx", form_value.Unsigned()); if ( verbose ) s.PutCString(" )"); break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Tue Sep 20 16:44:10 2011 @@ -274,7 +274,7 @@ { dw_uleb128_t addr_offset_n = debug_line_data.GetULEB128(&offset); dw_uleb128_t addr_offset = addr_offset_n * prologue.min_inst_length; - log->Printf( "0x%8.8x: DW_LNS_advance_pc (0x%llx)", op_offset, addr_offset); + log->Printf( "0x%8.8x: DW_LNS_advance_pc (0x%x)", op_offset, addr_offset); row.address += addr_offset; } break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp Tue Sep 20 16:44:10 2011 @@ -65,7 +65,7 @@ break; case DW_MACINFO_start_file: - s->Printf(" line:%u file index: '%s'\n", (uint32_t)m_line, (uint32_t)m_op2.file_idx); + s->Printf(" line:%u file index: '%u'\n", (uint32_t)m_line, (uint32_t)m_op2.file_idx); break; case DW_MACINFO_end_file: Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp Tue Sep 20 16:44:10 2011 @@ -437,7 +437,7 @@ if (verbose) s.PutCString(" => "); - s.Printf("{0x%8.8x}", (uvalue + (cu ? cu->GetOffset() : 0))); + s.Printf("{0x%8.8llx}", (uvalue + (cu ? cu->GetOffset() : 0))); } } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Tue Sep 20 16:44:10 2011 @@ -78,7 +78,7 @@ } } - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); *s << "Block" << ((const UserID&)*this); const Block* parent_block = GetParent(); Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Tue Sep 20 16:44:10 2011 @@ -93,7 +93,7 @@ void CompileUnit::Dump(Stream *s, bool show_context) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); *s << "CompileUnit" << (const UserID&)*this << ", language = \"" << (const Language&)*this Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Tue Sep 20 16:44:10 2011 @@ -355,7 +355,7 @@ void Function::Dump(Stream *s, bool show_context) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); *s << "Function" << (const UserID&)*this; @@ -363,7 +363,7 @@ if (m_type) { - s->Printf(", type = %.*p", (int)sizeof(void*) * 2, m_type); + s->Printf(", type = %p", m_type); } else if (m_type_uid != LLDB_INVALID_UID) { Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Sep 20 16:44:10 2011 @@ -749,15 +749,15 @@ s->Printf ("File: %s", path_str); if (m_type == eLineStartSpecified) { - s->Printf (" from line %d", m_start_line); + s->Printf (" from line %lu", m_start_line); if (m_type == eLineEndSpecified) - s->Printf ("to line %d", m_end_line); + s->Printf ("to line %lu", m_end_line); else - s->Printf ("to end", m_end_line); + s->Printf ("to end"); } else if (m_type == eLineEndSpecified) { - s->Printf (" from start to line %d", m_end_line); + s->Printf (" from start to line %ld", m_end_line); } s->Printf (".\n"); } @@ -765,16 +765,16 @@ if (m_type == eLineStartSpecified) { s->Indent(); - s->Printf ("From line %d", m_start_line); + s->Printf ("From line %lu", m_start_line); if (m_type == eLineEndSpecified) - s->Printf ("to line %d", m_end_line); + s->Printf ("to line %lu", m_end_line); else - s->Printf ("to end", m_end_line); + s->Printf ("to end"); s->Printf (".\n"); } else if (m_type == eLineEndSpecified) { - s->Printf ("From start to line %d.\n", m_end_line); + s->Printf ("From start to line %ld.\n", m_end_line); } if (m_type == eFunctionSpecified) Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolVendor.cpp (original) +++ lldb/trunk/source/Symbol/SymbolVendor.cpp Tue Sep 20 16:44:10 2011 @@ -279,7 +279,7 @@ Mutex::Locker locker(m_mutex); bool show_context = false; - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); s->PutCString("SymbolVendor"); if (m_sym_file_ap.get()) Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Tue Sep 20 16:44:10 2011 @@ -87,7 +87,7 @@ object_name = m_objfile->GetModule()->GetObjectName().GetCString(); if (file_spec) - s->Printf("Symtab, file = %s/%s%s%s%s, num_symbols = %u", + s->Printf("Symtab, file = %s/%s%s%s%s, num_symbols = %lu", file_spec.GetDirectory().AsCString(), file_spec.GetFilename().AsCString(), object_name ? "(" : "", @@ -95,7 +95,7 @@ object_name ? ")" : "", m_symbols.size()); else - s->Printf("Symtab, num_symbols = %u", m_symbols.size()); + s->Printf("Symtab, num_symbols = %lu", m_symbols.size()); if (!m_symbols.empty()) { @@ -169,7 +169,7 @@ const size_t num_symbols = GetNumSymbols(); //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - s->Printf("Symtab %u symbol indexes (%u symbols total):\n", indexes.size(), m_symbols.size()); + s->Printf("Symtab %lu symbol indexes (%lu symbols total):\n", indexes.size(), m_symbols.size()); s->IndentMore(); if (!indexes.empty()) Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Tue Sep 20 16:44:10 2011 @@ -142,7 +142,7 @@ void Type::Dump (Stream *s, bool show_context) { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); *s << "Type" << (const UserID&)*this << ' '; if (m_name) Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (original) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Sep 20 16:44:10 2011 @@ -166,7 +166,7 @@ if (base_addr != LLDB_INVALID_ADDRESS) s.Printf ("0x%16.16llx: CFA=", base_addr + GetOffset()); else - s.Printf ("0x%8.8x: CFA=", GetOffset()); + s.Printf ("0x%8.8llx: CFA=", GetOffset()); if (reg_info) s.Printf ("%s", reg_info->name); Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Tue Sep 20 16:44:10 2011 @@ -84,7 +84,7 @@ void Variable::Dump(Stream *s, bool show_context) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + s->Printf("%p: ", this); s->Indent(); *s << "Variable" << (const UserID&)*this; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Sep 20 16:44:10 2011 @@ -167,7 +167,7 @@ } else { - s.Printf ("%-10s %.*-7s ", + s.Printf ("%-10s %-7d %s ", platform->GetUserName (m_euid), (int)m_arch.GetTriple().getArchName().size(), m_arch.GetTriple().getArchName().data()); @@ -1107,7 +1107,7 @@ else { if (log) - log->Printf("Process::SetPrivateState (%s) state didn't change. Ignoring...", StateAsCString(new_state), StateAsCString(old_state)); + log->Printf("Process::SetPrivateState (%s) state didn't change. Ignoring...", StateAsCString(new_state)); } } @@ -2682,7 +2682,7 @@ } if (log) - log->Printf ("Process::ShouldBroadcastEvent (%p) => %s", event_ptr, StateAsCString(state), return_value ? "YES" : "NO"); + log->Printf ("Process::ShouldBroadcastEvent (%p) => %s - %s", event_ptr, StateAsCString(state), return_value ? "YES" : "NO"); return return_value; } @@ -2830,8 +2830,7 @@ __FUNCTION__, GetID(), StateAsCString(new_state), - StateAsCString (GetState ()), - IsHijackedForEvent(eBroadcastBitStateChanged) ? "hijacked" : "public"); + StateAsCString (GetState ())); } } } Modified: lldb/trunk/source/Target/StackFrameList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrameList.cpp (original) +++ lldb/trunk/source/Target/StackFrameList.cpp Tue Sep 20 16:44:10 2011 @@ -266,7 +266,7 @@ frame->DumpUsingSettingsFormat (s); } else - s->Printf("frame #%u", std::distance (begin, pos)); + s->Printf("frame #%ld", std::distance (begin, pos)); s->EOL(); } s->EOL(); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Tue Sep 20 16:44:10 2011 @@ -1018,7 +1018,7 @@ if (name && name[0] != '\0') sstr.Printf ("%s", name); else if ((GetIndexID() != 0) || (GetID() != 0)) - sstr.Printf ("0x%4.4x", GetIndexID(), GetID()); + sstr.Printf ("0x%4.4x", GetIndexID()); if (sstr.GetSize() > 0) Thread::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Tue Sep 20 16:44:10 2011 @@ -147,7 +147,7 @@ s->Printf ("\n\t0x%llx (bp: %d)", (uint64_t) (*pos).first, (*pos).second); } } - s->Printf(" stepped out address is 0x%lx.", (uint64_t) m_return_addr); + s->Printf(" stepped out address is 0x%llx.", (uint64_t) m_return_addr); } } Modified: lldb/trunk/source/Target/ThreadSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=140185&r1=140184&r2=140185&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadSpec.cpp (original) +++ lldb/trunk/source/Target/ThreadSpec.cpp Tue Sep 20 16:44:10 2011 @@ -104,7 +104,7 @@ else { if (GetTID() != LLDB_INVALID_THREAD_ID) - s->Printf("tid: 0x%llx ", GetTID()); + s->Printf("tid: 0x%x ", GetTID()); if (GetIndex() != UINT32_MAX) s->Printf("index: %d ", GetIndex()); From scallanan at apple.com Tue Sep 20 18:01:52 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 20 Sep 2011 23:01:52 -0000 Subject: [Lldb-commits] [lldb] r140202 - in /lldb/trunk: include/lldb/Target/Process.h source/Expression/ClangExpressionParser.cpp source/Expression/ClangUserExpression.cpp source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp source/Target/Process.cpp Message-ID: <20110920230152.2CA9B2A6C12C@llvm.org> Author: spyffe Date: Tue Sep 20 18:01:51 2011 New Revision: 140202 URL: http://llvm.org/viewvc/llvm-project?rev=140202&view=rev Log: Fixed a problem where expressions would attempt to allocate memory in a process that did not support expression execution. Also improved detection of whether or not a process can execute expressions. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=140202&r1=140201&r2=140202&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Sep 20 18:01:51 2011 @@ -2301,6 +2301,24 @@ AllocateMemory (size_t size, uint32_t permissions, Error &error); //------------------------------------------------------------------ + /// Determines whether executing JIT-compiled code in this process + /// is possible. + /// + /// @return + /// True if execution of JIT code is possible; false otherwise. + //------------------------------------------------------------------ + bool CanJIT (); + + //------------------------------------------------------------------ + /// Sets whether executing JIT-compiled code in this process + /// is possible. + /// + /// @param[in] can_jit + /// True if execution of JIT code is possible; false otherwise. + //------------------------------------------------------------------ + void SetCanJIT (bool can_jit); + + //------------------------------------------------------------------ /// Actually deallocate memory in the process. /// /// This function will deallocate memory in the process's address @@ -2771,6 +2789,12 @@ LanguageRuntimeCollection m_language_runtimes; std::auto_ptr m_next_event_action_ap; + enum { + eCanJITDontKnow= 0, + eCanJITYes, + eCanJITNo + } m_can_jit; + size_t RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const; Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=140202&r1=140201&r2=140202&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Sep 20 18:01:51 2011 @@ -496,8 +496,32 @@ return err; } - if (m_expr.NeedsValidation() && exe_ctx.process && exe_ctx.process->GetDynamicCheckers()) + if (execution_policy != eExecutionPolicyNever && + m_expr.NeedsValidation() && + exe_ctx.process) { + if (!exe_ctx.process->GetDynamicCheckers()) + { + DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); + + StreamString install_errors; + + if (!dynamic_checkers->Install(install_errors, exe_ctx)) + { + if (install_errors.GetString().empty()) + err.SetErrorString ("couldn't install checkers, unknown error"); + else + err.SetErrorString (install_errors.GetString().c_str()); + + return err; + } + + exe_ctx.process->SetDynamicCheckers(dynamic_checkers); + + if (log) + log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers =="); + } + IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str()); if (!ir_dynamic_checks.runOnModule(*module)) Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=140202&r1=140201&r2=140202&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Sep 20 18:01:51 2011 @@ -615,34 +615,8 @@ } } - if (exe_ctx.process == NULL) + if (exe_ctx.process == NULL || !exe_ctx.process->CanJIT()) execution_policy = eExecutionPolicyNever; - - if (execution_policy != eExecutionPolicyNever && !exe_ctx.process->GetDynamicCheckers()) - { - if (log) - log->Printf("== [ClangUserExpression::Evaluate] Installing dynamic checkers =="); - - DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); - - StreamString install_errors; - - if (!dynamic_checkers->Install(install_errors, exe_ctx)) - { - if (install_errors.GetString().empty()) - error.SetErrorString ("couldn't install checkers, unknown error"); - else - error.SetErrorString (install_errors.GetString().c_str()); - - result_valobj_sp = ValueObjectConstResult::Create (NULL, error); - return eExecutionSetupError; - } - - exe_ctx.process->SetDynamicCheckers(dynamic_checkers); - - if (log) - log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers =="); - } ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix)); Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=140202&r1=140201&r2=140202&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Tue Sep 20 18:01:51 2011 @@ -78,7 +78,10 @@ } if (create) + { + process->SetCanJIT(false); return new DynamicLoaderDarwinKernel (process); + } return NULL; } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=140202&r1=140201&r2=140202&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Sep 20 18:01:51 2011 @@ -601,7 +601,8 @@ m_memory_cache (*this), m_allocated_memory_cache (*this), m_attached_to_process (false), - m_next_event_action_ap() + m_next_event_action_ap(), + m_can_jit(eCanJITYes) { UpdateInstanceName(); @@ -1956,6 +1957,18 @@ #endif } +bool +Process::CanJIT () +{ + return m_can_jit == eCanJITYes; +} + +void +Process::SetCanJIT (bool can_jit) +{ + m_can_jit = (can_jit ? eCanJITYes : eCanJITNo); +} + Error Process::DeallocateMemory (addr_t ptr) { From jmolenda at apple.com Tue Sep 20 18:23:44 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 20 Sep 2011 23:23:44 -0000 Subject: [Lldb-commits] [lldb] r140205 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110920232344.3ACBA2A6C12C@llvm.org> Author: jmolenda Date: Tue Sep 20 18:23:44 2011 New Revision: 140205 URL: http://llvm.org/viewvc/llvm-project?rev=140205&view=rev Log: One last printf-style call cleanup. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=140205&r1=140204&r2=140205&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 20 18:23:44 2011 @@ -575,7 +575,7 @@ if (IS_VALID_LLDB_HOST_THREAD(embedded_interpreter_thread)) { if (log) - log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in creating thread (thread = %d)", embedded_interpreter_thread); + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in creating thread (thread_t = %p)", embedded_interpreter_thread); Error detach_error; Host::ThreadDetach (embedded_interpreter_thread, &detach_error); } From johnny.chen at apple.com Tue Sep 20 18:28:55 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 20 Sep 2011 23:28:55 -0000 Subject: [Lldb-commits] [lldb] r140211 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocationList.h include/lldb/Target/Target.h source/Breakpoint/WatchpointLocation.cpp source/Breakpoint/WatchpointLocationList.cpp source/Target/Target.cpp Message-ID: <20110920232855.C3FD92A6C12C@llvm.org> Author: johnny Date: Tue Sep 20 18:28:55 2011 New Revision: 140211 URL: http://llvm.org/viewvc/llvm-project?rev=140211&view=rev Log: Add some watchpoint maintenance methods to the Target class. Plus some minor changes to the WatchpointLocationList and WatchpointLocation classes. Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Breakpoint/WatchpointLocation.cpp lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140211&r1=140210&r2=140211&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Tue Sep 20 18:28:55 2011 @@ -209,7 +209,10 @@ lldb::DescriptionLevel level); void - ClearAllWatchpointLocations (); + SetEnabledAll (bool enabled); + + void + RemoveAll (); //------------------------------------------------------------------ /// Sets the passed in Locker to hold the Watchpoint Location List mutex. Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140211&r1=140210&r2=140211&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 20 18:28:55 2011 @@ -180,6 +180,10 @@ const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp); + // Helper function. + bool + ProcessIsValid (); + public: ~Target(); @@ -311,6 +315,24 @@ bool RemoveBreakpointByID (lldb::break_id_t break_id); + bool + RemoveAllWatchpointLocations (); + + bool + DisableAllWatchpointLocations (); + + bool + EnableAllWatchpointLocations (); + + bool + DisableWatchpointLocationByID (lldb::watch_id_t watch_id); + + bool + EnableWatchpointLocationByID (lldb::watch_id_t watch_id); + + bool + RemoveWatchpointLocationByID (lldb::watch_id_t watch_id); + void ModulesDidLoad (ModuleList &module_list); Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140211&r1=140210&r2=140211&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Tue Sep 20 18:28:55 2011 @@ -113,7 +113,8 @@ s->Printf("\n declare @ '%s'", m_decl_str.c_str()); if (description_level >= lldb::eDescriptionLevelVerbose) - s->Printf("\n hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p", + s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p", + GetHardwareIndex(), GetHitCount(), GetIgnoreCount(), m_callback, Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140211&r1=140210&r2=140211&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Tue Sep 20 18:28:55 2011 @@ -232,13 +232,27 @@ } void -WatchpointLocationList::ClearAllWatchpointLocations () +WatchpointLocationList::SetEnabledAll (bool enabled) { Mutex::Locker locker(m_mutex); + addr_map::iterator pos, end = m_address_to_location.end(); + for (pos = m_address_to_location.begin(); pos != end; ++pos) + pos->second->SetEnabled (enabled); +} +void +WatchpointLocationList::RemoveAll () +{ + Mutex::Locker locker(m_mutex); + + addr_map::iterator pos, end = m_address_to_location.end(); for (pos = m_address_to_location.begin(); pos != end; ++pos) - m_address_to_location.erase(pos); + m_address_to_location.erase(pos); + + collection::iterator p, e = m_locations.end(); + for (p = m_locations.begin(); p != e; ++pos) + m_locations.erase(p); } void Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140211&r1=140210&r2=140211&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 20 18:28:55 2011 @@ -124,7 +124,7 @@ // clean up needs some help from the process. m_breakpoint_list.ClearAllBreakpointSites(); m_internal_breakpoint_list.ClearAllBreakpointSites(); - m_watchpoint_location_list.ClearAllWatchpointLocations(); + m_watchpoint_location_list.RemoveAll(); m_process_sp.reset(); } } @@ -331,6 +331,12 @@ return bp_sp; } +bool +Target::ProcessIsValid() +{ + return (m_process_sp && m_process_sp->IsAlive()); +} + // See also WatchpointLocation::SetWatchpointType(uint32_t type) and // the OptionGroupWatchpoint::WatchType enum type. WatchpointLocationSP @@ -342,8 +348,7 @@ __FUNCTION__, addr, size, type); WatchpointLocationSP wp_loc_sp; - bool process_is_valid = m_process_sp && m_process_sp->IsAlive(); - if (!process_is_valid) + if (!ProcessIsValid()) return wp_loc_sp; if (addr == LLDB_INVALID_ADDRESS || size == 0) return wp_loc_sp; @@ -500,6 +505,148 @@ return false; } +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::RemoveAllWatchpointLocations () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s\n", __FUNCTION__); + + if (!ProcessIsValid()) + return false; + + size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); + if (!wp_loc_sp) + return false; + + Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + if (rc.Fail()) + return false; + } + m_watchpoint_location_list.RemoveAll (); + return true; // Success! +} + +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::DisableAllWatchpointLocations () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s\n", __FUNCTION__); + + if (!ProcessIsValid()) + return false; + + size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); + if (!wp_loc_sp) + return false; + + Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + if (rc.Fail()) + return false; + } + m_watchpoint_location_list.SetEnabledAll (false); + return true; // Success! +} + +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::EnableAllWatchpointLocations () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s\n", __FUNCTION__); + + if (!ProcessIsValid()) + return false; + + size_t num_watchpoints = m_watchpoint_location_list.GetSize(); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); + if (!wp_loc_sp) + return false; + + Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); + if (rc.Fail()) + return false; + } + m_watchpoint_location_list.SetEnabledAll (true); + return true; // Success! +} + +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); + + if (!ProcessIsValid()) + return false; + + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); + if (wp_loc_sp) + { + Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); + if (rc.Fail()) + return false; + + wp_loc_sp->SetEnabled (false); + return true; + } + return false; +} + +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); + + if (!ProcessIsValid()) + return false; + + WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); + if (wp_loc_sp) + { + Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); + if (rc.Fail()) + return false; + + wp_loc_sp->SetEnabled (true); + return true; + } + return false; +} + +// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +bool +Target::RemoveWatchpointLocationByID (lldb::watch_id_t watch_id) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); + if (log) + log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); + + if (DisableWatchpointLocationByID (watch_id)) + { + m_watchpoint_location_list.Remove(watch_id); + return true; + } + return false; +} + ModuleSP Target::GetExecutableModule () { @@ -722,8 +869,6 @@ if (load_addr_ptr) *load_addr_ptr = LLDB_INVALID_ADDRESS; - bool process_is_valid = m_process_sp && m_process_sp->IsAlive(); - size_t bytes_read = 0; addr_t load_addr = LLDB_INVALID_ADDRESS; @@ -759,7 +904,7 @@ return bytes_read; } - if (process_is_valid) + if (ProcessIsValid()) { if (load_addr == LLDB_INVALID_ADDRESS) load_addr = resolved_addr.GetLoadAddress (this); From johnny.chen at apple.com Tue Sep 20 20:00:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 21 Sep 2011 01:00:02 -0000 Subject: [Lldb-commits] [lldb] r140221 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h source/Commands/CommandObjectBreakpoint.cpp source/Interpreter/CommandObject.cpp Message-ID: <20110921010002.A15602A6C12C@llvm.org> Author: johnny Date: Tue Sep 20 20:00:02 2011 New Revision: 140221 URL: http://llvm.org/viewvc/llvm-project?rev=140221&view=rev Log: A little refactoring of the way to add break IDs or ID ranges as command argument data to the command argument entry. Add a static helper function: CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg) to be used from CommandObjectBreakpoint.cpp. The helper function could also be useful for commands in the future to manipulate watchpoints. Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=140221&r1=140220&r2=140221&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Sep 20 20:00:02 2011 @@ -361,6 +361,12 @@ bool m_is_alias; Flags m_flags; std::vector m_arguments; + + // Helper function to populate IDs or ID ranges as the command argument data + // to the specified command argument entry. + static void + AddIDsArgumentData(CommandArgumentEntry &arg); + }; } // namespace lldb_private Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140221&r1=140220&r2=140221&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Sep 20 20:00:02 2011 @@ -826,22 +826,7 @@ NULL) { CommandArgumentEntry arg; - CommandArgumentData bp_id_arg; - CommandArgumentData bp_id_range_arg; - - // Create the first variant for the first (and only) argument for this command. - bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatOptional; - - // Create the second variant for the first (and only) argument for this command. - bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatOptional; - - // The first (and only) argument for this command could be either a bp_id or a bp_id_range. - // Push both variants into the entry for the first argument for this command. - arg.push_back (bp_id_arg); - arg.push_back (bp_id_range_arg); - + CommandObject::AddIDsArgumentData(arg); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -942,22 +927,7 @@ NULL) { CommandArgumentEntry arg; - CommandArgumentData bp_id_arg; - CommandArgumentData bp_id_range_arg; - - // Create the first variant for the first (and only) argument for this command. - bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatOptional; - - // Create the second variant for the first (and only) argument for this command. - bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatOptional; - - // The first (and only) argument for this command could be either a bp_id or a bp_id_range. - // Push both variants into the entry for the first argument for this command. - arg.push_back (bp_id_arg); - arg.push_back (bp_id_range_arg); - + CommandObject::AddIDsArgumentData(arg); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -1238,22 +1208,7 @@ NULL) { CommandArgumentEntry arg; - CommandArgumentData bp_id_arg; - CommandArgumentData bp_id_range_arg; - - // Create the first variant for the first (and only) argument for this command. - bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatOptional; - - // Create the second variant for the first (and only) argument for this command. - bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatOptional; - - // The first (and only) argument for this command could be either a bp_id or a bp_id_range. - // Push both variants into the entry for the first argument for this command. - arg.push_back (bp_id_arg); - arg.push_back (bp_id_range_arg); - + CommandObject::AddIDsArgumentData(arg); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -1513,22 +1468,7 @@ m_options (interpreter) { CommandArgumentEntry arg; - CommandArgumentData bp_id_arg; - CommandArgumentData bp_id_range_arg; - - // Create the first variant for the first (and only) argument for this command. - bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatPlain; - - // Create the second variant for the first (and only) argument for this command. - bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatPlain; - - // The first (and only) argument for this command could be either a bp_id or a bp_id_range. - // Push both variants into the entry for the first argument for this command. - arg.push_back (bp_id_arg); - arg.push_back (bp_id_range_arg); - + CommandObject::AddIDsArgumentData(arg); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140221&r1=140220&r2=140221&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Sep 20 20:00:02 2011 @@ -743,6 +743,26 @@ " meaning of array slicing (taking elements n thru m inside the array or pointed-to memory)."; } +void +CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg) +{ + CommandArgumentData id_arg; + CommandArgumentData id_range_arg; + + // Create the first variant for the first (and only) argument for this command. + id_arg.arg_type = eArgTypeBreakpointID; + id_arg.arg_repetition = eArgRepeatOptional; + + // Create the second variant for the first (and only) argument for this command. + id_range_arg.arg_type = eArgTypeBreakpointIDRange; + id_range_arg.arg_repetition = eArgRepeatOptional; + + // The first (and only) argument for this command could be either a id or a id_range. + // Push both variants into the entry for the first argument for this command. + arg.push_back(id_arg); + arg.push_back(id_range_arg); +} + const char * CommandObject::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) { From johnny.chen at apple.com Tue Sep 20 20:04:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 21 Sep 2011 01:04:49 -0000 Subject: [Lldb-commits] [lldb] r140222 - /lldb/trunk/source/Interpreter/CommandObject.cpp Message-ID: <20110921010449.78C0A2A6C12C@llvm.org> Author: johnny Date: Tue Sep 20 20:04:49 2011 New Revision: 140222 URL: http://llvm.org/viewvc/llvm-project?rev=140222&view=rev Log: Fix comment typo. Modified: lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140222&r1=140221&r2=140222&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Sep 20 20:04:49 2011 @@ -757,7 +757,7 @@ id_range_arg.arg_type = eArgTypeBreakpointIDRange; id_range_arg.arg_repetition = eArgRepeatOptional; - // The first (and only) argument for this command could be either a id or a id_range. + // The first (and only) argument for this command could be either an id or an id_range. // Push both variants into the entry for the first argument for this command. arg.push_back(id_arg); arg.push_back(id_range_arg); From jingham at apple.com Tue Sep 20 20:17:13 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 21 Sep 2011 01:17:13 -0000 Subject: [Lldb-commits] [lldb] r140225 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ scripts/ scripts/Python/interface/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Plugins/DynamicLoader/Darwin-Kernel/ source/Plugins/SymbolFile/Symtab/ source/Target/ test/lang/objc/objc-stepping/ Message-ID: <20110921011713.E805E2A6C12C@llvm.org> Author: jingham Date: Tue Sep 20 20:17:13 2011 New Revision: 140225 URL: http://llvm.org/viewvc/llvm-project?rev=140225&view=rev Log: Add a new breakpoint type "break by source regular expression". Fix the RegularExpression class so it has a real copy constructor. Fix the breakpoint setting with multiple shared libraries so it makes one breakpoint not one per shared library. Add SBFileSpecList, to be used to expose the above to the SB interface (not done yet.) Added: lldb/trunk/include/lldb/API/SBFileSpecList.h lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h lldb/trunk/scripts/Python/interface/SBFileSpecList.i lldb/trunk/source/API/SBFileSpecList.cpp lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h lldb/trunk/include/lldb/Core/RegularExpression.h lldb/trunk/include/lldb/Core/SearchFilter.h lldb/trunk/include/lldb/Core/SourceManager.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/lldb-defines.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h lldb/trunk/source/Core/RegularExpression.cpp lldb/trunk/source/Core/SearchFilter.cpp lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/lang/objc/objc-stepping/TestObjCStepping.py Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Tue Sep 20 20:17:13 2011 @@ -80,6 +80,9 @@ lldb::ReturnStatus HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); +#ifndef SWIG + // This interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line + // and you can't do that in a scripting language interface in general... int HandleCompletion (const char *current_line, const char *cursor, @@ -87,6 +90,13 @@ int match_start_point, int max_return_elements, lldb::SBStringList &matches); +#endif + int + HandleCompletion (const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches); protected: Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Tue Sep 20 20:17:13 2011 @@ -59,6 +59,7 @@ private: friend class SBBlock; friend class SBCompileUnit; + friend class SBFileSpecList; friend class SBHostOS; friend class SBLineEntry; friend class SBModule; Added: lldb/trunk/include/lldb/API/SBFileSpecList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpecList.h?rev=140225&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpecList.h (added) +++ lldb/trunk/include/lldb/API/SBFileSpecList.h Tue Sep 20 20:17:13 2011 @@ -0,0 +1,76 @@ +//===-- SBFileSpecList.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBFileSpecList_h_ +#define LLDB_SBFileSpecList_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBFileSpecList +{ +public: + SBFileSpecList (); + + SBFileSpecList (const lldb::SBFileSpecList &rhs); + + ~SBFileSpecList (); + +#ifndef SWIG + const SBFileSpecList & + operator = (const lldb::SBFileSpecList &rhs); +#endif + + uint32_t + GetSize () const; + + bool + GetDescription (SBStream &description) const; + + void + Append (const SBFileSpec &sb_file); + + bool + AppendIfUnique (const SBFileSpec &sb_file); + + void + Clear(); + + uint32_t + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file); + + const SBFileSpec + GetFileSpecAtIndex (uint32_t idx) const; + +private: + +#ifndef SWIG + + const lldb_private::FileSpecList * + operator->() const; + + const lldb_private::FileSpecList * + get() const; + + const lldb_private::FileSpecList & + operator*() const; + + const lldb_private::FileSpecList & + ref() const; + +#endif + + std::auto_ptr m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBFileSpecList_h_ Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Sep 20 20:17:13 2011 @@ -316,6 +316,9 @@ lldb::SBBreakpoint BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Tue Sep 20 20:17:13 2011 @@ -120,7 +120,8 @@ enum ResolverTy { FileLineResolver, // This is an instance of BreakpointResolverFileLine AddressResolver, // This is an instance of BreakpointResolverAddress - NameResolver // This is an instance of BreakpointResolverName + NameResolver, // This is an instance of BreakpointResolverName + FileRegexResolver }; //------------------------------------------------------------------ Added: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h?rev=140225&view=auto ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h (added) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h Tue Sep 20 20:17:13 2011 @@ -0,0 +1,70 @@ +//===-- BreakpointResolverFileRegex.h ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_BreakpointResolverFileRegex_h_ +#define liblldb_BreakpointResolverFileRegex_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Breakpoint/BreakpointResolver.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h "lldb/Breakpoint/BreakpointResolverFileRegex.h" +/// @brief This class sets breakpoints by file and line. Optionally, it will look for inlined +/// instances of the file and line specification. +//---------------------------------------------------------------------- + +class BreakpointResolverFileRegex : + public BreakpointResolver +{ +public: + BreakpointResolverFileRegex (Breakpoint *bkpt, + const FileSpec &resolver, + RegularExpression ®ex); + + virtual + ~BreakpointResolverFileRegex (); + + virtual Searcher::CallbackReturn + SearchCallback (SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing); + + virtual Searcher::Depth + GetDepth (); + + virtual void + GetDescription (Stream *s); + + virtual void + Dump (Stream *s) const; + + /// Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const BreakpointResolverFileRegex *) { return true; } + static inline bool classof(const BreakpointResolver *V) { + return V->getResolverID() == BreakpointResolver::FileRegexResolver; + } + +protected: + friend class Breakpoint; + FileSpec m_file_spec; // This is the file spec we are looking for. + RegularExpression m_regex; // This is the line number that we are looking for. + +private: + DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex); +}; + +} // namespace lldb_private + +#endif // liblldb_BreakpointResolverFileRegex_h_ Modified: lldb/trunk/include/lldb/Core/RegularExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegularExpression.h (original) +++ lldb/trunk/include/lldb/Core/RegularExpression.h Tue Sep 20 20:17:13 2011 @@ -52,7 +52,11 @@ /// Flags that are passed the the \c regcomp() function. //------------------------------------------------------------------ explicit - RegularExpression (const char* re, int flags = REG_EXTENDED); + RegularExpression (const char* re, int flags); + + // This one uses flags = REG_EXTENDED. + explicit + RegularExpression (const char* re); //------------------------------------------------------------------ /// Destructor. @@ -61,6 +65,10 @@ /// object will be freed. //------------------------------------------------------------------ ~RegularExpression (); + + RegularExpression (const RegularExpression &rhs); + + const RegularExpression & operator=(const RegularExpression &rhs); //------------------------------------------------------------------ /// Compile a regular expression. @@ -84,7 +92,10 @@ /// \b false otherwise. //------------------------------------------------------------------ bool - Compile (const char* re, int flags = REG_EXTENDED); + Compile (const char* re); + + bool + Compile (const char* re, int flags); //------------------------------------------------------------------ /// Executes a regular expression. @@ -138,6 +149,12 @@ //------------------------------------------------------------------ const char* GetText () const; + + int + GetCompileFlags () const + { + return m_compile_flags; + } //------------------------------------------------------------------ /// Test if valid. @@ -161,7 +178,9 @@ std::string m_re; ///< A copy of the original regular expression text int m_comp_err; ///< Error code for the regular expression compilation regex_t m_preg; ///< The compiled regular expression + int m_compile_flags; ///< Stores the flags from the last compile. mutable std::vector m_matches; ///< Where parenthesized subexpressions results are stored + }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/SearchFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SearchFilter.h (original) +++ lldb/trunk/include/lldb/Core/SearchFilter.h Tue Sep 20 20:17:13 2011 @@ -321,6 +321,64 @@ FileSpec m_module_spec; }; +class SearchFilterByModuleList : + public SearchFilter +{ +public: + + //------------------------------------------------------------------ + /// The basic constructor takes a Target, which gives the space to search, + /// and the module list to restrict the search to. + /// + /// @param[in] target + /// The Target that provides the module list to search. + /// + /// @param[in] module + /// The Module that limits the search. + //------------------------------------------------------------------ + SearchFilterByModuleList (lldb::TargetSP &targetSP, + const FileSpecList &module_list); + + SearchFilterByModuleList (const SearchFilterByModuleList& rhs); + + virtual + ~SearchFilterByModuleList (); + + const SearchFilterByModuleList& + operator=(const SearchFilterByModuleList& rhs); + + virtual bool + ModulePasses (const lldb::ModuleSP &module_sp); + + virtual bool + ModulePasses (const FileSpec &spec); + + virtual bool + SymbolContextPasses (const SymbolContext &context, + lldb::SymbolContextItem scope); + + virtual bool + AddressPasses (Address &address); + + virtual bool + CompUnitPasses (FileSpec &fileSpec); + + virtual bool + CompUnitPasses (CompileUnit &compUnit); + + virtual void + GetDescription(Stream *s); + + virtual void + Dump (Stream *s) const; + + virtual void + Search (Searcher &searcher); + +private: + FileSpecList m_module_spec_list; +}; + } // namespace lldb_private #endif // liblldb_SearchFilter_h_ Modified: lldb/trunk/include/lldb/Core/SourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SourceManager.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SourceManager.h (original) +++ lldb/trunk/include/lldb/Core/SourceManager.h Tue Sep 20 20:17:13 2011 @@ -40,7 +40,15 @@ uint32_t context_before, uint32_t context_after, Stream *s); + void + FindLinesMatchingRegex (RegularExpression& regex, + uint32_t start_line, + uint32_t end_line, + std::vector &match_lines); + bool + GetLine (uint32_t line_no, std::string &buffer); + uint32_t GetLineOffset (uint32_t line); @@ -151,6 +159,13 @@ return (m_last_file_sp.get() != NULL); } + void + FindLinesMatchingRegex (FileSpec &file_spec, + RegularExpression& regex, + uint32_t start_line, + uint32_t end_line, + std::vector &match_lines); + protected: FileSP Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Sep 20 20:17:13 2011 @@ -214,7 +214,7 @@ // This handles command line completion. You are given a pointer to the command string buffer, to the current cursor, // and to the end of the string (in case it is not NULL terminated). - // You also passed in an Args object to fill with the returns. + // You also passed in an StringList object to fill with the returns. // The first element of the array will be filled with the string that you would need to insert at // the cursor point to complete the cursor point to the longest common matching prefix. // If you want to limit the number of elements returned, set max_return_elements to the number of elements Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 20 20:17:13 2011 @@ -244,12 +244,19 @@ // Use this to create a file and line breakpoint to a given module or all module it is NULL lldb::BreakpointSP - CreateBreakpoint (const FileSpec *containingModule, + CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal = false); + // Use this to create breakpoint that matches regex against the source lines in file: + lldb::BreakpointSP + CreateBreakpoint (const FileSpecList *containingModules, + const FileSpec &file, + RegularExpression &source_regex, + bool internal = false); + // Use this to create a breakpoint from a load address lldb::BreakpointSP CreateBreakpoint (lldb::addr_t load_addr, @@ -264,7 +271,7 @@ // When "skip_prologue is set to eLazyBoolCalculate, we use the current target // setting, else we use the values passed in lldb::BreakpointSP - CreateBreakpoint (const FileSpec *containingModule, + CreateBreakpoint (const FileSpecList *containingModules, RegularExpression &func_regexp, bool internal = false, LazyBool skip_prologue = eLazyBoolCalculate); @@ -273,7 +280,7 @@ // When "skip_prologue is set to eLazyBoolCalculate, we use the current target // setting, else we use the values passed in lldb::BreakpointSP - CreateBreakpoint (const FileSpec *containingModule, + CreateBreakpoint (const FileSpecList *containingModules, const char *func_name, uint32_t func_name_type_mask, bool internal = false, @@ -880,6 +887,9 @@ lldb::SearchFilterSP GetSearchFilterForModule (const FileSpec *containingModule); + lldb::SearchFilterSP + GetSearchFilterForModuleList (const FileSpecList *containingModuleList); + static void ImageSearchPathsChanged (const PathMappingList &path_list, void *baton); Modified: lldb/trunk/include/lldb/lldb-defines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-defines.h (original) +++ lldb/trunk/include/lldb/lldb-defines.h Tue Sep 20 20:17:13 2011 @@ -101,6 +101,7 @@ #define LLDB_OPT_SET_6 (1 << 5) #define LLDB_OPT_SET_7 (1 << 6) #define LLDB_OPT_SET_8 (1 << 7) +#define LLDB_OPT_SET_9 (1 << 8) #if defined(__cplusplus) Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 20 20:17:13 2011 @@ -400,6 +400,8 @@ 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D8FB3513B558DE00411094 /* ClangASTImporter.cpp */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; + 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CAA56121422D96A001FFA01 /* BreakpointResolverFileRegex.h */; }; + 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */; }; 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; 4CCA644D13B40B82003BDF98 /* ItaniumABILanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA643D13B40B82003BDF98 /* ItaniumABILanguageRuntime.cpp */; }; 4CCA645013B40B82003BDF98 /* AppleObjCRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644213B40B82003BDF98 /* AppleObjCRuntime.cpp */; }; @@ -408,6 +410,8 @@ 4CCA645613B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */; }; 4CCA645813B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */; }; 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; + 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; }; + 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; 94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; }; 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; }; 9443B122140C18C40013457C /* SBData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9443B121140C18C10013457C /* SBData.cpp */; }; @@ -1159,6 +1163,8 @@ 4C98D3E1118FB98F00E575D0 /* RecordingMemoryManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecordingMemoryManager.h; path = include/lldb/Expression/RecordingMemoryManager.h; sourceTree = ""; }; 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectApropos.cpp; path = source/Commands/CommandObjectApropos.cpp; sourceTree = ""; }; 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectApropos.h; path = source/Commands/CommandObjectApropos.h; sourceTree = ""; }; + 4CAA56121422D96A001FFA01 /* BreakpointResolverFileRegex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BreakpointResolverFileRegex.h; path = include/lldb/Breakpoint/BreakpointResolverFileRegex.h; sourceTree = ""; }; + 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BreakpointResolverFileRegex.cpp; path = source/Breakpoint/BreakpointResolverFileRegex.cpp; sourceTree = ""; }; 4CABA9DC134A8BA700539BDD /* ValueObjectMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectMemory.h; path = include/lldb/Core/ValueObjectMemory.h; sourceTree = ""; }; 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectMemory.cpp; path = source/Core/ValueObjectMemory.cpp; sourceTree = ""; }; 4CAFCE001101216B00CA63DB /* ThreadPlanRunToAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanRunToAddress.h; path = include/lldb/Target/ThreadPlanRunToAddress.h; sourceTree = ""; }; @@ -1186,6 +1192,8 @@ 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectDynamicValue.h; path = include/lldb/Core/ValueObjectDynamicValue.h; sourceTree = ""; }; 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; + 4CF52AF41428291E0051E832 /* SBFileSpecList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFileSpecList.h; path = include/lldb/API/SBFileSpecList.h; sourceTree = ""; }; + 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFileSpecList.cpp; path = source/API/SBFileSpecList.cpp; sourceTree = ""; }; 69A01E1B1236C5D400C660B5 /* Condition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Condition.cpp; sourceTree = ""; }; 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; 69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = ""; }; @@ -1685,6 +1693,8 @@ 9A9830FD1125FC5800A56CB0 /* SBEvent.cpp */, 26022531115F27FA00A601A2 /* SBFileSpec.h */, 26022532115F281400A601A2 /* SBFileSpec.cpp */, + 4CF52AF41428291E0051E832 /* SBFileSpecList.h */, + 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */, 9A633FE8112DCE3C001A7E43 /* SBFrame.h */, 9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */, 26DE205211618FAC00A093E2 /* SBFunction.h */, @@ -2176,6 +2186,8 @@ 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */, 26D0DD5110FE554D00271C65 /* BreakpointResolverFileLine.h */, 26D0DD5410FE555900271C65 /* BreakpointResolverFileLine.cpp */, + 4CAA56121422D96A001FFA01 /* BreakpointResolverFileRegex.h */, + 4CAA56141422D986001FFA01 /* BreakpointResolverFileRegex.cpp */, 26D0DD5210FE554D00271C65 /* BreakpointResolverName.h */, 26D0DD5510FE555900271C65 /* BreakpointResolverName.cpp */, 26BC7CF710F1B71400F91463 /* BreakpointSite.h */, @@ -2754,6 +2766,8 @@ 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, + 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */, + 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3037,6 +3051,8 @@ 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */, 26B1FA1413380E61002886E2 /* LLDBWrapPython.cpp in Sources */, 9443B122140C18C40013457C /* SBData.cpp in Sources */, + 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */, + 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i (original) +++ lldb/trunk/scripts/Python/interface/SBCommandInterpreter.i Tue Sep 20 20:17:13 2011 @@ -116,8 +116,7 @@ int HandleCompletion (const char *current_line, - const char *cursor, - const char *last_char, + uint32_t cursor_pos, int match_start_point, int max_return_elements, lldb::SBStringList &matches); Added: lldb/trunk/scripts/Python/interface/SBFileSpecList.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFileSpecList.i?rev=140225&view=auto ============================================================================== --- lldb/trunk/scripts/Python/interface/SBFileSpecList.i (added) +++ lldb/trunk/scripts/Python/interface/SBFileSpecList.i Tue Sep 20 20:17:13 2011 @@ -0,0 +1,45 @@ +//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBFileSpecList +{ +public: + SBFileSpecList (); + + SBFileSpecList (const lldb::SBFileSpecList &rhs); + + ~SBFileSpecList (); + + uint32_t + GetSize () const; + + bool + GetDescription (SBStream &description) const; + + void + Append (const SBFileSpec &sb_file); + + bool + AppendIfUnique (const SBFileSpec &sb_file); + + void + Clear(); + + uint32_t + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file); + + const SBFileSpec + GetFileSpecAtIndex (uint32_t idx) const; + +}; + + +} // namespace lldb Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Tue Sep 20 20:17:13 2011 @@ -372,6 +372,9 @@ BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); + + lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); uint32_t Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Tue Sep 20 20:17:13 2011 @@ -56,6 +56,7 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" #include "lldb/API/SBHostOS.h" @@ -106,6 +107,7 @@ %include "./Python/interface/SBError.i" %include "./Python/interface/SBEvent.i" %include "./Python/interface/SBFileSpec.i" +%include "./Python/interface/SBFileSpecList.i" %include "./Python/interface/SBFrame.i" %include "./Python/interface/SBFunction.i" %include "./Python/interface/SBHostOS.i" Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Tue Sep 20 20:17:13 2011 @@ -136,6 +136,18 @@ return num_completions; } +int +SBCommandInterpreter::HandleCompletion (const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches) +{ + const char *cursor = current_line + cursor_pos; + const char *last_char = current_line + strlen (current_line); + return HandleCompletion (current_line, cursor, last_char, match_start_point, max_return_elements, matches); +} + bool SBCommandInterpreter::HasCommands () { Added: lldb/trunk/source/API/SBFileSpecList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpecList.cpp?rev=140225&view=auto ============================================================================== --- lldb/trunk/source/API/SBFileSpecList.cpp (added) +++ lldb/trunk/source/API/SBFileSpecList.cpp Tue Sep 20 20:17:13 2011 @@ -0,0 +1,139 @@ +//===-- SBFileSpecListList.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" +#include "lldb/API/SBStream.h" +#include "lldb/Core/FileSpecList.h" +#include "lldb/Core/Log.h" +#include "lldb/Host/FileSpec.h" + +using namespace lldb; +using namespace lldb_private; + + + +SBFileSpecList::SBFileSpecList () : + m_opaque_ap(new FileSpecList()) +{ +} + +SBFileSpecList::SBFileSpecList (const SBFileSpecList &rhs) : + m_opaque_ap() +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + if (rhs.m_opaque_ap.get()) + m_opaque_ap.reset (new FileSpecList (*(rhs.get()))); + + if (log) + { + log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p): %s", + rhs.m_opaque_ap.get(), m_opaque_ap.get()); + } +} + +SBFileSpecList::~SBFileSpecList () +{ +} + +const SBFileSpecList & +SBFileSpecList::operator = (const SBFileSpecList &rhs) +{ + if (this != &rhs) + { + m_opaque_ap.reset (new lldb_private::FileSpecList(*(rhs.get()))); + } + return *this; +} + +uint32_t +SBFileSpecList::GetSize () const +{ + return m_opaque_ap->GetSize(); +} + +void +SBFileSpecList::Append (const SBFileSpec &sb_file) +{ + m_opaque_ap->Append (sb_file.ref()); +} + +bool +SBFileSpecList::AppendIfUnique (const SBFileSpec &sb_file) +{ + return m_opaque_ap->AppendIfUnique (sb_file.ref()); +} + +void +SBFileSpecList::Clear() +{ + m_opaque_ap->Clear(); +} + +uint32_t +SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file) +{ + return m_opaque_ap->FindFileIndex (idx, sb_file.ref()); +} + +const SBFileSpec +SBFileSpecList::GetFileSpecAtIndex (uint32_t idx) const +{ + SBFileSpec new_spec; + new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx)); + return new_spec; +} + +const lldb_private::FileSpecList * +SBFileSpecList::operator->() const +{ + return m_opaque_ap.get(); +} + +const lldb_private::FileSpecList * +SBFileSpecList::get() const +{ + return m_opaque_ap.get(); +} + + +const lldb_private::FileSpecList & +SBFileSpecList::operator*() const +{ + return *m_opaque_ap.get(); +} + +const lldb_private::FileSpecList & +SBFileSpecList::ref() const +{ + return *m_opaque_ap.get(); +} + +bool +SBFileSpecList::GetDescription (SBStream &description) const +{ + if (m_opaque_ap.get()) + { + uint32_t num_files = m_opaque_ap->GetSize(); + description.Printf ("%d files: ", num_files); + for (uint32_t i = 0; i < num_files; i++) + { + char path[PATH_MAX]; + if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path))) + description.Printf ("\n %s", path); + } + } + else + description.Printf ("No value"); + + return true; +} Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 20 20:17:13 2011 @@ -580,8 +580,9 @@ Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); if (module_name && module_name[0]) { - FileSpec module_file_spec(module_name, false); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); + FileSpecList module_spec_list; + module_spec_list.Append (FileSpec (module_name, false)); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } else { @@ -611,9 +612,10 @@ if (module_name && module_name[0]) { - FileSpec module_file_spec(module_name, false); + FileSpecList module_spec_list; + module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, regexp, false); } else { @@ -652,6 +654,42 @@ return sb_bp; } +lldb::SBBreakpoint +SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBBreakpoint sb_bp; + if (m_opaque_sp.get() && source_regex && source_regex[0]) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + RegularExpression regexp(source_regex); + + if (module_name && module_name[0]) + { + FileSpecList module_spec_list; + module_spec_list.Append (FileSpec (module_name, false)); + + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, source_file.ref(), regexp, false); + } + else + { + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, source_file.ref(), regexp, false); + } + } + + if (log) + { + char path[PATH_MAX]; + source_file->GetPath (path, sizeof(path)); + log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), source_regex, path, sb_bp.get()); + } + + return sb_bp; +} + + SBBreakpoint SBTarget::FindBreakpointByID (break_id_t bp_id) { Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Tue Sep 20 20:17:13 2011 @@ -67,12 +67,22 @@ Address line_start = sc.line_entry.range.GetBaseAddress(); if (line_start.IsValid()) { - BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); - if (log && bp_loc_sp && !m_breakpoint->IsInternal()) + if (filter.AddressPasses(line_start)) { - StreamString s; - bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Added location: %s\n", s.GetData()); + BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); + if (log && bp_loc_sp && !m_breakpoint->IsInternal()) + { + StreamString s; + bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Added location: %s\n", s.GetData()); + } + } + else if (log) + { + log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass the filter.\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString(""), + m_line_number); } } else Added: lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=140225&view=auto ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp (added) +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp Tue Sep 20 20:17:13 2011 @@ -0,0 +1,139 @@ +//===-- BreakpointResolverFileRegex.cpp --------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Breakpoint/BreakpointResolverFileRegex.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Core/SourceManager.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Target/Target.h" +#include "lldb/lldb-private-log.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// BreakpointResolverFileRegex: +//---------------------------------------------------------------------- +BreakpointResolverFileRegex::BreakpointResolverFileRegex +( + Breakpoint *bkpt, + const FileSpec &file_spec, + RegularExpression ®ex +) : + BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), + m_file_spec (file_spec), + m_regex (regex) +{ +} + +BreakpointResolverFileRegex::~BreakpointResolverFileRegex () +{ +} + +Searcher::CallbackReturn +BreakpointResolverFileRegex::SearchCallback +( + SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing +) +{ + + assert (m_breakpoint != NULL); + if (!context.target_sp) + return eCallbackReturnContinue; + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); + + CompileUnit *cu = context.comp_unit; + FileSpec cu_file_spec = *(static_cast(cu)); + if (cu_file_spec == m_file_spec + || (!m_file_spec.GetDirectory() && cu_file_spec.GetFilename() == m_file_spec.GetFilename())) + { + std::vector line_matches; + context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); + uint32_t num_matches = line_matches.size(); + for (int i = 0; i < num_matches; i++) + { + uint32_t start_idx = 0; + while (1) + { + LineEntry line_entry; + + // Cycle through all the line entries that might match this one: + start_idx = cu->FindLineEntry (start_idx, line_matches[i], NULL, &line_entry); + if (start_idx == UINT32_MAX) + break; + start_idx++; + + Address line_start = line_entry.range.GetBaseAddress(); + if (line_start.IsValid()) + { + if (filter.AddressPasses(line_start)) + { + BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); + if (log && bp_loc_sp && !m_breakpoint->IsInternal()) + { + StreamString s; + bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Added location: %s\n", s.GetData()); + } + } + else if (log) + { + log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass filter.\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString(""), + line_matches[i]); + } + } + else + { + if (log) + log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n", + line_start.GetFileAddress(), + m_file_spec.GetFilename().AsCString(""), + line_matches[i]); + } + + } + } + assert (m_breakpoint != NULL); + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); + + + } + return Searcher::eCallbackReturnContinue; +} + +Searcher::Depth +BreakpointResolverFileRegex::GetDepth() +{ + return Searcher::eDepthCompUnit; +} + +void +BreakpointResolverFileRegex::GetDescription (Stream *s) +{ + s->Printf ("file ='%s', regular expression = \"%s\"", m_file_spec.GetFilename().AsCString(), m_regex.GetText()); +} + +void +BreakpointResolverFileRegex::Dump (Stream *s) const +{ + +} + Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Tue Sep 20 20:17:13 2011 @@ -104,7 +104,6 @@ m_match_type (Breakpoint::Regexp), m_skip_prologue (skip_prologue) { - } BreakpointResolverName::BreakpointResolverName Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Sep 20 20:17:13 2011 @@ -56,6 +56,7 @@ m_func_name (), m_func_name_type_mask (0), m_func_regexp (), + m_source_text_regexp(), m_modules (), m_load_addr(), m_ignore_count (0), @@ -91,7 +92,7 @@ { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, - { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, + { LLDB_OPT_SET_1 | LLDB_OPT_SET_9, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Set the breakpoint by source location in this particular file."}, { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, @@ -124,6 +125,10 @@ { LLDB_OPT_SET_8, true, "basename", 'b', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the breakpoint by function basename (C++ namespaces and arguments will be ignored)." }, + { LLDB_OPT_SET_9, true, "source-pattern-regexp", 'p', required_argument, NULL, 0, eArgTypeRegularExpression, + "Set the breakpoint specifying a regular expression to match a pattern in the source text in a given source file." }, + + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -187,6 +192,10 @@ m_func_name_type_mask |= eFunctionNameTypeMethod; break; + case 'p': + m_source_text_regexp.assign (option_arg); + break; + case 'r': m_func_regexp.assign (option_arg); break; @@ -275,6 +284,52 @@ } bool +CommandObjectBreakpointSet::ChooseFile (Target *target, FileSpec &file, CommandReturnObject &result) +{ + if (m_options.m_filename.empty()) + { + uint32_t default_line; + // First use the Source Manager's default file. + // Then use the current stack frame's file. + if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) + { + StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; + if (cur_frame == NULL) + { + result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else if (!cur_frame->HasDebugInformation()) + { + result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else + { + const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); + if (sc.line_entry.file) + { + file = sc.line_entry.file; + } + else + { + result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + } + } + else + { + file.SetFile(m_options.m_filename.c_str(), false); + } + return true; +} + +bool CommandObjectBreakpointSet::Execute ( Args& command, @@ -294,6 +349,7 @@ // 2). -a [-s -g] (setting breakpoint by address) // 3). -n [-s -g] (setting breakpoint by function name) // 4). -r [-s -g] (setting breakpoint by function name regular expression) + // 5). -p -f (setting a breakpoint by comparing a reg-exp to source text) BreakpointSetType break_type = eSetTypeInvalid; @@ -305,94 +361,42 @@ break_type = eSetTypeFunctionName; else if (!m_options.m_func_regexp.empty()) break_type = eSetTypeFunctionRegexp; + else if (!m_options.m_source_text_regexp.empty()) + break_type = eSetTypeSourceRegexp; Breakpoint *bp = NULL; FileSpec module_spec; bool use_module = false; int num_modules = m_options.m_modules.size(); + FileSpecList module_spec_list; + FileSpecList *module_spec_list_ptr = NULL; + if ((num_modules > 0) && (break_type != eSetTypeAddress)) use_module = true; + + if (use_module) + { + module_spec_list_ptr = &module_spec_list; + for (int i = 0; i < num_modules; ++i) + { + module_spec.SetFile(m_options.m_modules[i].c_str(), false); + module_spec_list.AppendIfUnique (module_spec); + } + } switch (break_type) { case eSetTypeFileAndLine: // Breakpoint by source position { FileSpec file; - if (m_options.m_filename.empty()) - { - uint32_t default_line; - // First use the Source Manager's default file. - // Then use the current stack frame's file. - if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) - { - StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; - if (cur_frame == NULL) - { - result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); - result.SetStatus (eReturnStatusFailed); - break; - } - else if (!cur_frame->HasDebugInformation()) - { - result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); - result.SetStatus (eReturnStatusFailed); - break; - } - else - { - const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); - if (sc.line_entry.file) - { - file = sc.line_entry.file; - } - else - { - result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); - result.SetStatus (eReturnStatusFailed); - break; - } - } - } - } - else - { - file.SetFile(m_options.m_filename.c_str(), false); - } - - if (use_module) - { - for (int i = 0; i < num_modules; ++i) - { - module_spec.SetFile(m_options.m_modules[i].c_str(), false); - bp = target->CreateBreakpoint (&module_spec, - file, - m_options.m_line_num, - m_options.m_check_inlines).get(); - if (bp) - { - Stream &output_stream = result.GetOutputStream(); - result.AppendMessage ("Breakpoint created: "); - bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); - output_stream.EOL(); - if (bp->GetNumLocations() == 0) - output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" - " locations.\n"); - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else - { - result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", - m_options.m_modules[i].c_str()); - result.SetStatus (eReturnStatusFailed); - } - } - } - else - bp = target->CreateBreakpoint (NULL, - file, - m_options.m_line_num, - m_options.m_check_inlines).get(); + if (!ChooseFile (target, file, result)) + break; + + bp = target->CreateBreakpoint (module_spec_list_ptr, + file, + m_options.m_line_num, + m_options.m_check_inlines).get(); } break; @@ -407,72 +411,47 @@ if (name_type_mask == 0) name_type_mask = eFunctionNameTypeAuto; - if (use_module) - { - for (int i = 0; i < num_modules; ++i) - { - module_spec.SetFile(m_options.m_modules[i].c_str(), false); - bp = target->CreateBreakpoint (&module_spec, - m_options.m_func_name.c_str(), - name_type_mask, - Breakpoint::Exact).get(); - if (bp) - { - Stream &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); - bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); - output_stream.EOL(); - if (bp->GetNumLocations() == 0) - output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" - " locations.\n"); - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else - { - result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", - m_options.m_modules[i].c_str()); - result.SetStatus (eReturnStatusFailed); - } - } - } - else - bp = target->CreateBreakpoint (NULL, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get(); + bp = target->CreateBreakpoint (module_spec_list_ptr, + m_options.m_func_name.c_str(), + name_type_mask, + Breakpoint::Exact).get(); } break; case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name { RegularExpression regexp(m_options.m_func_regexp.c_str()); - if (use_module) + if (!regexp.IsValid()) { - for (int i = 0; i < num_modules; ++i) - { - module_spec.SetFile(m_options.m_modules[i].c_str(), false); - bp = target->CreateBreakpoint (&module_spec, regexp).get(); - if (bp) - { - Stream &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); - bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); - output_stream.EOL(); - if (bp->GetNumLocations() == 0) - output_stream.Printf ("WARNING: Unable to resolve breakpoint to any actual" - " locations.\n"); - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else - { - result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", - m_options.m_modules[i].c_str()); - result.SetStatus (eReturnStatusFailed); - } - } + char err_str[1024]; + regexp.GetErrorAsCString(err_str, sizeof(err_str)); + result.AppendErrorWithFormat("Function name regular expression could not be compiled: \"%s\"", + err_str); + result.SetStatus (eReturnStatusFailed); + return false; } - else - bp = target->CreateBreakpoint (NULL, regexp).get(); + bp = target->CreateBreakpoint (module_spec_list_ptr, regexp).get(); } break; + case eSetTypeSourceRegexp: // Breakpoint by regexp on source text. + { + FileSpec file; + if (!ChooseFile (target, file, result)) + break; + RegularExpression regexp(m_options.m_source_text_regexp.c_str()); + if (!regexp.IsValid()) + { + char err_str[1024]; + regexp.GetErrorAsCString(err_str, sizeof(err_str)); + result.AppendErrorWithFormat("Source text regular expression could not be compiled: \"%s\"", + err_str); + result.SetStatus (eReturnStatusFailed); + return false; + } + bp = target->CreateBreakpoint (module_spec_list_ptr, file, regexp).get(); + } + break; default: break; } @@ -496,7 +475,7 @@ bp->GetOptions()->SetIgnoreCount(m_options.m_ignore_count); } - if (bp && !use_module) + if (bp) { Stream &output_stream = result.GetOutputStream(); output_stream.Printf ("Breakpoint created: "); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Tue Sep 20 20:17:13 2011 @@ -57,7 +57,8 @@ eSetTypeFileAndLine, eSetTypeAddress, eSetTypeFunctionName, - eSetTypeFunctionRegexp + eSetTypeFunctionRegexp, + eSetTypeSourceRegexp } BreakpointSetType; CommandObjectBreakpointSet (CommandInterpreter &interpreter); @@ -103,6 +104,7 @@ std::string m_func_name; uint32_t m_func_name_type_mask; std::string m_func_regexp; + std::string m_source_text_regexp; STLStringArray m_modules; lldb::addr_t m_load_addr; uint32_t m_ignore_count; @@ -114,6 +116,9 @@ }; private: + bool + ChooseFile (Target *target, FileSpec &file, CommandReturnObject &result); + CommandOptions m_options; }; Modified: lldb/trunk/source/Core/RegularExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegularExpression.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Core/RegularExpression.cpp (original) +++ lldb/trunk/source/Core/RegularExpression.cpp Tue Sep 20 20:17:13 2011 @@ -19,6 +19,7 @@ m_re(), m_comp_err (1), m_preg(), + m_compile_flags(REG_EXTENDED), m_matches() { memset(&m_preg,0,sizeof(m_preg)); @@ -31,13 +32,43 @@ RegularExpression::RegularExpression(const char* re, int flags) : m_re(), m_comp_err (1), + m_compile_flags(flags), m_preg() { memset(&m_preg,0,sizeof(m_preg)); - Compile(re, flags); + Compile(re); } //---------------------------------------------------------------------- +// Constructor that compiles "re" using "flags" and stores the +// resulting compiled regular expression into this object. +//---------------------------------------------------------------------- +RegularExpression::RegularExpression(const char* re) : + m_re(), + m_comp_err (1), + m_compile_flags(REG_EXTENDED), + m_preg() +{ + memset(&m_preg,0,sizeof(m_preg)); + Compile(re); +} + +RegularExpression::RegularExpression(const RegularExpression &rhs) +{ + memset(&m_preg,0,sizeof(m_preg)); + Compile(rhs.GetText(), rhs.GetCompileFlags()); +} + +const RegularExpression & +RegularExpression::operator= (const RegularExpression &rhs) +{ + if (&rhs != this) + { + Compile (rhs.GetText(), rhs.GetCompileFlags()); + } + return *this; +} +//---------------------------------------------------------------------- // Destructor // // Any previosuly compiled regular expression contained in this @@ -61,9 +92,17 @@ // otherwise. //---------------------------------------------------------------------- bool +RegularExpression::Compile(const char* re) +{ + return Compile (re, m_compile_flags); +} + +bool RegularExpression::Compile(const char* re, int flags) { Free(); + m_compile_flags = flags; + if (re && re[0]) { m_re = re; Modified: lldb/trunk/source/Core/SearchFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Core/SearchFilter.cpp (original) +++ lldb/trunk/source/Core/SearchFilter.cpp Tue Sep 20 20:17:13 2011 @@ -432,3 +432,178 @@ { } +//---------------------------------------------------------------------- +// SearchFilterByModuleList: +// Selects a shared library matching a given file spec +//---------------------------------------------------------------------- + +//---------------------------------------------------------------------- +// SearchFilterByModuleList constructors +//---------------------------------------------------------------------- + +SearchFilterByModuleList::SearchFilterByModuleList (lldb::TargetSP &target_sp, const FileSpecList &module_list) : + SearchFilter (target_sp), + m_module_spec_list (module_list) +{ +} + + +//---------------------------------------------------------------------- +// SearchFilterByModuleList copy constructor +//---------------------------------------------------------------------- +SearchFilterByModuleList::SearchFilterByModuleList(const SearchFilterByModuleList& rhs) : + SearchFilter (rhs), + m_module_spec_list (rhs.m_module_spec_list) +{ +} + +//---------------------------------------------------------------------- +// SearchFilterByModuleList assignment operator +//---------------------------------------------------------------------- +const SearchFilterByModuleList& +SearchFilterByModuleList::operator=(const SearchFilterByModuleList& rhs) +{ + m_target_sp = rhs.m_target_sp; + m_module_spec_list = rhs.m_module_spec_list; + return *this; +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +SearchFilterByModuleList::~SearchFilterByModuleList() +{ +} + +bool +SearchFilterByModuleList::ModulePasses (const ModuleSP &module_sp) +{ + if (module_sp && m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec()) != UINT32_MAX) + return true; + else + return false; +} + +bool +SearchFilterByModuleList::ModulePasses (const FileSpec &spec) +{ + if (m_module_spec_list.FindFileIndex(0, spec) != UINT32_MAX) + return true; + else + return false; +} + +bool +SearchFilterByModuleList::SymbolContextPasses +( + const SymbolContext &context, + lldb::SymbolContextItem scope + ) +{ + if (!(scope & eSymbolContextModule)) + return false; + + if (context.module_sp && m_module_spec_list.FindFileIndex(0, context.module_sp->GetFileSpec()) != UINT32_MAX) + return true; + else + return false; +} + +bool +SearchFilterByModuleList::AddressPasses (Address &address) +{ + // FIXME: Not yet implemented + return true; +} + + +bool +SearchFilterByModuleList::CompUnitPasses (FileSpec &fileSpec) +{ + return true; +} + +bool +SearchFilterByModuleList::CompUnitPasses (CompileUnit &compUnit) +{ + return true; +} + +void +SearchFilterByModuleList::Search (Searcher &searcher) +{ + if (!m_target_sp) + return; + + if (searcher.GetDepth() == Searcher::eDepthTarget) + { + SymbolContext empty_sc; + empty_sc.target_sp = m_target_sp; + searcher.SearchCallback (*this, empty_sc, NULL, false); + } + + // If the module file spec is a full path, then we can just find the one + // filespec that passes. Otherwise, we need to go through all modules and + // find the ones that match the file name. + + ModuleList matching_modules; + const size_t num_modules = m_target_sp->GetImages().GetSize (); + for (size_t i = 0; i < num_modules; i++) + { + Module* module = m_target_sp->GetImages().GetModulePointerAtIndex(i); + if (m_module_spec_list.FindFileIndex(0, module->GetFileSpec()) != UINT32_MAX) + { + SymbolContext matchingContext(m_target_sp, ModuleSP(module)); + Searcher::CallbackReturn shouldContinue; + + shouldContinue = DoModuleIteration(matchingContext, searcher); + if (shouldContinue == Searcher::eCallbackReturnStop) + return; + } + } +} + +void +SearchFilterByModuleList::GetDescription (Stream *s) +{ + uint32_t num_modules = m_module_spec_list.GetSize(); + if (num_modules == 1) + { + s->Printf (", module = ", num_modules); + if (s->GetVerbose()) + { + char buffer[2048]; + m_module_spec_list.GetFileSpecAtIndex(0).GetPath(buffer, 2047); + s->PutCString(buffer); + } + else + { + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); + } + } + else + { + s->Printf (", modules(%d) = ", num_modules); + for (uint32_t i = 0; i < num_modules; i++) + { + if (s->GetVerbose()) + { + char buffer[2048]; + m_module_spec_list.GetFileSpecAtIndex(i).GetPath(buffer, 2047); + s->PutCString(buffer); + } + else + { + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); + } + if (i != num_modules - 1) + s->PutCString (", "); + } + } +} + +void +SearchFilterByModuleList::Dump (Stream *s) const +{ + +} Modified: lldb/trunk/source/Core/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Core/SourceManager.cpp (original) +++ lldb/trunk/source/Core/SourceManager.cpp Tue Sep 20 20:17:13 2011 @@ -231,6 +231,19 @@ return false; } +void +SourceManager::FindLinesMatchingRegex (FileSpec &file_spec, + RegularExpression& regex, + uint32_t start_line, + uint32_t end_line, + std::vector &match_lines) +{ + match_lines.clear(); + FileSP file_sp = GetFile (file_spec); + if (!file_sp) + return; + return file_sp->FindLinesMatchingRegex (regex, start_line, end_line, match_lines); +} SourceManager::File::File(const FileSpec &file_spec, Target *target) : m_file_spec_orig (file_spec), @@ -368,6 +381,36 @@ return 0; } +void +SourceManager::File::FindLinesMatchingRegex (RegularExpression& regex, uint32_t start_line, uint32_t end_line, std::vector &match_lines) +{ + TimeValue curr_mod_time (m_file_spec.GetModificationTime()); + if (m_mod_time != curr_mod_time) + { + m_mod_time = curr_mod_time; + m_data_sp = m_file_spec.ReadFileContents (); + m_offsets.clear(); + } + + match_lines.clear(); + + if (!LineIsValid(start_line) || (end_line != UINT32_MAX && !LineIsValid(end_line))) + return; + if (start_line > end_line) + return; + + for (uint32_t line_no = start_line; line_no < end_line; line_no++) + { + std::string buffer; + if (!GetLine (line_no, buffer)) + break; + if (regex.Execute(buffer.c_str())) + { + match_lines.push_back(line_no); + } + } +} + bool SourceManager::File::FileSpecMatches (const FileSpec &file_spec) { @@ -457,6 +500,23 @@ return false; } +bool +SourceManager::File::GetLine (uint32_t line_no, std::string &buffer) +{ + if (!LineIsValid(line_no)) + return false; + + uint32_t start_offset = GetLineOffset (line_no); + uint32_t end_offset = GetLineOffset (line_no + 1); + if (end_offset == UINT32_MAX) + { + end_offset = m_data_sp->GetByteSize(); + } + buffer.assign((char *) m_data_sp->GetBytes() + start_offset, end_offset - start_offset); + + return true; +} + void SourceManager::SourceFileCache::AddSourceFile (const FileSP &file_sp) { Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Tue Sep 20 20:17:13 2011 @@ -985,7 +985,9 @@ const bool internal_bp = false; const LazyBool skip_prologue = eLazyBoolNo; - Breakpoint *bp = m_process->GetTarget().CreateBreakpoint (&m_kernel.module_sp->GetFileSpec(), + FileSpecList module_spec_list; + module_spec_list.Append (m_kernel.module_sp->GetFileSpec()); + Breakpoint *bp = m_process->GetTarget().CreateBreakpoint (&module_spec_list, "OSKextLoadedKextSummariesUpdated", eFunctionNameTypeFull, internal_bp, Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Tue Sep 20 20:17:13 2011 @@ -124,7 +124,7 @@ // If we don't have any source file symbols we will just have one compile unit for // the entire object file if (m_source_indexes.empty()) - return 1; + return 0; // If we have any source file symbols we will logically orgnize the object symbols // using these. @@ -138,14 +138,14 @@ // If we don't have any source file symbols we will just have one compile unit for // the entire object file - if (m_source_indexes.empty()) - { - const FileSpec &obj_file_spec = m_obj_file->GetFileSpec(); - if (obj_file_spec) - cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, obj_file_spec, 0, eLanguageTypeUnknown)); - - } - else if (idx < m_source_indexes.size()) +// if (m_source_indexes.empty()) +// { +// const FileSpec &obj_file_spec = m_obj_file->GetFileSpec(); +// if (obj_file_spec) +// cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, obj_file_spec, 0, eLanguageTypeUnknown)); +// +// } + /* else */ if (idx < m_source_indexes.size()) { const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]); if (cu_symbol) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 20 20:17:13 2011 @@ -16,6 +16,7 @@ #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Breakpoint/BreakpointResolverAddress.h" #include "lldb/Breakpoint/BreakpointResolverFileLine.h" +#include "lldb/Breakpoint/BreakpointResolverFileRegex.h" #include "lldb/Breakpoint/BreakpointResolverName.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" @@ -206,9 +207,21 @@ } BreakpointSP -Target::CreateBreakpoint (const FileSpec *containingModule, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal) +Target::CreateBreakpoint (const FileSpecList *containingModules, + const FileSpec &file, + RegularExpression &source_regex, + bool internal) { - SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); + SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); + BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, file, source_regex)); + return CreateBreakpoint (filter_sp, resolver_sp, internal); +} + + +BreakpointSP +Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal) +{ + SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines)); return CreateBreakpoint (filter_sp, resolver_sp, internal); } @@ -242,7 +255,7 @@ } BreakpointSP -Target::CreateBreakpoint (const FileSpec *containingModule, +Target::CreateBreakpoint (const FileSpecList *containingModules, const char *func_name, uint32_t func_name_type_mask, bool internal, @@ -251,7 +264,7 @@ BreakpointSP bp_sp; if (func_name) { - SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); + SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_name, @@ -284,13 +297,33 @@ return filter_sp; } +SearchFilterSP +Target::GetSearchFilterForModuleList (const FileSpecList *containingModules) +{ + SearchFilterSP filter_sp; + lldb::TargetSP target_sp = this->GetSP(); + if (containingModules && containingModules->GetSize() != 0) + { + // TODO: We should look into sharing module based search filters + // across many breakpoints like we do for the simple target based one + filter_sp.reset (new SearchFilterByModuleList (target_sp, *containingModules)); + } + else + { + if (m_search_filter_sp.get() == NULL) + m_search_filter_sp.reset (new SearchFilter (target_sp)); + filter_sp = m_search_filter_sp; + } + return filter_sp; +} + BreakpointSP -Target::CreateBreakpoint (const FileSpec *containingModule, +Target::CreateBreakpoint (const FileSpecList *containingModules, RegularExpression &func_regex, bool internal, LazyBool skip_prologue) { - SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule)); + SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, func_regex, skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); Modified: lldb/trunk/test/lang/objc/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-stepping/TestObjCStepping.py?rev=140225&r1=140224&r2=140225&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/test/lang/objc/objc-stepping/TestObjCStepping.py Tue Sep 20 20:17:13 2011 @@ -3,6 +3,7 @@ import os, time import unittest2 import lldb +import lldbutil from lldbtest import * class TestObjCStepping(TestBase): @@ -25,17 +26,11 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line numbers to break inside main(). + # Find the line numbers that we will step to in main: self.main_source = "stepping-tests.m" - self.line1 = line_number(self.main_source, '// Set first breakpoint here.') - self.line2 = line_number(self.main_source, '// Set second breakpoint here.') - self.line3 = line_number(self.main_source, '// Set third breakpoint here.') - self.line4 = line_number(self.main_source, '// Set fourth breakpoint here.') - self.line5 = line_number(self.main_source, '// Set fifth breakpoint here.') self.source_randomMethod_line = line_number (self.main_source, '// Source randomMethod start line.') self.sourceBase_randomMethod_line = line_number (self.main_source, '// SourceBase randomMethod start line.') self.source_returnsStruct_start_line = line_number (self.main_source, '// Source returnsStruct start line.') - self.source_returnsStruct_call_line = line_number (self.main_source, '// Source returnsStruct call line.') self.sourceBase_returnsStruct_start_line = line_number (self.main_source, '// SourceBase returnsStruct start line.') def objc_stepping(self): @@ -45,22 +40,23 @@ target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - break1 = target.BreakpointCreateByLocation(self.main_source, self.line1) + self.main_source_spec = lldb.SBFileSpec (self.main_source) + break1 = target.BreakpointCreateBySourceRegex ("// Set first breakpoint here.", self.main_source_spec) self.assertTrue(break1, VALID_BREAKPOINT) - break2 = target.BreakpointCreateByLocation(self.main_source, self.line2) + break2 = target.BreakpointCreateBySourceRegex ("// Set second breakpoint here.", self.main_source_spec) self.assertTrue(break2, VALID_BREAKPOINT) - break3 = target.BreakpointCreateByLocation(self.main_source, self.line3) + break3 = target.BreakpointCreateBySourceRegex ('// Set third breakpoint here.', self.main_source_spec) self.assertTrue(break3, VALID_BREAKPOINT) - break4 = target.BreakpointCreateByLocation(self.main_source, self.line4) + break4 = target.BreakpointCreateBySourceRegex ('// Set fourth breakpoint here.', self.main_source_spec) self.assertTrue(break4, VALID_BREAKPOINT) - break5 = target.BreakpointCreateByLocation(self.main_source, self.line5) + break5 = target.BreakpointCreateBySourceRegex ('// Set fifth breakpoint here.', self.main_source_spec) self.assertTrue(break5, VALID_BREAKPOINT) - break_returnStruct_call_super = target.BreakpointCreateByLocation(self.main_source, self.source_returnsStruct_call_line) + break_returnStruct_call_super = target.BreakpointCreateBySourceRegex ('// Source returnsStruct call line.', self.main_source_spec) self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. @@ -69,16 +65,11 @@ self.assertTrue(process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - thread = process.GetThreadAtIndex(0) - if thread.GetStopReason() != lldb.eStopReasonBreakpoint: - from lldbutil import stop_reason_to_str - self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % - stop_reason_to_str(thread.GetStopReason())) + threads = lldbutil.get_threads_stopped_at_breakpoint (process, break1) + if len(threads) != 1: + self.fail ("Failed to stop at breakpoint 1.") - # Make sure we stopped at the first breakpoint. - - line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.line1, "Hit the first breakpoint.") + thread = threads[0] mySource = thread.GetFrameAtIndex(0).FindVariable("mySource") self.assertTrue(mySource, "Found mySource local variable.") @@ -100,18 +91,18 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod.") - process.Continue() - line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.line2, "Continued to second breakpoint in main.") + threads = lldbutil.continue_to_breakpoint (process, break2) + self.assertTrue (len(threads) == 1, "Continued to second breakpoint in main.") # Again, step in twice gets us to a stret method and a stret super call: + thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct.") - process.Continue() - line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct.") + threads = lldbutil.continue_to_breakpoint (process, break_returnStruct_call_super) + self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct.") + thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() @@ -120,10 +111,8 @@ # Cool now continue to get past the call that intializes the Observer, and then do our steps in again to see that # we can find our way when we're stepping through a KVO swizzled object. - process.Continue() - frame = thread.GetFrameAtIndex(0) - line_number = frame.GetLineEntry().GetLine() - self.assertTrue (line_number == self.line3, "Continued to third breakpoint in main, our object should now be swizzled.") + threads = lldbutil.continue_to_breakpoint (process, break3) + self.assertTrue (len(threads) == 1, "Continued to third breakpoint in main, our object should now be swizzled.") mySource_isa.GetValue () did_change = mySource_isa.GetValueDidChange () @@ -131,6 +120,7 @@ self.assertTrue (did_change, "The isa did indeed change, swizzled!") # Now step in, that should leave us in the Source randomMethod: + thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_randomMethod_line, "Stepped into Source randomMethod in swizzled object.") @@ -140,18 +130,18 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.sourceBase_randomMethod_line, "Stepped through super into SourceBase randomMethod in swizzled object.") - process.Continue() - line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.line4, "Continued to fourth breakpoint in main.") + threads = lldbutil.continue_to_breakpoint (process, break4) + self.assertTrue (len(threads) == 1, "Continued to fourth breakpoint in main.") + thread = threads[0] # Again, step in twice gets us to a stret method and a stret super call: thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.source_returnsStruct_start_line, "Stepped into Source returnsStruct in swizzled object.") - process.Continue() - line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() - self.assertTrue (line_number == self.source_returnsStruct_call_line, "Stepped to the call super line in Source returnsStruct - second time.") + threads = lldbutil.continue_to_breakpoint(process, break_returnStruct_call_super) + self.assertTrue (len(threads) == 1, "Stepped to the call super line in Source returnsStruct - second time.") + thread = threads[0] thread.StepInto() line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() From gclayton at apple.com Tue Sep 20 22:57:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Sep 2011 03:57:31 -0000 Subject: [Lldb-commits] [lldb] r140236 - in /lldb/trunk: lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme source/Core/ArchSpec.cpp source/Core/Module.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20110921035731.CECE62A6C12C@llvm.org> Author: gclayton Date: Tue Sep 20 22:57:31 2011 New Revision: 140236 URL: http://llvm.org/viewvc/llvm-project?rev=140236&view=rev Log: The first part of a fix for being able to select an architecture slice from a file when the target has a triple with an unknown vendor and/or OS and the slice of the file itself has a valid vendor and/or OS. The Module now adopts the ObjectFile's architecture after a valid architecture has been loaded to make sure the module matches the object file. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=140236&r1=140235&r2=140236&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Tue Sep 20 22:57:31 2011 @@ -99,12 +99,6 @@ ReferencedContainer = "container:lldb.xcodeproj"> - - - - core; update_triple = false; - m_triple.setArch (core_def->machine); + // Always use the architecture name because it might be more descriptive + // than the architecture enum ("armv7" -> llvm::Triple::arm). + m_triple.setArchName(llvm::StringRef(core_def->name)); if (arch_type == eArchTypeMachO) { m_triple.setVendor (llvm::Triple::Apple); @@ -549,6 +551,9 @@ m_triple.setVendor (llvm::Triple::UnknownVendor); m_triple.setOS (llvm::Triple::UnknownOS); } + // Fall back onto setting the machine type if the arch by name failed... + if (m_triple.getArch () == llvm::Triple::UnknownArch) + m_triple.setArch (core_def->machine); } } } @@ -665,13 +670,38 @@ { const llvm::Triple &lhs_triple = lhs.GetTriple(); const llvm::Triple &rhs_triple = rhs.GetTriple(); - if (lhs_triple.getVendor() != rhs_triple.getVendor() - || lhs_triple.getOS() != rhs_triple.getOS() - || lhs_triple.getArch() != rhs_triple.getArch() - || lhs_triple.getEnvironment() != rhs_triple.getEnvironment()) - return false; - else - return true; + + const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor(); + const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor(); + if (lhs_triple_vendor != rhs_triple_vendor) + { + // Only fail if both vendor types are not unknown + if (lhs_triple_vendor != llvm::Triple::UnknownVendor && + rhs_triple_vendor != llvm::Triple::UnknownVendor) + return false; + } + + const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS(); + const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS(); + if (lhs_triple_os != rhs_triple_os) + { + // Only fail if both os types are not unknown + if (lhs_triple_os != llvm::Triple::UnknownOS && + rhs_triple_os != llvm::Triple::UnknownOS) + return false; + } + + const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment(); + const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment(); + + if (lhs_triple_env != rhs_triple_env) + { + // Only fail if both environment types are not unknown + if (lhs_triple_env != llvm::Triple::UnknownEnvironment && + rhs_triple_env != llvm::Triple::UnknownEnvironment) + return false; + } + return true; } } Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=140236&r1=140235&r2=140236&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Sep 20 22:57:31 2011 @@ -637,6 +637,13 @@ Timer scoped_timer(__PRETTY_FUNCTION__, "Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString("")); m_objfile_sp = ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize()); + if (m_objfile_sp) + { + // Once we get the object file, update our module with the object file's + // architecture since it might differ in vendor/os if some parts were + // unknown. + m_objfile_sp->GetArchitecture (m_arch); + } } return m_objfile_sp.get(); } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=140236&r1=140235&r2=140236&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Sep 20 22:57:31 2011 @@ -1792,6 +1792,15 @@ { lldb_private::Mutex::Locker locker(m_mutex); arch.SetArchitecture (eArchTypeMachO, m_header.cputype, m_header.cpusubtype); + + // Files with type MH_PRELOAD are currently used in cases where the image + // debugs at the addresses in the file itself. Below we set the OS to + // unknown to make sure we use the DynamicLoaderStatic()... + if (m_header.filetype == HeaderFileTypePreloadedExecutable) + { + arch.GetTriple().setOS (llvm::Triple::UnknownOS); + } + return true; } From gclayton at apple.com Wed Sep 21 01:45:51 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Sep 2011 06:45:51 -0000 Subject: [Lldb-commits] [lldb] r140239 - in /lldb/trunk/source/API: SBFileSpecList.cpp SBTarget.cpp Message-ID: <20110921064551.E9E152A6C12C@llvm.org> Author: gclayton Date: Wed Sep 21 01:45:51 2011 New Revision: 140239 URL: http://llvm.org/viewvc/llvm-project?rev=140239&view=rev Log: Fixed two printf format errors. Modified: lldb/trunk/source/API/SBFileSpecList.cpp lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/source/API/SBFileSpecList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpecList.cpp?rev=140239&r1=140238&r2=140239&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpecList.cpp (original) +++ lldb/trunk/source/API/SBFileSpecList.cpp Wed Sep 21 01:45:51 2011 @@ -36,7 +36,7 @@ if (log) { - log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p): %s", + log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p)", rhs.m_opaque_ap.get(), m_opaque_ap.get()); } } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140239&r1=140238&r2=140239&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Sep 21 01:45:51 2011 @@ -683,7 +683,7 @@ char path[PATH_MAX]; source_file->GetPath (path, sizeof(path)); log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", - m_opaque_sp.get(), source_regex, path, sb_bp.get()); + m_opaque_sp.get(), source_regex, path, module_name, sb_bp.get()); } return sb_bp; From johnny.chen at apple.com Wed Sep 21 17:47:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 21 Sep 2011 22:47:15 -0000 Subject: [Lldb-commits] [lldb] r140279 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h include/lldb/Target/StopInfo.h source/Breakpoint/WatchpointLocation.cpp source/Target/StopInfo.cpp source/Target/ThreadPlanBase.cpp Message-ID: <20110921224715.630AE2A6C12C@llvm.org> Author: johnny Date: Wed Sep 21 17:47:15 2011 New Revision: 140279 URL: http://llvm.org/viewvc/llvm-project?rev=140279&view=rev Log: StopInfoWatchpoint should override the StopInfo::ShouldStop() virtual method and delegate to the WatchpointLocation object to check whether it should stop and allow it to update the hit count, among other bookkeepings. Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h lldb/trunk/include/lldb/Target/StopInfo.h lldb/trunk/source/Breakpoint/WatchpointLocation.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/ThreadPlanBase.cpp Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=140279&r1=140278&r2=140279&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Wed Sep 21 17:47:15 2011 @@ -40,12 +40,14 @@ void SetEnabled (bool enabled); + virtual bool + ShouldStop (StoppointCallbackContext *context); + bool WatchpointRead () const; bool WatchpointWrite () const; uint32_t GetIgnoreCount () const; void SetIgnoreCount (uint32_t n); void SetWatchpointType (uint32_t type); - bool BreakpointWasHit (StoppointCallbackContext *context); bool SetCallback (WatchpointHitCallback callback, void *callback_baton); void SetDeclInfo (std::string &str); void GetDescription (Stream *s, lldb::DescriptionLevel level); Modified: lldb/trunk/include/lldb/Target/StopInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=140279&r1=140278&r2=140279&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StopInfo.h (original) +++ lldb/trunk/include/lldb/Target/StopInfo.h Wed Sep 21 17:47:15 2011 @@ -53,7 +53,7 @@ // ---------------------------------------------- // eStopReasonBreakpoint BreakpointSiteID // eStopReasonSignal Signal number - // eStopReasonWatchpoint WatchpointSiteID + // eStopReasonWatchpoint WatchpointLocationID // eStopReasonPlanComplete No significance uint64_t Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140279&r1=140278&r2=140279&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Wed Sep 21 17:47:15 2011 @@ -62,7 +62,7 @@ // should continue. bool -WatchpointLocation::BreakpointWasHit (StoppointCallbackContext *context) +WatchpointLocation::ShouldStop (StoppointCallbackContext *context) { m_hit_count++; @@ -73,7 +73,11 @@ access |= LLDB_WATCH_TYPE_READ; if (m_watch_was_written) access |= LLDB_WATCH_TYPE_WRITE; - return m_callback(m_callback_baton, context, GetID(), access); + + if (m_callback) + return m_callback(m_callback_baton, context, GetID(), access); + else + return true; } return false; } Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=140279&r1=140278&r2=140279&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Wed Sep 21 17:47:15 2011 @@ -324,8 +324,10 @@ public: StopInfoWatchpoint (Thread &thread, break_id_t watch_id) : - StopInfo (thread, watch_id), - m_description() + StopInfo(thread, watch_id), + m_description(), + m_should_stop(false), + m_should_stop_is_valid(false) { } @@ -339,6 +341,40 @@ return eStopReasonWatchpoint; } + virtual bool + ShouldStop (Event *event_ptr) + { + // ShouldStop() method is idempotent and should not affect hit count. + if (m_should_stop_is_valid) + return m_should_stop; + + WatchpointLocationSP wp_loc_sp = + m_thread.GetProcess().GetTarget().GetWatchpointLocationList().FindByID(GetValue()); + if (wp_loc_sp) + { + // Check if we should stop at a watchpoint. + StoppointCallbackContext context (event_ptr, + &m_thread.GetProcess(), + &m_thread, + m_thread.GetStackFrameAtIndex(0).get(), + true); + + m_should_stop = wp_loc_sp->ShouldStop (&context); + } + else + { + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + + if (log) + log->Printf ("Process::%s could not find watchpoint location id: %lld...", + __FUNCTION__, GetValue()); + + m_should_stop = true; + } + m_should_stop_is_valid = true; + return m_should_stop; + } + virtual const char * GetDescription () { @@ -351,10 +387,10 @@ return m_description.c_str(); } - - private: std::string m_description; + bool m_should_stop; + bool m_should_stop_is_valid; }; Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=140279&r1=140278&r2=140279&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanBase.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanBase.cpp Wed Sep 21 17:47:15 2011 @@ -99,6 +99,7 @@ return false; case eStopReasonBreakpoint: + case eStopReasonWatchpoint: if (stop_info_sp->ShouldStop(event_ptr)) { // If we are going to stop for a breakpoint, then unship the other plans From scallanan at apple.com Wed Sep 21 19:41:12 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 22 Sep 2011 00:41:12 -0000 Subject: [Lldb-commits] [lldb] r140285 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/API/SBValue.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRInterpreter.cpp test/expression_command/formatters/TestFormatters.py test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Message-ID: <20110922004112.2B3502A6C12C@llvm.org> Author: spyffe Date: Wed Sep 21 19:41:11 2011 New Revision: 140285 URL: http://llvm.org/viewvc/llvm-project?rev=140285&view=rev Log: Fixed a problem with the IR interpreter that caused it to generate result variables that were not bound to their underlying data. This allowed the SBValue class to use the interpreter (if possible). Also made sure that any result variables that point to stack allocations in the stack frame of the interpreted expressions do not get live data. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRInterpreter.cpp lldb/trunk/test/expression_command/formatters/TestFormatters.py lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Sep 21 19:41:11 2011 @@ -463,6 +463,10 @@ /// @param[in] type /// The type of the data. /// + /// @param[in] transient + /// True if the data should be treated as disappearing after the + /// expression completes. In that case, it gets no live data. + /// /// @return /// True on success; false otherwise. //------------------------------------------------------------------ @@ -470,7 +474,8 @@ CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj, lldb_private::Value &value, const ConstString &name, - lldb_private::TypeFromParser type); + lldb_private::TypeFromParser type, + bool transient); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Materialize the entire struct Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Wed Sep 21 19:41:11 2011 @@ -379,7 +379,7 @@ ValueObjectSP result_valobj_sp; m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression (expression, m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(), - eExecutionPolicyAlways, + eExecutionPolicyOnlyWhenNeeded, true, // unwind on error true, // keep in memory eNoDynamicValues, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 21 19:41:11 2011 @@ -320,7 +320,8 @@ ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj, lldb_private::Value &value, const ConstString &name, - lldb_private::TypeFromParser type) + lldb_private::TypeFromParser type, + bool transient) { assert (m_parser_vars.get()); @@ -330,7 +331,8 @@ return false; if (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && - !pvar_sp->m_live_sp) + !pvar_sp->m_live_sp && + !transient) { // The reference comes from the program. We need to set up a live SP for it. @@ -927,11 +929,20 @@ } else if (persistent_var_sp) { - lldb_private::Value ret; - ret.SetValueType(Value::eValueTypeHostAddress); - ret.SetContext(Value::eContextTypeInvalid, NULL); - ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes(); - return ret; + if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference || + persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) && + persistent_var_sp->m_live_sp) + { + return persistent_var_sp->m_live_sp->GetValue(); + } + else + { + lldb_private::Value ret; + ret.SetValueType(Value::eValueTypeHostAddress); + ret.SetContext(Value::eContextTypeInvalid, NULL); + ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes(); + return ret; + } } else { Modified: lldb/trunk/source/Expression/IRInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRInterpreter.cpp (original) +++ lldb/trunk/source/Expression/IRInterpreter.cpp Wed Sep 21 19:41:11 2011 @@ -717,6 +717,8 @@ lldb_private::Value base; + bool transient = false; + if (m_decl_map.ResultIsReference(result_name)) { PointerType *R_ptr_ty = dyn_cast(R_ty); @@ -737,6 +739,9 @@ if (!R_final.m_allocation) return false; + 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); } @@ -747,7 +752,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); + return m_decl_map.CompleteResultVariable (result, base, result_name, result_type, transient); } }; Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/formatters/TestFormatters.py?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/test/expression_command/formatters/TestFormatters.py (original) +++ lldb/trunk/test/expression_command/formatters/TestFormatters.py Wed Sep 21 19:41:11 2011 @@ -18,16 +18,12 @@ self.line = line_number('main.cpp', '// Stop here') - # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in - @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): """Test expr + formatters for good interoperability.""" self.buildDsym() self.do_my_test() - # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in - @unittest2.expectedFailure def test_with_dwarf_(self): """Test expr + formatters for good interoperability.""" self.buildDsym() Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=140285&r1=140284&r2=140285&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Wed Sep 21 19:41:11 2011 @@ -12,7 +12,6 @@ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc") # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in - @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test data formatter commands.""" @@ -20,7 +19,6 @@ self.data_formatter_commands() # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in - @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Test data formatter commands.""" self.buildDwarf() From jmolenda at apple.com Wed Sep 21 21:24:49 2011 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 22 Sep 2011 02:24:49 -0000 Subject: [Lldb-commits] [lldb] r140289 - /lldb/trunk/source/Core/SearchFilter.cpp Message-ID: <20110922022449.AB4AA2A6C12C@llvm.org> Author: jmolenda Date: Wed Sep 21 21:24:49 2011 New Revision: 140289 URL: http://llvm.org/viewvc/llvm-project?rev=140289&view=rev Log: Fix printf call in SearchFilterByModuleList::GetDescription. Modified: lldb/trunk/source/Core/SearchFilter.cpp Modified: lldb/trunk/source/Core/SearchFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=140289&r1=140288&r2=140289&view=diff ============================================================================== --- lldb/trunk/source/Core/SearchFilter.cpp (original) +++ lldb/trunk/source/Core/SearchFilter.cpp Wed Sep 21 21:24:49 2011 @@ -569,7 +569,7 @@ uint32_t num_modules = m_module_spec_list.GetSize(); if (num_modules == 1) { - s->Printf (", module = ", num_modules); + s->Printf (", module = "); if (s->GetVerbose()) { char buffer[2048]; From gclayton at apple.com Wed Sep 21 23:58:26 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 22 Sep 2011 04:58:26 -0000 Subject: [Lldb-commits] [lldb] r140298 - in /lldb/trunk: include/lldb/ include/lldb/Expression/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/Disassembler/llvm/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/UnwindAssembly/InstEmulation/ source/Symbol/ source/Target/ Message-ID: <20110922045827.DC9162A6C12C@llvm.org> Author: gclayton Date: Wed Sep 21 23:58:26 2011 New Revision: 140298 URL: http://llvm.org/viewvc/llvm-project?rev=140298&view=rev Log: Converted the lldb_private::Process over to use the intrusive shared pointers. Changed the ExecutionContext over to use shared pointers for the target, process, thread and frame since these objects can easily go away at any time and any object that was holding onto an ExecutionContext was running the risk of using a bad object. Now that the shared pointers for target, process, thread and frame are just a single pointer (they all use the instrusive shared pointers) the execution context is much safer and still the same size. Made the shared pointers in the the ExecutionContext class protected and made accessors for all of the various ways to get at the pointers, references, and shared pointers. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Target/ExecutionContext.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/Breakpoint/BreakpointOptions.cpp lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSource.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/Disassembler.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/SearchFilter.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectDynamicValue.cpp lldb/trunk/source/Core/ValueObjectMemory.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Target/ExecutionContext.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Sep 21 23:58:26 2011 @@ -701,8 +701,8 @@ Target * GetTarget() { - if (m_exe_ctx && m_exe_ctx->target) - return m_exe_ctx->target; + if (m_exe_ctx && m_exe_ctx->GetTargetPtr()) + return m_exe_ctx->GetTargetPtr(); else if (m_sym_ctx.target_sp) m_sym_ctx.target_sp.get(); return NULL; Modified: lldb/trunk/include/lldb/Target/ExecutionContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ExecutionContext.h?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ExecutionContext.h (original) +++ lldb/trunk/include/lldb/Target/ExecutionContext.h Wed Sep 21 23:58:26 2011 @@ -39,6 +39,10 @@ //------------------------------------------------------------------ ExecutionContext(); + ExecutionContext (const ExecutionContext &rhs); + + ExecutionContext & + operator =(const ExecutionContext &rhs); ExecutionContext (Target* t, bool fill_current_process_thread_frame = true); //------------------------------------------------------------------ @@ -64,6 +68,7 @@ ExecutionContext (ExecutionContextScope &exe_scope); + ~ExecutionContext(); //------------------------------------------------------------------ /// Clear the object's state. /// @@ -76,20 +81,95 @@ RegisterContext * GetRegisterContext () const; - ExecutionContextScope * GetBestExecutionContextScope () const; - + + Target * + GetTargetPtr () const; + Process * - GetProcess () const; + GetProcessPtr () const; + + Thread * + GetThreadPtr () const + { + return m_thread_sp.get(); + } + + StackFrame * + GetFramePtr () const + { + return m_frame_sp.get(); + } + + Target & + GetTargetRef () const; + + Process & + GetProcessRef () const; + + Thread & + GetThreadRef () const; + + StackFrame & + GetFrameRef () const; + + const lldb::TargetSP & + GetTargetSP () + { + return m_target_sp; + } + + const lldb::ProcessSP & + GetProcessSP () + { + return m_process_sp; + } + + const lldb::ThreadSP & + GetThreadSP () + { + return m_thread_sp; + } + + const lldb::StackFrameSP & + GetFrameSP () + { + return m_frame_sp; + } + + void + SetTargetSP (const lldb::TargetSP &target_sp); + + void + SetProcessSP (const lldb::ProcessSP &process_sp); + + void + SetThreadSP (const lldb::ThreadSP &thread_sp); + + void + SetFrameSP (const lldb::StackFrameSP &frame_sp); + + void + SetTargetPtr (Target* target); + + void + SetProcessPtr (Process *process); + + void + SetThreadPtr (Thread *thread); + + void + SetFramePtr (StackFrame *frame); +protected: //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ - Target *target; ///< The target that owns the process/thread/frame - Process *process; ///< The process that owns the thread/frame - Thread *thread; ///< The thread that owns the frame - StackFrame *frame; ///< The stack frame in thread. + lldb::TargetSP m_target_sp; ///< The target that owns the process/thread/frame + lldb::ProcessSP m_process_sp; ///< The process that owns the thread/frame + lldb::ThreadSP m_thread_sp; ///< The thread that owns the frame + lldb::StackFrameSP m_frame_sp; ///< The stack frame in thread. }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Sep 21 23:58:26 2011 @@ -994,6 +994,7 @@ /// @brief A plug-in interface definition class for debugging a process. //---------------------------------------------------------------------- class Process : + public ReferenceCountedBaseVirtual, public UserID, public Broadcaster, public ExecutionContextScope, 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=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Wed Sep 21 23:58:26 2011 @@ -54,7 +54,7 @@ typedef IntrusiveSharedPtr::Type ObjectFileSP; typedef SharedPtr::Type OptionValueSP; typedef SharedPtr::Type PlatformSP; - typedef SharedPtr::Type ProcessSP; + typedef IntrusiveSharedPtr::Type ProcessSP; typedef SharedPtr::Type RegisterContextSP; typedef SharedPtr::Type RegularExpressionSP; typedef SharedPtr::Type SectionSP; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 21 23:58:26 2011 @@ -410,7 +410,7 @@ 4CCA645613B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644813B40B82003BDF98 /* AppleObjCTrampolineHandler.cpp */; }; 4CCA645813B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */; }; 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; - 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; }; + 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CF52AF41428291E0051E832 /* SBFileSpecList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; 94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */; }; 9415F61813B2C0EF00A52B36 /* FormatManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9415F61713B2C0EF00A52B36 /* FormatManager.cpp */; }; Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Sep 21 23:58:26 2011 @@ -487,22 +487,24 @@ lldb::user_id_t break_loc_id ) { - BreakpointSP bp_sp(ctx->exe_ctx.target->GetBreakpointList().FindBreakpointByID(break_id)); + BreakpointSP bp_sp(ctx->exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); if (baton && bp_sp) { CallbackData *data = (CallbackData *)baton; lldb_private::Breakpoint *bp = bp_sp.get(); if (bp && data->callback) { - if (ctx->exe_ctx.process) + Process *process = ctx->exe_ctx.GetProcessPtr(); + if (process) { - SBProcess sb_process (ctx->exe_ctx.process->GetSP()); + SBProcess sb_process (process->GetSP()); SBThread sb_thread; SBBreakpointLocation sb_location; assert (bp_sp); sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); - if (ctx->exe_ctx.thread) - sb_thread.SetThread(ctx->exe_ctx.thread->GetSP()); + Thread *thread = ctx->exe_ctx.GetThreadPtr(); + if (thread) + sb_thread.SetThread(thread->GetSP()); return data->callback (data->callback_baton, sb_process, @@ -522,7 +524,7 @@ if (log) log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", m_opaque_sp.get(), callback, baton); - if (m_opaque_sp.get()) + if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Wed Sep 21 23:58:26 2011 @@ -131,7 +131,7 @@ { api_locker.Reset (target->GetAPIMutex().GetMutex()); target->CalculateExecutionContext (exe_ctx); - exe_ctx.process = target->GetProcessSP().get(); + exe_ctx.SetProcessSP(target->GetProcessSP()); } Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule(); if (module) Modified: lldb/trunk/source/API/SBInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstruction.cpp (original) +++ lldb/trunk/source/API/SBInstruction.cpp Wed Sep 21 23:58:26 2011 @@ -122,7 +122,7 @@ { lldb_private::ExecutionContext exe_ctx; frame->CalculateExecutionContext (exe_ctx); - lldb_private::Target *target = exe_ctx.target; + lldb_private::Target *target = exe_ctx.GetTargetPtr(); lldb_private::ArchSpec arch = target->GetArchitecture(); return m_opaque_sp->Emulate (arch, Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Wed Sep 21 23:58:26 2011 @@ -180,7 +180,8 @@ return NULL; // FIXME: I shouldn't have to do this, the process should handle it for me: - if (!exe_ctx.process->GetDynamicCheckers()) + Process *process = exe_ctx.GetProcessPtr(); + if (!process->GetDynamicCheckers()) { DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); @@ -192,11 +193,11 @@ return NULL; } - exe_ctx.process->SetDynamicCheckers(dynamic_checkers); + process->SetDynamicCheckers(dynamic_checkers); } // Get the boolean type from the process's scratch AST context - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + ClangASTContext *ast_context = exe_ctx.GetTargetRef().GetScratchClangASTContext(); TypeFromUser bool_type(ast_context->GetBuiltInType_bool(), ast_context->getASTContext()); const bool keep_in_memory = false; @@ -209,7 +210,7 @@ // FIXME: When we can execute static expressions without running the target, we should check that here, // and return something to indicate we should stop or just continue. - ThreadPlan *new_plan = new ThreadPlanTestCondition (*exe_ctx.thread, + ThreadPlan *new_plan = new ThreadPlanTestCondition (exe_ctx.GetThreadRef(), exe_ctx, m_condition_ap.get(), break_loc_sp, Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Wed Sep 21 23:58:26 2011 @@ -105,7 +105,7 @@ ConstString target_triple; - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (!process) { result.AppendError ("Args found no process."); @@ -131,7 +131,7 @@ return false; } - Thread *thread = m_interpreter.GetExecutionContext ().thread; + Thread *thread = m_interpreter.GetExecutionContext ().GetThreadPtr(); if (!thread) { Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 21 23:58:26 2011 @@ -293,7 +293,7 @@ // Then use the current stack frame's file. if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) { - StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; + StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr(); if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Wed Sep 21 23:58:26 2011 @@ -803,10 +803,11 @@ if (commands.GetSize() > 0) { - if (context->exe_ctx.target) + Target *target = context->exe_ctx.GetTargetPtr(); + if (target) { CommandReturnObject result; - Debugger &debugger = context->exe_ctx.target->GetDebugger(); + Debugger &debugger = target->GetDebugger(); // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously // if the debugger is set up that way. Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Wed Sep 21 23:58:26 2011 @@ -314,15 +314,16 @@ else { AddressRange range; + StackFrame *frame = exe_ctx.GetFramePtr(); if (m_options.frame_line) { - if (exe_ctx.frame == NULL) + if (frame == NULL) { result.AppendError ("Cannot disassemble around the current line without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); return false; } - LineEntry pc_line_entry (exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry).line_entry); + LineEntry pc_line_entry (frame->GetSymbolContext(eSymbolContextLineEntry).line_entry); if (pc_line_entry.IsValid()) { range = pc_line_entry.range; @@ -335,13 +336,13 @@ } else if (m_options.cur_function) { - if (exe_ctx.frame == NULL) + if (frame == NULL) { result.AppendError ("Cannot disassemble around the current function without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); return false; } - Symbol *symbol = exe_ctx.frame->GetSymbolContext(eSymbolContextSymbol).symbol; + Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol; if (symbol) range = symbol->GetAddressRangeRef(); } @@ -352,13 +353,13 @@ { if (m_options.at_pc) { - if (exe_ctx.frame == NULL) + if (frame == NULL) { result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n"); result.SetStatus (eReturnStatusFailed); return false; } - range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + range.GetBaseAddress() = frame->GetFrameCodeAddress(); if (m_options.num_instructions == 0) { // Disassembling at the PC always disassembles some number of instructions (not the whole function). @@ -389,15 +390,15 @@ if (!range.GetBaseAddress().IsValid()) { // The default action is to disassemble the current frame function. - if (exe_ctx.frame) + if (frame) { - SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); if (sc.function) range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress(); else if (sc.symbol && sc.symbol->GetAddressRangePtr()) range.GetBaseAddress() = sc.symbol->GetAddressRangePtr()->GetBaseAddress(); else - range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + range.GetBaseAddress() = frame->GetFrameCodeAddress(); } if (!range.GetBaseAddress().IsValid()) @@ -431,15 +432,15 @@ if (!range.GetBaseAddress().IsValid()) { // The default action is to disassemble the current frame function. - if (exe_ctx.frame) + if (frame) { - SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); if (sc.function) range = sc.function->GetAddressRange(); else if (sc.symbol && sc.symbol->GetAddressRangePtr()) range = *sc.symbol->GetAddressRangePtr(); else - range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + range.GetBaseAddress() = frame->GetFrameCodeAddress(); } else { Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Sep 21 23:58:26 2011 @@ -271,7 +271,8 @@ CommandReturnObject *result ) { - if (m_exe_ctx.target) + Target *target = m_exe_ctx.GetTargetPtr(); + if (target) { lldb::ValueObjectSP result_valobj_sp; @@ -283,7 +284,7 @@ switch (m_options.use_dynamic) { case eLazyBoolCalculate: - use_dynamic = m_exe_ctx.target->GetPreferDynamicValue(); + use_dynamic = target->GetPreferDynamicValue(); break; case eLazyBoolYes: use_dynamic = lldb::eDynamicCanRunTarget; @@ -293,34 +294,39 @@ break; } - exe_results = m_exe_ctx.target->EvaluateExpression(expr, - m_exe_ctx.frame, - eExecutionPolicyOnlyWhenNeeded, - m_options.unwind_on_error, - keep_in_memory, - use_dynamic, - result_valobj_sp); + exe_results = target->EvaluateExpression (expr, + m_exe_ctx.GetFramePtr(), + eExecutionPolicyOnlyWhenNeeded, + m_options.unwind_on_error, + keep_in_memory, + use_dynamic, + result_valobj_sp); if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) { uint32_t start_frame = 0; uint32_t num_frames = 1; uint32_t num_frames_with_source = 0; - if (m_exe_ctx.thread) + Thread *thread = m_exe_ctx.GetThreadPtr(); + if (thread) { - m_exe_ctx.thread->GetStatus (result->GetOutputStream(), - start_frame, - num_frames, - num_frames_with_source); - } - else if (m_exe_ctx.process) - { - bool only_threads_with_stop_reason = true; - m_exe_ctx.process->GetThreadStatus (result->GetOutputStream(), - only_threads_with_stop_reason, - start_frame, - num_frames, - num_frames_with_source); + thread->GetStatus (result->GetOutputStream(), + start_frame, + num_frames, + num_frames_with_source); + } + else + { + Process *process = m_exe_ctx.GetProcessPtr(); + if (process) + { + bool only_threads_with_stop_reason = true; + process->GetThreadStatus (result->GetOutputStream(), + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); + } } } Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Sep 21 23:58:26 2011 @@ -74,9 +74,10 @@ CommandReturnObject &result) { ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - if (exe_ctx.frame) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) { - exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream()); + frame->DumpUsingSettingsFormat (&result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); } else @@ -192,14 +193,15 @@ CommandReturnObject &result) { ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - if (exe_ctx.thread) + Thread *thread = exe_ctx.GetThreadPtr(); + if (thread) { - const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount(); + const uint32_t num_frames = thread->GetStackFrameCount(); uint32_t frame_idx = UINT32_MAX; if (m_options.relative_frame_offset != INT32_MIN) { // The one and only argument is a signed relative frame index - frame_idx = exe_ctx.thread->GetSelectedFrameIndex (); + frame_idx = thread->GetSelectedFrameIndex (); if (frame_idx == UINT32_MAX) frame_idx = 0; @@ -254,13 +256,13 @@ if (frame_idx < num_frames) { - exe_ctx.thread->SetSelectedFrameByIndex (frame_idx); - exe_ctx.frame = exe_ctx.thread->GetSelectedFrame ().get(); - - if (exe_ctx.frame) + thread->SetSelectedFrameByIndex (frame_idx); + exe_ctx.SetFrameSP(thread->GetSelectedFrame ()); + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) { bool already_shown = false; - SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); + SymbolContext frame_sc(frame->GetSymbolContext(eSymbolContextLineEntry)); if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); @@ -270,11 +272,11 @@ bool show_source = !already_shown; uint32_t source_lines_before = 3; uint32_t source_lines_after = 3; - if (exe_ctx.frame->GetStatus(result.GetOutputStream(), - show_frame_info, - show_source, - source_lines_before, - source_lines_after)) + if (frame->GetStatus (result.GetOutputStream(), + show_frame_info, + show_source, + source_lines_before, + source_lines_after)) { result.SetStatus (eReturnStatusSuccessFinishResult); return result.Succeeded(); @@ -369,7 +371,8 @@ ) { ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - if (exe_ctx.frame == NULL) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame == NULL) { result.AppendError ("you must be stopped in a valid stack frame to view frame variables."); result.SetStatus (eReturnStatusFailed); @@ -383,9 +386,7 @@ // Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList // for the thread. So hold onto a shared pointer to the frame so it stays alive. - StackFrameSP frame_sp = exe_ctx.frame->GetSP(); - - VariableList *variable_list = frame_sp->GetVariableList (get_file_globals); + VariableList *variable_list = frame->GetVariableList (get_file_globals); VariableSP var_sp; ValueObjectSP valobj_sp; @@ -458,7 +459,7 @@ var_sp = regex_var_list.GetVariableAtIndex (regex_idx); if (var_sp) { - valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); + valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic); if (valobj_sp) { if (m_option_variable.format != eFormatDefault) @@ -499,11 +500,11 @@ Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember; lldb::VariableSP var_sp; - valobj_sp = frame_sp->GetValueForVariableExpressionPath (name_cstr, - m_varobj_options.use_dynamic, - expr_path_options, - var_sp, - error); + valobj_sp = frame->GetValueForVariableExpressionPath (name_cstr, + m_varobj_options.use_dynamic, + expr_path_options, + var_sp, + error); if (valobj_sp) { if (m_option_variable.format != eFormatDefault) @@ -533,8 +534,7 @@ size = valobj_sp->GetByteSize(); } uint32_t watch_type = m_option_watchpoint.watch_type; - WatchpointLocation *wp_loc = - exe_ctx.target->CreateWatchpointLocation(addr, size, watch_type).get(); + WatchpointLocation *wp_loc = exe_ctx.GetTargetRef().CreateWatchpointLocation(addr, size, watch_type).get(); if (wp_loc) { if (var_sp && var_sp->GetDeclaration().GetFile()) @@ -613,8 +613,8 @@ // Use the variable object code to make sure we are // using the same APIs as the the public API will be // using... - valobj_sp = frame_sp->GetValueObjectForFrameVariable (var_sp, - m_varobj_options.use_dynamic); + valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, + m_varobj_options.use_dynamic); if (valobj_sp) { if (m_option_variable.format != eFormatDefault) Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Sep 21 23:58:26 2011 @@ -351,7 +351,8 @@ CommandReturnObject &result) { ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - if (exe_ctx.target == NULL) + Target *target = exe_ctx.GetTargetPtr(); + if (target == NULL) { result.AppendError("need at least a target to read memory"); result.SetStatus(eReturnStatusFailed); @@ -440,9 +441,10 @@ } ConstString lookup_type_name(type_str.c_str()); - if (exe_ctx.frame) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) { - sc = exe_ctx.frame->GetSymbolContext (eSymbolContextModule); + sc = frame->GetSymbolContext (eSymbolContextModule); if (sc.module_sp) { sc.module_sp->FindTypes (sc, @@ -454,11 +456,11 @@ } if (type_list.GetSize() == 0) { - exe_ctx.target->GetImages().FindTypes (sc, - lookup_type_name, - append, - 1, - type_list); + target->GetImages().FindTypes (sc, + lookup_type_name, + append, + 1, + type_list); } if (type_list.GetSize() == 0) @@ -502,7 +504,7 @@ } else { - error = m_memory_options.FinalizeSettings (exe_ctx.target, m_format_options); + error = m_memory_options.FinalizeSettings (target, m_format_options); } // Look for invalid combinations of settings @@ -562,7 +564,7 @@ { data_sp.reset (new DataBufferHeap (total_byte_size, '\0')); Address address(NULL, addr); - bytes_read = exe_ctx.target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error); + bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error); if (bytes_read == 0) { result.AppendWarningWithFormat("Read from 0x%llx failed.\n", addr); @@ -677,8 +679,8 @@ result.SetStatus(eReturnStatusSuccessFinishResult); DataExtractor data (data_sp, - exe_ctx.target->GetArchitecture().GetByteOrder(), - exe_ctx.target->GetArchitecture().GetAddressByteSize()); + target->GetArchitecture().GetByteOrder(), + target->GetArchitecture().GetAddressByteSize()); assert (output_stream); @@ -870,7 +872,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError("need a process to read memory"); Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Sep 21 23:58:26 2011 @@ -373,7 +373,7 @@ { Error error; const uint32_t argc = args.GetArgumentCount(); - Target *target = m_interpreter.GetExecutionContext().target; + Target *target = m_interpreter.GetExecutionContext().GetTargetPtr(); if (target) { Module *exe_module = target->GetExecutableModulePointer(); Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Sep 21 23:58:26 2011 @@ -174,7 +174,7 @@ exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); StateType state = eStateInvalid; - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) { state = process->GetState(); @@ -566,7 +566,7 @@ // and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop // ourselves here. - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); StateType state = eStateInvalid; if (process) { @@ -828,7 +828,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); bool synchronous_execution = m_interpreter.GetSynchronous (); if (process == NULL) @@ -915,7 +915,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -1025,7 +1025,7 @@ TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget()); Error error; - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) { if (process->IsAlive()) @@ -1139,7 +1139,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1198,7 +1198,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1275,7 +1275,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("no process to signal"); @@ -1350,7 +1350,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("no process to halt"); @@ -1412,7 +1412,7 @@ Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("no process to kill"); @@ -1476,18 +1476,19 @@ Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - if (exe_ctx.process) + Process *process = exe_ctx.GetProcessPtr(); + if (process) { const bool only_threads_with_stop_reason = true; const uint32_t start_frame = 0; const uint32_t num_frames = 1; const uint32_t num_frames_with_source = 1; - exe_ctx.process->GetStatus(strm); - exe_ctx.process->GetThreadStatus (strm, - only_threads_with_stop_reason, - start_frame, - num_frames, - num_frames_with_source); + process->GetStatus(strm); + process->GetThreadStatus (strm, + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); } else Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Wed Sep 21 23:58:26 2011 @@ -99,7 +99,7 @@ if (reg_addr != LLDB_INVALID_ADDRESS) { Address so_reg_addr; - if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr)) + if (exe_ctx.GetTargetRef().GetSectionLoadList().ResolveLoadAddress(reg_addr, so_reg_addr)) { strm.PutCString (" "); so_reg_addr.Dump(&strm, exe_ctx.GetBestExecutionContextScope(), Address::DumpStyleResolvedDescription); Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Wed Sep 21 23:58:26 2011 @@ -280,11 +280,9 @@ } ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - Target *target = NULL; + Target *target = exe_ctx.GetTargetPtr(); - if (exe_ctx.target) - target = exe_ctx.target; - else + if (target == NULL) target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -427,7 +425,7 @@ { const bool show_inlines = true; m_breakpoint_locations.Reset (start_file, 0, show_inlines); - SearchFilter target_search_filter (exe_ctx.target->GetSP()); + SearchFilter target_search_filter (exe_ctx.GetTargetSP()); target_search_filter.Search (m_breakpoint_locations); } else Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Sep 21 23:58:26 2011 @@ -649,8 +649,8 @@ Execute (Args& args, CommandReturnObject &result) { ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); - - if (exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (target) { const size_t argc = args.GetArgumentCount(); if (argc > 0) @@ -675,21 +675,21 @@ return false; } use_var_name = true; - matches = exe_ctx.target->GetImages().FindGlobalVariables (regex, - true, - UINT32_MAX, - variable_list); + matches = target->GetImages().FindGlobalVariables (regex, + true, + UINT32_MAX, + variable_list); } else { Error error (Variable::GetValuesForVariableExpressionPath (arg, exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, - exe_ctx.target, + target, variable_list, valobj_list)); -// matches = exe_ctx.target->GetImages().FindGlobalVariables (ConstString(arg), +// matches = target->GetImages().FindGlobalVariables (ConstString(arg), // true, // UINT32_MAX, // variable_list); @@ -1170,7 +1170,7 @@ LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) line_table->GetDescription (&strm, - interpreter.GetExecutionContext().target, + interpreter.GetExecutionContext().GetTargetPtr(), lldb::eDescriptionLevelBrief); else strm << "No line table"; @@ -1248,7 +1248,7 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, interpreter.GetExecutionContext().target, sort_order); + symtab->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), sort_order); } } } @@ -1270,7 +1270,7 @@ strm << '(' << module->GetObjectName() << ')'; strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName()); strm.IndentMore(); - section_list->Dump(&strm, interpreter.GetExecutionContext().target, true, UINT32_MAX); + section_list->Dump(&strm, interpreter.GetExecutionContext().GetTargetPtr(), true, UINT32_MAX); strm.IndentLess(); } } @@ -1309,7 +1309,7 @@ lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Target *target = interpreter.GetExecutionContext().target; + Target *target = interpreter.GetExecutionContext().GetTargetPtr(); if (target && !target->GetSectionLoadList().IsEmpty()) { if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr)) @@ -1394,7 +1394,7 @@ { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, interpreter.GetExecutionContext().target, i); + symbol->Dump (&strm, interpreter.GetExecutionContext().GetTargetPtr(), i); } strm.IndentLess (); return num_matches; @@ -2208,7 +2208,7 @@ result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(i), file_spec, - exe_ctx.process != NULL && exe_ctx.process->IsAlive())) + exe_ctx.GetProcessPtr() && exe_ctx.GetProcessRef().IsAlive())) num_dumped++; } if (num_dumped == 0) Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Wed Sep 21 23:58:26 2011 @@ -163,13 +163,14 @@ if (command.GetArgumentCount() == 0) { ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - if (exe_ctx.thread) + Thread *thread = exe_ctx.GetThreadPtr(); + if (thread) { // Thread::GetStatus() returns the number of frames shown. - if (exe_ctx.thread->GetStatus (strm, - m_options.m_start, - m_options.m_count, - num_frames_with_source)) + if (thread->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) { result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -182,7 +183,7 @@ } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); uint32_t num_threads = process->GetThreadList().GetSize(); for (uint32_t i = 0; i < num_threads; i++) { @@ -205,7 +206,7 @@ else { uint32_t num_args = command.GetArgumentCount(); - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); std::vector thread_sps; for (uint32_t i = 0; i < num_args; i++) @@ -398,7 +399,7 @@ CommandReturnObject &result ) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); bool synchronous_execution = m_interpreter.GetSynchronous(); if (process == NULL) @@ -639,7 +640,7 @@ return false; } - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -903,7 +904,7 @@ return false; } - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1125,7 +1126,7 @@ CommandReturnObject &result ) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { result.AppendError ("no process"); @@ -1198,18 +1199,19 @@ Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - if (exe_ctx.process) + Process *process = exe_ctx.GetProcessPtr(); + if (process) { const bool only_threads_with_stop_reason = false; const uint32_t start_frame = 0; const uint32_t num_frames = 0; const uint32_t num_frames_with_source = 0; - exe_ctx.process->GetStatus(strm); - exe_ctx.process->GetThreadStatus (strm, - only_threads_with_stop_reason, - start_frame, - num_frames, - num_frames_with_source); + process->GetStatus(strm); + process->GetThreadStatus (strm, + only_threads_with_stop_reason, + start_frame, + num_frames, + num_frames_with_source); } else { Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Wed Sep 21 23:58:26 2011 @@ -108,9 +108,10 @@ exe_scope->CalculateExecutionContext(exe_ctx); // If we have any sections that are loaded, try and resolve using the // section load list - if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) + Target *target = exe_ctx.GetTargetPtr(); + if (target && !target->GetSectionLoadList().IsEmpty()) { - if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr)) + if (target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr)) return true; } else Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Sep 21 23:58:26 2011 @@ -337,22 +337,22 @@ Debugger::GetSelectedExecutionContext () { ExecutionContext exe_ctx; - exe_ctx.Clear(); - - TargetSP target_sp = GetSelectedTarget(); - exe_ctx.target = target_sp.get(); + TargetSP target_sp(GetSelectedTarget()); + exe_ctx.SetTargetSP (target_sp); if (target_sp) { - exe_ctx.process = target_sp->GetProcessSP().get(); - if (exe_ctx.process && exe_ctx.process->IsRunning() == false) + ProcessSP process_sp (target_sp->GetProcessSP()); + exe_ctx.SetProcessSP (process_sp); + if (process_sp && process_sp->IsRunning() == false) { - exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get(); - if (exe_ctx.thread) + ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread()); + if (thread_sp) { - exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get(); - if (exe_ctx.frame == NULL) - exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex (0).get(); + exe_ctx.SetThreadSP (thread_sp); + exe_ctx.SetFrameSP (thread_sp->GetSelectedFrame()); + if (exe_ctx.GetFramePtr() == NULL) + exe_ctx.SetFrameSP (thread_sp->GetStackFrameAtIndex (0)); } } } @@ -1259,10 +1259,10 @@ for (;index_lower<=index_higher;index_lower++) { - ValueObject* item = ExpandIndexedExpression(target, - index_lower, - exe_ctx->frame, - false).get(); + ValueObject* item = ExpandIndexedExpression (target, + index_lower, + exe_ctx->GetFramePtr(), + false).get(); if (!item) { @@ -1307,77 +1307,85 @@ case 'p': if (::strncmp (var_name_begin, "process.", strlen("process.")) == 0) { - if (exe_ctx && exe_ctx->process != NULL) + if (exe_ctx) { - var_name_begin += ::strlen ("process."); - if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) - { - s.Printf("%i", exe_ctx->process->GetID()); - var_success = true; - } - else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) || - (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) || - (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0)) + Process *process = exe_ctx->GetProcessPtr(); + if (process) { - Module *exe_module = exe_ctx->process->GetTarget().GetExecutableModulePointer(); - if (exe_module) + var_name_begin += ::strlen ("process."); + if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) { - if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f') - { - format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename(); - var_success = format_file_spec; - } - else + s.Printf("%i", process->GetID()); + var_success = true; + } + else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) || + (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) || + (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0)) + { + Module *exe_module = process->GetTarget().GetExecutableModulePointer(); + if (exe_module) { - format_file_spec = exe_module->GetFileSpec(); - var_success = format_file_spec; + if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f') + { + format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename(); + var_success = format_file_spec; + } + else + { + format_file_spec = exe_module->GetFileSpec(); + var_success = format_file_spec; + } } } } - } + } } break; case 't': if (::strncmp (var_name_begin, "thread.", strlen("thread.")) == 0) { - if (exe_ctx && exe_ctx->thread) + if (exe_ctx) { - var_name_begin += ::strlen ("thread."); - if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) - { - s.Printf("0x%4.4x", exe_ctx->thread->GetID()); - var_success = true; - } - else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) - { - s.Printf("%u", exe_ctx->thread->GetIndexID()); - var_success = true; - } - else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) + Thread *thread = exe_ctx->GetThreadPtr(); + if (thread) { - cstr = exe_ctx->thread->GetName(); - var_success = cstr && cstr[0]; - if (var_success) - s.PutCString(cstr); - } - else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0) - { - cstr = exe_ctx->thread->GetQueueName(); - var_success = cstr && cstr[0]; - if (var_success) - s.PutCString(cstr); - } - else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0) - { - StopInfoSP stop_info_sp = exe_ctx->thread->GetStopInfo (); - if (stop_info_sp) + var_name_begin += ::strlen ("thread."); + if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) { - cstr = stop_info_sp->GetDescription(); - if (cstr && cstr[0]) - { + s.Printf("0x%4.4x", thread->GetID()); + var_success = true; + } + else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) + { + s.Printf("%u", thread->GetIndexID()); + var_success = true; + } + else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) + { + cstr = thread->GetName(); + var_success = cstr && cstr[0]; + if (var_success) s.PutCString(cstr); - var_success = true; + } + else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0) + { + cstr = thread->GetQueueName(); + var_success = cstr && cstr[0]; + if (var_success) + s.PutCString(cstr); + } + else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0) + { + StopInfoSP stop_info_sp = thread->GetStopInfo (); + if (stop_info_sp) + { + cstr = stop_info_sp->GetDescription(); + if (cstr && cstr[0]) + { + s.PutCString(cstr); + var_success = true; + } } } } @@ -1455,50 +1463,54 @@ } else if (::strncmp (var_name_begin, "frame.", strlen("frame.")) == 0) { - if (exe_ctx && exe_ctx->frame) + if (exe_ctx) { - var_name_begin += ::strlen ("frame."); - if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) - { - s.Printf("%u", exe_ctx->frame->GetFrameIndex()); - var_success = true; - } - else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0) - { - reg_kind = eRegisterKindGeneric; - reg_num = LLDB_REGNUM_GENERIC_PC; - var_success = true; - } - else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0) - { - reg_kind = eRegisterKindGeneric; - reg_num = LLDB_REGNUM_GENERIC_SP; - var_success = true; - } - else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0) - { - reg_kind = eRegisterKindGeneric; - reg_num = LLDB_REGNUM_GENERIC_FP; - var_success = true; - } - else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0) + StackFrame *frame = exe_ctx->GetFramePtr(); + if (frame) { - reg_kind = eRegisterKindGeneric; - reg_num = LLDB_REGNUM_GENERIC_FLAGS; - var_success = true; - } - else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0) - { - reg_ctx = exe_ctx->frame->GetRegisterContext().get(); - if (reg_ctx) + var_name_begin += ::strlen ("frame."); + if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) + { + s.Printf("%u", frame->GetFrameIndex()); + var_success = true; + } + else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0) { - var_name_begin += ::strlen ("reg."); - if (var_name_begin < var_name_end) + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_PC; + var_success = true; + } + else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_SP; + var_success = true; + } + else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_FP; + var_success = true; + } + else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_FLAGS; + var_success = true; + } + else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0) + { + reg_ctx = frame->GetRegisterContext().get(); + if (reg_ctx) { - std::string reg_name (var_name_begin, var_name_end); - reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str()); - if (reg_info) - var_success = true; + var_name_begin += ::strlen ("reg."); + if (var_name_begin < var_name_end) + { + std::string reg_name (var_name_begin, var_name_end); + reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str()); + if (reg_info) + var_success = true; + } } } } @@ -1564,10 +1576,11 @@ } else if (::strncmp (var_name_begin, "pc-offset}", strlen("pc-offset}")) == 0) { - var_success = exe_ctx->frame; + StackFrame *frame = exe_ctx->GetFramePtr(); + var_success = frame != NULL; if (var_success) { - format_addr = exe_ctx->frame->GetFrameCodeAddress(); + format_addr = frame->GetFrameCodeAddress(); calculate_format_addr_function_offset = true; } } @@ -1622,15 +1635,16 @@ // If format addr is valid, then we need to print an address if (reg_num != LLDB_INVALID_REGNUM) { + StackFrame *frame = exe_ctx->GetFramePtr(); // We have a register value to display... if (reg_num == LLDB_REGNUM_GENERIC_PC && reg_kind == eRegisterKindGeneric) { - format_addr = exe_ctx->frame->GetFrameCodeAddress(); + format_addr = frame->GetFrameCodeAddress(); } else { if (reg_ctx == NULL) - reg_ctx = exe_ctx->frame->GetRegisterContext().get(); + reg_ctx = frame->GetRegisterContext().get(); if (reg_ctx) { Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Wed Sep 21 23:58:26 2011 @@ -81,15 +81,16 @@ { // If we weren't passed in a section offset address range, // try and resolve it to something - if (exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (target) { - if (exe_ctx.target->GetSectionLoadList().IsEmpty()) + if (target->GetSectionLoadList().IsEmpty()) { - exe_ctx.target->GetImages().ResolveFileAddress (addr.GetOffset(), resolved_addr); + target->GetImages().ResolveFileAddress (addr.GetOffset(), resolved_addr); } else { - exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), resolved_addr); + target->GetSectionLoadList().ResolveLoadAddress (addr.GetOffset(), resolved_addr); } // We weren't able to resolve the address, just treat it as a // raw address @@ -174,16 +175,16 @@ true, sc_list); } - else if (exe_ctx.target) + else if (exe_ctx.GetTargetPtr()) { - exe_ctx.target->GetImages().FindFunctions (name, - eFunctionNameTypeBase | - eFunctionNameTypeFull | - eFunctionNameTypeMethod | - eFunctionNameTypeSelector, - include_symbols, - false, - sc_list); + exe_ctx.GetTargetPtr()->GetImages().FindFunctions (name, + eFunctionNameTypeBase | + eFunctionNameTypeFull | + eFunctionNameTypeMethod | + eFunctionNameTypeSelector, + include_symbols, + false, + sc_list); } } @@ -333,8 +334,10 @@ AddressRange sc_range; const Address *pc_addr_ptr = NULL; ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope(); - if (exe_ctx.frame) - pc_addr_ptr = &exe_ctx.frame->GetFrameCodeAddress(); + StackFrame *frame = exe_ctx.GetFramePtr(); + + if (frame) + pc_addr_ptr = &frame->GetFrameCodeAddress(); const uint32_t scope = eSymbolContextLineEntry | eSymbolContextFunction | eSymbolContextSymbol; const bool use_inline_block_range = false; for (size_t i=0; iGetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); + SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); if (sc.function) { range = sc.function->GetAddressRange(); @@ -449,7 +453,7 @@ } else { - range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress(); + range.GetBaseAddress() = frame->GetFrameCodeAddress(); } if (range.GetBaseAddress().IsValid() && range.GetByteSize() == 0) @@ -848,32 +852,34 @@ const AddressRange &range ) { - Target *target = exe_ctx->target; - const addr_t byte_size = range.GetByteSize(); - if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid()) - return 0; - - DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0'); - DataBufferSP data_sp(heap_buffer); - - Error error; - const bool prefer_file_cache = true; - const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(), - prefer_file_cache, - heap_buffer->GetBytes(), - heap_buffer->GetByteSize(), - error); - - if (bytes_read > 0) + if (exe_ctx) { - if (bytes_read != heap_buffer->GetByteSize()) - heap_buffer->SetByteSize (bytes_read); - DataExtractor data (data_sp, - m_arch.GetByteOrder(), - m_arch.GetAddressByteSize()); - return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false); + Target *target = exe_ctx->GetTargetPtr(); + const addr_t byte_size = range.GetByteSize(); + if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid()) + return 0; + + DataBufferHeap *heap_buffer = new DataBufferHeap (byte_size, '\0'); + DataBufferSP data_sp(heap_buffer); + + Error error; + const bool prefer_file_cache = true; + const size_t bytes_read = target->ReadMemory (range.GetBaseAddress(), + prefer_file_cache, + heap_buffer->GetBytes(), + heap_buffer->GetByteSize(), + error); + + if (bytes_read > 0) + { + if (bytes_read != heap_buffer->GetByteSize()) + heap_buffer->SetByteSize (bytes_read); + DataExtractor data (data_sp, + m_arch.GetByteOrder(), + m_arch.GetAddressByteSize()); + return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false); + } } - return 0; } @@ -887,10 +893,10 @@ { m_instruction_list.Clear(); - if (num_instructions == 0 || !start.IsValid()) + if (exe_ctx == NULL || num_instructions == 0 || !start.IsValid()) return 0; - Target *target = exe_ctx->target; + Target *target = exe_ctx->GetTargetPtr(); // Calculate the max buffer size we will need in order to disassemble const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize(); Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Wed Sep 21 23:58:26 2011 @@ -84,8 +84,9 @@ ExecutionContext exe_ctx; object->GetExecutionContextScope()->CalculateExecutionContext(exe_ctx); SymbolContext sc; - if (exe_ctx.frame) - sc = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything); + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) + sc = frame->GetSymbolContext(lldb::eSymbolContextEverything); if (m_show_members_oneliner) { Modified: lldb/trunk/source/Core/SearchFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/SearchFilter.cpp (original) +++ lldb/trunk/source/Core/SearchFilter.cpp Wed Sep 21 23:58:26 2011 @@ -583,7 +583,7 @@ } else { - s->Printf (", modules(%d) = ", num_modules); + s->Printf (", modules(%u) = ", num_modules); for (uint32_t i = 0; i < num_modules; i++) { if (s->GetVerbose()) Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Wed Sep 21 23:58:26 2011 @@ -366,7 +366,7 @@ } else { - Process *process = exe_ctx->GetProcess(); + Process *process = exe_ctx->GetProcessPtr(); if (process == NULL) { error.SetErrorString ("can't read load address (invalid process)"); @@ -386,7 +386,7 @@ { error.SetErrorString ("can't read file address (no execution context)"); } - else if (exe_ctx->target == NULL) + else if (exe_ctx->GetTargetPtr() == NULL) { error.SetErrorString ("can't read file address (invalid target)"); } @@ -419,14 +419,14 @@ if (objfile) { Address so_addr(address, objfile->GetSectionList()); - addr_t load_address = so_addr.GetLoadAddress (exe_ctx->target); + addr_t load_address = so_addr.GetLoadAddress (exe_ctx->GetTargetPtr()); if (load_address != LLDB_INVALID_ADDRESS) { resolved = true; address = load_address; address_type = eAddressTypeLoad; - data.SetByteOrder(exe_ctx->target->GetArchitecture().GetByteOrder()); - data.SetAddressByteSize(exe_ctx->target->GetArchitecture().GetAddressByteSize()); + data.SetByteOrder(exe_ctx->GetTargetRef().GetArchitecture().GetByteOrder()); + data.SetAddressByteSize(exe_ctx->GetTargetRef().GetArchitecture().GetAddressByteSize()); } else { @@ -532,7 +532,7 @@ // want to read the actual value by setting "prefer_file_cache" // to false. const bool prefer_file_cache = false; - if (exe_ctx->target->ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, error) != byte_size) + if (exe_ctx->GetTargetRef().ReadMemory(file_so_addr, prefer_file_cache, dst, byte_size, error) != byte_size) { error.SetErrorStringWithFormat("read memory from 0x%llx failed", (uint64_t)address); } @@ -543,7 +543,7 @@ // might have a valid process in the exe_ctx->target, so use // the ExecutionContext::GetProcess accessor to ensure we // get the process if there is one. - Process *process = exe_ctx->GetProcess(); + Process *process = exe_ctx->GetProcessPtr(); if (process) { Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Sep 21 23:58:26 2011 @@ -3439,22 +3439,21 @@ // and if so we want to cache that not the original. if (exe_scope) exe_scope->CalculateExecutionContext(exe_ctx); - if (exe_ctx.target != NULL) + Target *target = exe_ctx.GetTargetPtr(); + if (target != NULL) { - m_target_sp = exe_ctx.target->GetSP(); - - if (exe_ctx.process == NULL) - m_process_sp = exe_ctx.target->GetProcessSP(); - else - m_process_sp = exe_ctx.process->GetSP(); + m_target_sp = target; + m_process_sp = exe_ctx.GetProcessSP(); + if (!m_process_sp) + m_process_sp = target->GetProcessSP(); - if (m_process_sp != NULL) + if (m_process_sp) { m_mod_id = m_process_sp->GetModID(); - Thread *thread = NULL; + Thread *thread = exe_ctx.GetThreadPtr(); - if (exe_ctx.thread == NULL) + if (thread == NULL) { if (use_selected) { @@ -3463,17 +3462,17 @@ computed_exe_scope = thread; } } - else - thread = exe_ctx.thread; if (thread != NULL) { m_thread_id = thread->GetIndexID(); - if (exe_ctx.frame == NULL) + + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame == NULL) { if (use_selected) { - StackFrame *frame = exe_ctx.thread->GetSelectedFrame().get(); + frame = thread->GetSelectedFrame().get(); if (frame) { m_stack_id = frame->GetStackID(); @@ -3482,7 +3481,7 @@ } } else - m_stack_id = exe_ctx.frame->GetStackID(); + m_stack_id = frame->GetStackID(); } } } Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original) +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Wed Sep 21 23:58:26 2011 @@ -127,11 +127,11 @@ } ExecutionContext exe_ctx (GetExecutionContextScope()); - - if (exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (target) { - m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); - m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + m_data.SetByteOrder(target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); } // First make sure our Type and/or Address haven't changed: Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp (original) +++ lldb/trunk/source/Core/ValueObjectMemory.cpp Wed Sep 21 23:58:26 2011 @@ -185,10 +185,11 @@ ExecutionContext exe_ctx (GetExecutionContextScope()); - if (exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (target) { - m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); - m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + m_data.SetByteOrder(target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); } Value old_value(m_value); @@ -220,9 +221,9 @@ // Make sure this type has a value before we try and read it // If we have a file address, convert it to a load address if we can. - if (value_type == Value::eValueTypeFileAddress && exe_ctx.process) + if (value_type == Value::eValueTypeFileAddress && exe_ctx.GetProcessPtr()) { - lldb::addr_t load_addr = m_address.GetLoadAddress(exe_ctx.target); + lldb::addr_t load_addr = m_address.GetLoadAddress(target); if (load_addr != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Wed Sep 21 23:58:26 2011 @@ -126,10 +126,11 @@ lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; ExecutionContext exe_ctx (GetExecutionContextScope()); - if (exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (target) { - m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); - m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + m_data.SetByteOrder(target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); } if (expr.IsLocationList()) @@ -137,7 +138,7 @@ SymbolContext sc; variable->CalculateSymbolContext (&sc); if (sc.function) - loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); + loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target); } Value old_value(m_value); if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error)) @@ -187,7 +188,8 @@ // Make sure this type has a value before we try and read it // If we have a file address, convert it to a load address if we can. - if (value_type == Value::eValueTypeFileAddress && exe_ctx.process && exe_ctx.process->IsAlive()) + Process *process = exe_ctx.GetProcessPtr(); + if (value_type == Value::eValueTypeFileAddress && process && process->IsAlive()) { lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); if (file_addr != LLDB_INVALID_ADDRESS) @@ -200,7 +202,7 @@ if (objfile) { Address so_addr(file_addr, objfile->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target); + lldb::addr_t load_addr = so_addr.GetLoadAddress (target); if (load_addr != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 21 23:58:26 2011 @@ -69,27 +69,30 @@ { EnableParserVars(); m_parser_vars->m_exe_ctx = &exe_ctx; - - if (exe_ctx.frame) - m_parser_vars->m_sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything); - else if (exe_ctx.thread) - m_parser_vars->m_sym_ctx = exe_ctx.thread->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything); - else if (exe_ctx.process) + + Target *target = exe_ctx.GetTargetPtr(); + if (exe_ctx.GetFramePtr()) + m_parser_vars->m_sym_ctx = exe_ctx.GetFramePtr()->GetSymbolContext(lldb::eSymbolContextEverything); + else if (exe_ctx.GetThreadPtr()) + m_parser_vars->m_sym_ctx = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything); + else if (exe_ctx.GetProcessPtr()) { m_parser_vars->m_sym_ctx.Clear(); - m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target; + m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP(); } - else if (exe_ctx.target) + else if (target) { m_parser_vars->m_sym_ctx.Clear(); - m_parser_vars->m_sym_ctx.target_sp = exe_ctx.target; + m_parser_vars->m_sym_ctx.target_sp = exe_ctx.GetTargetSP(); } - if (exe_ctx.target) - m_parser_vars->m_persistent_vars = &exe_ctx.target->GetPersistentVariables(); + if (target) + { + m_parser_vars->m_persistent_vars = &target->GetPersistentVariables(); - if (exe_ctx.target && !exe_ctx.target->GetScratchClangASTContext()) - return false; + if (!target->GetScratchClangASTContext()) + return false; + } m_parser_vars->m_target_info = GetTargetInfo(); @@ -137,16 +140,23 @@ TargetInfo ret; ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - - if (exe_ctx->process) - { - ret.byte_order = exe_ctx->process->GetByteOrder(); - ret.address_byte_size = exe_ctx->process->GetAddressByteSize(); - } - else if (exe_ctx->target) + if (exe_ctx) { - ret.byte_order = exe_ctx->target->GetArchitecture().GetByteOrder(); - ret.address_byte_size = exe_ctx->target->GetArchitecture().GetAddressByteSize(); + Process *process = exe_ctx->GetProcessPtr(); + if (process) + { + ret.byte_order = process->GetByteOrder(); + ret.address_byte_size = process->GetAddressByteSize(); + } + else + { + Target *target = exe_ctx->GetTargetPtr(); + if (target) + { + ret.byte_order = target->GetArchitecture().GetByteOrder(); + ret.address_byte_size = target->GetArchitecture().GetAddressByteSize(); + } + } } return ret; @@ -174,7 +184,11 @@ assert (m_parser_vars.get()); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + if (exe_ctx == NULL) + return lldb::ClangExpressionVariableSP(); + Target *target = exe_ctx->GetTargetPtr(); + + ASTContext *context(target->GetScratchClangASTContext()->getASTContext()); TypeFromUser user_type(ClangASTContext::CopyType(context, type.GetASTContext(), @@ -249,7 +263,13 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + if (exe_ctx == NULL) + return lldb::ClangExpressionVariableSP(); + Target *target = exe_ctx->GetTargetPtr(); + if (target == NULL) + return lldb::ClangExpressionVariableSP(); + + ASTContext *context(target->GetScratchClangASTContext()->getASTContext()); ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl)); @@ -266,12 +286,16 @@ TypeFromUser var_type = var_sp->GetTypeFromUser(); - VariableSP var = FindVariableInScope (*exe_ctx->frame, var_sp->GetName(), &var_type); + StackFrame *frame = exe_ctx->GetFramePtr(); + if (frame == NULL) + return lldb::ClangExpressionVariableSP(); + + VariableSP var = FindVariableInScope (*frame, var_sp->GetName(), &var_type); if (!var) return lldb::ClangExpressionVariableSP(); // but we should handle this; it may be a persistent variable - ValueObjectSP var_valobj = exe_ctx->frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues); + ValueObjectSP var_valobj = frame->GetValueObjectForFrameVariable(var, lldb::eNoDynamicValues); if (!var_valobj) return lldb::ClangExpressionVariableSP(); @@ -377,8 +401,13 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - - ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + if (exe_ctx == NULL) + return false; + Target *target = exe_ctx->GetTargetPtr(); + if (target == NULL) + return false; + + ASTContext *context(target->GetScratchClangASTContext()->getASTContext()); TypeFromUser user_type(ClangASTContext::CopyType(context, parser_type.GetASTContext(), @@ -612,9 +641,12 @@ assert (m_parser_vars.get()); lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; + if (exe_ctx == NULL) + return false; + Target *target = exe_ctx->GetTargetPtr(); // Back out in all cases where we're not fully initialized - if (m_parser_vars->m_exe_ctx->target == NULL) + if (target == NULL) return false; if (!m_parser_vars->m_sym_ctx.target_sp) return false; @@ -665,7 +697,7 @@ if (!func_so_addr || !func_so_addr->IsValid()) return false; - func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target); + func_addr = func_so_addr->GetCallableLoadAddress (target); return true; } @@ -737,10 +769,10 @@ assert (m_parser_vars.get()); if (!m_parser_vars->m_exe_ctx || - !m_parser_vars->m_exe_ctx->target) + !m_parser_vars->m_exe_ctx->GetTargetPtr()) return false; - return GetSymbolAddress(*m_parser_vars->m_exe_ctx->target, name); + return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name); } // Interface for IRInterpreter @@ -754,9 +786,10 @@ ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; + Process *process = exe_ctx->GetProcessPtr(); if (value.GetContextType() == Value::eContextTypeRegisterInfo) { - if (!exe_ctx->process) + if (!process) return false; RegisterContext *reg_ctx = exe_ctx->GetRegisterContext(); @@ -768,7 +801,7 @@ lldb_private::RegisterValue reg_value; Error err; - if (!reg_value.SetFromMemoryData (reg_info, data, length, exe_ctx->process->GetByteOrder(), err)) + if (!reg_value.SetFromMemoryData (reg_info, data, length, process->GetByteOrder(), err)) return false; return reg_ctx->WriteRegister(reg_info, reg_value); @@ -781,28 +814,29 @@ return false; case Value::eValueTypeFileAddress: { - if (!exe_ctx->process) + if (!process) return false; + Target *target = exe_ctx->GetTargetPtr(); Address file_addr; - if (!exe_ctx->target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr)) + if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr)) return false; - lldb::addr_t load_addr = file_addr.GetLoadAddress(exe_ctx->target); + lldb::addr_t load_addr = file_addr.GetLoadAddress(target); Error err; - exe_ctx->process->WriteMemory(load_addr, data, length, err); + process->WriteMemory(load_addr, data, length, err); return err.Success(); } case Value::eValueTypeLoadAddress: { - if (!exe_ctx->process) + if (!process) return false; Error err; - exe_ctx->process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err); + process->WriteMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err); return err.Success(); } @@ -823,10 +857,12 @@ assert (m_parser_vars.get()); ExecutionContext *exe_ctx = m_parser_vars->m_exe_ctx; - + + Process *process = exe_ctx->GetProcessPtr(); + if (value.GetContextType() == Value::eContextTypeRegisterInfo) { - if (!exe_ctx->process) + if (!process) return false; RegisterContext *reg_ctx = exe_ctx->GetRegisterContext(); @@ -841,7 +877,7 @@ if (!reg_ctx->ReadRegister(reg_info, reg_value)) return false; - return reg_value.GetAsMemoryData(reg_info, data, length, exe_ctx->process->GetByteOrder(), err); + return reg_value.GetAsMemoryData(reg_info, data, length, process->GetByteOrder(), err); } else { @@ -851,26 +887,27 @@ return false; case Value::eValueTypeFileAddress: { - if (!exe_ctx->target) + Target *target = exe_ctx->GetTargetPtr(); + if (target == NULL) return false; Address file_addr; - if (!exe_ctx->target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr)) + if (!target->GetImages().ResolveFileAddress((lldb::addr_t)value.GetScalar().ULongLong(), file_addr)) return false; Error err; - exe_ctx->target->ReadMemory(file_addr, true, data, length, err); + target->ReadMemory(file_addr, true, data, length, err); return err.Success(); } case Value::eValueTypeLoadAddress: { - if (!exe_ctx->process) + if (!process) return false; Error err; - exe_ctx->process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err); + process->ReadMemory((lldb::addr_t)value.GetScalar().ULongLong(), data, length, err); return err.Success(); } @@ -898,22 +935,25 @@ const ConstString &name(expr_var_sp->GetName()); TypeFromUser type(expr_var_sp->GetTypeFromUser()); - if (m_parser_vars->m_exe_ctx->frame) + StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr(); + if (frame) { - VariableSP var(FindVariableInScope (*exe_ctx.frame, name, &type)); + VariableSP var(FindVariableInScope (*frame, name, &type)); if (var) return *GetVariableValue(exe_ctx, var, NULL); } - if (m_parser_vars->m_exe_ctx->target) + Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr(); + + if (target) { - VariableSP global(FindGlobalVariable (*exe_ctx.target, name.GetCString(), &type)); + VariableSP global(FindGlobalVariable (*target, name.GetCString(), &type)); if (global) return *GetVariableValue(exe_ctx, global, NULL); - lldb::addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name); + lldb::addr_t location_load_addr = GetSymbolAddress(*target, name); if (location_load_addr != LLDB_INVALID_ADDRESS) { @@ -962,7 +1002,7 @@ { EnableMaterialVars(); - m_material_vars->m_process = exe_ctx.process; + m_material_vars->m_process = exe_ctx.GetProcessPtr(); bool result = DoMaterialize(false /* dematerialize */, exe_ctx, @@ -989,7 +1029,11 @@ { assert (m_struct_vars.get()); - if (!exe_ctx.frame || !exe_ctx.target || !exe_ctx.process) + Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); + StackFrame *frame = exe_ctx.GetFramePtr(); + + if (frame == NULL || process == NULL || target == NULL) { err.SetErrorString("Couldn't load 'this' because the context is incomplete"); return false; @@ -1001,7 +1045,7 @@ return false; } - VariableSP object_ptr_var = FindVariableInScope (*exe_ctx.frame, + VariableSP object_ptr_var = FindVariableInScope (*frame, object_name, (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type)); @@ -1029,7 +1073,7 @@ case Value::eValueTypeLoadAddress: { lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - uint32_t address_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize(); + uint32_t address_byte_size = target->GetArchitecture().GetAddressByteSize(); if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) @@ -1039,7 +1083,7 @@ } Error read_error; - object_ptr = exe_ctx.process->ReadPointerFromMemory (value_addr, read_error); + object_ptr = process->ReadPointerFromMemory (value_addr, read_error); if (read_error.Fail() || object_ptr == LLDB_INVALID_ADDRESS) { err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString()); @@ -1133,14 +1177,16 @@ err.SetErrorString("Structure hasn't been laid out yet"); return false; } - - if (!exe_ctx.process) + Process *process = exe_ctx.GetProcessPtr(); + + if (!process) { err.SetErrorString("Couldn't find the process"); return false; } - if (!exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (!target) { err.SetErrorString("Couldn't find the target"); return false; @@ -1155,7 +1201,7 @@ lldb::DataBufferSP data_sp(new DataBufferHeap(m_struct_vars->m_struct_size, 0)); Error error; - if (exe_ctx.process->ReadMemory (m_material_vars->m_materialized_location, + if (process->ReadMemory (m_material_vars->m_materialized_location, data_sp->GetBytes(), data_sp->GetByteSize(), error) != data_sp->GetByteSize()) { @@ -1163,7 +1209,7 @@ return false; } - DataExtractor extractor(data_sp, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize()); + DataExtractor extractor(data_sp, process->GetByteOrder(), target->GetArchitecture().GetAddressByteSize()); for (size_t member_idx = 0, num_members = m_struct_members.GetSize(); member_idx < num_members; @@ -1219,13 +1265,15 @@ return false; } - if (!exe_ctx.frame) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (!frame) { err.SetErrorString("Received null execution frame"); return false; } + Target *target = exe_ctx.GetTargetPtr(); - ClangPersistentVariables &persistent_vars = exe_ctx.target->GetPersistentVariables(); + ClangPersistentVariables &persistent_vars = target->GetPersistentVariables(); if (!m_struct_vars->m_struct_size) { @@ -1237,20 +1285,21 @@ return true; } - const SymbolContext &sym_ctx(exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything)); + const SymbolContext &sym_ctx(frame->GetSymbolContext(lldb::eSymbolContextEverything)); if (!dematerialize) { + Process *process = exe_ctx.GetProcessPtr(); if (m_material_vars->m_materialized_location) { - exe_ctx.process->DeallocateMemory(m_material_vars->m_materialized_location); + process->DeallocateMemory(m_material_vars->m_materialized_location); m_material_vars->m_materialized_location = 0; } if (log) log->PutCString("Allocating memory for materialized argument struct"); - lldb::addr_t mem = exe_ctx.process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size, + lldb::addr_t mem = process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, err); @@ -1369,7 +1418,8 @@ return false; Error error; - + Process *process = exe_ctx.GetProcessPtr(); + lldb::addr_t mem; // The address of a spare memory area used to hold the persistent variable. if (dematerialize) @@ -1383,7 +1433,7 @@ // Get the location of the target out of the struct. Error read_error; - mem = exe_ctx.process->ReadPointerFromMemory (addr, read_error); + mem = process->ReadPointerFromMemory (addr, read_error); if (mem == LLDB_INVALID_ADDRESS) { @@ -1429,7 +1479,7 @@ // Read the contents of the spare memory area var_sp->ValueUpdated (); - if (exe_ctx.process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size) + if (process->ReadMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size) { err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); return false; @@ -1461,7 +1511,7 @@ } else { - Error deallocate_error = exe_ctx.process->DeallocateMemory(mem); + Error deallocate_error = process->DeallocateMemory(mem); if (!err.Success()) { @@ -1488,7 +1538,7 @@ Error allocate_error; - mem = exe_ctx.process->AllocateMemory(pvar_byte_size, + mem = process->AllocateMemory(pvar_byte_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, allocate_error); @@ -1518,7 +1568,7 @@ // Write the contents of the variable to the area. - if (exe_ctx.process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size) + if (process->WriteMemory (mem, pvar_data, pvar_byte_size, error) != pvar_byte_size) { err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); return false; @@ -1530,9 +1580,9 @@ { // Now write the location of the area into the struct. Error write_error; - if (!exe_ctx.process->WriteScalarToMemory (addr, + if (!process->WriteScalarToMemory (addr, var_sp->m_live_sp->GetValue().GetScalar(), - exe_ctx.process->GetAddressByteSize(), + process->GetAddressByteSize(), write_error)) { err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString()); @@ -1564,8 +1614,11 @@ ) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - - if (!exe_ctx.frame || !exe_ctx.process) + Target *target = exe_ctx.GetTargetPtr(); + Process *process = exe_ctx.GetProcessPtr(); + StackFrame *frame = exe_ctx.GetFramePtr(); + + if (!frame || !process || !target) return false; // Vital information about the value @@ -1573,8 +1626,8 @@ const ConstString &name(expr_var->GetName()); TypeFromUser type(expr_var->GetTypeFromUser()); - VariableSP var = FindVariableInScope (*exe_ctx.frame, name, &type); - Symbol *sym = FindGlobalDataSymbol(*exe_ctx.target, name); + VariableSP var = FindVariableInScope (*frame, name, &type); + Symbol *sym = FindGlobalDataSymbol(*target, name); std::auto_ptr location_value; @@ -1588,7 +1641,7 @@ { location_value.reset(new Value); - addr_t location_load_addr = GetSymbolAddress(*exe_ctx.target, name); + addr_t location_load_addr = GetSymbolAddress(*target, name); if (location_load_addr == LLDB_INVALID_ADDRESS) { @@ -1654,9 +1707,9 @@ { Error write_error; - if (!exe_ctx.process->WriteScalarToMemory (addr, + if (!process->WriteScalarToMemory (addr, location_value->GetScalar(), - exe_ctx.process->GetAddressByteSize(), + process->GetAddressByteSize(), write_error)) { err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", @@ -1738,7 +1791,7 @@ // Deallocate the spare area and clear the variable's live data. - Error deallocate_error = exe_ctx.process->DeallocateMemory(reg_addr.ULongLong()); + Error deallocate_error = process->DeallocateMemory(reg_addr.ULongLong()); if (!deallocate_error.Success()) { @@ -1757,7 +1810,7 @@ Error allocate_error; - Scalar reg_addr (exe_ctx.process->AllocateMemory (value_byte_size, + Scalar reg_addr (process->AllocateMemory (value_byte_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, allocate_error)); @@ -1783,9 +1836,9 @@ Error write_error; - if (!exe_ctx.process->WriteScalarToMemory (addr, + if (!process->WriteScalarToMemory (addr, reg_addr, - exe_ctx.process->GetAddressByteSize(), + process->GetAddressByteSize(), write_error)) { err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", @@ -2088,6 +2141,8 @@ // Only look for functions by name out in our symbols if the function // doesn't start with our phony prefix of '$' + Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr(); + StackFrame *frame = m_parser_vars->m_exe_ctx->GetFramePtr(); if (name_unique_cstr[0] != '$') { ValueObjectSP valobj; @@ -2095,9 +2150,9 @@ Error err; bool found = false; - if (m_parser_vars->m_exe_ctx->frame) + if (frame) { - valobj = m_parser_vars->m_exe_ctx->frame->GetValueForVariableExpressionPath(name_unique_cstr, + valobj = frame->GetValueForVariableExpressionPath(name_unique_cstr, eNoDynamicValues, StackFrame::eExpressionPathOptionCheckPtrVsMember, var, @@ -2110,11 +2165,11 @@ found = true; } } - else if (m_parser_vars->m_exe_ctx->target) + else if (target) { - var = FindGlobalVariable(*m_parser_vars->m_exe_ctx->target, - name_unique_cstr, - NULL); + var = FindGlobalVariable (*target, + name_unique_cstr, + NULL); if (var) { @@ -2183,7 +2238,7 @@ // We couldn't find a variable or function for this. Now we'll hunt for a generic // data symbol, and -- if it is found -- treat it as a variable. - Symbol *data_symbol = FindGlobalDataSymbol(*m_parser_vars->m_exe_ctx->target, name); + Symbol *data_symbol = FindGlobalDataSymbol(*target, name); if (data_symbol) { @@ -2221,10 +2276,10 @@ { // Clang is looking for the type of "this" - if (!m_parser_vars->m_exe_ctx->frame) + if (!frame) return; - VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false); + VariableList *vars = frame->GetVariableList(false); if (!vars) return; @@ -2232,8 +2287,8 @@ lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); if (!this_var || - !this_var->IsInScope(m_parser_vars->m_exe_ctx->frame) || - !this_var->LocationIsValidForFrame (m_parser_vars->m_exe_ctx->frame)) + !this_var->IsInScope(frame) || + !this_var->LocationIsValidForFrame (frame)) return; Type *this_type = this_var->GetType(); @@ -2286,10 +2341,10 @@ { // Clang is looking for the type of "*self" - if (!m_parser_vars->m_exe_ctx->frame) + if (!frame) return; - VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false); + VariableList *vars = frame->GetVariableList(false); if (!vars) return; @@ -2297,8 +2352,8 @@ lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); if (!self_var || - !self_var->IsInScope(m_parser_vars->m_exe_ctx->frame) || - !self_var->LocationIsValidForFrame (m_parser_vars->m_exe_ctx->frame)) + !self_var->IsInScope(frame) || + !self_var->LocationIsValidForFrame (frame)) return; Type *self_type = self_var->GetType(); @@ -2336,10 +2391,10 @@ do { - if (!m_parser_vars->m_exe_ctx->target) + if (!target) break; - ClangASTContext *scratch_clang_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext(); + ClangASTContext *scratch_clang_ast_context = target->GetScratchClangASTContext(); if (!scratch_clang_ast_context) break; @@ -2547,11 +2602,13 @@ lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; + Target *target = exe_ctx.GetTargetPtr(); + if (var_location_expr.IsLocationList()) { SymbolContext var_sc; var->CalculateSymbolContext (&var_sc); - loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); + loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target); } Error err; @@ -2600,7 +2657,7 @@ Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress(exe_ctx.target); + lldb::addr_t load_addr = so_addr.GetLoadAddress(target); if (load_addr != LLDB_INVALID_ADDRESS) { @@ -2708,7 +2765,12 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); + Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr(); + + if (target == NULL) + return; + + ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext(); TypeFromUser user_type (ClangASTContext::CreateLValueReferenceType(scratch_ast_context, ClangASTContext::GetVoidPtrType(scratch_ast_context, true)), scratch_ast_context); @@ -2731,7 +2793,7 @@ AddressRange &symbol_range = symbol.GetAddressRangeRef(); Address &symbol_address = symbol_range.GetBaseAddress(); - lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(m_parser_vars->m_exe_ctx->target); + lldb::addr_t symbol_load_addr = symbol_address.GetLoadAddress(target); symbol_location->SetContext(Value::eContextTypeClangType, user_type.GetOpaqueQualType()); symbol_location->GetScalar() = symbol_load_addr; @@ -2767,8 +2829,9 @@ ClangExpressionDeclMap::ResolveUnknownTypes() { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - - ASTContext *scratch_ast_context = m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext(); + Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr(); + + ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext(); for (size_t index = 0, num_entities = m_found_entities.GetSize(); index < num_entities; @@ -2934,7 +2997,9 @@ return; } - lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(m_parser_vars->m_exe_ctx->target); + Target *target = m_parser_vars->m_exe_ctx->GetTargetPtr(); + + lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(target); fun_location->SetValueType(Value::eValueTypeLoadAddress); fun_location->GetScalar() = load_addr; Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Sep 21 23:58:26 2011 @@ -463,9 +463,9 @@ if (decl_map) { Stream *error_stream = NULL; - - if (exe_ctx.target) - error_stream = &exe_ctx.target->GetDebugger().GetErrorStream(); + Target *target = exe_ctx.GetTargetPtr(); + if (target) + error_stream = &target->GetDebugger().GetErrorStream(); IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(), @@ -489,7 +489,9 @@ return err; } - if (!exe_ctx.process || execution_policy == eExecutionPolicyNever) + Process *process = exe_ctx.GetProcessPtr(); + + if (!process || execution_policy == eExecutionPolicyNever) { err.SetErrorToGenericError(); err.SetErrorString("Execution needed to run in the target, but the target can't be run"); @@ -498,9 +500,9 @@ if (execution_policy != eExecutionPolicyNever && m_expr.NeedsValidation() && - exe_ctx.process) + process) { - if (!exe_ctx.process->GetDynamicCheckers()) + if (!process->GetDynamicCheckers()) { DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); @@ -516,13 +518,13 @@ return err; } - exe_ctx.process->SetDynamicCheckers(dynamic_checkers); + process->SetDynamicCheckers(dynamic_checkers); if (log) log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers =="); } - IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str()); + IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(), function_name.c_str()); if (!ir_dynamic_checks.runOnModule(*module)) { @@ -586,9 +588,9 @@ m_jitted_functions.push_back (ClangExpressionParser::JittedFunction(function_name.c_str(), (lldb::addr_t)fun_ptr)); - ExecutionContext &exc_context(exe_ctx); - - if (exc_context.process == NULL) + + Process *process = exe_ctx.GetProcessPtr(); + if (process == NULL) { err.SetErrorToGenericError(); err.SetErrorString("Couldn't write the JIT compiled code into the target because there is no target"); @@ -615,7 +617,7 @@ } Error alloc_error; - func_allocation_addr = exc_context.process->AllocateMemory (alloc_size, + func_allocation_addr = process->AllocateMemory (alloc_size, lldb::ePermissionsReadable|lldb::ePermissionsExecutable, alloc_error); @@ -636,7 +638,7 @@ Error write_error; - if (exc_context.process->WriteMemory(cursor, (void *) lstart, size, write_error) != size) + if (process->WriteMemory(cursor, (void *) lstart, size, write_error) != size) { err.SetErrorToGenericError(); err.SetErrorStringWithFormat("Couldn't copy JIT code for function into the target: %s", write_error.AsCString("unknown error")); @@ -731,7 +733,8 @@ if (log) log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second); - if (!exe_ctx.target) + Target *target = exe_ctx.GetTargetPtr(); + if (!target) { ret.SetErrorToGenericError(); ret.SetErrorString("Couldn't find the target"); @@ -739,8 +742,9 @@ lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0)); + Process *process = exe_ctx.GetProcessPtr(); Error err; - exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); + process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); if (!err.Success()) { @@ -749,7 +753,7 @@ return ret; } - ArchSpec arch(exe_ctx.target->GetArchitecture()); + ArchSpec arch(target->GetArchitecture()); Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL); @@ -760,7 +764,7 @@ return ret; } - if (!exe_ctx.process) + if (!process) { ret.SetErrorToGenericError(); ret.SetErrorString("Couldn't find the process"); @@ -768,8 +772,8 @@ } DataExtractor extractor(buffer_sp, - exe_ctx.process->GetByteOrder(), - exe_ctx.target->GetArchitecture().GetAddressByteSize()); + process->GetByteOrder(), + target->GetArchitecture().GetAddressByteSize()); if (log) { Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Sep 21 23:58:26 2011 @@ -237,7 +237,7 @@ bool ClangFunction::WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors) { - Process *process = exe_ctx.process; + Process *process = exe_ctx.GetProcessPtr(); if (!process) return false; @@ -266,8 +266,8 @@ if (!jit_error.Success()) return false; - if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = exe_ctx.process->GetSP(); + if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) + m_jit_process_sp = process->GetSP(); return true; } @@ -299,7 +299,7 @@ using namespace clang; ExecutionResults return_value = eExecutionSetupError; - Process *process = exe_ctx.process; + Process *process = exe_ctx.GetProcessPtr(); if (process == NULL) return return_value; @@ -324,7 +324,7 @@ } // TODO: verify fun_addr needs to be a callable address - Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.target)); + Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.GetTargetPtr())); int first_offset = m_member_offsets[0]; process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error); @@ -394,8 +394,8 @@ lldb::addr_t *cmd_arg) { // FIXME: Use the errors Stream for better error reporting. - - if (exe_ctx.thread == NULL) + Thread *thread = exe_ctx.GetThreadPtr(); + if (thread == NULL) { errors.Printf("Can't call a function without a valid thread."); return NULL; @@ -404,7 +404,7 @@ // Okay, now run the function: Address wrapper_address (NULL, func_addr); - ThreadPlan *new_plan = new ThreadPlanCallFunction (*exe_ctx.thread, + ThreadPlan *new_plan = new ThreadPlanCallFunction (*thread, wrapper_address, args_addr, stop_others, @@ -420,7 +420,7 @@ // Read the return value - it is the last field in the struct: // FIXME: How does clang tell us there's no return value? We need to handle that case. - Process *process = exe_ctx.process; + Process *process = exe_ctx.GetProcessPtr(); if (process == NULL) return false; @@ -446,7 +446,7 @@ if (pos != m_wrapper_args_addrs.end()) m_wrapper_args_addrs.erase(pos); - exe_ctx.process->DeallocateMemory(args_addr); + exe_ctx.GetProcessRef().DeallocateMemory(args_addr); } ExecutionResults @@ -490,16 +490,24 @@ Stream &errors, lldb::addr_t *this_arg) { - lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exe_ctx, function_address, void_arg, - errors, stop_others, discard_on_error, - this_arg)); + lldb::ThreadPlanSP call_plan_sp (ClangFunction::GetThreadPlanToCallFunction (exe_ctx, + function_address, + void_arg, + errors, + stop_others, + discard_on_error, + this_arg)); if (call_plan_sp == NULL) return eExecutionSetupError; call_plan_sp->SetPrivate(true); - return exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error, - single_thread_timeout_usec, errors); + return exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, call_plan_sp, + stop_others, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + errors); } ExecutionResults Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Sep 21 23:58:26 2011 @@ -80,12 +80,13 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx) { - m_target = exe_ctx.target; + m_target = exe_ctx.GetTargetPtr(); - if (!exe_ctx.frame) + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame == NULL) return; - SymbolContext sym_ctx = exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextFunction); + SymbolContext sym_ctx = frame->GetSymbolContext(lldb::eSymbolContextFunction); if (!sym_ctx.function) return; @@ -246,7 +247,7 @@ // Set up the target and compiler // - Target *target = exe_ctx.target; + Target *target = exe_ctx.GetTargetPtr(); if (!target) { @@ -268,7 +269,8 @@ return false; } - ClangExpressionParser parser(exe_ctx.process, *this); + Process *process = exe_ctx.GetProcessPtr(); + ClangExpressionParser parser(process, *this); unsigned num_errors = parser.Parse (error_stream); @@ -285,8 +287,8 @@ // Prepare the output of the parser for execution, evaluating it statically if possible // - if (execution_policy != eExecutionPolicyNever && exe_ctx.process) - m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process)); + if (execution_policy != eExecutionPolicyNever && process) + m_data_allocator.reset(new ProcessDataAllocator(*process)); Error jit_error = parser.PrepareForExecution (m_jit_alloc, m_jit_start_addr, @@ -309,8 +311,8 @@ if (jit_error.Success()) { - if (exe_ctx.process && m_jit_alloc != LLDB_INVALID_ADDRESS) - m_jit_process_sp = exe_ctx.process->GetSP(); + if (process && m_jit_alloc != LLDB_INVALID_ADDRESS) + m_jit_process_sp = process->GetSP(); return true; } else @@ -505,7 +507,7 @@ const bool try_all_threads = true; Address wrapper_address (NULL, m_jit_start_addr); - lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), + lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(), wrapper_address, struct_address, stop_others, @@ -526,13 +528,13 @@ if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --"); - ExecutionResults execution_result = exe_ctx.process->RunThreadPlan (exe_ctx, - call_plan_sp, - stop_others, - try_all_threads, - discard_on_error, - single_thread_timeout_usec, - error_stream); + ExecutionResults execution_result = exe_ctx.GetProcessRef().RunThreadPlan (exe_ctx, + call_plan_sp, + stop_others, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_stream); if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --"); @@ -602,7 +604,9 @@ ExecutionResults execution_results = eExecutionSetupError; - if (exe_ctx.process == NULL || exe_ctx.process->GetState() != lldb::eStateStopped) + Process *process = exe_ctx.GetProcessPtr(); + + if (process == NULL || process->GetState() != lldb::eStateStopped) { if (execution_policy == eExecutionPolicyAlways) { @@ -615,7 +619,7 @@ } } - if (exe_ctx.process == NULL || !exe_ctx.process->CanJIT()) + if (process == NULL || !process->CanJIT()) execution_policy = eExecutionPolicyNever; ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix)); Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Wed Sep 21 23:58:26 2011 @@ -77,7 +77,7 @@ // Set up the target and compiler // - Target *target = exe_ctx.target; + Target *target = exe_ctx.GetTargetPtr(); if (!target) { @@ -85,7 +85,7 @@ return false; } - Process *process = exe_ctx.process; + Process *process = exe_ctx.GetProcessPtr(); if (!process) { @@ -101,7 +101,7 @@ m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory)); - m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process)); + m_data_allocator.reset(new ProcessDataAllocator(*process)); if (!m_expr_decl_map->WillParse(exe_ctx)) { @@ -147,8 +147,8 @@ log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str()); } - if (exe_ctx.process && m_jit_start_addr != LLDB_INVALID_ADDRESS) - m_jit_process_sp = exe_ctx.process->GetSP(); + if (m_jit_start_addr != LLDB_INVALID_ADDRESS) + m_jit_process_sp = process->GetSP(); #if 0 // jingham: look here Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Wed Sep 21 23:58:26 2011 @@ -930,10 +930,14 @@ { uint32_t offset = 0; addr_t pc; + StackFrame *frame = NULL; if (reg_ctx) pc = reg_ctx->GetPC(); else - pc = exe_ctx->frame->GetRegisterContext()->GetPC(); + { + frame = exe_ctx->GetFramePtr(); + pc = frame->GetRegisterContext()->GetPC(); + } if (loclist_base_load_addr != LLDB_INVALID_ADDRESS) { @@ -1000,8 +1004,16 @@ { std::vector stack; - if (reg_ctx == NULL && exe_ctx && exe_ctx->frame) - reg_ctx = exe_ctx->frame->GetRegisterContext().get(); + Process *process = NULL; + StackFrame *frame = NULL; + + if (exe_ctx) + { + process = exe_ctx->GetProcessPtr(); + frame = exe_ctx->GetFramePtr(); + } + if (reg_ctx == NULL && frame) + reg_ctx = frame->GetRegisterContext().get(); if (initial_value_ptr) stack.push_back(*initial_value_ptr); @@ -1110,15 +1122,15 @@ case Value::eValueTypeLoadAddress: if (exe_ctx) { - if (exe_ctx->process) + if (process) { lldb::addr_t pointer_addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS); uint8_t addr_bytes[sizeof(lldb::addr_t)]; - uint32_t addr_size = exe_ctx->process->GetAddressByteSize(); + uint32_t addr_size = process->GetAddressByteSize(); Error error; - if (exe_ctx->process->ReadMemory(pointer_addr, &addr_bytes, addr_size, error) == addr_size) + if (process->ReadMemory(pointer_addr, &addr_bytes, addr_size, error) == addr_size) { - DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), exe_ctx->process->GetByteOrder(), addr_size); + DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), addr_size); uint32_t addr_data_offset = 0; stack.back().GetScalar() = addr_data.GetPointer(&addr_data_offset); stack.back().ClearContext(); @@ -1202,14 +1214,14 @@ case Value::eValueTypeLoadAddress: if (exe_ctx) { - if (exe_ctx->process) + if (process) { lldb::addr_t pointer_addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS); uint8_t addr_bytes[sizeof(lldb::addr_t)]; Error error; - if (exe_ctx->process->ReadMemory(pointer_addr, &addr_bytes, size, error) == size) + if (process->ReadMemory(pointer_addr, &addr_bytes, size, error) == size) { - DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), exe_ctx->process->GetByteOrder(), size); + DataExtractor addr_data(addr_bytes, sizeof(addr_bytes), process->GetByteOrder(), size); uint32_t addr_data_offset = 0; switch (size) { @@ -2170,25 +2182,35 @@ break; case DW_OP_fbreg: - if (exe_ctx && exe_ctx->frame) + if (exe_ctx) { - Scalar value; - if (exe_ctx->frame->GetFrameBaseValue(value, error_ptr)) + if (frame) { - int64_t fbreg_offset = opcodes.GetSLEB128(&offset); - value += fbreg_offset; - stack.push_back(value); - stack.back().SetValueType (Value::eValueTypeLoadAddress); + Scalar value; + if (frame->GetFrameBaseValue(value, error_ptr)) + { + int64_t fbreg_offset = opcodes.GetSLEB128(&offset); + value += fbreg_offset; + stack.push_back(value); + stack.back().SetValueType (Value::eValueTypeLoadAddress); + } + else + return false; } else + { + if (error_ptr) + error_ptr->SetErrorString ("Invalid stack frame in context for DW_OP_fbreg opcode."); return false; + } } else { if (error_ptr) - error_ptr->SetErrorString ("Invalid stack frame in context for DW_OP_fbreg opcode."); + error_ptr->SetErrorStringWithFormat ("NULL execution context for DW_OP_fbreg.\n"); return false; } + break; //---------------------------------------------------------------------- @@ -2474,14 +2496,14 @@ data.SetByteSize(byte_size); Error error; - if (exe_ctx->process->ReadMemory (source_addr, data.GetBytes(), byte_size, error) != byte_size) + if (process->ReadMemory (source_addr, data.GetBytes(), byte_size, error) != byte_size) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); return false; } - if (exe_ctx->process->WriteMemory (target_addr, data.GetBytes(), byte_size, error) != byte_size) + if (process->WriteMemory (target_addr, data.GetBytes(), byte_size, error) != byte_size) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); @@ -2490,7 +2512,7 @@ } break; case Value::eValueTypeHostAddress: - if (exe_ctx->process->GetByteOrder() != lldb::endian::InlHostByteOrder()) + if (process->GetByteOrder() != lldb::endian::InlHostByteOrder()) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented"); @@ -2499,7 +2521,7 @@ else { Error error; - if (exe_ctx->process->ReadMemory (source_addr, (uint8_t*)target_addr, byte_size, error) != byte_size) + if (process->ReadMemory (source_addr, (uint8_t*)target_addr, byte_size, error) != byte_size) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); @@ -2515,7 +2537,7 @@ switch (target_value_type) { case Value::eValueTypeLoadAddress: - if (exe_ctx->process->GetByteOrder() != lldb::endian::InlHostByteOrder()) + if (process->GetByteOrder() != lldb::endian::InlHostByteOrder()) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Copy of composite types between incompatible byte orders is unimplemented"); @@ -2524,7 +2546,7 @@ else { Error error; - if (exe_ctx->process->WriteMemory (target_addr, (uint8_t*)source_addr, byte_size, error) != byte_size) + if (process->WriteMemory (target_addr, (uint8_t*)source_addr, byte_size, error) != byte_size) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Wed Sep 21 23:58:26 2011 @@ -56,9 +56,11 @@ if (!m_valid_pointer_check->Install(error_stream, exe_ctx)) return false; - if (exe_ctx.process) + Process *process = exe_ctx.GetProcessPtr(); + + if (process) { - ObjCLanguageRuntime *objc_language_runtime = exe_ctx.process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_language_runtime = process->GetObjCLanguageRuntime(); if (objc_language_runtime) { Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Sep 21 23:58:26 2011 @@ -1856,8 +1856,12 @@ CommandInterpreter::GetPlatform (bool prefer_target_platform) { PlatformSP platform_sp; - if (prefer_target_platform && m_exe_ctx.target) - platform_sp = m_exe_ctx.target->GetPlatform(); + if (prefer_target_platform) + { + Target *target = m_exe_ctx.GetTargetPtr(); + if (target) + platform_sp = target->GetPlatform(); + } if (!platform_sp) platform_sp = m_debugger.GetPlatformList().GetSelectedPlatform(); @@ -2222,31 +2226,32 @@ if (override_context != NULL) { - m_exe_ctx.target = override_context->target; - m_exe_ctx.process = override_context->process; - m_exe_ctx.thread = override_context->thread; - m_exe_ctx.frame = override_context->frame; + m_exe_ctx = *override_context; } else { TargetSP target_sp (m_debugger.GetSelectedTarget()); if (target_sp) { - m_exe_ctx.target = target_sp.get(); - m_exe_ctx.process = target_sp->GetProcessSP().get(); - if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning()) + m_exe_ctx.SetTargetSP (target_sp); + ProcessSP process_sp (target_sp->GetProcessSP()); + m_exe_ctx.SetProcessSP (process_sp); + if (process_sp && process_sp->IsAlive() && !process_sp->IsRunning()) { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get(); - if (m_exe_ctx.thread) + ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread().get()); + if (thread_sp) { - m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get(); - if (m_exe_ctx.frame == NULL) + m_exe_ctx.SetThreadSP (thread_sp); + StackFrameSP frame_sp (thread_sp->GetSelectedFrame()); + if (!frame_sp) { - m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); + frame_sp = thread_sp->GetStackFrameAtIndex (0); // If we didn't have a selected frame select one here. - if (m_exe_ctx.frame != NULL) - m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame); + if (frame_sp) + thread_sp->SetSelectedFrame(frame_sp.get()); } + if (frame_sp) + m_exe_ctx.SetFrameSP (frame_sp); } } } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Wed Sep 21 23:58:26 2011 @@ -232,7 +232,7 @@ if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) { - Process *process = m_interpreter.GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process == NULL) { // A process that is not running is considered paused. Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Wed Sep 21 23:58:26 2011 @@ -138,7 +138,7 @@ be_raw = false; ignore_cap = false; - Target *target = interpreter.GetExecutionContext().target; + Target *target = interpreter.GetExecutionContext().GetTargetPtr(); if (target != NULL) use_dynamic = target->GetPreferDynamicValue(); else Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Sep 21 23:58:26 2011 @@ -314,9 +314,9 @@ run_string.Clear(); - ExecutionContext exe_ctx = m_interpreter.GetDebugger().GetSelectedExecutionContext(); + ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetSelectedExecutionContext()); - if (exe_ctx.target) + if (exe_ctx.GetTargetPtr()) run_string.Printf ("run_one_line (%s, 'lldb.target = lldb.debugger.GetSelectedTarget()')", m_dictionary_name.c_str()); else @@ -324,14 +324,14 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - if (exe_ctx.process) + if (exe_ctx.GetProcessPtr()) run_string.Printf ("run_one_line (%s, 'lldb.process = lldb.target.GetProcess()')", m_dictionary_name.c_str()); else run_string.Printf ("run_one_line (%s, 'lldb.process = None')", m_dictionary_name.c_str()); PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - if (exe_ctx.thread) + if (exe_ctx.GetThreadPtr()) run_string.Printf ("run_one_line (%s, 'lldb.thread = lldb.process.GetSelectedThread ()')", m_dictionary_name.c_str()); else @@ -339,7 +339,7 @@ PyRun_SimpleString (run_string.GetData()); run_string.Clear(); - if (exe_ctx.frame) + if (exe_ctx.GetFramePtr()) run_string.Printf ("run_one_line (%s, 'lldb.frame = lldb.thread.GetSelectedFrame ()')", m_dictionary_name.c_str()); else @@ -1560,7 +1560,7 @@ if (!context) return true; - Target *target = context->exe_ctx.target; + Target *target = context->exe_ctx.GetTargetPtr(); if (!target) return true; @@ -1575,8 +1575,7 @@ if (python_function_name != NULL && python_function_name[0] != '\0') { - Thread *thread = context->exe_ctx.thread; - const StackFrameSP stop_frame_sp (thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame)); + const StackFrameSP stop_frame_sp (context->exe_ctx.GetFrameSP()); BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); if (breakpoint_sp) { Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Wed Sep 21 23:58:26 2011 @@ -103,9 +103,12 @@ StreamString &comment, uint64_t operand_value, const Address &inst_addr) { Address so_addr; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) + Target *target = NULL; + if (exe_ctx) + target = exe_ctx->GetTargetPtr(); + if (target && !target->GetSectionLoadList().IsEmpty()) { - if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr)) + if (target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr)) so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); } else @@ -223,8 +226,11 @@ { addr_t base_addr = LLDB_INVALID_ADDRESS; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) - base_addr = GetAddress().GetLoadAddress (exe_ctx->target); + Target *target = NULL; + if (exe_ctx) + target = exe_ctx->GetTargetPtr(); + if (target && !target->GetSectionLoadList().IsEmpty()) + base_addr = GetAddress().GetLoadAddress (target); if (base_addr == LLDB_INVALID_ADDRESS) base_addr = GetAddress().GetFileAddress (); Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Sep 21 23:58:26 2011 @@ -505,7 +505,7 @@ if (dyld_instance->InitializeFromAllImageInfos()) return dyld_instance->GetStopWhenImagesChange(); - Process *process = context->exe_ctx.process; + Process *process = context->exe_ctx.GetProcessPtr(); const lldb::ABISP &abi = process->GetABI(); if (abi != NULL) { @@ -524,7 +524,7 @@ input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); argument_values.PushValue (input_value); - if (abi->GetArgumentValues (*context->exe_ctx.thread, argument_values)) + if (abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values)) { uint32_t dyld_mode = argument_values.GetValueAtIndex(0)->GetScalar().UInt (-1); if (dyld_mode != -1) Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Wed Sep 21 23:58:26 2011 @@ -65,18 +65,19 @@ ExecutionContext exe_ctx; exe_scope->CalculateExecutionContext(exe_ctx); - - if (!exe_ctx.process) + Process *process = exe_ctx.GetProcessPtr(); + if (!process) return false; // We need other parts of the exe_ctx, but the processes have to match. - assert (m_process == exe_ctx.process); + assert (m_process == process); // Get the function address for the print function. const Address *function_address = GetPrintForDebuggerAddr(); if (!function_address) return false; + Target *target = exe_ctx.GetTargetPtr(); if (value.GetClangType()) { clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); @@ -89,7 +90,7 @@ else { // If it is not a pointer, see if we can make it into a pointer. - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + ClangASTContext *ast_context = target->GetScratchClangASTContext(); void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id(); if (opaque_type_ptr == NULL) opaque_type_ptr = ast_context->GetVoidPtrType(false); @@ -100,7 +101,7 @@ arg_value_list.PushValue(value); // This is the return value: - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); + ClangASTContext *ast_context = target->GetScratchClangASTContext(); void *return_qualtype = ast_context->GetCStringType(true); Value ret; @@ -144,7 +145,7 @@ size_t curr_len = full_buffer_len; while (curr_len == full_buffer_len) { - curr_len = exe_ctx.process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); + curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); strm.Write (buf, curr_len); cstr_len += curr_len; } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Wed Sep 21 23:58:26 2011 @@ -398,7 +398,7 @@ { // The Update function is called with the address of an added region. So we grab that address, and // feed it into ReadRegions. Of course, our friend the ABI will get the values for us. - Process *process = context->exe_ctx.process; + Process *process = context->exe_ctx.GetProcessPtr(); const ABI *abi = process->GetABI().get(); ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext(); @@ -409,7 +409,7 @@ input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); argument_values.PushValue(input_value); - bool success = abi->GetArgumentValues (*(context->exe_ctx.thread), argument_values); + bool success = abi->GetArgumentValues (context->exe_ctx.GetThreadRef(), argument_values); if (!success) return false; @@ -878,7 +878,8 @@ { ConstString our_utility_function_name("__lldb_objc_find_implementation_for_selector"); SymbolContextList sc_list; - exe_ctx.target->GetImages().FindSymbolsWithNameAndType (our_utility_function_name, eSymbolTypeCode, sc_list); + + exe_ctx.GetTargetRef().GetImages().FindSymbolsWithNameAndType (our_utility_function_name, eSymbolTypeCode, sc_list); if (sc_list.GetSize() == 1) { SymbolContext sc; @@ -886,7 +887,7 @@ if (sc.symbol != NULL) impl_code_address = sc.symbol->GetValue(); - //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.target); + //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.GetTargetPtr()); //printf ("Getting address for our_utility_function: 0x%llx.\n", addr); } else Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp Wed Sep 21 23:58:26 2011 @@ -67,9 +67,9 @@ AppleThreadPlanStepThroughObjCTrampoline::DidPush () { StreamString errors; - ExecutionContext exc_context; - m_thread.CalculateExecutionContext(exc_context); - m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others)); + ExecutionContext exc_ctx; + m_thread.CalculateExecutionContext(exc_ctx); + m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_ctx, m_args_addr, errors, m_stop_others)); m_func_sp->SetPrivate(true); m_thread.QueueThreadPlan (m_func_sp, false); } @@ -116,13 +116,13 @@ if (!m_run_to_sp) { Value target_addr_value; - ExecutionContext exc_context; - m_thread.CalculateExecutionContext(exc_context); - m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value); - m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr); + ExecutionContext exc_ctx; + m_thread.CalculateExecutionContext(exc_ctx); + m_impl_function->FetchFunctionResults (exc_ctx, m_args_addr, target_addr_value); + m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr); lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong(); Address target_so_addr; - target_so_addr.SetOpcodeLoadAddress(target_addr, exc_context.target); + target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr()); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (target_addr == 0) { Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Wed Sep 21 23:58:26 2011 @@ -113,7 +113,7 @@ m_inst_emulator_ap->SetInstruction (inst->GetOpcode(), inst->GetAddress(), - exe_ctx.target); + exe_ctx.GetTargetPtr()); m_inst_emulator_ap->EvaluateInstruction (eEmulateInstructionOptionIgnoreConditions); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 21 23:58:26 2011 @@ -3114,10 +3114,12 @@ // the changing size of base classes that are newer than this class. // So if we have a process around that we can ask about this object, do so. child_byte_offset = LLDB_INVALID_IVAR_OFFSET; - - if (exe_ctx && exe_ctx->process) + Process *process = NULL; + if (exe_ctx) + process = exe_ctx->GetProcessPtr(); + if (process) { - ObjCLanguageRuntime *objc_runtime = exe_ctx->process->GetObjCLanguageRuntime(); + ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime(); if (objc_runtime != NULL) { ClangASTType parent_ast_type (ast, parent_qual_type.getAsOpaquePtr()); Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Sep 21 23:58:26 2011 @@ -1132,37 +1132,40 @@ clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); if (ClangASTContext::IsCStringType (clang_type, length)) { - - if (exe_ctx && exe_ctx->process) + if (exe_ctx) { - uint32_t offset = data_byte_offset; - lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size); - std::vector buf; - if (length > 0) - buf.resize (length); - else - buf.resize (256); - - lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4); - buf.back() = '\0'; - size_t bytes_read; - size_t total_cstr_len = 0; - Error error; - while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) + Process *process = exe_ctx->GetProcessPtr(); + if (process) { - const size_t len = strlen((const char *)&buf.front()); - if (len == 0) - break; - if (total_cstr_len == 0) - s->PutCString (" \""); - cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); - total_cstr_len += len; - if (len < buf.size()) - break; - pointer_addresss += total_cstr_len; + uint32_t offset = data_byte_offset; + lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size); + std::vector buf; + if (length > 0) + buf.resize (length); + else + buf.resize (256); + + lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), process->GetByteOrder(), 4); + buf.back() = '\0'; + size_t bytes_read; + size_t total_cstr_len = 0; + Error error; + while ((bytes_read = process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) + { + const size_t len = strlen((const char *)&buf.front()); + if (len == 0) + break; + if (total_cstr_len == 0) + s->PutCString (" \""); + cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + total_cstr_len += len; + if (len < buf.size()) + break; + pointer_addresss += total_cstr_len; + } + if (total_cstr_len > 0) + s->PutChar ('"'); } - if (total_cstr_len > 0) - s->PutChar ('"'); } } } @@ -1656,10 +1659,13 @@ } else { - if (exe_ctx && exe_ctx->process) + Process *process = NULL; + if (exe_ctx) + process = exe_ctx->GetProcessPtr(); + if (process) { Error error; - return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size; + return process->ReadMemory(addr, dst, byte_size, error) == byte_size; } } } @@ -1713,10 +1719,13 @@ } else { - if (exe_ctx && exe_ctx->process) + Process *process = NULL; + if (exe_ctx) + process = exe_ctx->GetProcessPtr(); + if (process) { Error error; - return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size; + return process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size; } } } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Wed Sep 21 23:58:26 2011 @@ -357,8 +357,11 @@ if (address != LLDB_INVALID_ADDRESS) { DataExtractor data; - if (exe_ctx->target) - data.SetByteOrder (exe_ctx->target->GetArchitecture().GetByteOrder()); + Target *target = NULL; + if (exe_ctx) + target = exe_ctx->GetTargetPtr(); + if (target) + data.SetByteOrder (target->GetArchitecture().GetByteOrder()); if (ReadFromMemory (exe_ctx, address, address_type, data)) { DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose); @@ -397,10 +400,14 @@ } else { - if (exe_ctx && exe_ctx->process) + if (exe_ctx) { - Error error; - return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size; + Process *process = exe_ctx->GetProcessPtr(); + if (process) + { + Error error; + return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, error) == byte_size; + } } } } Modified: lldb/trunk/source/Target/ExecutionContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/ExecutionContext.cpp (original) +++ lldb/trunk/source/Target/ExecutionContext.cpp Wed Sep 21 23:58:26 2011 @@ -17,36 +17,57 @@ using namespace lldb_private; ExecutionContext::ExecutionContext() : - target (NULL), - process (NULL), - thread (NULL), - frame (NULL) + m_target_sp (), + m_process_sp (), + m_thread_sp (), + m_frame_sp () { } +ExecutionContext::ExecutionContext (const ExecutionContext &rhs) : + m_target_sp (rhs.m_target_sp), + m_process_sp(rhs.m_process_sp), + m_thread_sp (rhs.m_thread_sp), + m_frame_sp (rhs.m_frame_sp) +{ +} + +ExecutionContext & +ExecutionContext::operator =(const ExecutionContext &rhs) +{ + if (this != &rhs) + { + m_target_sp = rhs.m_target_sp; + m_process_sp = rhs.m_process_sp; + m_thread_sp = rhs.m_thread_sp; + m_frame_sp = rhs.m_frame_sp; + } + return *this; +} + ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) : - target (t), - process (NULL), - thread (NULL), - frame (NULL) + m_target_sp (t), + m_process_sp (), + m_thread_sp (), + m_frame_sp () { if (t && fill_current_process_thread_frame) { - process = t->GetProcessSP().get(); - if (process) + m_process_sp = t->GetProcessSP(); + if (m_process_sp) { - thread = process->GetThreadList().GetSelectedThread().get(); - if (thread) - frame = thread->GetSelectedFrame().get(); + m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread(); + if (m_thread_sp) + m_frame_sp = m_thread_sp->GetSelectedFrame().get(); } } } -ExecutionContext::ExecutionContext(Process* p, Thread *t, StackFrame *f) : - target (p ? &p->GetTarget() : NULL), - process (p), - thread (t), - frame (f) +ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) : + m_target_sp (process ? &process->GetTarget() : NULL), + m_process_sp (process), + m_thread_sp (thread), + m_frame_sp (frame) { } @@ -56,10 +77,10 @@ exe_scope_ptr->CalculateExecutionContext (*this); else { - target = NULL; - process = NULL; - thread = NULL; - frame = NULL; + m_target_sp.reset(); + m_process_sp.reset(); + m_thread_sp.reset(); + m_frame_sp.reset(); } } @@ -71,41 +92,132 @@ void ExecutionContext::Clear() { - target = NULL; - process = NULL; - thread = NULL; - frame = NULL; + m_target_sp.reset(); + m_process_sp.reset(); + m_thread_sp.reset(); + m_frame_sp.reset(); +} + +ExecutionContext::~ExecutionContext() +{ } RegisterContext * ExecutionContext::GetRegisterContext () const { - if (frame) - return frame->GetRegisterContext().get(); - else if (thread) - return thread->GetRegisterContext().get(); + if (m_frame_sp) + return m_frame_sp->GetRegisterContext().get(); + else if (m_thread_sp) + return m_thread_sp->GetRegisterContext().get(); return NULL; } -ExecutionContextScope * -ExecutionContext::GetBestExecutionContextScope () const +Target * +ExecutionContext::GetTargetPtr () const { - if (frame) - return frame; - if (thread) - return thread; - if (process) - return process; - return target; + if (m_target_sp) + return m_target_sp.get(); + if (m_process_sp) + return &m_process_sp->GetTarget(); + return NULL; } Process * -ExecutionContext::GetProcess () const +ExecutionContext::GetProcessPtr () const { - if (process) - return process; - if (target) - return target->GetProcessSP().get(); + if (m_process_sp) + return m_process_sp.get(); + if (m_target_sp) + return m_target_sp->GetProcessSP().get(); return NULL; } + +ExecutionContextScope * +ExecutionContext::GetBestExecutionContextScope () const +{ + if (m_frame_sp) + return m_frame_sp.get(); + if (m_thread_sp) + return m_thread_sp.get(); + if (m_process_sp) + return m_process_sp.get(); + return m_target_sp.get(); +} + +Target & +ExecutionContext::GetTargetRef () const +{ + assert (m_target_sp.get()); + return *m_target_sp; +} + +Process & +ExecutionContext::GetProcessRef () const +{ + assert (m_process_sp.get()); + return *m_process_sp; +} + +Thread & +ExecutionContext::GetThreadRef () const +{ + assert (m_thread_sp.get()); + return *m_thread_sp; +} + +StackFrame & +ExecutionContext::GetFrameRef () const +{ + assert (m_frame_sp.get()); + return *m_frame_sp; +} + +void +ExecutionContext::SetTargetSP (const lldb::TargetSP &target_sp) +{ + m_target_sp = target_sp; +} + +void +ExecutionContext::SetProcessSP (const lldb::ProcessSP &process_sp) +{ + m_process_sp = process_sp; +} + +void +ExecutionContext::SetThreadSP (const lldb::ThreadSP &thread_sp) +{ + m_thread_sp = thread_sp; +} + +void +ExecutionContext::SetFrameSP (const lldb::StackFrameSP &frame_sp) +{ + m_frame_sp = frame_sp; +} + +void +ExecutionContext::SetTargetPtr (Target* target) +{ + m_target_sp = target; +} + +void +ExecutionContext::SetProcessPtr (Process *process) +{ + m_process_sp = process; +} + +void +ExecutionContext::SetThreadPtr (Thread *thread) +{ + m_thread_sp = thread; +} + +void +ExecutionContext::SetFramePtr (StackFrame *frame) +{ + m_frame_sp = frame; +} + Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Sep 21 23:58:26 2011 @@ -3128,10 +3128,10 @@ void Process::CalculateExecutionContext (ExecutionContext &exe_ctx) { - exe_ctx.target = &m_target; - exe_ctx.process = this; - exe_ctx.thread = NULL; - exe_ctx.frame = NULL; + exe_ctx.SetTargetPtr (&m_target); + exe_ctx.SetProcessPtr (this); + exe_ctx.SetThreadPtr(NULL); + exe_ctx.SetFramePtr (NULL); } lldb::ProcessSP @@ -3368,6 +3368,19 @@ errors.Printf("RunThreadPlan called with empty thread plan."); return eExecutionSetupError; } + + if (exe_ctx.GetProcessPtr() != this) + { + errors.Printf("RunThreadPlan called on wrong process."); + return eExecutionSetupError; + } + + Thread *thread = exe_ctx.GetThreadPtr(); + if (thread == NULL) + { + errors.Printf("RunThreadPlan called with invalid thread."); + return eExecutionSetupError; + } // We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes. // For that to be true the plan can't be private - since private plans suppress themselves in the @@ -3383,13 +3396,13 @@ } // Save the thread & frame from the exe_ctx for restoration after we run - const uint32_t thread_idx_id = exe_ctx.thread->GetIndexID(); - StackID ctx_frame_id = exe_ctx.thread->GetSelectedFrame()->GetStackID(); + const uint32_t thread_idx_id = thread->GetIndexID(); + StackID ctx_frame_id = thread->GetSelectedFrame()->GetStackID(); // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, // so we should arrange to reset them as well. - lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread(); + lldb::ThreadSP selected_thread_sp = GetThreadList().GetSelectedThread(); uint32_t selected_tid; StackID selected_stack_id; @@ -3403,7 +3416,7 @@ selected_tid = LLDB_INVALID_THREAD_ID; } - exe_ctx.thread->QueueThreadPlan(thread_plan_sp, true); + thread->QueueThreadPlan(thread_plan_sp, true); Listener listener("lldb.process.listener.run-thread-plan"); @@ -3418,8 +3431,8 @@ StreamString s; thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); log->Printf ("Process::RunThreadPlan(): Resuming thread %u - 0x%4.4x to run thread plan \"%s\".", - exe_ctx.thread->GetIndexID(), - exe_ctx.thread->GetID(), + thread->GetIndexID(), + thread->GetID(), s.GetData()); } @@ -3443,7 +3456,7 @@ { // Do the initial resume and wait for the running event before going further. - Error resume_error = exe_ctx.process->Resume (); + Error resume_error = Resume (); if (!resume_error.Success()) { errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); @@ -3522,7 +3535,7 @@ case lldb::eStateStopped: { // Yay, we're done. Now make sure that our thread plan actually completed. - ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (thread_idx_id); + ThreadSP thread_sp = GetThreadList().FindThreadByIndexID (thread_idx_id); if (!thread_sp) { // Ooh, our thread has vanished. Unlikely that this was successful execution... @@ -3614,7 +3627,7 @@ single_thread_timeout_usec); } - Error halt_error = exe_ctx.process->Halt(); + Error halt_error = Halt(); if (halt_error.Success()) { if (log) @@ -3643,7 +3656,7 @@ // Between the time we initiated the Halt and the time we delivered it, the process could have // already finished its job. Check that here: - if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + if (thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " @@ -3717,7 +3730,7 @@ // Between the time we initiated the Halt and the time we delivered it, the process could have // already finished its job. Check that here: - if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + if (thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " @@ -3845,7 +3858,7 @@ if (discard_on_error && thread_plan_sp) { - exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread->DiscardThreadPlansUpToPlan (thread_plan_sp); thread_plan_sp->SetPrivate (orig_plan_private); } } @@ -3857,19 +3870,19 @@ if (discard_on_error && thread_plan_sp) { - exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread->DiscardThreadPlansUpToPlan (thread_plan_sp); thread_plan_sp->SetPrivate (orig_plan_private); } } else { - if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) + if (thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) log->PutCString("Process::RunThreadPlan(): thread plan is done"); return_value = eExecutionCompleted; } - else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) + else if (thread->WasThreadPlanDiscarded (thread_plan_sp.get())) { if (log) log->PutCString("Process::RunThreadPlan(): thread plan was discarded"); @@ -3883,7 +3896,7 @@ { if (log) log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set."); - exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread->DiscardThreadPlansUpToPlan (thread_plan_sp); thread_plan_sp->SetPrivate (orig_plan_private); } } @@ -3892,10 +3905,10 @@ // Thread we ran the function in may have gone away because we ran the target // Check that it's still there, and if it is put it back in the context. Also restore the // frame in the context if it is still present. - exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(thread_idx_id, true).get(); - if (exe_ctx.thread) + thread = GetThreadList().FindThreadByIndexID(thread_idx_id, true).get(); + if (thread) { - exe_ctx.frame = exe_ctx.thread->GetFrameWithStackID (ctx_frame_id).get(); + exe_ctx.SetFrameSP (thread->GetFrameWithStackID (ctx_frame_id)); } // Also restore the current process'es selected frame & thread, since this function calling may @@ -3903,12 +3916,12 @@ if (selected_tid != LLDB_INVALID_THREAD_ID) { - if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid()) + if (GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid()) { // We were able to restore the selected thread, now restore the frame: - StackFrameSP old_frame_sp = exe_ctx.process->GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id); + StackFrameSP old_frame_sp = GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id); if (old_frame_sp) - exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get()); + GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get()); } } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Wed Sep 21 23:58:26 2011 @@ -1168,7 +1168,7 @@ StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx) { m_thread.CalculateExecutionContext (exe_ctx); - exe_ctx.frame = this; + exe_ctx.SetFramePtr(this); } void Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Wed Sep 21 23:58:26 2011 @@ -225,7 +225,7 @@ } else { - Debugger &debugger = context.exe_ctx.target->GetDebugger(); + Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger(); StreamSP error_sp = debugger.GetAsyncErrorStream (); error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint "); bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Sep 21 23:58:26 2011 @@ -1177,10 +1177,8 @@ void Target::CalculateExecutionContext (ExecutionContext &exe_ctx) { - exe_ctx.target = this; - exe_ctx.process = NULL; // Do NOT fill in process... - exe_ctx.thread = NULL; - exe_ctx.frame = NULL; + exe_ctx.Clear(); + exe_ctx.SetTargetPtr(this); } PathMappingList & @@ -1278,11 +1276,8 @@ Target *target = NULL; if (sc_ptr != NULL) target = sc_ptr->target_sp.get(); - if (target == NULL) - { - if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL) - target = &exe_ctx_ptr->process->GetTarget(); - } + if (target == NULL && exe_ctx_ptr) + target = exe_ctx_ptr->GetTargetPtr(); return target; } @@ -1656,7 +1651,7 @@ if ((cur_hook_sp->GetSpecifier () == NULL || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i])) && (cur_hook_sp->GetThreadSpecifier() == NULL - || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].thread))) + || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadPtr()))) { if (!hooks_ran) { @@ -1670,7 +1665,7 @@ } if (print_thread_header) - result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID()); + result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID()); bool stop_on_continue = true; bool stop_on_error = true; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Wed Sep 21 23:58:26 2011 @@ -912,8 +912,8 @@ Thread::CalculateExecutionContext (ExecutionContext &exe_ctx) { m_process.CalculateExecutionContext (exe_ctx); - exe_ctx.thread = this; - exe_ctx.frame = NULL; + exe_ctx.SetThreadPtr (this); + exe_ctx.SetFramePtr (NULL); } @@ -943,16 +943,17 @@ Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx) { ExecutionContext exe_ctx; + StackFrameSP frame_sp; SymbolContext frame_sc; CalculateExecutionContext (exe_ctx); if (frame_idx != LLDB_INVALID_INDEX32) { - StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx)); + frame_sp = GetStackFrameAtIndex (frame_idx); if (frame_sp) { - exe_ctx.frame = frame_sp.get(); - frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything); + exe_ctx.SetFrameSP(frame_sp); + frame_sc = frame_sp->GetSymbolContext(eSymbolContextEverything); } } @@ -960,7 +961,7 @@ assert (thread_format); const char *end = NULL; Debugger::FormatPrompt (thread_format, - exe_ctx.frame ? &frame_sc : NULL, + frame_sp ? &frame_sc : NULL, &exe_ctx, NULL, strm, Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=140298&r1=140297&r2=140298&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Wed Sep 21 23:58:26 2011 @@ -102,7 +102,7 @@ m_did_stop = true; } } - else if (m_exe_ctx.thread->WasThreadPlanDiscarded (m_expression_plan_sp.get())) + else if (m_exe_ctx.GetThreadRef().WasThreadPlanDiscarded (m_expression_plan_sp.get())) { if (log) log->Printf("ExecuteExpression thread plan was discarded.\n"); From johnny.chen at apple.com Thu Sep 22 13:04:59 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 22 Sep 2011 18:04:59 -0000 Subject: [Lldb-commits] [lldb] r140322 - in /lldb/trunk: include/lldb/Breakpoint/ lldb.xcodeproj/ source/Breakpoint/ source/Commands/ source/Interpreter/ source/Target/ test/functionalities/watchpoint/hello_watchpoint/ Message-ID: <20110922180459.4F46D2A6C12C@llvm.org> Author: johnny Date: Thu Sep 22 13:04:58 2011 New Revision: 140322 URL: http://llvm.org/viewvc/llvm-project?rev=140322&view=rev Log: Add initial implementation of watchpoint commands for list, enable, disable, and delete. Test cases to be added later. Added: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.h Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Breakpoint/WatchpointLocation.cpp lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Thu Sep 22 13:04:58 2011 @@ -85,7 +85,7 @@ return m_hw_preferred; } - bool + virtual bool IsHardware () const { return m_hw_index != LLDB_INVALID_INDEX32; Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Thu Sep 22 13:04:58 2011 @@ -41,6 +41,9 @@ SetEnabled (bool enabled); virtual bool + IsHardware () const; + + virtual bool ShouldStop (StoppointCallbackContext *context); bool WatchpointRead () const; @@ -55,7 +58,8 @@ void DumpWithLevel (Stream *s, lldb::DescriptionLevel description_level) const; private: - bool m_enabled; // Is this breakpoint enabled + bool m_enabled; // Is this watchpoint enabled + bool m_is_hardware; // Is this a hardware watchpoint uint32_t m_watch_read:1, // 1 if we stop when the watched data is read from m_watch_write:1, // 1 if we stop when the watched data is written to m_watch_was_read:1, // Set to 1 when watchpoint is hit for a read access Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Thu Sep 22 13:04:58 2011 @@ -224,7 +224,6 @@ GetListMutex (lldb_private::Mutex::Locker &locker); protected: - typedef std::vector collection; typedef std::map addr_map; addr_map::iterator @@ -233,7 +232,6 @@ addr_map::const_iterator GetIDConstIterator(lldb::watch_id_t watchID) const; - collection m_locations; addr_map m_address_to_location; mutable Mutex m_mutex; }; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Sep 22 13:04:58 2011 @@ -442,6 +442,7 @@ 9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; }; 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; }; + B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */; }; B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */; }; B271B11413D6139300C3FEDB /* FormatClasses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94A9112D13D5DF210046D8A6 /* FormatClasses.cpp */; }; B27318421416AC12006039C8 /* WatchpointLocationList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B27318411416AC12006039C8 /* WatchpointLocationList.cpp */; }; @@ -1304,6 +1305,8 @@ AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindLLDB.cpp; path = Utility/UnwindLLDB.cpp; sourceTree = ""; }; AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = ""; }; AF94005711C03F6500085DB9 /* SymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolVendor.cpp; path = source/Symbol/SymbolVendor.cpp; sourceTree = ""; }; + B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectWatchpoint.cpp; path = source/Commands/CommandObjectWatchpoint.cpp; sourceTree = ""; }; + B207C4941429609C00F36E4E /* CommandObjectWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommandObjectWatchpoint.h; path = source/Commands/CommandObjectWatchpoint.h; sourceTree = ""; }; B23DD24F12EDFAC1000C3894 /* ARMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMUtils.h; path = Utility/ARMUtils.h; sourceTree = ""; }; B2462246141AD37D00F3D409 /* OptionGroupWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OptionGroupWatchpoint.cpp; path = source/Interpreter/OptionGroupWatchpoint.cpp; sourceTree = ""; }; B2462248141AD39B00F3D409 /* OptionGroupWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupWatchpoint.h; path = include/lldb/Interpreter/OptionGroupWatchpoint.h; sourceTree = ""; }; @@ -2257,6 +2260,8 @@ 9463D4CC13B1798800C230D4 /* CommandObjectType.cpp */, B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */, B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */, + B207C4941429609C00F36E4E /* CommandObjectWatchpoint.h */, + B207C4921429607D00F36E4E /* CommandObjectWatchpoint.cpp */, ); name = Commands; sourceTree = ""; @@ -3384,6 +3389,7 @@ B2462247141AD37D00F3D409 /* OptionGroupWatchpoint.cpp in Sources */, 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */, 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */, + B207C4931429607D00F36E4E /* CommandObjectWatchpoint.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Thu Sep 22 13:04:58 2011 @@ -21,6 +21,7 @@ WatchpointLocation::WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware) : StoppointLocation (GetNextID(), addr, size, hardware), m_enabled(0), + m_is_hardware(hardware), m_watch_read(0), m_watch_write(0), m_watch_was_read(0), @@ -58,28 +59,36 @@ } +bool +WatchpointLocation::IsHardware () const +{ + return m_is_hardware; +} + // RETURNS - true if we should stop at this breakpoint, false if we // should continue. bool WatchpointLocation::ShouldStop (StoppointCallbackContext *context) { - m_hit_count++; + ++m_hit_count; + + if (!IsEnabled()) + return false; + + if (m_hit_count <= GetIgnoreCount()) + return false; - if (m_hit_count > m_ignore_count) - { - 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 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; } void Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Thu Sep 22 13:04:58 2011 @@ -20,7 +20,6 @@ using namespace lldb_private; WatchpointLocationList::WatchpointLocationList() : - m_locations (), m_address_to_location (), m_mutex (Mutex::eMutexTypeRecursive) { @@ -41,21 +40,10 @@ addr_map::iterator iter = m_address_to_location.find(wp_addr); if (iter == m_address_to_location.end()) - { m_address_to_location.insert(iter, addr_map::value_type(wp_addr, wp_loc_sp)); - } else - { m_address_to_location[wp_addr] = wp_loc_sp; - collection::iterator pos, end = m_locations.end(); - for (pos = m_locations.begin(); pos != end; ++pos) - if ((*pos)->GetLoadAddress() == wp_addr) - { - m_locations.erase(pos); - break; - } - } - m_locations.push_back(wp_loc_sp); + return wp_loc_sp->GetID(); } @@ -154,9 +142,12 @@ { Mutex::Locker locker (m_mutex); WatchpointLocationSP wp_loc_sp; - if (i < m_locations.size()) - wp_loc_sp = m_locations[i]; - + if (i < m_address_to_location.size()) + { + addr_map::const_iterator pos = m_address_to_location.begin(); + std::advance(pos, i); + wp_loc_sp = pos->second; + } return wp_loc_sp; } @@ -165,9 +156,12 @@ { Mutex::Locker locker (m_mutex); WatchpointLocationSP wp_loc_sp; - if (i < m_locations.size()) - wp_loc_sp = m_locations[i]; - + if (i < m_address_to_location.size()) + { + addr_map::const_iterator pos = m_address_to_location.begin(); + std::advance(pos, i); + wp_loc_sp = pos->second; + } return wp_loc_sp; } @@ -175,17 +169,10 @@ WatchpointLocationList::Remove (lldb::watch_id_t watch_id) { Mutex::Locker locker (m_mutex); - addr_map::iterator pos = GetIDIterator(watch_id); // Predicate + addr_map::iterator pos = GetIDIterator(watch_id); if (pos != m_address_to_location.end()) { m_address_to_location.erase(pos); - collection::iterator pos, end = m_locations.end(); - for (pos = m_locations.begin(); pos != end; ++pos) - if ((*pos)->GetID() == watch_id) - { - m_locations.erase(pos); - break; - } return true; } return false; @@ -205,6 +192,7 @@ bool WatchpointLocationList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t watch_id) { + WatchpointLocationSP wp_loc_sp = FindByID (watch_id); if (wp_loc_sp) { @@ -245,14 +233,7 @@ WatchpointLocationList::RemoveAll () { Mutex::Locker locker(m_mutex); - - addr_map::iterator pos, end = m_address_to_location.end(); - for (pos = m_address_to_location.begin(); pos != end; ++pos) - m_address_to_location.erase(pos); - - collection::iterator p, e = m_locations.end(); - for (p = m_locations.begin(); p != e; ++pos) - m_locations.erase(p); + m_address_to_location.clear(); } void Added: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=140322&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (added) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Thu Sep 22 13:04:58 2011 @@ -0,0 +1,557 @@ +//===-- CommandObjectWatchpoint.cpp -----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectWatchpoint.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Breakpoint/WatchpointLocation.h" +#include "lldb/Breakpoint/WatchpointLocationList.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/Target.h" +#include "lldb/Interpreter/CommandCompletions.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +static void +AddWatchpointDescription(Stream *s, WatchpointLocation *wp_loc, lldb::DescriptionLevel level) +{ + s->IndentMore(); + wp_loc->GetDescription(s, level); + s->IndentLess(); + s->EOL(); +} + +static bool +CheckTargetForWatchpointOperations(Target *target, CommandReturnObject &result) +{ + if (target == NULL) + { + result.AppendError ("Invalid target. No existing target or watchpoints."); + result.SetStatus (eReturnStatusFailed); + return false; + } + bool process_is_valid = target->GetProcessSP() && target->GetProcessSP()->IsAlive(); + if (!process_is_valid) + { + result.AppendError ("Thre's no process or it is not alive."); + result.SetStatus (eReturnStatusFailed); + return false; + } + // Target passes our checks, return true. + return true; +} + +#include "llvm/ADT/StringRef.h" + +// Equivalent class: {"-", "to", "To", "TO"} of range specifier array. +static const char* RSA[4] = { "-", "to", "To", "TO" }; + +// Return the index to RSA if found; otherwise -1 is returned. +static int32_t +WithRSAIndex(llvm::StringRef &Arg) +{ + + uint32_t i; + for (i = 0; i < 4; ++i) + if (Arg.find(RSA[i]) != llvm::StringRef::npos) + return i; + return -1; +} + +// Return true if wp_ids is successfully populated with the watch ids. +// False otherwise. +static bool +VerifyWatchpointIDs(Args &args, std::vector &wp_ids) +{ + // Pre-condition: args.GetArgumentCount() > 0. + assert(args.GetArgumentCount() > 0); + + llvm::StringRef Minus("-"); + std::vector StrRefArgs; + std::pair Pair; + size_t i; + int32_t idx; + // Go through the argments and make a canonical form of arg list containing + // only numbers with possible "-" in between. + for (i = 0; i < args.GetArgumentCount(); ++i) { + llvm::StringRef Arg(args.GetArgumentAtIndex(i)); + if ((idx = WithRSAIndex(Arg)) == -1) { + StrRefArgs.push_back(Arg); + continue; + } + // The Arg contains the range specifier, split it, then. + Pair = Arg.split(RSA[idx]); + if (!Pair.first.empty()) + StrRefArgs.push_back(Pair.first); + StrRefArgs.push_back(Minus); + if (!Pair.second.empty()) + StrRefArgs.push_back(Pair.second); + } + // Now process the canonical list and fill in the vector of uint32_t's. + // If there is any error, return false and the client should ignore wp_ids. + uint32_t beg, end, id; + size_t size = StrRefArgs.size(); + bool in_range = false; + for (i = 0; i < size; ++i) { + llvm::StringRef Arg = StrRefArgs[i]; + if (in_range) { + // Look for the 'end' of the range. Note StringRef::getAsInteger() + // returns true to signify error while parsing. + if (Arg.getAsInteger(0, end)) + return false; + // Found a range! Now append the elements. + for (id = beg; id <= end; ++id) + wp_ids.push_back(id); + in_range = false; + continue; + } + if (i < (size - 1) && StrRefArgs[i+1] == Minus) { + if (Arg.getAsInteger(0, beg)) + return false; + // Turn on the in_range flag, we are looking for end of range next. + ++i; in_range = true; + continue; + } + // Otherwise, we have a simple ID. Just append it. + if (Arg.getAsInteger(0, beg)) + return false; + wp_ids.push_back(beg); + } + // It is an error if after the loop, we're still in_range. + if (in_range) + return false; + + return true; // Success! +} + +//------------------------------------------------------------------------- +// CommandObjectMultiwordWatchpoint +//------------------------------------------------------------------------- +#pragma mark MultiwordWatchpoint + +CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(CommandInterpreter &interpreter) : + CommandObjectMultiword (interpreter, + "watchpoint", + "A set of commands for operating on watchpoints.", + "watchpoint []") +{ + bool status; + + CommandObjectSP list_command_object (new CommandObjectWatchpointList (interpreter)); + CommandObjectSP enable_command_object (new CommandObjectWatchpointEnable (interpreter)); + CommandObjectSP disable_command_object (new CommandObjectWatchpointDisable (interpreter)); + CommandObjectSP delete_command_object (new CommandObjectWatchpointDelete (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"); + + status = LoadSubCommand ("list", list_command_object); + status = LoadSubCommand ("enable", enable_command_object); + status = LoadSubCommand ("disable", disable_command_object); + status = LoadSubCommand ("delete", delete_command_object); +} + +CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint() +{ +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointList::Options +//------------------------------------------------------------------------- +#pragma mark List::CommandOptions + +CommandObjectWatchpointList::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : + Options(interpreter), + m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to brief descriptions +{ +} + +CommandObjectWatchpointList::CommandOptions::~CommandOptions() +{ +} + +OptionDefinition +CommandObjectWatchpointList::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "brief", 'b', no_argument, NULL, 0, eArgTypeNone, + "Give a brief description of the watchpoint (no location info)."}, + + { LLDB_OPT_SET_2, false, "full", 'f', no_argument, NULL, 0, eArgTypeNone, + "Give a full description of the watchpoint and its locations."}, + + { LLDB_OPT_SET_3, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, + "Explain everything we know about the watchpoint (for debugging debugger bugs)." }, + + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + +const OptionDefinition* +CommandObjectWatchpointList::CommandOptions::GetDefinitions() +{ + return g_option_table; +} + +Error +CommandObjectWatchpointList::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 'b': + m_level = lldb::eDescriptionLevelBrief; + break; + case 'f': + m_level = lldb::eDescriptionLevelFull; + break; + case 'v': + m_level = lldb::eDescriptionLevelVerbose; + break; + default: + error.SetErrorStringWithFormat("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; +} + +void +CommandObjectWatchpointList::CommandOptions::OptionParsingStarting() +{ + m_level = lldb::eDescriptionLevelFull; +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointList +//------------------------------------------------------------------------- +#pragma mark List + +CommandObjectWatchpointList::CommandObjectWatchpointList(CommandInterpreter &interpreter) : + CommandObject(interpreter, + "watchpoint list", + "List all watchpoints at configurable levels of detail.", + NULL), + m_options(interpreter) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back(arg); +} + +CommandObjectWatchpointList::~CommandObjectWatchpointList() +{ +} + +Options * +CommandObjectWatchpointList::GetOptions() +{ + return &m_options; +} + +bool +CommandObjectWatchpointList::Execute(Args& args, CommandReturnObject &result) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (target == NULL) + { + result.AppendError ("Invalid target. No current target or watchpoints."); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + return true; + } + + const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + Mutex::Locker locker; + target->GetWatchpointLocationList().GetListMutex(locker); + + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendMessage("No watchpoints currently set."); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return true; + } + + Stream &output_stream = result.GetOutputStream(); + + if (args.GetArgumentCount() == 0) + { + // No watchpoint selected; show info about all currently set watchpoints. + result.AppendMessage ("Current watchpoints:"); + for (size_t i = 0; i < num_watchpoints; ++i) + { + WatchpointLocation *wp_loc = watchpoints.GetByIndex(i).get(); + AddWatchpointDescription(&output_stream, wp_loc, m_options.m_level); + } + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + else + { + // Particular watchpoints selected; enable them. + std::vector wp_ids; + if (!VerifyWatchpointIDs(args, wp_ids)) + { + result.AppendError("Invalid watchpoints specification."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + const size_t size = wp_ids.size(); + for (size_t i = 0; i < size; ++i) + { + WatchpointLocation *wp_loc = watchpoints.FindByID(wp_ids[i]).get(); + if (wp_loc) + AddWatchpointDescription(&output_stream, wp_loc, m_options.m_level); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + } + + return result.Succeeded(); +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointEnable +//------------------------------------------------------------------------- +#pragma mark Enable + +CommandObjectWatchpointEnable::CommandObjectWatchpointEnable(CommandInterpreter &interpreter) : + CommandObject(interpreter, + "enable", + "Enable the specified disabled watchpoint(s). If no watchpoints are specified, enable all of them.", + NULL) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back(arg); +} + +CommandObjectWatchpointEnable::~CommandObjectWatchpointEnable() +{ +} + +bool +CommandObjectWatchpointEnable::Execute(Args& args, CommandReturnObject &result) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (!CheckTargetForWatchpointOperations(target, result)) + return false; + + Mutex::Locker locker; + target->GetWatchpointLocationList().GetListMutex(locker); + + const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendError("No watchpoints exist to be enabled."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (args.GetArgumentCount() == 0) + { + // No watchpoint selected; enable all currently set watchpoints. + target->EnableAllWatchpointLocations(); + result.AppendMessageWithFormat("All watchpoints enabled. (%lu watchpoints)\n", num_watchpoints); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + else + { + // Particular watchpoints selected; enable 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) + if (target->EnableWatchpointLocationByID(wp_ids[i])) + ++count; + result.AppendMessageWithFormat("%d watchpoints enabled.\n", count); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointDisable +//------------------------------------------------------------------------- +#pragma mark Disable + +CommandObjectWatchpointDisable::CommandObjectWatchpointDisable(CommandInterpreter &interpreter) : + CommandObject(interpreter, + "watchpoint disable", + "Disable the specified watchpoint(s) without removing it/them. If no watchpoints are specified, disable them all.", + NULL) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back(arg); +} + +CommandObjectWatchpointDisable::~CommandObjectWatchpointDisable() +{ +} + +bool +CommandObjectWatchpointDisable::Execute(Args& args, CommandReturnObject &result) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (!CheckTargetForWatchpointOperations(target, result)) + return false; + + Mutex::Locker locker; + target->GetWatchpointLocationList().GetListMutex(locker); + + const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendError("No watchpoints exist to be disabled."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (args.GetArgumentCount() == 0) + { + // No watchpoint selected; disable all currently set watchpoints. + if (target->DisableAllWatchpointLocations()) + { + result.AppendMessageWithFormat("All watchpoints disabled. (%lu watchpoints)\n", num_watchpoints); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError("Disable all watchpoints failed\n"); + result.SetStatus(eReturnStatusFailed); + } + } + else + { + // Particular watchpoints selected; disable 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) + if (target->DisableWatchpointLocationByID(wp_ids[i])) + ++count; + result.AppendMessageWithFormat("%d watchpoints disabled.\n", count); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + +//------------------------------------------------------------------------- +// CommandObjectWatchpointDelete +//------------------------------------------------------------------------- +#pragma mark Delete + +CommandObjectWatchpointDelete::CommandObjectWatchpointDelete(CommandInterpreter &interpreter) : + CommandObject(interpreter, + "watchpoint delete", + "Delete the specified watchpoint(s). If no watchpoints are specified, delete them all.", + NULL) +{ + CommandArgumentEntry arg; + CommandObject::AddIDsArgumentData(arg); + // Add the entry for the first argument for this command to the object's arguments vector. + m_arguments.push_back(arg); +} + +CommandObjectWatchpointDelete::~CommandObjectWatchpointDelete() +{ +} + +bool +CommandObjectWatchpointDelete::Execute(Args& args, CommandReturnObject &result) +{ + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + if (!CheckTargetForWatchpointOperations(target, result)) + return false; + + Mutex::Locker locker; + target->GetWatchpointLocationList().GetListMutex(locker); + + const WatchpointLocationList &watchpoints = target->GetWatchpointLocationList(); + + size_t num_watchpoints = watchpoints.GetSize(); + + if (num_watchpoints == 0) + { + result.AppendError("No watchpoints exist to be deleted."); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (args.GetArgumentCount() == 0) + { + if (!m_interpreter.Confirm("About to delete all watchpoints, do you want to do that?", true)) + { + result.AppendMessage("Operation cancelled..."); + } + else + { + target->RemoveAllWatchpointLocations(); + result.AppendMessageWithFormat("All watchpoints removed. (%lu watchpoints)\n", num_watchpoints); + } + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + // Particular watchpoints selected; delete 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) + if (target->RemoveWatchpointLocationByID(wp_ids[i])) + ++count; + result.AppendMessageWithFormat("%d watchpoints deleted.\n",count); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + + return result.Succeeded(); +} + Added: lldb/trunk/source/Commands/CommandObjectWatchpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.h?rev=140322&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.h (added) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.h Thu Sep 22 13:04:58 2011 @@ -0,0 +1,145 @@ +//===-- CommandObjectWatchpoint.h -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandObjectWatchpoint_h_ +#define liblldb_CommandObjectWatchpoint_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Interpreter/Options.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// CommandObjectMultiwordWatchpoint +//------------------------------------------------------------------------- + +class CommandObjectMultiwordWatchpoint : public CommandObjectMultiword +{ +public: + CommandObjectMultiwordWatchpoint (CommandInterpreter &interpreter); + + virtual + ~CommandObjectMultiwordWatchpoint (); +}; + +//------------------------------------------------------------------------- +// CommandObjectWatchpointList +//------------------------------------------------------------------------- + +class CommandObjectWatchpointList : public CommandObject +{ +public: + CommandObjectWatchpointList (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointList (); + + 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. + + lldb::DescriptionLevel m_level; + }; + +private: + CommandOptions m_options; +}; + +//------------------------------------------------------------------------- +// CommandObjectWatchpointEnable +//------------------------------------------------------------------------- + +class CommandObjectWatchpointEnable : public CommandObject +{ +public: + CommandObjectWatchpointEnable (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointEnable (); + + virtual bool + Execute (Args& command, + CommandReturnObject &result); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectWatchpointDisable +//------------------------------------------------------------------------- + +class CommandObjectWatchpointDisable : public CommandObject +{ +public: + CommandObjectWatchpointDisable (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointDisable (); + + virtual bool + Execute (Args& command, + CommandReturnObject &result); + +private: +}; + +//------------------------------------------------------------------------- +// CommandObjectWatchpointDelete +//------------------------------------------------------------------------- + +class CommandObjectWatchpointDelete : public CommandObject +{ +public: + CommandObjectWatchpointDelete (CommandInterpreter &interpreter); + + virtual + ~CommandObjectWatchpointDelete (); + + virtual bool + Execute (Args& command, + CommandReturnObject &result); + +private: +}; + +} // namespace lldb_private + +#endif // liblldb_CommandObjectWatchpoint_h_ Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Sep 22 13:04:58 2011 @@ -37,6 +37,7 @@ #include "../Commands/CommandObjectThread.h" #include "../Commands/CommandObjectType.h" #include "../Commands/CommandObjectVersion.h" +#include "../Commands/CommandObjectWatchpoint.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" @@ -266,6 +267,7 @@ m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); m_command_dict["type"] = CommandObjectSP (new CommandObjectType (*this)); m_command_dict["version"] = CommandObjectSP (new CommandObjectVersion (*this)); + m_command_dict["watchpoint"]= CommandObjectSP (new CommandObjectMultiwordWatchpoint (*this)); std::auto_ptr break_regex_cmd_ap(new CommandObjectRegexCommand (*this, Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Sep 22 13:04:58 2011 @@ -586,7 +586,6 @@ if (rc.Fail()) return false; } - m_watchpoint_location_list.SetEnabledAll (false); return true; // Success! } @@ -612,7 +611,6 @@ if (rc.Fail()) return false; } - m_watchpoint_location_list.SetEnabledAll (true); return true; // Success! } @@ -631,11 +629,10 @@ if (wp_loc_sp) { Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); - if (rc.Fail()) - return false; + if (rc.Success()) + return true; - wp_loc_sp->SetEnabled (false); - return true; + // Else, fallthrough. } return false; } @@ -655,11 +652,10 @@ if (wp_loc_sp) { Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); - if (rc.Fail()) - return false; + if (rc.Success()) + return true; - wp_loc_sp->SetEnabled (true); - return true; + // Else, fallthrough. } return false; } 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=140322&r1=140321&r2=140322&view=diff ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py (original) +++ lldb/trunk/test/functionalities/watchpoint/hello_watchpoint/TestMyFirstWatchpoint.py Thu Sep 22 13:04:58 2011 @@ -62,6 +62,11 @@ substrs = ['Watchpoint created', 'size = 4', 'type = w', '%s:%d' % (self.source, self.decl)]) + # 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']) + self.runCmd("process continue") # We should be stopped again due to the watchpoint (write type), but @@ -76,6 +81,11 @@ self.expect("process status", substrs = ['exited']) + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should now be 1. + self.expect("watchpoint list -v", + substrs = ['hit_count = 1']) + if __name__ == '__main__': import atexit From gclayton at apple.com Thu Sep 22 16:17:19 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 22 Sep 2011 21:17:19 -0000 Subject: [Lldb-commits] [lldb] r140338 - /lldb/trunk/include/lldb/API/SBDefines.h Message-ID: <20110922211719.ECB462A6C12C@llvm.org> Author: gclayton Date: Thu Sep 22 16:17:19 2011 New Revision: 140338 URL: http://llvm.org/viewvc/llvm-project?rev=140338&view=rev Log: Added missing forward declarations for SBFileSpecList and SBInstructionList. Modified: lldb/trunk/include/lldb/API/SBDefines.h Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=140338&r1=140337&r2=140338&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Thu Sep 22 16:17:19 2011 @@ -40,11 +40,13 @@ class SBEvent; class SBEventList; class SBFileSpec; +class SBFileSpecList; class SBFrame; class SBFunction; class SBHostOS; class SBInputReader; class SBInstruction; +class SBInstructionList; class SBLineEntry; class SBListener; class SBModule; From johnny.chen at apple.com Thu Sep 22 17:34:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 22 Sep 2011 22:34:09 -0000 Subject: [Lldb-commits] [lldb] r140346 - in /lldb/trunk: include/lldb/Interpreter/CommandObject.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectBreakpoint.cpp source/Commands/CommandObjectWatchpoint.cpp source/Interpreter/CommandObject.cpp Message-ID: <20110922223409.7FABA2A6C12E@llvm.org> Author: johnny Date: Thu Sep 22 17:34:09 2011 New Revision: 140346 URL: http://llvm.org/viewvc/llvm-project?rev=140346&view=rev Log: Watchpoint IDs and ID Ranges are not quite the same as Breakpoint IDs and ID Ranges. Add eArgTypeWatchpointID and eArgTypeWatchpointIDRange to the CommandArgumentType enums and modify the signature of CommandObject::AddIDsArgumentData() from: AddIDsArgumentData(CommandArgumentEntry &arg) to: AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange) to accommodate. Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=140346&r1=140345&r2=140346&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Thu Sep 22 17:34:09 2011 @@ -365,7 +365,7 @@ // Helper function to populate IDs or ID ranges as the command argument data // to the specified command argument entry. static void - AddIDsArgumentData(CommandArgumentEntry &arg); + AddIDsArgumentData(CommandArgumentEntry &arg, lldb::CommandArgumentType ID, lldb::CommandArgumentType IDRange); }; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=140346&r1=140345&r2=140346&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Sep 22 17:34:09 2011 @@ -408,6 +408,8 @@ eArgTypeWidth, eArgTypeNone, eArgTypePlatform, + eArgTypeWatchpointID, + eArgTypeWatchpointIDRange, eArgTypeWatchType, eArgTypeLastArg // Always keep this entry as the last entry in this enumeration!! } CommandArgumentType; Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140346&r1=140345&r2=140346&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu Sep 22 17:34:09 2011 @@ -805,7 +805,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(arg); + CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -906,7 +906,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(arg); + CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -1187,7 +1187,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(arg); + CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } @@ -1447,7 +1447,7 @@ m_options (interpreter) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(arg); + CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID, eArgTypeBreakpointIDRange); // Add the entry for the first argument for this command to the object's arguments vector. m_arguments.push_back (arg); } Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=140346&r1=140345&r2=140346&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Thu Sep 22 17:34:09 2011 @@ -251,7 +251,7 @@ m_options(interpreter) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(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); } @@ -339,7 +339,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(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); } @@ -411,7 +411,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(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); } @@ -489,7 +489,7 @@ NULL) { CommandArgumentEntry arg; - CommandObject::AddIDsArgumentData(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); } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=140346&r1=140345&r2=140346&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Thu Sep 22 17:34:09 2011 @@ -744,17 +744,17 @@ } void -CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg) +CommandObject::AddIDsArgumentData(CommandArgumentEntry &arg, CommandArgumentType ID, CommandArgumentType IDRange) { CommandArgumentData id_arg; CommandArgumentData id_range_arg; // Create the first variant for the first (and only) argument for this command. - id_arg.arg_type = eArgTypeBreakpointID; + id_arg.arg_type = ID; id_arg.arg_repetition = eArgRepeatOptional; // Create the second variant for the first (and only) argument for this command. - id_range_arg.arg_type = eArgTypeBreakpointIDRange; + id_range_arg.arg_type = IDRange; id_range_arg.arg_repetition = eArgRepeatOptional; // The first (and only) argument for this command could be either an id or an id_range. @@ -850,6 +850,8 @@ { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, { NULL, false }, "Help text goes here." }, { eArgTypeNone, "none", CommandCompletions::eNoCompletion, { NULL, false }, "No help available for this." }, { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, { NULL, false }, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }, + { eArgTypeWatchpointID, "watchpt-id", CommandCompletions::eNoCompletion, { NULL, false }, "Watchpoint IDs are positive integers." }, + { eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { NULL, false }, "For example, '1-3' or '1 to 3'." }, { eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { NULL, false }, "Specify the type for a watchpoint." } }; From jmolenda at apple.com Thu Sep 22 19:27:44 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 23 Sep 2011 00:27:44 -0000 Subject: [Lldb-commits] [lldb] r140357 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20110923002744.A2F7D2A6C12C@llvm.org> Author: jmolenda Date: Thu Sep 22 19:27:44 2011 New Revision: 140357 URL: http://llvm.org/viewvc/llvm-project?rev=140357&view=rev Log: LookupAddressInModule: Remove a couple of the extra newlines output at the end of 'image lookup' / 'image lookup -v'. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140357&r1=140356&r2=140357&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Sep 22 19:27:44 2011 @@ -1337,12 +1337,10 @@ strm.SetIndentLevel (save_indent + 11); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); strm.SetIndentLevel (save_indent); - strm.EOL(); // Print out detailed address information when verbose is enabled if (verbose) { - if (so_addr.Dump (&strm, exe_scope, Address::DumpStyleDetailedSymbolContext)) - strm.EOL(); + so_addr.Dump (&strm, exe_scope, Address::DumpStyleDetailedSymbolContext); } strm.IndentLess(); return true; From jmolenda at apple.com Thu Sep 22 19:42:55 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 23 Sep 2011 00:42:55 -0000 Subject: [Lldb-commits] [lldb] r140358 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20110923004255.A0BCD2A6C12C@llvm.org> Author: jmolenda Date: Thu Sep 22 19:42:55 2011 New Revision: 140358 URL: http://llvm.org/viewvc/llvm-project?rev=140358&view=rev Log: Remove the Stop Hooks / End Stop Hooks lines before/after running the stop-hooks. I've been living on lldb with some stop-hooks defined for the past week and the five extra lines of output on every stop is really detracting from the usefulness of this feature. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140358&r1=140357&r2=140358&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Sep 22 19:42:55 2011 @@ -1651,7 +1651,6 @@ { if (!hooks_ran) { - result.AppendMessage("\n** Stop Hooks **"); hooks_ran = true; } if (print_hook_header && !any_thread_matched) @@ -1686,9 +1685,7 @@ } } } - if (hooks_ran) - result.AppendMessage ("\n** End Stop Hooks **\n"); - + result.GetImmediateOutputStream()->Flush(); result.GetImmediateErrorStream()->Flush(); } From jingham at apple.com Thu Sep 22 19:54:11 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 23 Sep 2011 00:54:11 -0000 Subject: [Lldb-commits] [lldb] r140362 - in /lldb/trunk: include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ scripts/Python/interface/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Host/common/ source/Plugins/DynamicLoader/Darwin-Kernel/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ test/functionali... Message-ID: <20110923005411.CFC5E2A6C12C@llvm.org> Author: jingham Date: Thu Sep 22 19:54:11 2011 New Revision: 140362 URL: http://llvm.org/viewvc/llvm-project?rev=140362&view=rev Log: Added the ability to restrict breakpoints by function name, function regexp, selector etc to specific source files. Added SB API's to specify these source files & also more than one module. Added an "exact" option to CompileUnit's FindLineEntry API. Added: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/a.c lldb/trunk/test/functionalities/breakpoint/breakpoint_command/b.c Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBFileSpecList.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h lldb/trunk/include/lldb/Core/FileSpecList.h lldb/trunk/include/lldb/Core/SearchFilter.h lldb/trunk/include/lldb/Symbol/CompileUnit.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/scripts/Python/interface/SBCompileUnit.i lldb/trunk/scripts/Python/interface/SBFileSpecList.i lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBFileSpecList.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/FileLineResolver.cpp lldb/trunk/source/Core/FileSpecList.cpp lldb/trunk/source/Core/SearchFilter.cpp lldb/trunk/source/Host/common/FileSpec.cpp lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/breakpoint/breakpoint_command/Makefile lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Thu Sep 22 19:54:11 2011 @@ -47,6 +47,12 @@ uint32_t line, lldb::SBFileSpec *inline_file_spec) const; + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec, + bool exact) const; + #ifndef SWIG bool Modified: lldb/trunk/include/lldb/API/SBFileSpecList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpecList.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpecList.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpecList.h Thu Sep 22 19:54:11 2011 @@ -44,13 +44,15 @@ Clear(); uint32_t - FindFileIndex (uint32_t idx, const SBFileSpec &sb_file); + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); const SBFileSpec GetFileSpecAtIndex (uint32_t idx) const; private: +friend class SBTarget; + #ifndef SWIG const lldb_private::FileSpecList * Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Thu Sep 22 19:54:11 2011 @@ -14,6 +14,7 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBType.h" namespace lldb { @@ -315,10 +316,27 @@ BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); lldb::SBBreakpoint - BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); + BreakpointCreateByRegex (const char *symbol_name_regex, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, + const lldb::SBFileSpec &source_file, + const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, + const SBFileSpecList &module_list, + const lldb::SBFileSpecList &source_file); lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolverFileRegex.h Thu Sep 22 19:54:11 2011 @@ -29,7 +29,6 @@ { public: BreakpointResolverFileRegex (Breakpoint *bkpt, - const FileSpec &resolver, RegularExpression ®ex); virtual @@ -58,8 +57,7 @@ protected: friend class Breakpoint; - FileSpec m_file_spec; // This is the file spec we are looking for. - RegularExpression m_regex; // This is the line number that we are looking for. + RegularExpression m_regex; // This is the line expression that we are looking for. private: DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex); Modified: lldb/trunk/include/lldb/Core/FileSpecList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpecList.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpecList.h (original) +++ lldb/trunk/include/lldb/Core/FileSpecList.h Thu Sep 22 19:54:11 2011 @@ -116,12 +116,15 @@ /// @param[in] file /// The file specification to search for. /// + /// @param[in] full + /// Should FileSpec::Equal be called with "full" true or false. + /// /// @return /// The index of the file that matches \a file if it is found, /// else UINT32_MAX is returned. //------------------------------------------------------------------ uint32_t - FindFileIndex (uint32_t idx, const FileSpec &file) const; + FindFileIndex (uint32_t idx, const FileSpec &file, bool full) const; //------------------------------------------------------------------ /// Get file at index. Modified: lldb/trunk/include/lldb/Core/SearchFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/SearchFilter.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/SearchFilter.h (original) +++ lldb/trunk/include/lldb/Core/SearchFilter.h Thu Sep 22 19:54:11 2011 @@ -217,6 +217,21 @@ SearchInModuleList (Searcher &searcher, ModuleList &modules); //------------------------------------------------------------------ + /// This determines which items are REQUIRED for the filter to pass. + /// For instance, if you are filtering by Compilation Unit, obviously + /// symbols that have no compilation unit can't pass So return eSymbolContextCU + /// and search callbacks can then short cut the search to avoid looking at + /// things that obviously won't pass. + /// + /// @return + /// The required elements for the search, which is an or'ed together + /// set of lldb:SearchContextItem enum's. + /// + //------------------------------------------------------------------ + virtual uint32_t + GetFilterRequiredItems (); + + //------------------------------------------------------------------ /// Prints a canonical description for the search filter to the stream \a s. /// /// @param[in] s @@ -311,6 +326,9 @@ virtual void GetDescription(Stream *s); + virtual uint32_t + GetFilterRequiredItems (); + virtual void Dump (Stream *s) const; @@ -369,6 +387,65 @@ virtual void GetDescription(Stream *s); + virtual uint32_t + GetFilterRequiredItems (); + + virtual void + Dump (Stream *s) const; + + virtual void + Search (Searcher &searcher); + +private: + FileSpecList m_module_spec_list; +}; + +class SearchFilterByModuleListAndCU : + public SearchFilterByModuleList +{ +public: + + //------------------------------------------------------------------ + /// The basic constructor takes a Target, which gives the space to search, + /// and the module list to restrict the search to. + /// + /// @param[in] target + /// The Target that provides the module list to search. + /// + /// @param[in] module + /// The Module that limits the search. + //------------------------------------------------------------------ + SearchFilterByModuleListAndCU (lldb::TargetSP &targetSP, + const FileSpecList &module_list, + const FileSpecList &cu_list); + + SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs); + + virtual + ~SearchFilterByModuleListAndCU (); + + const SearchFilterByModuleListAndCU& + operator=(const SearchFilterByModuleListAndCU& rhs); + + virtual bool + SymbolContextPasses (const SymbolContext &context, + lldb::SymbolContextItem scope); + + virtual bool + AddressPasses (Address &address); + + virtual bool + CompUnitPasses (FileSpec &fileSpec); + + virtual bool + CompUnitPasses (CompileUnit &compUnit); + + virtual void + GetDescription(Stream *s); + + virtual uint32_t + GetFilterRequiredItems (); + virtual void Dump (Stream *s) const; @@ -377,6 +454,7 @@ private: FileSpecList m_module_spec_list; + FileSpecList m_cu_spec_list; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original) +++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Thu Sep 22 19:54:11 2011 @@ -202,6 +202,10 @@ /// else if NULL, search for line entries that match the compile /// unit file. /// + /// @param[in] exact + /// If \btrue match only if there is a line table entry for this line number. + /// If \bfalse, find the line table entry equal to or after this line number. + /// /// @param[out] line_entry /// If non-NULL, a copy of the line entry that was found. /// @@ -213,6 +217,7 @@ FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, + bool exact, LineEntry *line_entry); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Thu Sep 22 19:54:11 2011 @@ -250,10 +250,10 @@ bool check_inlines, bool internal = false); - // Use this to create breakpoint that matches regex against the source lines in file: + // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list: lldb::BreakpointSP - CreateBreakpoint (const FileSpecList *containingModules, - const FileSpec &file, + CreateSourceRegexBreakpoint (const FileSpecList *containingModules, + const FileSpecList *source_file_list, RegularExpression &source_regex, bool internal = false); @@ -267,11 +267,12 @@ CreateBreakpoint (Address &addr, bool internal = false); - // Use this to create a function breakpoint by regexp in containingModule, or all modules if it is NULL + // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL // When "skip_prologue is set to eLazyBoolCalculate, we use the current target // setting, else we use the values passed in lldb::BreakpointSP - CreateBreakpoint (const FileSpecList *containingModules, + CreateFuncRegexBreakpoint (const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, RegularExpression &func_regexp, bool internal = false, LazyBool skip_prologue = eLazyBoolCalculate); @@ -281,6 +282,7 @@ // setting, else we use the values passed in lldb::BreakpointSP CreateBreakpoint (const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_name, uint32_t func_name_type_mask, bool internal = false, @@ -889,6 +891,10 @@ lldb::SearchFilterSP GetSearchFilterForModuleList (const FileSpecList *containingModuleList); + + lldb::SearchFilterSP + GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles); + static void ImageSearchPathsChanged (const PathMappingList &path_list, Modified: lldb/trunk/scripts/Python/interface/SBCompileUnit.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBCompileUnit.i?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBCompileUnit.i (original) +++ lldb/trunk/scripts/Python/interface/SBCompileUnit.i Thu Sep 22 19:54:11 2011 @@ -71,6 +71,12 @@ uint32_t line, lldb::SBFileSpec *inline_file_spec) const; + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec, + bool exact) const; + bool GetDescription (lldb::SBStream &description); }; Modified: lldb/trunk/scripts/Python/interface/SBFileSpecList.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFileSpecList.i?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBFileSpecList.i (original) +++ lldb/trunk/scripts/Python/interface/SBFileSpecList.i Thu Sep 22 19:54:11 2011 @@ -34,7 +34,7 @@ Clear(); uint32_t - FindFileIndex (uint32_t idx, const SBFileSpec &sb_file); + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); const SBFileSpec GetFileSpecAtIndex (uint32_t idx) const; Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Thu Sep 22 19:54:11 2011 @@ -99,6 +99,13 @@ uint32_t SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { + const bool exact = true; + return FindLineEntryIndex (start_idx, line, inline_file_spec, exact); +} + +uint32_t +SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec, bool exact) const +{ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); uint32_t index = UINT32_MAX; @@ -114,6 +121,7 @@ index = m_opaque_ptr->FindLineEntry (start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL, + exact, NULL); } Modified: lldb/trunk/source/API/SBFileSpecList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpecList.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpecList.cpp (original) +++ lldb/trunk/source/API/SBFileSpecList.cpp Thu Sep 22 19:54:11 2011 @@ -80,9 +80,9 @@ } uint32_t -SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file) +SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full) { - return m_opaque_ap->FindFileIndex (idx, sb_file.ref()); + return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full); } const SBFileSpec Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Thu Sep 22 19:54:11 2011 @@ -575,18 +575,18 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; - if (m_opaque_sp.get() && symbol_name && symbol_name[0]) + if (m_opaque_sp.get()) { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); if (module_name && module_name[0]) { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false); } } @@ -599,6 +599,34 @@ return sb_bp; } +lldb::SBBreakpoint +SBTarget::BreakpointCreateByName (const char *symbol_name, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBBreakpoint sb_bp; + if (m_opaque_sp.get() && symbol_name && symbol_name[0]) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + *sb_bp = m_opaque_sp->CreateBreakpoint (module_list.get(), + comp_unit_list.get(), + symbol_name, + eFunctionNameTypeFull | eFunctionNameTypeBase, + false); + } + + if (log) + { + log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), symbol_name, sb_bp.get()); + } + + return sb_bp; +} + + SBBreakpoint SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) { @@ -615,11 +643,11 @@ FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, regexp, false); + *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false); + *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, false); } } @@ -632,7 +660,30 @@ return sb_bp; } +lldb::SBBreakpoint +SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBBreakpoint sb_bp; + if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + RegularExpression regexp(symbol_name_regex); + + *sb_bp = m_opaque_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, false); + } + + if (log) + { + log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), symbol_name_regex, sb_bp.get()); + } + return sb_bp; +} SBBreakpoint SBTarget::BreakpointCreateByAddress (addr_t address) @@ -664,17 +715,19 @@ { Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); RegularExpression regexp(source_regex); + FileSpecList source_file_spec_list; + source_file_spec_list.Append (source_file.ref()); if (module_name && module_name[0]) { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = m_opaque_sp->CreateBreakpoint (&module_spec_list, source_file.ref(), regexp, false); + *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false); } else { - *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, source_file.ref(), regexp, false); + *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false); } } @@ -689,6 +742,29 @@ return sb_bp; } +lldb::SBBreakpoint +SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, + const SBFileSpecList &module_list, + const lldb::SBFileSpecList &source_file_list) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBBreakpoint sb_bp; + if (m_opaque_sp.get() && source_regex && source_regex[0]) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + RegularExpression regexp(source_regex); + *sb_bp = m_opaque_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false); + } + + if (log) + { + log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), source_regex, sb_bp.get()); + } + + return sb_bp; +} SBBreakpoint SBTarget::FindBreakpointByID (break_id_t bp_id) Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp Thu Sep 22 19:54:11 2011 @@ -29,11 +29,9 @@ BreakpointResolverFileRegex::BreakpointResolverFileRegex ( Breakpoint *bkpt, - const FileSpec &file_spec, RegularExpression ®ex ) : BreakpointResolver (bkpt, BreakpointResolver::FileLineResolver), - m_file_spec (file_spec), m_regex (regex) { } @@ -60,62 +58,58 @@ CompileUnit *cu = context.comp_unit; FileSpec cu_file_spec = *(static_cast(cu)); - if (cu_file_spec == m_file_spec - || (!m_file_spec.GetDirectory() && cu_file_spec.GetFilename() == m_file_spec.GetFilename())) + std::vector line_matches; + context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); + uint32_t num_matches = line_matches.size(); + for (int i = 0; i < num_matches; i++) { - std::vector line_matches; - context.target_sp->GetSourceManager().FindLinesMatchingRegex(cu_file_spec, m_regex, 1, UINT32_MAX, line_matches); - uint32_t num_matches = line_matches.size(); - for (int i = 0; i < num_matches; i++) + uint32_t start_idx = 0; + bool exact = false; + while (1) { - uint32_t start_idx = 0; - while (1) - { - LineEntry line_entry; + LineEntry line_entry; + + // Cycle through all the line entries that might match this one: + start_idx = cu->FindLineEntry (start_idx, line_matches[i], NULL, exact, &line_entry); + if (start_idx == UINT32_MAX) + break; + exact = true; + start_idx++; - // Cycle through all the line entries that might match this one: - start_idx = cu->FindLineEntry (start_idx, line_matches[i], NULL, &line_entry); - if (start_idx == UINT32_MAX) - break; - start_idx++; - - Address line_start = line_entry.range.GetBaseAddress(); - if (line_start.IsValid()) + Address line_start = line_entry.range.GetBaseAddress(); + if (line_start.IsValid()) + { + if (filter.AddressPasses(line_start)) { - if (filter.AddressPasses(line_start)) + BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); + if (log && bp_loc_sp && !m_breakpoint->IsInternal()) { - BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start)); - if (log && bp_loc_sp && !m_breakpoint->IsInternal()) - { - StreamString s; - bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Added location: %s\n", s.GetData()); - } - } - else if (log) - { - log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass filter.\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString(""), - line_matches[i]); + StreamString s; + bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Added location: %s\n", s.GetData()); } } - else + else if (log) { - if (log) - log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n", - line_start.GetFileAddress(), - m_file_spec.GetFilename().AsCString(""), - line_matches[i]); + log->Printf ("Breakpoint at file address 0x%llx for %s:%d didn't pass filter.\n", + line_start.GetFileAddress(), + cu_file_spec.GetFilename().AsCString(""), + line_matches[i]); } - } + else + { + if (log) + log->Printf ("error: Unable to set breakpoint at file address 0x%llx for %s:%d\n", + line_start.GetFileAddress(), + cu_file_spec.GetFilename().AsCString(""), + line_matches[i]); + } + } - assert (m_breakpoint != NULL); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); - - } + assert (m_breakpoint != NULL); + return Searcher::eCallbackReturnContinue; } @@ -128,7 +122,7 @@ void BreakpointResolverFileRegex::GetDescription (Stream *s) { - s->Printf ("file ='%s', regular expression = \"%s\"", m_file_spec.GetFilename().AsCString(), m_regex.GetText()); + s->Printf ("source regex = \"%s\"", m_regex.GetText()); } void Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Thu Sep 22 19:54:11 2011 @@ -161,16 +161,22 @@ const bool include_symbols = false; const bool append = false; + bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0; + switch (m_match_type) { case Breakpoint::Exact: if (context.module_sp) { - if (context.module_sp->FindFunctions (m_func_name, + uint32_t num_functions = context.module_sp->FindFunctions (m_func_name, m_func_name_type_mask, include_symbols, append, - func_list) == 0) + func_list); + // If the search filter specifies a Compilation Unit, then we don't need to bother to look in plain + // symbols, since all the ones from a set compilation unit will have been found above already. + + if (num_functions == 0 && !filter_by_cu) { if (m_func_name_type_mask & (eFunctionNameTypeBase | eFunctionNameTypeFull)) context.module_sp->FindSymbolsWithNameAndType (m_func_name, eSymbolTypeCode, sym_list); @@ -180,7 +186,8 @@ case Breakpoint::Regexp: if (context.module_sp) { - context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, eSymbolTypeCode, sym_list); + if (!filter_by_cu) + context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, eSymbolTypeCode, sym_list); context.module_sp->FindFunctions (m_regex, include_symbols, append, @@ -192,7 +199,26 @@ log->Warning ("glob is not supported yet."); break; } - + + // If the filter specifies a Compilation Unit, remove the ones that don't pass at this point. + if (filter_by_cu) + { + uint32_t num_functions = func_list.GetSize(); + + for (size_t idx = 0; idx < num_functions; idx++) + { + SymbolContext sc; + func_list.GetContextAtIndex(idx, sc); + if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit)) + { + func_list.RemoveContextAtIndex(idx); + num_functions--; + idx--; + } + } + } + + if (!m_basename_filter.empty()) { // Filter out any matches whose names don't contain the basename filter Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu Sep 22 19:54:11 2011 @@ -49,7 +49,7 @@ CommandObjectBreakpointSet::CommandOptions::CommandOptions(CommandInterpreter &interpreter) : Options (interpreter), - m_filename (), + m_filenames (), m_line_num (0), m_column (0), m_check_inlines (true), @@ -71,6 +71,8 @@ { } +#define LLDB_OPT_FILE (LLDB_OPT_SET_ALL & ~(LLDB_OPT_SET_2)) + OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = { @@ -92,11 +94,11 @@ { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, eArgTypeQueueName, "The breakpoint stops only for threads in the queue whose name is given by this argument."}, - { LLDB_OPT_SET_1 | LLDB_OPT_SET_9, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, - "Set the breakpoint by source location in this particular file."}, + { LLDB_OPT_FILE, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, + "Specifies the source file in which to set this breakpoint."}, { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, - "Set the breakpoint by source location at this particular line."}, + "Specifies the line number on which to set this breakpoint."}, // Comment out this option for the moment, as we don't actually use it, but will in the future. // This way users won't see it, but the infrastructure is left in place. @@ -160,7 +162,7 @@ break; case 'f': - m_filename.assign (option_arg); + m_filenames.AppendIfUnique (FileSpec(option_arg, false)); break; case 'l': @@ -202,7 +204,7 @@ case 's': { - m_modules.push_back (std::string (option_arg)); + m_modules.AppendIfUnique (FileSpec (option_arg, false)); break; } case 'i': @@ -244,14 +246,14 @@ void CommandObjectBreakpointSet::CommandOptions::OptionParsingStarting () { - m_filename.clear(); + m_filenames.Clear(); m_line_num = 0; m_column = 0; m_func_name.clear(); m_func_name_type_mask = 0; m_func_regexp.clear(); m_load_addr = LLDB_INVALID_ADDRESS; - m_modules.clear(); + m_modules.Clear(); m_ignore_count = 0; m_thread_id = LLDB_INVALID_THREAD_ID; m_thread_index = UINT32_MAX; @@ -284,48 +286,41 @@ } bool -CommandObjectBreakpointSet::ChooseFile (Target *target, FileSpec &file, CommandReturnObject &result) +CommandObjectBreakpointSet::GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result) { - if (m_options.m_filename.empty()) + uint32_t default_line; + // First use the Source Manager's default file. + // Then use the current stack frame's file. + if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) { - uint32_t default_line; - // First use the Source Manager's default file. - // Then use the current stack frame's file. - if (!target->GetSourceManager().GetDefaultFileAndLine(file, default_line)) + StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr(); + if (cur_frame == NULL) + { + result.AppendError ("No selected frame to use to find the default file."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else if (!cur_frame->HasDebugInformation()) { - StackFrame *cur_frame = m_interpreter.GetExecutionContext().GetFramePtr(); - if (cur_frame == NULL) + result.AppendError ("Cannot use the selected frame to find the default file, it has no debug info."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else + { + const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); + if (sc.line_entry.file) { - result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); - result.SetStatus (eReturnStatusFailed); - return false; + file = sc.line_entry.file; } - else if (!cur_frame->HasDebugInformation()) + else { - result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); + result.AppendError ("Can't find the file for the selected frame to use as the default file."); result.SetStatus (eReturnStatusFailed); return false; } - else - { - const SymbolContext &sc = cur_frame->GetSymbolContext (eSymbolContextLineEntry); - if (sc.line_entry.file) - { - file = sc.line_entry.file; - } - else - { - result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); - result.SetStatus (eReturnStatusFailed); - return false; - } - } } } - else - { - file.SetFile(m_options.m_filename.c_str(), false); - } return true; } @@ -367,33 +362,36 @@ Breakpoint *bp = NULL; FileSpec module_spec; bool use_module = false; - int num_modules = m_options.m_modules.size(); - - FileSpecList module_spec_list; - FileSpecList *module_spec_list_ptr = NULL; + int num_modules = m_options.m_modules.GetSize(); if ((num_modules > 0) && (break_type != eSetTypeAddress)) use_module = true; - if (use_module) - { - module_spec_list_ptr = &module_spec_list; - for (int i = 0; i < num_modules; ++i) - { - module_spec.SetFile(m_options.m_modules[i].c_str(), false); - module_spec_list.AppendIfUnique (module_spec); - } - } - switch (break_type) { case eSetTypeFileAndLine: // Breakpoint by source position { FileSpec file; - if (!ChooseFile (target, file, result)) - break; + uint32_t num_files = m_options.m_filenames.GetSize(); + if (num_files == 0) + { + if (!GetDefaultFile (target, file, result)) + { + result.AppendError("No file supplied and no default file available."); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else if (num_files > 1) + { + result.AppendError("Only one file at a time is allowed for file and line breakpoints."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else + file = m_options.m_filenames.GetFileSpecAtIndex(0); - bp = target->CreateBreakpoint (module_spec_list_ptr, + bp = target->CreateBreakpoint (&(m_options.m_modules), file, m_options.m_line_num, m_options.m_check_inlines).get(); @@ -410,8 +408,9 @@ if (name_type_mask == 0) name_type_mask = eFunctionNameTypeAuto; - - bp = target->CreateBreakpoint (module_spec_list_ptr, + + bp = target->CreateBreakpoint (&(m_options.m_modules), + &(m_options.m_filenames), m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get(); @@ -430,15 +429,29 @@ result.SetStatus (eReturnStatusFailed); return false; } - bp = target->CreateBreakpoint (module_spec_list_ptr, regexp).get(); + + bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get(); } break; case eSetTypeSourceRegexp: // Breakpoint by regexp on source text. { - FileSpec file; - if (!ChooseFile (target, file, result)) - break; - + int num_files = m_options.m_filenames.GetSize(); + + if (num_files == 0) + { + FileSpec file; + if (!GetDefaultFile (target, file, result)) + { + result.AppendError ("No files provided and could not find default file."); + result.SetStatus (eReturnStatusFailed); + return false; + } + else + { + m_options.m_filenames.Append (file); + } + } + RegularExpression regexp(m_options.m_source_text_regexp.c_str()); if (!regexp.IsValid()) { @@ -449,7 +462,7 @@ result.SetStatus (eReturnStatusFailed); return false; } - bp = target->CreateBreakpoint (module_spec_list_ptr, file, regexp).get(); + bp = target->CreateSourceRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp).get(); } break; default: Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Thu Sep 22 19:54:11 2011 @@ -97,7 +97,7 @@ // Instance variables to hold the values for command options. - std::string m_filename; + FileSpecList m_filenames; uint32_t m_line_num; uint32_t m_column; bool m_check_inlines; @@ -105,7 +105,7 @@ uint32_t m_func_name_type_mask; std::string m_func_regexp; std::string m_source_text_regexp; - STLStringArray m_modules; + FileSpecList m_modules; lldb::addr_t m_load_addr; uint32_t m_ignore_count; lldb::tid_t m_thread_id; @@ -117,7 +117,7 @@ private: bool - ChooseFile (Target *target, FileSpec &file, CommandReturnObject &result); + GetDefaultFile (Target *target, FileSpec &file, CommandReturnObject &result); CommandOptions m_options; }; Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Thu Sep 22 19:54:11 2011 @@ -999,7 +999,8 @@ while (index_ptr <= end_ptr) { LineEntry line_entry; - index_ptr = sc.comp_unit->FindLineEntry(index_ptr, line_number, sc.comp_unit, &line_entry); + const bool exact = false; + index_ptr = sc.comp_unit->FindLineEntry(index_ptr, line_number, sc.comp_unit, exact, &line_entry); if (index_ptr == UINT32_MAX) break; Modified: lldb/trunk/source/Core/FileLineResolver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileLineResolver.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Core/FileLineResolver.cpp (original) +++ lldb/trunk/source/Core/FileLineResolver.cpp Thu Sep 22 19:54:11 2011 @@ -52,7 +52,7 @@ if (m_inlines || m_file_spec.Compare(*cu, m_file_spec, m_file_spec.GetDirectory())) { uint32_t start_file_idx = 0; - uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec); + uint32_t file_idx = cu->GetSupportFiles().FindFileIndex(start_file_idx, m_file_spec, false); if (file_idx != UINT32_MAX) { LineTable *line_table = cu->GetLineTable(); @@ -67,7 +67,7 @@ line_table->FineLineEntriesForFileIndex (file_idx, append, m_sc_list); // Get the next file index in case we have multiple file // entries for the same file - file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1, m_file_spec); + file_idx = cu->GetSupportFiles().FindFileIndex(file_idx + 1, m_file_spec, false); } } else Modified: lldb/trunk/source/Core/FileSpecList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpecList.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpecList.cpp (original) +++ lldb/trunk/source/Core/FileSpecList.cpp Thu Sep 22 19:54:11 2011 @@ -107,7 +107,7 @@ // it is found, else UINT32_MAX is returned. //------------------------------------------------------------------ uint32_t -FileSpecList::FindFileIndex (uint32_t start_idx, const FileSpec &file_spec) const +FileSpecList::FindFileIndex (uint32_t start_idx, const FileSpec &file_spec, bool full) const { const uint32_t num_files = m_files.size(); uint32_t idx; @@ -125,7 +125,7 @@ } else { - if (m_files[idx] == file_spec) + if (FileSpec::Equal (m_files[idx], file_spec, full)) return idx; } } Modified: lldb/trunk/source/Core/SearchFilter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SearchFilter.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Core/SearchFilter.cpp (original) +++ lldb/trunk/source/Core/SearchFilter.cpp Thu Sep 22 19:54:11 2011 @@ -110,6 +110,12 @@ return true; } +uint32_t +SearchFilter::GetFilterRequiredItems() +{ + return (lldb::SymbolContextItem) 0; +} + void SearchFilter::GetDescription (Stream *s) { @@ -427,6 +433,12 @@ } } +uint32_t +SearchFilterByModule::GetFilterRequiredItems() +{ + return eSymbolContextModule; +} + void SearchFilterByModule::Dump (Stream *s) const { @@ -478,7 +490,10 @@ bool SearchFilterByModuleList::ModulePasses (const ModuleSP &module_sp) { - if (module_sp && m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec()) != UINT32_MAX) + if (m_module_spec_list.GetSize() == 0) + return true; + + if (module_sp && m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) != UINT32_MAX) return true; else return false; @@ -487,7 +502,10 @@ bool SearchFilterByModuleList::ModulePasses (const FileSpec &spec) { - if (m_module_spec_list.FindFileIndex(0, spec) != UINT32_MAX) + if (m_module_spec_list.GetSize() == 0) + return true; + + if (m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX) return true; else return false; @@ -503,7 +521,7 @@ if (!(scope & eSymbolContextModule)) return false; - if (context.module_sp && m_module_spec_list.FindFileIndex(0, context.module_sp->GetFileSpec()) != UINT32_MAX) + if (context.module_sp && m_module_spec_list.FindFileIndex(0, context.module_sp->GetFileSpec(), true) != UINT32_MAX) return true; else return false; @@ -551,7 +569,7 @@ for (size_t i = 0; i < num_modules; i++) { Module* module = m_target_sp->GetImages().GetModulePointerAtIndex(i); - if (m_module_spec_list.FindFileIndex(0, module->GetFileSpec()) != UINT32_MAX) + if (m_module_spec_list.FindFileIndex(0, module->GetFileSpec(), false) != UINT32_MAX) { SymbolContext matchingContext(m_target_sp, ModuleSP(module)); Searcher::CallbackReturn shouldContinue; @@ -602,8 +620,204 @@ } } +uint32_t +SearchFilterByModuleList::GetFilterRequiredItems() +{ + return eSymbolContextModule; +} + void SearchFilterByModuleList::Dump (Stream *s) const { } + +//---------------------------------------------------------------------- +// SearchFilterByModuleListAndCU: +// Selects a shared library matching a given file spec +//---------------------------------------------------------------------- + +//---------------------------------------------------------------------- +// SearchFilterByModuleListAndCU constructors +//---------------------------------------------------------------------- + +SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU (lldb::TargetSP &target_sp, + const FileSpecList &module_list, + const FileSpecList &cu_list) : + SearchFilterByModuleList (target_sp, module_list), + m_cu_spec_list (cu_list) +{ +} + + +//---------------------------------------------------------------------- +// SearchFilterByModuleListAndCU copy constructor +//---------------------------------------------------------------------- +SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU(const SearchFilterByModuleListAndCU& rhs) : + SearchFilterByModuleList (rhs), + m_cu_spec_list (rhs.m_cu_spec_list) +{ +} + +//---------------------------------------------------------------------- +// SearchFilterByModuleListAndCU assignment operator +//---------------------------------------------------------------------- +const SearchFilterByModuleListAndCU& +SearchFilterByModuleListAndCU::operator=(const SearchFilterByModuleListAndCU& rhs) +{ + if (&rhs != this) + { + m_target_sp = rhs.m_target_sp; + m_module_spec_list = rhs.m_module_spec_list; + m_cu_spec_list = rhs.m_cu_spec_list; + } + return *this; +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +SearchFilterByModuleListAndCU::~SearchFilterByModuleListAndCU() +{ +} + +bool +SearchFilterByModuleListAndCU::SymbolContextPasses +( + const SymbolContext &context, + lldb::SymbolContextItem scope + ) +{ + if (!SearchFilterByModuleList::SymbolContextPasses(context, scope)) + return false; + if (!(scope & eSymbolContextCompUnit)) + return false; + if (context.comp_unit && m_cu_spec_list.FindFileIndex(0, static_cast(context.comp_unit), false) == UINT32_MAX) + return false; + return true; +} + +bool +SearchFilterByModuleListAndCU::AddressPasses (Address &address) +{ + // FIXME: Not yet implemented + return true; +} + + +bool +SearchFilterByModuleListAndCU::CompUnitPasses (FileSpec &fileSpec) +{ + return m_cu_spec_list.FindFileIndex(0, fileSpec, false) != UINT32_MAX; +} + +bool +SearchFilterByModuleListAndCU::CompUnitPasses (CompileUnit &compUnit) +{ + return m_cu_spec_list.FindFileIndex(0, static_cast(compUnit), false) != UINT32_MAX; +} + +void +SearchFilterByModuleListAndCU::Search (Searcher &searcher) +{ + if (!m_target_sp) + return; + + if (searcher.GetDepth() == Searcher::eDepthTarget) + { + SymbolContext empty_sc; + empty_sc.target_sp = m_target_sp; + searcher.SearchCallback (*this, empty_sc, NULL, false); + } + + // If the module file spec is a full path, then we can just find the one + // filespec that passes. Otherwise, we need to go through all modules and + // find the ones that match the file name. + + ModuleList matching_modules; + const size_t num_modules = m_target_sp->GetImages().GetSize (); + bool no_modules_in_filter = m_module_spec_list.GetSize() == 0; + for (size_t i = 0; i < num_modules; i++) + { + lldb::ModuleSP module_sp = m_target_sp->GetImages().GetModuleAtIndex(i); + if (no_modules_in_filter || m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) != UINT32_MAX) + { + SymbolContext matchingContext(m_target_sp, module_sp); + Searcher::CallbackReturn shouldContinue; + + if (searcher.GetDepth() == Searcher::eDepthModule) + { + shouldContinue = DoModuleIteration(matchingContext, searcher); + if (shouldContinue == Searcher::eCallbackReturnStop) + return; + } + else + { + const size_t num_cu = module_sp->GetNumCompileUnits(); + for (size_t cu_idx = 0; cu_idx < num_cu; cu_idx++) + { + CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx); + matchingContext.comp_unit = cu_sp.get(); + if (m_cu_spec_list.FindFileIndex(0, static_cast(matchingContext.comp_unit), false) != UINT32_MAX) + { + shouldContinue = DoCUIteration(module_sp, matchingContext, searcher); + if (shouldContinue == Searcher::eCallbackReturnStop) + return; + } + } + } + } + } +} + +void +SearchFilterByModuleListAndCU::GetDescription (Stream *s) +{ + uint32_t num_modules = m_module_spec_list.GetSize(); + if (num_modules == 1) + { + s->Printf (", module = "); + if (s->GetVerbose()) + { + char buffer[2048]; + m_module_spec_list.GetFileSpecAtIndex(0).GetPath(buffer, 2047); + s->PutCString(buffer); + } + else + { + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString("")); + } + } + else if (num_modules > 0) + { + s->Printf (", modules(%d) = ", num_modules); + for (uint32_t i = 0; i < num_modules; i++) + { + if (s->GetVerbose()) + { + char buffer[2048]; + m_module_spec_list.GetFileSpecAtIndex(i).GetPath(buffer, 2047); + s->PutCString(buffer); + } + else + { + s->PutCString(m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString("")); + } + if (i != num_modules - 1) + s->PutCString (", "); + } + } +} + +uint32_t +SearchFilterByModuleListAndCU::GetFilterRequiredItems() +{ + return eSymbolContextModule | eSymbolContextCompUnit; +} + +void +SearchFilterByModuleListAndCU::Dump (Stream *s) const +{ + +} + Modified: lldb/trunk/source/Host/common/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Host/common/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Thu Sep 22 19:54:11 2011 @@ -506,10 +506,10 @@ bool FileSpec::Equal (const FileSpec& a, const FileSpec& b, bool full) { - if (full) - return a == b; - else + if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty())) return a.m_filename == b.m_filename; + else + return a == b; } Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Thu Sep 22 19:54:11 2011 @@ -988,6 +988,7 @@ FileSpecList module_spec_list; module_spec_list.Append (m_kernel.module_sp->GetFileSpec()); Breakpoint *bp = m_process->GetTarget().CreateBreakpoint (&module_spec_list, + NULL, "OSKextLoadedKextSummariesUpdated", eFunctionNameTypeFull, internal_bp, Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Thu Sep 22 19:54:11 2011 @@ -262,6 +262,7 @@ if (!m_cxx_exception_bp_sp) m_cxx_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL, + NULL, "__cxa_throw", eFunctionNameTypeBase, true); @@ -270,6 +271,7 @@ if (!m_cxx_exception_alloc_bp_sp) m_cxx_exception_alloc_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL, + NULL, "__cxa_allocate", eFunctionNameTypeBase, true); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu Sep 22 19:54:11 2011 @@ -114,6 +114,7 @@ if (!m_objc_exception_bp_sp) { m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL, + NULL, "objc_exception_throw", eFunctionNameTypeBase, true); 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=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Sep 22 19:54:11 2011 @@ -480,6 +480,7 @@ if (!m_objc_exception_bp_sp) { m_objc_exception_bp_sp = m_process->GetTarget().CreateBreakpoint (NULL, + NULL, "__cxa_throw", eFunctionNameTypeBase, true); 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=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Sep 22 19:54:11 2011 @@ -2534,7 +2534,7 @@ { for (int i = 0; bp_names[i] != NULL; i++) { - Breakpoint *breakpoint = m_target.CreateBreakpoint (NULL, bp_names[i], eFunctionNameTypeFull, true).get(); + Breakpoint *breakpoint = m_target.CreateBreakpoint (NULL, NULL, bp_names[i], eFunctionNameTypeFull, true).get(); if (breakpoint) { if (log) 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=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 22 19:54:11 2011 @@ -1804,7 +1804,7 @@ // find it in the support files, we are done. if (check_inlines) { - file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); + file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec, true); if (file_idx == UINT32_MAX) continue; } @@ -1818,7 +1818,7 @@ // We will have already looked up the file index if // we are searching for inline entries. if (!check_inlines) - file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec); + file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex (1, file_spec, true); if (file_idx != UINT32_MAX) { Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Thu Sep 22 19:54:11 2011 @@ -253,13 +253,13 @@ } uint32_t -CompileUnit::FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, LineEntry *line_entry_ptr) +CompileUnit::FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, bool exact, LineEntry *line_entry_ptr) { uint32_t file_idx = 0; if (file_spec_ptr) { - file_idx = GetSupportFiles().FindFileIndex (1, *file_spec_ptr); + file_idx = GetSupportFiles().FindFileIndex (1, *file_spec_ptr, true); if (file_idx == UINT32_MAX) return UINT32_MAX; } @@ -269,13 +269,14 @@ // Unit that is in the support files (the one at 0 was artifically added.) // So prefer the one further on in the support files if it exists... FileSpecList &support_files = GetSupportFiles(); - file_idx = support_files.FindFileIndex (1, support_files.GetFileSpecAtIndex(0)); + const bool full = true; + file_idx = support_files.FindFileIndex (1, support_files.GetFileSpecAtIndex(0), full); if (file_idx == UINT32_MAX) file_idx = 0; } LineTable *line_table = GetLineTable(); if (line_table) - return line_table->FindLineEntryIndexByFileIndex (start_idx, file_idx, line, true, line_entry_ptr); + return line_table->FindLineEntryIndexByFileIndex (start_idx, file_idx, line, exact, line_entry_ptr); return UINT32_MAX; } @@ -304,11 +305,11 @@ if (file_spec_matches_cu_file_spec == false && check_inlines == false) return 0; - uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec); + uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec, true); while (file_idx != UINT32_MAX) { file_indexes.push_back (file_idx); - file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec); + file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec, true); } const size_t num_file_indexes = file_indexes.size(); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Sep 22 19:54:11 2011 @@ -207,13 +207,13 @@ } BreakpointSP -Target::CreateBreakpoint (const FileSpecList *containingModules, - const FileSpec &file, +Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules, + const FileSpecList *source_file_spec_list, RegularExpression &source_regex, bool internal) { - SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); - BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, file, source_regex)); + SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list)); + BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex)); return CreateBreakpoint (filter_sp, resolver_sp, internal); } @@ -255,7 +255,8 @@ } BreakpointSP -Target::CreateBreakpoint (const FileSpecList *containingModules, +Target::CreateBreakpoint (const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_name, uint32_t func_name_type_mask, bool internal, @@ -264,7 +265,7 @@ BreakpointSP bp_sp; if (func_name) { - SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); + SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_name, @@ -317,13 +318,36 @@ return filter_sp; } +SearchFilterSP +Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles) +{ + if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0) + return GetSearchFilterForModuleList(containingModules); + + SearchFilterSP filter_sp; + lldb::TargetSP target_sp = this->GetSP(); + if (containingModules == NULL) + { + // We could make a special "CU List only SearchFilter". Better yet was if these could be composable, + // but that will take a little reworking. + + filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, FileSpecList(), *containingSourceFiles)); + } + else + { + filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, *containingModules, *containingSourceFiles)); + } + return filter_sp; +} + BreakpointSP -Target::CreateBreakpoint (const FileSpecList *containingModules, +Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, RegularExpression &func_regex, bool internal, LazyBool skip_prologue) { - SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); + SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, func_regex, skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/Makefile?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/Makefile (original) +++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/Makefile Thu Sep 22 19:54:11 2011 @@ -1,5 +1,5 @@ LEVEL = ../../../make -C_SOURCES := main.c +C_SOURCES := main.c a.c b.c include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py?rev=140362&r1=140361&r2=140362&view=diff ============================================================================== --- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Thu Sep 22 19:54:11 2011 @@ -77,6 +77,25 @@ "print >> here", "here.close()"]) + # Next lets try some other breakpoint kinds. First break with a regular expression + # and then specify only one file. The first time we should get two locations, + # the second time only one: + self.expect ("break set -r ._MyFunction", + patterns = ["Breakpoint created: [0-9]+: regex = '\._MyFunction', locations = 2"]) + + self.expect ("break set -r ._MyFunction -f a.c", + patterns = ["Breakpoint created: [0-9]+: regex = '\._MyFunction', locations = 1"]) + + self.expect ("break set -r ._MyFunction -f a.c -f b.c", + patterns = ["Breakpoint created: [0-9]+: regex = '\._MyFunction', locations = 2"]) + + # Now try a source regex breakpoint: + self.expect ("break set -p \"is about to return [12]0\" -f a.c -f b.c", + patterns = ["Breakpoint created: [0-9]+: source regex = \"is about to return \[12\]0\", locations = 2"]) + + self.expect ("break set -p \"is about to return [12]0\" -f a.c", + patterns = ["Breakpoint created: [0-9]+: source regex = \"is about to return \[12\]0\", locations = 1"]) + # Run the program. Remove 'output.txt' if it exists. if os.path.exists('output.txt'): os.remove('output.txt') Added: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/a.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/a.c?rev=140362&view=auto ============================================================================== --- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/a.c (added) +++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/a.c Thu Sep 22 19:54:11 2011 @@ -0,0 +1,9 @@ +#include + +int +a_MyFunction () +{ + // Set a breakpoint here. + printf ("a is about to return 10.\n"); + return 10; +} Added: lldb/trunk/test/functionalities/breakpoint/breakpoint_command/b.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_command/b.c?rev=140362&view=auto ============================================================================== --- lldb/trunk/test/functionalities/breakpoint/breakpoint_command/b.c (added) +++ lldb/trunk/test/functionalities/breakpoint/breakpoint_command/b.c Thu Sep 22 19:54:11 2011 @@ -0,0 +1,9 @@ +#include + +int +b_MyFunction () +{ + // Set a breakpoint here. + printf ("b is about to return 20.\n"); + return 20; +} From johnny.chen at apple.com Fri Sep 23 12:53:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 17:53:13 -0000 Subject: [Lldb-commits] [lldb] r140392 - /lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Message-ID: <20110923175313.E06722A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 12:53:13 2011 New Revision: 140392 URL: http://llvm.org/viewvc/llvm-project?rev=140392&view=rev Log: The "Stop Hooks" anchors have been removed from the stop-hook output. Update the test case to fix test suite failure. Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=140392&r1=140391&r2=140392&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Fri Sep 23 12:53:13 2011 @@ -65,7 +65,7 @@ child.expect_exact(prompt) child.sendline('thread step-over') #self.DebugPExpect(child) - child.expect_exact('** End Stop Hooks **') + child.expect_exact(prompt) #self.DebugPExpect(child) # Verify that the 'Stop Hooks' mechanism is fired off. self.expect(child.before, exe=False, From johnny.chen at apple.com Fri Sep 23 12:57:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 17:57:49 -0000 Subject: [Lldb-commits] [lldb] r140393 - /lldb/trunk/test/help/TestHelp.py Message-ID: <20110923175749.C5ABF2A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 12:57:49 2011 New Revision: 140393 URL: http://llvm.org/viewvc/llvm-project?rev=140393&view=rev Log: Add a simple test case for 'help watchpoint', 'help watchpt-id', and 'help watchpt-id-list'. Modified: lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=140393&r1=140392&r2=140393&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Fri Sep 23 12:57:49 2011 @@ -112,6 +112,15 @@ self.expect("help target variable", substrs = [' [ [...]]']) + def test_help_watchpoint_and_its_args(self): + """Command 'help watchpoint', 'help watchpt-id', and 'help watchpt-id-list' should work.""" + self.expect("help watchpoint", + substrs = ['delete', 'disable', 'enable', 'list']) + self.expect("help watchpt-id", + substrs = ['']) + self.expect("help watchpt-id-list", + substrs = ['']) + if __name__ == '__main__': import atexit From johnny.chen at apple.com Fri Sep 23 13:25:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 18:25:02 -0000 Subject: [Lldb-commits] [lldb] r140396 - /lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Message-ID: <20110923182502.6BF132A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 13:25:02 2011 New Revision: 140396 URL: http://llvm.org/viewvc/llvm-project?rev=140396&view=rev Log: A second try to make the TestStopHookMechanism.py more robust after recent changes. Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=140396&r1=140395&r2=140396&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Fri Sep 23 13:25:02 2011 @@ -64,12 +64,8 @@ child.sendline('run') child.expect_exact(prompt) child.sendline('thread step-over') - #self.DebugPExpect(child) - child.expect_exact(prompt) - #self.DebugPExpect(child) - # Verify that the 'Stop Hooks' mechanism is fired off. - self.expect(child.before, exe=False, - substrs = ['(void *) $']) + # Expecting to find the output emitted by the firing of our stop hook. + child.expect_exact('(void *) $') # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range. child.sendline('process continue') From johnny.chen at apple.com Fri Sep 23 13:42:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 18:42:28 -0000 Subject: [Lldb-commits] [lldb] r140398 - in /lldb/trunk/test/functionalities/watchpoint/watchpoint_commands: ./ Makefile TestWatchpointCommands.py main.c Message-ID: <20110923184228.E53C12A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 13:42:28 2011 New Revision: 140398 URL: http://llvm.org/viewvc/llvm-project?rev=140398&view=rev Log: Add test cases for watchpoint list, enable, disable, and delete commands. Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/Makefile lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/Makefile?rev=140398&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/Makefile (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/Makefile Fri Sep 23 13:42:28 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: 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=140398&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/TestWatchpointCommands.py Fri Sep 23 13:42:28 2011 @@ -0,0 +1,308 @@ +""" +Test watchpoint list, enable, disable, and delete commands. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class WatchpointCommandsTestCase(TestBase): + + mydir = os.path.join("functionalities", "watchpoint", "watchpoint_commands") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.c' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + self.line2 = line_number(self.source, '// Set 2nd break point for disable_then_enable test case.') + # 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 = {'C_SOURCES': self.source, 'EXE': self.exe_name} + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_rw_watchpoint_with_dsym(self): + """Test read_write watchpoint and expect to stop two times.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.normal_read_write_watchpoint() + + def test_rw_watchpoint_with_dwarf(self): + """Test read_write watchpoint and expect to stop two times.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.normal_read_write_watchpoint() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_rw_watchpoint_delete_with_dsym(self): + """Test delete watchpoint and expect not to stop for watchpoint.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.delete_read_write_watchpoint() + + def test_rw_watchpoint_delete_with_dwarf(self): + """Test delete watchpoint and expect not to stop for watchpoint.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.delete_read_write_watchpoint() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_rw_disable_after_first_stop_with_dsym(self): + """Test read_write watchpoint but disable it after the first stop.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.read_write_watchpoint_disable_after_first_stop() + + def test_rw_disable_after_first_stop__with_dwarf(self): + """Test read_write watchpoint but disable it after the first stop.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.read_write_watchpoint_disable_after_first_stop() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_rw_disable_then_enable_with_dsym(self): + """Test read_write watchpoint, disable initially, then enable it.""" + self.buildDsym(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.read_write_watchpoint_disable_then_enable() + + def test_rw_disable_then_enable_with_dwarf(self): + """Test read_write watchpoint, disable initially, then enable it.""" + self.buildDwarf(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) + self.read_write_watchpoint_disable_then_enable() + + def normal_read_write_watchpoint(self): + """Do read_write watchpoint and expect to stop two times.""" + 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 read_write-type watchpoint for 'global'. + # 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)]) + + # 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']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (read_write type). + # The stop reason of the thread should be watchpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stop reason = watchpoint']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (read_write type). + # The stop reason of the thread should be watchpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stop reason = watchpoint']) + + self.runCmd("process continue") + + # There should be no more watchpoint hit and the process status should + # be 'exited'. + self.expect("process status", + substrs = ['exited']) + + # 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 = 2']) + + def delete_read_write_watchpoint(self): + """Do delete watchpoint immediately and expect not to stop for watchpoint.""" + 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 read_write-type watchpoint for 'global'. + # 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)]) + + # Delete the watchpoint immediately, but set auto-confirm to true first. + self.runCmd("settings set auto-confirm true") + self.expect("watchpoint delete", + substrs = ['All watchpoints removed.']) + # Restore the original setting of auto-confirm. + self.runCmd("settings set -r auto-confirm") + + # Use the '-v' option to do verbose listing of the watchpoint. + self.runCmd("watchpoint list -v") + + self.runCmd("process continue") + + # There should be no more watchpoint hit and the process status should + # be 'exited'. + self.expect("process status", + substrs = ['exited']) + + def read_write_watchpoint_disable_after_first_stop(self): + """Do read_write watchpoint but disable it after the first stop.""" + 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 read_write-type watchpoint for 'global'. + # 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)]) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 0 initially. + self.expect("watchpoint list -v", + substrs = ['state = enabled', 'hit_count = 0']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (read_write type). + # The stop reason of the thread should be watchpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stop reason = watchpoint']) + + # Before continuing, we'll disable the watchpoint, which means we won't + # stop agian after this. + self.runCmd("watchpoint disable") + + self.expect("watchpoint list -v", + substrs = ['state = disabled', 'hit_count = 1']) + + self.runCmd("process continue") + + # There should be no more watchpoint hit and the process status should + # be 'exited'. + self.expect("process status", + substrs = ['exited']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 1. + self.expect("watchpoint list -v", + substrs = ['hit_count = 1']) + + def read_write_watchpoint_disable_then_enable(self): + """Do read_write watchpoint, disable initially, then enable it.""" + 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)) + self.expect("breakpoint set -l %d" % self.line2, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: file ='%s', line = %d, locations = 1" % + (self.source, self.line2)) + + # 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 read_write-type watchpoint for 'global'. + # 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)]) + + # Immediately, we disable the watchpoint. We won't be stopping due to a + # watchpoint after this. + self.runCmd("watchpoint disable") + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 0 initially. + self.expect("watchpoint list -v", + substrs = ['state = disabled', 'hit_count = 0']) + + self.runCmd("process continue") + + # We should be stopped again due to the breakpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stop reason = breakpoint']) + + # Before continuing, we'll enable the watchpoint, which means we will + # stop agian after this. + self.runCmd("watchpoint enable") + + self.expect("watchpoint list -v", + substrs = ['state = enabled', 'hit_count = 0']) + + self.runCmd("process continue") + + # We should be stopped again due to the watchpoint (read_write type). + # The stop reason of the thread should be watchpoint. + self.expect("thread backtrace", STOPPED_DUE_TO_WATCHPOINT, + substrs = ['stop reason = watchpoint']) + + self.runCmd("process continue") + + # There should be no more watchpoint hit and the process status should + # be 'exited'. + self.expect("process status", + substrs = ['exited']) + + # Use the '-v' option to do verbose listing of the watchpoint. + # The hit count should be 1. + self.expect("watchpoint list -v", + substrs = ['hit_count = 1']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c?rev=140398&view=auto ============================================================================== --- lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c (added) +++ lldb/trunk/test/functionalities/watchpoint/watchpoint_commands/main.c Fri Sep 23 13:42:28 2011 @@ -0,0 +1,24 @@ +//===-- 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 = 10; // Watchpoint variable declaration. + +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 write. + global = 20; + local += argc; + ++local; // Set 2nd break point for disable_then_enable test case. + printf("local: %d\n", local); + printf("global=%d\n", global); +} From jingham at apple.com Fri Sep 23 16:08:11 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 23 Sep 2011 21:08:11 -0000 Subject: [Lldb-commits] [lldb] r140416 - /lldb/trunk/source/Target/ThreadPlanStepRange.cpp Message-ID: <20110923210811.5222B2A6C12C@llvm.org> Author: jingham Date: Fri Sep 23 16:08:11 2011 New Revision: 140416 URL: http://llvm.org/viewvc/llvm-project?rev=140416&view=rev Log: If stepping takes us from the line range we were stepping through into the MIDDLE of another line, then continue till we get to the real beginning of a line. This is mostly to work around debug information bugs. Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=140416&r1=140415&r2=140416&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Fri Sep 23 16:08:11 2011 @@ -115,20 +115,44 @@ SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything)); if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid()) { - if ((m_addr_context.line_entry.file == new_context.line_entry.file) - && (m_addr_context.line_entry.line == new_context.line_entry.line)) + if (m_addr_context.line_entry.file == new_context.line_entry.file) { - m_addr_context = new_context; - m_address_range = m_addr_context.line_entry.range; - ret_value = true; - if (log) + if (m_addr_context.line_entry.line == new_context.line_entry.line) { - StreamString s; - m_address_range.Dump (&s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); + m_addr_context = new_context; + m_address_range = m_addr_context.line_entry.range; + ret_value = true; + if (log) + { + StreamString s; + m_address_range.Dump (&s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); - log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData()); + log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData()); + } + } + else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget()) + != pc_load_addr) + { + // Another thing that sometimes happens here is that we step out of one line into the MIDDLE of another + // line. So far I mostly see this due to bugs in the debug information. + // But we probably don't want to be in the middle of a line range, so in that case reset the stepping + // range to the line we've stepped into the middle of and continue. + m_addr_context = new_context; + m_address_range = m_addr_context.line_entry.range; + ret_value = true; + if (log) + { + StreamString s; + m_address_range.Dump (&s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); + + log->Printf ("Step range plan stepped to the middle of new line(%d): %s, continuing to clear this line.", + new_context.line_entry.line, + s.GetData()); + } + } } + } } From jmolenda at apple.com Fri Sep 23 16:15:42 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 23 Sep 2011 21:15:42 -0000 Subject: [Lldb-commits] [lldb] r140417 - /lldb/trunk/source/Commands/CommandObjectTarget.cpp Message-ID: <20110923211542.945502A6C12C@llvm.org> Author: jmolenda Date: Fri Sep 23 16:15:42 2011 New Revision: 140417 URL: http://llvm.org/viewvc/llvm-project?rev=140417&view=rev Log: in CommandObjectTargetStopHookList::Execute, if we don't have a target, return before we try to dereference the target later in the function. Currently, % lldb -x (lldb) target stop-hook list crashes because of this. Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140417&r1=140416&r2=140417&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Sep 23 16:15:42 2011 @@ -3914,6 +3914,7 @@ { result.AppendError ("invalid target\n"); result.SetStatus (eReturnStatusFailed); + return result.Succeeded(); } size_t num_hooks = target->GetNumStopHooks (); From johnny.chen at apple.com Fri Sep 23 16:21:43 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 21:21:43 -0000 Subject: [Lldb-commits] [lldb] r140418 - in /lldb/trunk: include/lldb/Target/Target.h source/Target/Target.cpp Message-ID: <20110923212143.614352A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 16:21:43 2011 New Revision: 140418 URL: http://llvm.org/viewvc/llvm-project?rev=140418&view=rev Log: Add a (bool)end_to_end parameter, default true, to the Target::Remove/Disable/EnableALLWatchpointLocations() methods. If passed as false, it signifies that only the debugger side is affected. Modify Target::DeleteCurrentProcess() to use DisableAllWatchpointLocations(false) to disable the watchpoint locations, instead of removing them between process instances. Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140418&r1=140417&r2=140418&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Fri Sep 23 16:21:43 2011 @@ -324,14 +324,17 @@ bool RemoveBreakpointByID (lldb::break_id_t break_id); + // The flag 'end_to_end', default to true, signifies that the operation is + // performed end to end, for both the debugger and the debuggee. + bool - RemoveAllWatchpointLocations (); + RemoveAllWatchpointLocations (bool end_to_end = true); bool - DisableAllWatchpointLocations (); + DisableAllWatchpointLocations (bool end_to_end = true); bool - EnableAllWatchpointLocations (); + EnableAllWatchpointLocations (bool end_to_end = true); bool DisableWatchpointLocationByID (lldb::watch_id_t watch_id); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140418&r1=140417&r2=140418&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Sep 23 16:21:43 2011 @@ -125,7 +125,8 @@ // clean up needs some help from the process. m_breakpoint_list.ClearAllBreakpointSites(); m_internal_breakpoint_list.ClearAllBreakpointSites(); - m_watchpoint_location_list.RemoveAll(); + // Disable watchpoint locations just on the debugger side. + DisableAllWatchpointLocations(false); m_process_sp.reset(); } } @@ -562,14 +563,25 @@ return false; } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// The flag 'end_to_end', default to true, signifies that the operation is +// performed end to end, for both the debugger and the debuggee. + +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list +// for end to end operations. bool -Target::RemoveAllWatchpointLocations () +Target::RemoveAllWatchpointLocations (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); + if (!end_to_end) { + m_watchpoint_location_list.RemoveAll(); + return true; + } + + // Otherwise, it's an end to end operation. + if (!ProcessIsValid()) return false; @@ -588,14 +600,22 @@ return true; // Success! } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list +// for end to end operations. bool -Target::DisableAllWatchpointLocations () +Target::DisableAllWatchpointLocations (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); + if (!end_to_end) { + m_watchpoint_location_list.SetEnabledAll(false); + return true; + } + + // Otherwise, it's an end to end operation. + if (!ProcessIsValid()) return false; @@ -613,14 +633,22 @@ return true; // Success! } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list +// for end to end operations. bool -Target::EnableAllWatchpointLocations () +Target::EnableAllWatchpointLocations (bool end_to_end) { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); if (log) log->Printf ("Target::%s\n", __FUNCTION__); + if (!end_to_end) { + m_watchpoint_location_list.SetEnabledAll(true); + return true; + } + + // Otherwise, it's an end to end operation. + if (!ProcessIsValid()) return false; @@ -638,7 +666,7 @@ return true; // Success! } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. bool Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) { @@ -661,7 +689,7 @@ return false; } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. bool Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) { @@ -684,7 +712,7 @@ return false; } -// Assumption: caller holds the list mutex lock for m_watchpoint_location_list. +// Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. bool Target::RemoveWatchpointLocationByID (lldb::watch_id_t watch_id) { From jingham at apple.com Fri Sep 23 16:24:58 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 23 Sep 2011 21:24:58 -0000 Subject: [Lldb-commits] [lldb] r140419 - in /lldb/trunk/test/functionalities/stop-hook: TestStopHookMechanism.py main.cpp Message-ID: <20110923212458.153D42A6C12C@llvm.org> Author: jingham Date: Fri Sep 23 16:24:57 2011 New Revision: 140419 URL: http://llvm.org/viewvc/llvm-project?rev=140419&view=rev Log: Added a test for problems caused when Clang errantly makes the line range for one line too long, so that the jump from the line above the bad line to the line after ends up in the middle of the bad line instead. Added a workaround to lldb to just continue to the end if we find ourselves stopped in the middle of some other line. Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py lldb/trunk/test/functionalities/stop-hook/main.cpp Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=140419&r1=140418&r2=140419&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookMechanism.py Fri Sep 23 16:24:57 2011 @@ -29,6 +29,7 @@ # Find the line numbers inside main.cpp. self.begl = line_number('main.cpp', '// Set breakpoint here to test target stop-hook.') self.endl = line_number('main.cpp', '// End of the line range for which stop-hook is to be run.') + self.correct_step_line = line_number ('main.cpp', '// We should stop here after stepping.') self.line = line_number('main.cpp', '// Another breakpoint which is outside of the stop-hook range.') def stop_hook_firing(self): @@ -66,6 +67,13 @@ child.sendline('thread step-over') # Expecting to find the output emitted by the firing of our stop hook. child.expect_exact('(void *) $') + # This is orthogonal to the main stop hook test, but this example shows a bug in + # CLANG where the line table entry for the "return -1" actually includes some code + # from the other branch of the if/else, so we incorrectly stop at the "return -1" line. + # I fixed that in lldb and I'm sticking in a test here because I don't want to have to + # make up a whole nother test case for it. + child.sendline('frame info') + child.expect_exact('at main.cpp:%d'%self.correct_step_line) # Now continue the inferior, we'll stop at another breakpoint which is outside the stop-hook range. child.sendline('process continue') Modified: lldb/trunk/test/functionalities/stop-hook/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/main.cpp?rev=140419&r1=140418&r2=140419&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/main.cpp (original) +++ lldb/trunk/test/functionalities/stop-hook/main.cpp Fri Sep 23 16:24:57 2011 @@ -30,7 +30,7 @@ if (!ptr) // Set breakpoint here to test target stop-hook. return -1; else - printf("ptr=%p\n", ptr); + printf("ptr=%p\n", ptr); // We should stop here after stepping. return rc; // End of the line range for which stop-hook is to be run. } From johnny.chen at apple.com Fri Sep 23 16:34:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 23 Sep 2011 21:34:40 -0000 Subject: [Lldb-commits] [lldb] r140421 - /lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py Message-ID: <20110923213440.738462A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 16:34:40 2011 New Revision: 140421 URL: http://llvm.org/viewvc/llvm-project?rev=140421&view=rev Log: Add a simple regression test for 'target stop-hook list' with no target specified. It should not crash lldb. Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py Modified: lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py?rev=140421&r1=140420&r2=140421&view=diff ============================================================================== --- lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py (original) +++ lldb/trunk/test/functionalities/stop-hook/TestStopHookCmd.py Fri Sep 23 16:34:40 2011 @@ -12,6 +12,11 @@ mydir = os.path.join("functionalities", "stop-hook") + # Regression test. + def test_not_crashing_if_no_target(self): + """target stop-hook list should not crash if no target has been set.""" + self.runCmd("target stop-hook list", check=False) + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): """Test a sequence of target stop-hook commands.""" From johnny.chen at apple.com Fri Sep 23 19:50:33 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 24 Sep 2011 00:50:33 -0000 Subject: [Lldb-commits] [lldb] r140436 - in /lldb/trunk: include/lldb/API/SBFrame.h scripts/Python/interface/SBFrame.i source/API/SBFrame.cpp test/python_api/watchpoint/ test/python_api/watchpoint/Makefile test/python_api/watchpoint/TestSetWatchpoint.py test/python_api/watchpoint/main.c Message-ID: <20110924005033.6F8682A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 19:50:33 2011 New Revision: 140436 URL: http://llvm.org/viewvc/llvm-project?rev=140436&view=rev Log: Add an SB API SBFrame::WatchValue() and exported to the Python interface to set a watchpoint Pythonically. If the find-and-watch-a-variable operation fails, an invalid SBValue is returned, instead. Example Python usage: value = frame0.WatchValue('global', lldb.eValueTypeVariableGlobal, lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) Add TestSetWatchpoint.py to exercise this API. We have 400 test cases now. Added: lldb/trunk/test/python_api/watchpoint/ lldb/trunk/test/python_api/watchpoint/Makefile lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py lldb/trunk/test/python_api/watchpoint/main.c Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/scripts/Python/interface/SBFrame.i lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=140436&r1=140435&r2=140436&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Fri Sep 23 19:50:33 2011 @@ -176,6 +176,13 @@ lldb::SBValue FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); + /// Find and watch a variable using the frame as the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + lldb::SBValue + WatchValue (const char *name, ValueType value_type, uint32_t watch_type); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/scripts/Python/interface/SBFrame.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBFrame.i?rev=140436&r1=140435&r2=140436&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBFrame.i (original) +++ lldb/trunk/scripts/Python/interface/SBFrame.i Fri Sep 23 19:50:33 2011 @@ -215,6 +215,15 @@ lldb::SBValue FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); + %feature("docstring", " + /// Find and watch a variable using the frame as the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + ") FindValue; + lldb::SBValue + WatchValue (const char *name, ValueType value_type, uint32_t watch_type); + bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=140436&r1=140435&r2=140436&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Fri Sep 23 19:50:33 2011 @@ -14,6 +14,7 @@ #include "lldb/lldb-types.h" +#include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/Address.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" @@ -405,6 +406,48 @@ return value; } +/// Find and watch a variable using the frame as the scope. +/// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. +SBValue +SBFrame::WatchValue (const char *name, ValueType value_type, uint32_t watch_type) +{ + SBValue sb_value_empty; + + if (!IsValid()) + return sb_value_empty; + + // Acquire the API locker, to be released at the end of the method call. + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); + + switch (value_type) { + case eValueTypeVariableGlobal: // global variable + case eValueTypeVariableStatic: // static variable + case eValueTypeVariableArgument: // function argument variables + case eValueTypeVariableLocal: // function local variables + break; + default: + return sb_value_empty; // these are not eligible for watching + } + + SBValue sb_value = FindValue(name, value_type); + // If the SBValue is not valid, there's no point in even trying to watch it. + if (!sb_value.IsValid()) + return sb_value; + + addr_t addr = sb_value.GetLoadAddress(); + size_t size = sb_value.GetByteSize(); + + WatchpointLocationSP wp_loc_sp = m_opaque_sp->GetThread().GetProcess().GetTarget(). + CreateWatchpointLocation(addr, size, watch_type); + + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBFrame(%p)::WatchValue (name=\"%s\", value_type=%i, watch_type=%i) => SBValue(%p) & wp_loc(%p)", + m_opaque_sp.get(), name, value_type, watch_type, sb_value.get(), wp_loc_sp.get()); + + return wp_loc_sp ? sb_value : sb_value_empty; +} + SBValue SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) { Added: lldb/trunk/test/python_api/watchpoint/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/Makefile?rev=140436&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/Makefile (added) +++ lldb/trunk/test/python_api/watchpoint/Makefile Fri Sep 23 19:50:33 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py?rev=140436&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py (added) +++ lldb/trunk/test/python_api/watchpoint/TestSetWatchpoint.py Fri Sep 23 19:50:33 2011 @@ -0,0 +1,97 @@ +""" +Use lldb Python SBFrame API to create a watchpoint for read_write of 'globl' var +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class SetWatchpointAPITestCase(TestBase): + + mydir = os.path.join("python_api", "watchpoint") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Our simple source filename. + self.source = 'main.c' + # Find the line number to break inside main(). + self.line = line_number(self.source, '// Set break point at this line.') + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_watch_val_with_dsym(self): + """Exercise SBFrame.WatchValue() API to set a watchpoint.""" + self.buildDsym() + self.do_set_watchpoint() + + @python_api_test + def test_watch_val_with_dwarf(self): + """Exercise SBFrame.WatchValue() API to set a watchpoint.""" + self.buildDwarf() + self.do_set_watchpoint() + + def do_set_watchpoint(self): + """Use SBFrame.WatchValue() to set a watchpoint and verify that the program stops later due to the watchpoint.""" + exe = os.path.join(os.getcwd(), "a.out") + + # 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) + + value = frame0.WatchValue('global', + lldb.eValueTypeVariableGlobal, + lldb.LLDB_WATCH_TYPE_READ|lldb.LLDB_WATCH_TYPE_WRITE) + self.assertTrue(value, "Successfully found the variable and set a watchpoint") + self.DebugSBValue(value) + + # 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) + + # Continue. Expect the program to stop due to the variable being read from. + 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) + + # Continue the process. We don't expect the program to be stopped again. + process.Continue() + + # At this point, the inferior process should have exited. + self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/watchpoint/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/main.c?rev=140436&view=auto ============================================================================== --- lldb/trunk/test/python_api/watchpoint/main.c (added) +++ lldb/trunk/test/python_api/watchpoint/main.c Fri Sep 23 19:50:33 2011 @@ -0,0 +1,24 @@ +//===-- 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 = 10; // Watchpoint variable declaration. + +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 write. + global = 20; + local += argc; + ++local; + printf("local: %d\n", local); + printf("global=%d\n", global); +} From gclayton at apple.com Fri Sep 23 19:52:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 24 Sep 2011 00:52:29 -0000 Subject: [Lldb-commits] [lldb] r140437 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ scripts/ scripts/Python/interface/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Target/ test/python_api/default-constructor/ test/python_api/function_symbol/ Message-ID: <20110924005230.246792A6C12C@llvm.org> Author: gclayton Date: Fri Sep 23 19:52:29 2011 New Revision: 140437 URL: http://llvm.org/viewvc/llvm-project?rev=140437&view=rev Log: Added to the public API to allow symbolication: - New SBSection objects that are object file sections which can be accessed through the SBModule classes. You can get the number of sections, get a section at index, and find a section by name. - SBSections can contain subsections (first find "__TEXT" on darwin, then us the resulting SBSection to find "__text" sub section). - Set load addresses for a SBSection in the SBTarget interface - Set the load addresses of all SBSection in a SBModule in the SBTarget interface - Add a new module the an existing target in the SBTarget interface - Get a SBSection from a SBAddress object This should get us a lot closer to being able to symbolicate using LLDB through the public API. Added: lldb/trunk/include/lldb/API/SBSection.h lldb/trunk/source/API/SBSection.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBData.h lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/TargetList.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/interface/SBAddress.i lldb/trunk/scripts/Python/interface/SBDebugger.i lldb/trunk/scripts/Python/interface/SBModule.i lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/TargetList.cpp lldb/trunk/test/python_api/default-constructor/sb_address.py lldb/trunk/test/python_api/default-constructor/sb_module.py lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Fri Sep 23 19:52:29 2011 @@ -54,9 +54,6 @@ bool GetDescription (lldb::SBStream &description); - SectionType - GetSectionType (); - // The following queries can lookup symbol information for a given address. // An address might refer to code or data from an existing module, or it // might refer to something on the stack or heap. The following functions @@ -76,6 +73,9 @@ // One or more bits from the SymbolContextItem enumerations can be logically // OR'ed together to more efficiently retrieve multiple symbol objects. + lldb::SBSection + GetSection (); + lldb::SBModule GetModule (); @@ -102,6 +102,7 @@ friend class SBLineEntry; friend class SBInstruction; friend class SBModule; + friend class SBSection; friend class SBSymbol; friend class SBSymbolContext; friend class SBTarget; @@ -135,7 +136,7 @@ private: - std::auto_ptr m_opaque_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBData.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBData.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBData.h (original) +++ lldb/trunk/include/lldb/API/SBData.h Fri Sep 23 19:52:29 2011 @@ -126,7 +126,8 @@ private: friend class SBValue; - + friend class SBSection; + lldb::DataExtractorSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Sep 23 19:52:29 2011 @@ -100,6 +100,13 @@ FILE *err); lldb::SBTarget + CreateTarget (const char *filename, + const char *target_triple, + const char *platform_name, + bool add_dependent_modules, + lldb::SBError& error); + + lldb::SBTarget CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple); Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Fri Sep 23 19:52:29 2011 @@ -11,6 +11,8 @@ #define LLDB_SBModule_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBSection.h" #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBValueList.h" @@ -84,10 +86,11 @@ operator != (const lldb::SBModule &rhs) const; #endif + lldb::SBSection + FindSection (const char *sect_name); - bool - ResolveFileAddress (lldb::addr_t vm_addr, - lldb::SBAddress& addr); + lldb::SBAddress + ResolveFileAddress (lldb::addr_t vm_addr); lldb::SBSymbolContext ResolveSymbolContextForAddress (const lldb::SBAddress& addr, @@ -102,6 +105,11 @@ lldb::SBSymbol GetSymbolAtIndex (size_t idx); + size_t + GetNumSections (); + + lldb::SBSection + GetSectionAtIndex (size_t idx); //------------------------------------------------------------------ /// Find functions by name. /// @@ -162,6 +170,7 @@ private: friend class SBAddress; friend class SBFrame; + friend class SBSection; friend class SBSymbolContext; friend class SBTarget; @@ -187,6 +196,10 @@ const lldb_private::Module * get() const; + const lldb::ModuleSP & + get_sp() const; + + #endif lldb::ModuleSP m_opaque_sp; Added: lldb/trunk/include/lldb/API/SBSection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=140437&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBSection.h (added) +++ lldb/trunk/include/lldb/API/SBSection.h Fri Sep 23 19:52:29 2011 @@ -0,0 +1,97 @@ +//===-- SBSection.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSection_h_ +#define LLDB_SBSection_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBData.h" + +namespace lldb { + +class SBSection +{ +public: + + SBSection (); + + SBSection (const lldb::SBSection &rhs); + + ~SBSection (); + +#ifndef SWIG + const lldb::SBSection & + operator = (const lldb::SBSection &rhs); +#endif + bool + IsValid () const; + + lldb::SBSection + FindSubSection (const char *sect_name); + + size_t + GetNumSubSections (); + + lldb::SBSection + GetSubSectionAtIndex (size_t idx); + + lldb::addr_t + GetFileAddress (); + + lldb::addr_t + GetByteSize (); + + uint64_t + GetFileOffset (); + + uint64_t + GetFileByteSize (); + + lldb::SBData + GetSectionData (uint64_t offset = 0, + uint64_t size = UINT64_MAX); + + SectionType + GetSectionType (); + +#ifndef SWIG + bool + operator == (const lldb::SBSection &rhs); + + bool + operator != (const lldb::SBSection &rhs); + +#endif + + bool + GetDescription (lldb::SBStream &description); + +private: + +#ifndef SWIG + friend class SBAddress; + friend class SBModule; + friend class SBTarget; + + SBSection (const lldb_private::Section *section); + + const lldb_private::Section * + GetSection(); + + void + SetSection (const lldb_private::Section *section); +#endif + + std::auto_ptr m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBSection_h_ Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Fri Sep 23 19:52:29 2011 @@ -237,12 +237,23 @@ lldb::SBFileSpec GetExecutable (); + bool + AddModule (lldb::SBModule &module); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid); + uint32_t GetNumModules () const; lldb::SBModule GetModuleAtIndex (uint32_t idx); + bool + RemoveModule (lldb::SBModule module); + lldb::SBDebugger GetDebugger() const; @@ -250,6 +261,76 @@ FindModule (const lldb::SBFileSpec &file_spec); //------------------------------------------------------------------ + /// Set the base load address for a module section. + /// + /// @param[in] section + /// The section whose base load address will be set within this + /// target. + /// + /// @param[in] section_base_addr + /// The base address for the section. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + SetSectionLoadAddress (lldb::SBSection section, + lldb::addr_t section_base_addr); + + //------------------------------------------------------------------ + /// Clear the base load address for a module section. + /// + /// @param[in] section + /// The section whose base load address will be cleared within + /// this target. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + ClearSectionLoadAddress (lldb::SBSection section); + + //------------------------------------------------------------------ + /// Slide all file addresses for all module sections so that \a module + /// appears to loaded at these slide addresses. + /// + /// When you need all sections within a module to be loaded at a + /// rigid slide from the addresses found in the module object file, + /// this function will allow you to easily and quickly slide all + /// module sections. + /// + /// @param[in] module + /// The module to load. + /// + /// @param[in] sections_offset + /// An offset that will be applied to all section file addresses + /// (the virtual addresses found in the object file itself). + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + SetModuleLoadAddress (lldb::SBModule module, + int64_t sections_offset); + + + //------------------------------------------------------------------ + /// The the section base load addresses for all sections in a module. + /// + /// @param[in] module + /// The module to unload. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + ClearModuleLoadAddress (lldb::SBModule module); + + //------------------------------------------------------------------ /// Find functions by name. /// /// @param[in] name Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Fri Sep 23 19:52:29 2011 @@ -73,10 +73,10 @@ /// A shared pointer to a module to add to this collection. //------------------------------------------------------------------ void - Append (lldb::ModuleSP &module_sp); + Append (const lldb::ModuleSP &module_sp); bool - AppendIfNeeded (lldb::ModuleSP &module_sp); + AppendIfNeeded (const lldb::ModuleSP &module_sp); //------------------------------------------------------------------ /// Clear the object's state. @@ -358,7 +358,7 @@ TypeList& types); bool - Remove (lldb::ModuleSP &module_sp); + Remove (const lldb::ModuleSP &module_sp); size_t Remove (ModuleList &module_list); Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupPlatform.h Fri Sep 23 19:52:29 2011 @@ -61,7 +61,7 @@ lldb::PlatformSP CreatePlatformWithOptions (CommandInterpreter &interpreter, bool make_selected, - Error& error); + Error& error) const; bool PlatformWasSpecified () const Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Fri Sep 23 19:52:29 2011 @@ -32,8 +32,6 @@ #include "lldb/Target/PathMappingList.h" #include "lldb/Target/SectionLoadList.h" -#include "lldb/API/SBTarget.h" - namespace lldb_private { //---------------------------------------------------------------------- @@ -854,9 +852,7 @@ }; -protected: - friend class lldb::SBTarget; - +protected: //------------------------------------------------------------------ // Member variables. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/TargetList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/TargetList.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/TargetList.h (original) +++ lldb/trunk/include/lldb/Target/TargetList.h Fri Sep 23 19:52:29 2011 @@ -58,31 +58,55 @@ /// locate an appropriate target to deliver asynchronous information /// to. /// + /// @param[in] debugger + /// The debugger to associate this target with + /// /// @param[in] file_spec /// The main executable file for a debug target. This value /// can be NULL and the file can be set later using: /// Target::SetExecutableModule (ModuleSP&) /// - /// @param[in] arch - /// The architecture to use when launching the \a file_spec for - /// debugging. This can be NULL if the architecture is not known - /// or when attaching to a process. - /// - /// @param[in] uuid_ptr - /// An optional UUID to use when loading a target. When this is - /// specified, plug-ins might be able to track down a different - /// executable than the one on disk specified by "file_spec" in - /// an alternate SDK or build location (such as when doing - /// symbolication on non-native OS builds). + /// @param[in] triple_cstr + /// A target triple string to be used for the target. This can + /// be NULL if the triple is not known or when attaching to a + /// process. + /// + /// @param[in] get_dependent_modules + /// Track down the dependent modules for an executable and + /// load those into the module list. + /// + /// @param[in] platform_options + /// A pointer to the platform options to use when creating this + /// target. If this value is NULL, then the currently selected + /// platform will be used. + /// + /// @param[out] target_sp + /// A shared pointer to a target that will be filled in if + /// this call is successful. /// /// @return - /// A shared pointer to a target object. + /// An error object that indicates success or failure + //------------------------------------------------------------------ + Error + CreateTarget (Debugger &debugger, + const FileSpec& file_spec, + const char *triple_cstr, + bool get_dependent_modules, + const OptionGroupPlatform *platform_options, + lldb::TargetSP &target_sp); + + //------------------------------------------------------------------ + /// Create a new Target. + /// + /// Same as the function above, but used when you already know the + /// platform you will be using //------------------------------------------------------------------ Error CreateTarget (Debugger &debugger, const FileSpec& file_spec, const ArchSpec& arch, - bool get_dependent_files, + bool get_dependent_modules, + const lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp); //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Fri Sep 23 19:52:29 2011 @@ -19,6 +19,7 @@ class ABI; class Address; +class AddressImpl; class AddressRange; class AddressResolver; class ArchSpec; @@ -100,6 +101,8 @@ class NameSearchContext; class ObjCLanguageRuntime; class ObjectContainer; +class OptionGroup; +class OptionGroupPlatform; class ObjectFile; class OperatingSystem; class Options; @@ -125,6 +128,7 @@ class ScriptInterpreterPython; class SearchFilter; class Section; +class SectionImpl; class SectionList; class SourceManager; class StackFrame; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 23 19:52:29 2011 @@ -350,6 +350,8 @@ 26B1FCBD13381071002886E2 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 26B1FCC21338115F002886E2 /* Host.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EE810F1B88F00F91463 /* Host.mm */; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26B8283D142D01E9002DBC64 /* SBSection.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B8283C142D01E9002DBC64 /* SBSection.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26B82840142D020F002DBC64 /* SBSection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B8283F142D020F002DBC64 /* SBSection.cpp */; }; 26BCFC521368AE38006DC050 /* OptionGroupFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC511368AE38006DC050 /* OptionGroupFormat.cpp */; }; 26BD407F135D2AE000237D80 /* FileLineResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BD407E135D2ADF00237D80 /* FileLineResolver.cpp */; }; 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -753,6 +755,8 @@ 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = ""; }; 26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = ""; }; 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = ""; }; + 26B8283C142D01E9002DBC64 /* SBSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSection.h; path = include/lldb/API/SBSection.h; sourceTree = ""; }; + 26B8283F142D020F002DBC64 /* SBSection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSection.cpp; path = source/API/SBSection.cpp; sourceTree = ""; }; 26B8B42212EEC52A00A831B2 /* UniqueDWARFASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniqueDWARFASTType.h; sourceTree = ""; }; 26B8B42312EEC52A00A831B2 /* UniqueDWARFASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueDWARFASTType.cpp; sourceTree = ""; }; 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-defines.h"; path = "include/lldb/lldb-defines.h"; sourceTree = ""; }; @@ -1718,6 +1722,8 @@ 26DE204C11618E7A00A093E2 /* SBModule.cpp */, 9A9831041125FC5800A56CB0 /* SBProcess.h */, 9A9831031125FC5800A56CB0 /* SBProcess.cpp */, + 26B8283C142D01E9002DBC64 /* SBSection.h */, + 26B8283F142D020F002DBC64 /* SBSection.cpp */, 9A9831061125FC5800A56CB0 /* SBSourceManager.h */, 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp */, 26C72C93124322890068DC16 /* SBStream.h */, @@ -2773,6 +2779,7 @@ 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, 4CAA56131422D96A001FFA01 /* BreakpointResolverFileRegex.h in Headers */, 4CF52AF51428291E0051E832 /* SBFileSpecList.h in Headers */, + 26B8283D142D01E9002DBC64 /* SBSection.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3058,6 +3065,7 @@ 9443B122140C18C40013457C /* SBData.cpp in Sources */, 4CAA56151422D986001FFA01 /* BreakpointResolverFileRegex.cpp in Sources */, 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */, + 26B82840142D020F002DBC64 /* SBSection.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/scripts/Python/interface/SBAddress.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBAddress.i (original) +++ lldb/trunk/scripts/Python/interface/SBAddress.i Fri Sep 23 19:52:29 2011 @@ -79,8 +79,8 @@ bool GetDescription (lldb::SBStream &description); - SectionType - GetSectionType (); + lldb::SBSection + GetSection (); %feature("docstring", " //------------------------------------------------------------------ Modified: lldb/trunk/scripts/Python/interface/SBDebugger.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDebugger.i?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBDebugger.i (original) +++ lldb/trunk/scripts/Python/interface/SBDebugger.i Fri Sep 23 19:52:29 2011 @@ -177,6 +177,13 @@ FILE *err); lldb::SBTarget + CreateTarget (const char *filename, + const char *target_triple, + const char *platform_name, + bool add_dependent_modules, + lldb::SBError& sb_error); + + lldb::SBTarget CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple); Modified: lldb/trunk/scripts/Python/interface/SBModule.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i (original) +++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Sep 23 19:52:29 2011 @@ -89,9 +89,11 @@ const char * GetUUIDString () const; - bool - ResolveFileAddress (lldb::addr_t vm_addr, - lldb::SBAddress& addr); + lldb::SBSection + FindSection (const char *sect_name); + + lldb::SBAddress + ResolveFileAddress (lldb::addr_t vm_addr); lldb::SBSymbolContext ResolveSymbolContextForAddress (const lldb::SBAddress& addr, @@ -106,6 +108,13 @@ lldb::SBSymbol GetSymbolAtIndex (size_t idx); + size_t + GetNumSections (); + + lldb::SBSection + GetSectionAtIndex (size_t idx); + + %feature("docstring", " //------------------------------------------------------------------ /// Find functions by name. Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Fri Sep 23 19:52:29 2011 @@ -277,18 +277,43 @@ lldb::SBFileSpec GetExecutable (); + bool + AddModule (lldb::SBModule &module); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid); + uint32_t GetNumModules () const; lldb::SBModule GetModuleAtIndex (uint32_t idx); + bool + RemoveModule (lldb::SBModule module); + lldb::SBDebugger GetDebugger() const; lldb::SBModule FindModule (const lldb::SBFileSpec &file_spec); + lldb::SBError + SetSectionLoadAddress (lldb::SBSection section, + lldb::addr_t section_base_addr); + + lldb::SBError + ClearSectionLoadAddress (lldb::SBSection section); + + lldb::SBError + SetModuleLoadAddress (lldb::SBModule module, + int64_t sections_offset); + + lldb::SBError + ClearModuleLoadAddress (lldb::SBModule module); + %feature("docstring", " //------------------------------------------------------------------ /// Find functions by name. Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Fri Sep 23 19:52:29 2011 @@ -67,6 +67,7 @@ #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" @@ -118,6 +119,7 @@ %include "./Python/interface/SBListener.i" %include "./Python/interface/SBModule.i" %include "./Python/interface/SBProcess.i" +%include "./Python/interface/SBSection.i" %include "./Python/interface/SBSourceManager.i" %include "./Python/interface/SBStream.i" %include "./Python/interface/SBStringList.i" Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Fri Sep 23 19:52:29 2011 @@ -9,6 +9,7 @@ #include "lldb/API/SBAddress.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBSection.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Address.h" #include "lldb/Core/Log.h" @@ -16,6 +17,69 @@ #include "lldb/Host/Mutex.h" #include "lldb/Target/Target.h" +namespace lldb_private +{ + // We need a address implementation to hold onto a reference to the module + // since if the module goes away and we have anyone still holding onto a + // SBAddress object, we could crash. + class AddressImpl + { + public: + AddressImpl () : + m_module_sp(), + m_address() + { + } + + AddressImpl (const Address &addr) : + m_module_sp (addr.GetModule()), + m_address (addr) + { + } + + AddressImpl (const AddressImpl &rhs) : + m_module_sp (rhs.m_module_sp), + m_address (rhs.m_address) + { + } + + bool + IsValid () const + { + return m_address.IsValid(); + } + + void + operator = (const AddressImpl &rhs) + { + m_module_sp = rhs.m_module_sp; + m_address = rhs.m_address; + } + + Address & + GetAddress () + { + return m_address; + } + + Module * + GetModule() + { + return m_module_sp.get(); + } + + const lldb::ModuleSP & + GetModuleSP() const + { + return m_module_sp; + } + protected: + lldb::ModuleSP m_module_sp; + Address m_address; + }; +} + + using namespace lldb; using namespace lldb_private; @@ -25,18 +89,18 @@ { } -SBAddress::SBAddress (const lldb_private::Address *lldb_object_ptr) : +SBAddress::SBAddress (const Address *lldb_object_ptr) : m_opaque_ap () { if (lldb_object_ptr) - m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); + m_opaque_ap.reset (new AddressImpl(*lldb_object_ptr)); } SBAddress::SBAddress (const SBAddress &rhs) : m_opaque_ap () { if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); + m_opaque_ap.reset (new AddressImpl(*rhs.m_opaque_ap.get())); } // Create an address by resolving a load address using the supplied target @@ -55,8 +119,13 @@ const SBAddress & SBAddress::operator = (const SBAddress &rhs) { - if (this != &rhs && rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); + if (this != &rhs) + { + if (rhs.IsValid()) + m_opaque_ap.reset(new AddressImpl(*rhs.m_opaque_ap.get())); + else + m_opaque_ap.reset(); + } return *this; } @@ -73,25 +142,24 @@ } void -SBAddress::SetAddress (const lldb_private::Address *lldb_object_ptr) +SBAddress::SetAddress (const Address *lldb_object_ptr) { if (lldb_object_ptr) { if (m_opaque_ap.get()) *m_opaque_ap = *lldb_object_ptr; else - m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); - return; + m_opaque_ap.reset (new AddressImpl(*lldb_object_ptr)); } - if (m_opaque_ap.get()) - m_opaque_ap->Clear(); + else + m_opaque_ap.reset(); } lldb::addr_t SBAddress::GetFileAddress () const { if (m_opaque_ap.get()) - return m_opaque_ap->GetFileAddress(); + return m_opaque_ap->GetAddress().GetFileAddress(); else return LLDB_INVALID_ADDRESS; } @@ -99,13 +167,13 @@ lldb::addr_t SBAddress::GetLoadAddress (const SBTarget &target) const { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); lldb::addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_ap.get()) { Mutex::Locker api_locker (target->GetAPIMutex()); - addr = m_opaque_ap->GetLoadAddress (target.get()); + addr = m_opaque_ap->GetAddress().GetLoadAddress (target.get()); } if (log) @@ -127,14 +195,14 @@ if (target.IsValid()) *this = target.ResolveLoadAddress(load_addr); else - m_opaque_ap->Clear(); + m_opaque_ap->GetAddress().Clear(); // Check if we weren't were able to resolve a section offset address. // If we weren't it is ok, the load address might be a location on the // stack or heap, so we should just have an address with no section and // a valid offset if (!m_opaque_ap->IsValid()) - m_opaque_ap->SetOffset(load_addr); + m_opaque_ap->GetAddress().SetOffset(load_addr); } bool @@ -142,50 +210,66 @@ { if (m_opaque_ap.get()) { - addr_t addr_offset = m_opaque_ap->GetOffset(); + addr_t addr_offset = m_opaque_ap->GetAddress().GetOffset(); if (addr_offset != LLDB_INVALID_ADDRESS) { - m_opaque_ap->SetOffset(addr_offset + offset); + m_opaque_ap->GetAddress().SetOffset(addr_offset + offset); return true; } } return false; } -lldb_private::Address * +lldb::SBSection +SBAddress::GetSection () +{ + lldb::SBSection sb_section; + if (m_opaque_ap.get()) + sb_section.SetSection(m_opaque_ap->GetAddress().GetSection()); + return sb_section; +} + + +Address * SBAddress::operator->() { - return m_opaque_ap.get(); + if (m_opaque_ap.get()) + return &m_opaque_ap->GetAddress(); + return NULL; } -const lldb_private::Address * +const Address * SBAddress::operator->() const { - return m_opaque_ap.get(); + if (m_opaque_ap.get()) + return &m_opaque_ap->GetAddress(); + return NULL; } -lldb_private::Address & +Address & SBAddress::ref () { if (m_opaque_ap.get() == NULL) - m_opaque_ap.reset (new lldb_private::Address); - return *m_opaque_ap; + m_opaque_ap.reset (new AddressImpl()); + return m_opaque_ap->GetAddress(); } -const lldb_private::Address & +const Address & SBAddress::ref () const { // "const SBAddress &addr" should already have checked "addr.IsValid()" // prior to calling this function. In case you didn't we will assert // and die to let you know. assert (m_opaque_ap.get()); - return *m_opaque_ap; + return m_opaque_ap->GetAddress(); } -lldb_private::Address * +Address * SBAddress::get () { - return m_opaque_ap.get(); + if (m_opaque_ap.get()) + return &m_opaque_ap->GetAddress(); + return NULL; } bool @@ -195,26 +279,13 @@ // case there isn't one already... description.ref(); if (m_opaque_ap.get()) - m_opaque_ap->Dump (description.get(), NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4); + m_opaque_ap->GetAddress().Dump (description.get(), NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4); else description.Printf ("No value"); return true; } -SectionType -SBAddress::GetSectionType () -{ - if (m_opaque_ap.get()) - { - const Section *section = m_opaque_ap->GetSection(); - if (section) - return section->GetType(); - } - return eSectionTypeInvalid; -} - - SBModule SBAddress::GetModule () { @@ -233,7 +304,7 @@ { SBSymbolContext sb_sc; if (m_opaque_ap.get()) - m_opaque_ap->CalculateSymbolContext (&sb_sc.ref(), resolve_scope); + m_opaque_ap->GetAddress().CalculateSymbolContext (&sb_sc.ref(), resolve_scope); return sb_sc; } @@ -242,7 +313,7 @@ { SBCompileUnit sb_comp_unit; if (m_opaque_ap.get()) - sb_comp_unit.reset(m_opaque_ap->CalculateSymbolContextCompileUnit()); + sb_comp_unit.reset(m_opaque_ap->GetAddress().CalculateSymbolContextCompileUnit()); return sb_comp_unit; } @@ -251,7 +322,7 @@ { SBFunction sb_function; if (m_opaque_ap.get()) - sb_function.reset(m_opaque_ap->CalculateSymbolContextFunction()); + sb_function.reset(m_opaque_ap->GetAddress().CalculateSymbolContextFunction()); return sb_function; } @@ -260,7 +331,7 @@ { SBBlock sb_block; if (m_opaque_ap.get()) - sb_block.reset(m_opaque_ap->CalculateSymbolContextBlock()); + sb_block.reset(m_opaque_ap->GetAddress().CalculateSymbolContextBlock()); return sb_block; } @@ -269,7 +340,7 @@ { SBSymbol sb_symbol; if (m_opaque_ap.get()) - sb_symbol.reset(m_opaque_ap->CalculateSymbolContextSymbol()); + sb_symbol.reset(m_opaque_ap->GetAddress().CalculateSymbolContextSymbol()); return sb_symbol; } @@ -280,7 +351,7 @@ if (m_opaque_ap.get()) { LineEntry line_entry; - if (m_opaque_ap->CalculateSymbolContextLineEntry (line_entry)) + if (m_opaque_ap->GetAddress().CalculateSymbolContextLineEntry (line_entry)) sb_line_entry.SetLineEntry (line_entry); } return sb_line_entry; Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Sep 23 19:52:29 2011 @@ -29,6 +29,7 @@ #include "lldb/Core/State.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/OptionGroupPlatform.h" #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" @@ -459,6 +460,52 @@ return result; } +lldb::SBTarget +SBDebugger::CreateTarget (const char *filename, + const char *target_triple, + const char *platform_name, + bool add_dependent_modules, + lldb::SBError& sb_error) +{ + SBTarget sb_target; + if (m_opaque_sp) + { + sb_error.Clear(); + FileSpec filename_spec (filename, true); + OptionGroupPlatform platform_options (false); + platform_options.SetPlatformName (platform_name); + + TargetSP target_sp; + sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, + filename_spec, + target_triple, + add_dependent_modules, + &platform_options, + target_sp); + + if (sb_error.Success()) + sb_target.reset (target_sp); + } + else + { + sb_error.SetErrorString("invalid target"); + } + + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + { + log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, platform_name=%s, add_dependent_modules=%u, error=%s) => SBTarget(%p)", + m_opaque_sp.get(), + filename, + target_triple, + platform_name, + add_dependent_modules, + sb_error.GetCString(), + sb_target.get()); + } + + return sb_target; +} SBTarget SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, @@ -467,11 +514,15 @@ SBTarget target; if (m_opaque_sp) { - ArchSpec arch; FileSpec file_spec (filename, true); - arch.SetTriple (target_triple, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get()); TargetSP target_sp; - Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, true, target_sp)); + const bool add_dependent_modules = true; + Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, + file_spec, + target_triple, + add_dependent_modules, + NULL, + target_sp)); target.reset (target_sp); } @@ -494,14 +545,16 @@ if (m_opaque_sp) { FileSpec file (filename, true); - ArchSpec arch; TargetSP target_sp; Error error; + const bool add_dependent_modules = true; - if (arch_cstr) - arch.SetTriple (arch_cstr, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get()); - - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, + file, + arch_cstr, + add_dependent_modules, + NULL, + target_sp); if (error.Success()) { @@ -529,8 +582,14 @@ ArchSpec arch = Target::GetDefaultArchitecture (); TargetSP target_sp; Error error; + const bool add_dependent_modules = true; - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, + file, + arch, + add_dependent_modules, + m_opaque_sp->GetPlatformList().GetSelectedPlatform(), + target_sp); if (error.Success()) { Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Fri Sep 23 19:52:29 2011 @@ -217,6 +217,11 @@ return m_opaque_sp.get(); } +const lldb::ModuleSP & +SBModule::get_sp() const +{ + return m_opaque_sp; +} void SBModule::SetModule (const lldb::ModuleSP& module_sp) @@ -225,15 +230,17 @@ } -bool -SBModule::ResolveFileAddress (lldb::addr_t vm_addr, SBAddress& addr) +SBAddress +SBModule::ResolveFileAddress (lldb::addr_t vm_addr) { - if (m_opaque_sp && addr.IsValid()) - return m_opaque_sp->ResolveFileAddress (vm_addr, addr.ref()); - - if (addr.IsValid()) - addr->Clear(); - return false; + lldb::SBAddress sb_addr; + if (m_opaque_sp) + { + Address addr; + if (m_opaque_sp->ResolveFileAddress (vm_addr, addr)) + sb_addr.ref() = addr; + } + return sb_addr; } SBSymbolContext @@ -292,6 +299,40 @@ return sb_symbol; } +size_t +SBModule::GetNumSections () +{ + if (m_opaque_sp) + { + ObjectFile *obj_file = m_opaque_sp->GetObjectFile(); + if (obj_file) + { + SectionList *section_list = obj_file->GetSectionList (); + if (section_list) + return section_list->GetSize(); + } + } + return 0; +} + +SBSection +SBModule::GetSectionAtIndex (size_t idx) +{ + SBSection sb_section; + if (m_opaque_sp) + { + ObjectFile *obj_file = m_opaque_sp->GetObjectFile(); + if (obj_file) + { + SectionList *section_list = obj_file->GetSectionList (); + + if (section_list) + sb_section.SetSection(section_list->GetSectionAtIndex (idx).get()); + } + } + return sb_section; +} + uint32_t SBModule::FindFunctions (const char *name, uint32_t name_type_mask, @@ -396,3 +437,30 @@ return retval; } + + +SBSection +SBModule::FindSection (const char *sect_name) +{ + SBSection sb_section; + + if (IsValid()) + { + ObjectFile *objfile = m_opaque_sp->GetObjectFile(); + if (objfile) + { + SectionList *section_list = objfile->GetSectionList(); + if (section_list) + { + ConstString const_sect_name(sect_name); + SectionSP section_sp (section_list->FindSectionByName(const_sect_name)); + if (section_sp) + { + sb_section.SetSection(section_sp.get()); + } + } + } + } + return sb_section; +} + Added: lldb/trunk/source/API/SBSection.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=140437&view=auto ============================================================================== --- lldb/trunk/source/API/SBSection.cpp (added) +++ lldb/trunk/source/API/SBSection.cpp Fri Sep 23 19:52:29 2011 @@ -0,0 +1,324 @@ +//===-- SBSection.cpp -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBSection.h" +#include "lldb/API/SBStream.h" +#include "lldb/Core/DataBuffer.h" +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Section.h" +#include "lldb/Core/Module.h" + +namespace lldb_private +{ + // We need a section implementation to hold onto a reference to the module + // since if the module goes away and we have anyone still holding onto a + // SBSection object, we could crash. + class SectionImpl + { + public: + SectionImpl (const lldb_private::Section *section = NULL) : + m_module_sp (), + m_section (section) + { + if (section) + m_module_sp = section->GetModule(); + } + + SectionImpl (const SectionImpl &rhs) : + m_module_sp (rhs.m_module_sp), + m_section (rhs.m_section) + { + } + + bool + IsValid () const + { + return m_section != NULL; + } + + void + operator = (const SectionImpl &rhs) + { + m_module_sp = rhs.m_module_sp; + m_section = rhs.m_section; + } + + void + operator =(const lldb_private::Section *section) + { + m_section = section; + if (section) + m_module_sp.reset(section->GetModule()); + else + m_module_sp.reset(); + } + + const lldb_private::Section * + GetSection () const + { + return m_section; + } + + Module * + GetModule() + { + return m_module_sp.get(); + } + + const lldb::ModuleSP & + GetModuleSP() const + { + return m_module_sp; + } + protected: + lldb::ModuleSP m_module_sp; + const lldb_private::Section *m_section; + }; +} + +using namespace lldb; +using namespace lldb_private; + + +SBSection::SBSection () : + m_opaque_ap () +{ +} + +SBSection::SBSection (const SBSection &rhs) : + m_opaque_ap () +{ + if (rhs.IsValid()) + m_opaque_ap.reset (new SectionImpl (*rhs.m_opaque_ap)); +} + + + +SBSection::SBSection (const lldb_private::Section *section) : + m_opaque_ap () +{ + if (section) + m_opaque_ap.reset (new SectionImpl(section)); +} + +const SBSection & +SBSection::operator = (const SBSection &rhs) +{ + if (this != &rhs && rhs.IsValid()) + m_opaque_ap.reset (new SectionImpl(*rhs.m_opaque_ap)); + else + m_opaque_ap.reset (); + return *this; +} + +SBSection::~SBSection () +{ +} + +bool +SBSection::IsValid () const +{ + return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); +} + +lldb::SBSection +SBSection::FindSubSection (const char *sect_name) +{ + lldb::SBSection sb_section; + if (IsValid()) + { + ConstString const_sect_name(sect_name); + sb_section.SetSection(m_opaque_ap->GetSection()->GetChildren ().FindSectionByName(const_sect_name).get()); + } + return sb_section; +} + +size_t +SBSection::GetNumSubSections () +{ + if (IsValid()) + return m_opaque_ap->GetSection()->GetChildren ().GetSize(); + return 0; +} + +lldb::SBSection +SBSection::GetSubSectionAtIndex (size_t idx) +{ + lldb::SBSection sb_section; + if (IsValid()) + sb_section.SetSection(m_opaque_ap->GetSection()->GetChildren ().GetSectionAtIndex(idx).get()); + return sb_section; +} + +const lldb_private::Section * +SBSection::GetSection() +{ + if (m_opaque_ap.get()) + return m_opaque_ap->GetSection(); + return NULL; +} + +void +SBSection::SetSection (const lldb_private::Section *section) +{ + m_opaque_ap.reset (new SectionImpl(section)); +} + + + + +lldb::addr_t +SBSection::GetFileAddress () +{ + lldb::addr_t file_addr = LLDB_INVALID_ADDRESS; + if (IsValid()) + return m_opaque_ap->GetSection()->GetFileAddress(); + return file_addr; +} + +lldb::addr_t +SBSection::GetByteSize () +{ + if (IsValid()) + { + const Section *section = m_opaque_ap->GetSection(); + if (section) + return section->GetByteSize(); + } + return 0; +} + +uint64_t +SBSection::GetFileOffset () +{ + if (IsValid()) + { + const Section *section = m_opaque_ap->GetSection(); + if (section) + { + Module *module = m_opaque_ap->GetModule(); + if (module) + { + ObjectFile *objfile = module->GetObjectFile(); + if (objfile) + return objfile->GetOffset() + section->GetFileOffset(); + } + return section->GetFileOffset(); + } + } + return 0; +} + +uint64_t +SBSection::GetFileByteSize () +{ + if (IsValid()) + { + const Section *section = m_opaque_ap->GetSection(); + if (section) + return section->GetFileSize(); + } + return 0; +} + +SBData +SBSection::GetSectionData (uint64_t offset, uint64_t size) +{ + SBData sb_data; + if (IsValid()) + { + const Section *section = m_opaque_ap->GetSection(); + if (section) + { + const uint64_t sect_file_size = section->GetFileSize(); + if (sect_file_size > 0) + { + Module *module = m_opaque_ap->GetModule(); + if (module) + { + ObjectFile *objfile = module->GetObjectFile(); + if (objfile) + { + const uint64_t sect_file_offset = objfile->GetOffset() + section->GetFileOffset(); + const uint64_t file_offset = sect_file_offset + offset; + uint64_t file_size = size; + if (file_size == UINT64_MAX) + { + file_size = section->GetByteSize(); + if (file_size > offset) + file_size -= offset; + else + file_size = 0; + } + DataBufferSP data_buffer_sp (objfile->GetFileSpec().ReadFileContents (file_offset, file_size)); + if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) + { + DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp, + objfile->GetByteOrder(), + objfile->GetAddressByteSize())); + + sb_data.SetOpaque (data_extractor_sp); + } + } + } + } + } + } + return sb_data; +} + +SectionType +SBSection::GetSectionType () +{ + if (m_opaque_ap.get()) + { + const Section *section = m_opaque_ap->GetSection(); + if (section) + return section->GetType(); + } + return eSectionTypeInvalid; +} + + +bool +SBSection::operator == (const SBSection &rhs) +{ + SectionImpl *lhs_ptr = m_opaque_ap.get(); + SectionImpl *rhs_ptr = rhs.m_opaque_ap.get(); + if (lhs_ptr && rhs_ptr) + return lhs_ptr->GetSection() == rhs_ptr->GetSection(); + return false; +} + +bool +SBSection::operator != (const SBSection &rhs) +{ + SectionImpl *lhs_ptr = m_opaque_ap.get(); + SectionImpl *rhs_ptr = rhs.m_opaque_ap.get(); + if (lhs_ptr && rhs_ptr) + return lhs_ptr->GetSection() != rhs_ptr->GetSection(); + return false; +} + +bool +SBSection::GetDescription (SBStream &description) +{ + if (m_opaque_ap.get()) + { + description.Printf ("SBSection"); + } + else + { + description.Printf ("No value"); + } + + return true; +} + Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Sep 23 19:52:29 2011 @@ -867,6 +867,52 @@ } +lldb::SBModule +SBTarget::AddModule (const char *path, + const char *triple, + const char *uuid_cstr) +{ + lldb::SBModule sb_module; + if (m_opaque_sp) + { + FileSpec module_file_spec; + UUID module_uuid; + ArchSpec module_arch; + + if (path) + module_file_spec.SetFile(path, false); + + if (uuid_cstr) + module_uuid.SetfromCString(uuid_cstr); + + if (triple) + module_arch.SetTriple (triple, m_opaque_sp->GetPlatform ().get()); + + sb_module.SetModule(m_opaque_sp->GetSharedModule (module_file_spec, + module_arch, + uuid_cstr ? &module_uuid : NULL)); + } + return sb_module; +} + +bool +SBTarget::AddModule (lldb::SBModule &module) +{ + if (m_opaque_sp) + { + m_opaque_sp->GetImages().AppendIfNeeded (module.get_sp()); + return true; + } + return false; +} + +lldb::SBModule +AddModule (const char *path, + const char *triple, + const char *uuid); + + + uint32_t SBTarget::GetNumModules () const { @@ -930,6 +976,14 @@ return sb_module; } +bool +SBTarget::RemoveModule (lldb::SBModule module) +{ + if (m_opaque_sp) + return m_opaque_sp->GetImages().Remove(module.get_sp()); + return false; +} + SBBroadcaster SBTarget::GetBroadcaster () const @@ -1079,3 +1133,149 @@ SBSourceManager source_manager (*this); return source_manager; } + + +SBError +SBTarget::SetSectionLoadAddress (lldb::SBSection section, + lldb::addr_t section_base_addr) +{ + SBError sb_error; + + if (IsValid()) + { + if (!section.IsValid()) + { + sb_error.SetErrorStringWithFormat ("invalid section"); + } + else + { + m_opaque_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSection(), section_base_addr); + } + } + else + { + sb_error.SetErrorStringWithFormat ("invalid target"); + } + return sb_error; +} + +SBError +SBTarget::ClearSectionLoadAddress (lldb::SBSection section) +{ + SBError sb_error; + + if (IsValid()) + { + if (!section.IsValid()) + { + sb_error.SetErrorStringWithFormat ("invalid section"); + } + else + { + m_opaque_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection()); + } + } + else + { + sb_error.SetErrorStringWithFormat ("invalid target"); + } + return sb_error; +} + +SBError +SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) +{ + SBError sb_error; + + char path[PATH_MAX]; + if (IsValid()) + { + if (!module.IsValid()) + { + sb_error.SetErrorStringWithFormat ("invalid module"); + } + else + { + ObjectFile *objfile = module->GetObjectFile(); + if (objfile) + { + SectionList *section_list = objfile->GetSectionList(); + if (section_list) + { + const size_t num_sections = section_list->GetSize(); + for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) + { + SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); + if (section_sp) + m_opaque_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), section_sp->GetFileAddress() + slide_offset); + } + } + else + { + module->GetFileSpec().GetPath (path, sizeof(path)); + sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); + } + } + else + { + module->GetFileSpec().GetPath (path, sizeof(path)); + sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); + } + } + } + else + { + sb_error.SetErrorStringWithFormat ("invalid target"); + } + return sb_error; +} + +SBError +SBTarget::ClearModuleLoadAddress (lldb::SBModule module) +{ + SBError sb_error; + + char path[PATH_MAX]; + if (IsValid()) + { + if (!module.IsValid()) + { + sb_error.SetErrorStringWithFormat ("invalid module"); + } + else + { + ObjectFile *objfile = module->GetObjectFile(); + if (objfile) + { + SectionList *section_list = objfile->GetSectionList(); + if (section_list) + { + const size_t num_sections = section_list->GetSize(); + for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) + { + SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); + if (section_sp) + m_opaque_sp->GetSectionLoadList().SetSectionUnloaded (section_sp.get()); + } + } + else + { + module->GetFileSpec().GetPath (path, sizeof(path)); + sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); + } + } + else + { + module->GetFileSpec().GetPath (path, sizeof(path)); + sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); + } + } + } + else + { + sb_error.SetErrorStringWithFormat ("invalid target"); + } + return sb_error; +} + + Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Sep 23 19:52:29 2011 @@ -585,13 +585,13 @@ // If there isn't a current target create one. TargetSP new_target_sp; FileSpec emptyFileSpec; - ArchSpec emptyArchSpec; Error error; error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), emptyFileSpec, - emptyArchSpec, + NULL, false, + NULL, // No platform options new_target_sp); target = new_target_sp.get(); if (target == NULL || error.Fail()) @@ -1041,12 +1041,12 @@ { // If there isn't a current target create one. FileSpec emptyFileSpec; - ArchSpec emptyArchSpec; error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), emptyFileSpec, - emptyArchSpec, + NULL, false, + NULL, // No platform options target_sp); if (!target_sp || error.Fail()) { Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Sep 23 19:52:29 2011 @@ -186,48 +186,18 @@ const char *file_path = command.GetArgumentAtIndex(0); Timer scoped_timer(__PRETTY_FUNCTION__, "(lldb) target create '%s'", file_path); FileSpec file_spec (file_path, true); - - bool select = true; - PlatformSP platform_sp; - - Error error; - - if (m_platform_options.PlatformWasSpecified ()) - { - platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error); - if (!platform_sp) - { - result.AppendError(error.AsCString()); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - ArchSpec file_arch; - - const char *arch_cstr = m_arch_option.GetArchitectureName(); - if (arch_cstr) - { - if (!platform_sp) - platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform(); - if (!m_arch_option.GetArchitecture(platform_sp.get(), file_arch)) - { - result.AppendErrorWithFormat("invalid architecture '%s'\n", arch_cstr); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - - if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation()) - { - result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path); - result.SetStatus (eReturnStatusFailed); - return false; - } - + TargetSP target_sp; Debugger &debugger = m_interpreter.GetDebugger(); - error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp); - + const char *arch_cstr = m_arch_option.GetArchitectureName(); + const bool get_dependent_files = true; + Error error (debugger.GetTargetList().CreateTarget (debugger, + file_spec, + arch_cstr, + get_dependent_files, + &m_platform_options, + target_sp)); + if (target_sp) { debugger.GetTargetList().SetSelectedTarget(target_sp.get()); Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Fri Sep 23 19:52:29 2011 @@ -61,7 +61,7 @@ } void -ModuleList::Append (ModuleSP &module_sp) +ModuleList::Append (const ModuleSP &module_sp) { if (module_sp) { @@ -71,7 +71,7 @@ } bool -ModuleList::AppendIfNeeded (ModuleSP &module_sp) +ModuleList::AppendIfNeeded (const ModuleSP &module_sp) { if (module_sp) { @@ -90,7 +90,7 @@ } bool -ModuleList::Remove (ModuleSP &module_sp) +ModuleList::Remove (const ModuleSP &module_sp) { if (module_sp) { Modified: lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupPlatform.cpp Fri Sep 23 19:52:29 2011 @@ -21,7 +21,7 @@ using namespace lldb_private; PlatformSP -OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool make_selected, Error& error) +OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool make_selected, Error& error) const { PlatformSP platform_sp; if (!m_platform_name.empty()) Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Fri Sep 23 19:52:29 2011 @@ -423,12 +423,12 @@ { TargetSP new_target_sp; FileSpec emptyFileSpec; - ArchSpec emptyArchSpec; error = debugger.GetTargetList().CreateTarget (debugger, emptyFileSpec, - emptyArchSpec, + NULL, false, + NULL, new_target_sp); target = new_target_sp.get(); } Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri Sep 23 19:52:29 2011 @@ -360,12 +360,12 @@ { TargetSP new_target_sp; FileSpec emptyFileSpec; - ArchSpec emptyArchSpec; error = debugger.GetTargetList().CreateTarget (debugger, emptyFileSpec, - emptyArchSpec, + NULL, false, + NULL, new_target_sp); target = new_target_sp.get(); } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Sep 23 19:52:29 2011 @@ -782,7 +782,7 @@ } } - if (executable_objfile) + if (executable_objfile && get_dependent_files) { executable_objfile->GetDependentModules(dependent_files); for (uint32_t i=0; iPlatformWasSpecified ()) + { + const bool select_platform = true; + platform_sp = platform_options->CreatePlatformWithOptions (debugger.GetCommandInterpreter(), + select_platform, + error); + if (!platform_sp) + return error; + } + } + + if (!platform_sp) + platform_sp = debugger.GetPlatformList().GetSelectedPlatform (); + + ArchSpec arch; + + if (triple_cstr) + { + arch.SetTriple(triple_cstr, platform_sp.get()); + if (!arch.IsValid()) + { + error.SetErrorStringWithFormat("invalid triple '%s'\n", triple_cstr); + return error; + } + } + error = TargetList::CreateTarget (debugger, + file, + arch, + get_dependent_files, + platform_sp, + target_sp); + return error; +} + +Error TargetList::CreateTarget ( Debugger &debugger, const FileSpec& file, const ArchSpec& arch, bool get_dependent_files, + const PlatformSP &platform_sp, TargetSP &target_sp ) { @@ -62,7 +110,6 @@ arch.GetArchitectureName()); Error error; - PlatformSP platform_sp (debugger.GetPlatformList().GetSelectedPlatform ()); if (file) { Modified: lldb/trunk/test/python_api/default-constructor/sb_address.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_address.py?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_address.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_address.py Fri Sep 23 19:52:29 2011 @@ -11,7 +11,7 @@ obj.SetLoadAddress(0xffff, lldb.SBTarget()) obj.OffsetAddress(sys.maxint) obj.GetDescription(lldb.SBStream()) - obj.GetSectionType() + obj.GetSection() obj.GetSymbolContext(lldb.eSymbolContextEverything) obj.GetModule() obj.GetCompileUnit() Modified: lldb/trunk/test/python_api/default-constructor/sb_module.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_module.py?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_module.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_module.py Fri Sep 23 19:52:29 2011 @@ -10,7 +10,7 @@ obj.GetPlatformFileSpec() obj.SetPlatformFileSpec(lldb.SBFileSpec()) obj.GetUUIDString() - obj.ResolveFileAddress(sys.maxint, lldb.SBAddress()) + obj.ResolveFileAddress(sys.maxint) obj.ResolveSymbolContextForAddress(lldb.SBAddress(), 0) obj.GetDescription(lldb.SBStream()) obj.GetNumSymbols() Modified: lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py?rev=140437&r1=140436&r2=140437&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py Fri Sep 23 19:52:29 2011 @@ -66,7 +66,7 @@ self.assertTrue(symbol_line1.GetType() == lldb.eSymbolTypeCode) addr_line1 = symbol_line1.GetStartAddress() # And a section type of code, too. - self.assertTrue(addr_line1.GetSectionType() == lldb.eSectionTypeCode) + self.assertTrue(addr_line1.GetSection().GetSectionType() == lldb.eSectionTypeCode) # Continue the inferior, the breakpoint 2 should be hit. process.Continue() @@ -79,7 +79,7 @@ self.assertTrue(symbol_line2.GetType() == lldb.eSymbolTypeCode) addr_line2 = symbol_line2.GetStartAddress() # And a section type of code, too. - self.assertTrue(addr_line2.GetSectionType() == lldb.eSectionTypeCode) + self.assertTrue(addr_line2.GetSection().GetSectionType() == lldb.eSectionTypeCode) # Now verify that both addresses point to the same module. if self.TraceOn(): From johnny.chen at apple.com Fri Sep 23 20:02:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 24 Sep 2011 01:02:22 -0000 Subject: [Lldb-commits] [lldb] r140439 - /lldb/trunk/test/python_api/default-constructor/sb_frame.py Message-ID: <20110924010222.545402A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 20:02:22 2011 New Revision: 140439 URL: http://llvm.org/viewvc/llvm-project?rev=140439&view=rev Log: Add FindValue() and WatchValue() fuzz calls to the mix. Modified: lldb/trunk/test/python_api/default-constructor/sb_frame.py Modified: lldb/trunk/test/python_api/default-constructor/sb_frame.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_frame.py?rev=140439&r1=140438&r2=140439&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_frame.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_frame.py Fri Sep 23 20:02:22 2011 @@ -31,5 +31,8 @@ obj.GetRegisters() obj.FindVariable("my_var") obj.FindVariable("my_var", lldb.eDynamicCanRunTarget) + obj.FindValue("your_var", lldb.eValueTypeVariableGlobal) + obj.FindValue("your_var", lldb.eValueTypeVariableStatic, lldb.eDynamicCanRunTarget) + obj.WatchValue("global_var", lldb.eValueTypeVariableGlobal, lldb.LLDB_WATCH_TYPE_READ) obj.GetDescription(lldb.SBStream()) obj.Clear() From jingham at apple.com Fri Sep 23 20:04:57 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 24 Sep 2011 01:04:57 -0000 Subject: [Lldb-commits] [lldb] r140440 - in /lldb/trunk: include/lldb/API/SBAddress.h include/lldb/API/SBBreakpointLocation.h lldb.xcodeproj/project.pbxproj source/API/SBBreakpointLocation.cpp Message-ID: <20110924010457.8CED82A6C12C@llvm.org> Author: jingham Date: Fri Sep 23 20:04:57 2011 New Revision: 140440 URL: http://llvm.org/viewvc/llvm-project?rev=140440&view=rev Log: Add GetAddress to SBBreakpointLocation, and put the .i files in the API section of the Xcode project. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBBreakpointLocation.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=140440&r1=140439&r2=140440&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Fri Sep 23 20:04:57 2011 @@ -97,6 +97,7 @@ protected: + friend class SBBreakpointLocation; friend class SBFrame; friend class SBFunction; friend class SBLineEntry; Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=140440&r1=140439&r2=140440&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Fri Sep 23 20:04:57 2011 @@ -33,6 +33,9 @@ bool IsValid() const; + lldb::SBAddress + GetAddress (); + lldb::addr_t GetLoadAddress (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140440&r1=140439&r2=140440&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 23 20:04:57 2011 @@ -1194,6 +1194,42 @@ 4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCTrampolineHandler.h; sourceTree = ""; }; 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = ""; }; 4CCA644B13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleThreadPlanStepThroughObjCTrampoline.h; sourceTree = ""; }; + 4CCB54F3142D62A40059177B /* SBAddress.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBAddress.i; path = "../lldb-clean/scripts/Python/interface/SBAddress.i"; sourceTree = ""; }; + 4CCB54F4142D62A40059177B /* SBBlock.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBlock.i; path = "../lldb-clean/scripts/Python/interface/SBBlock.i"; sourceTree = ""; }; + 4CCB54F5142D62A50059177B /* SBBreakpoint.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBreakpoint.i; path = "../lldb-clean/scripts/Python/interface/SBBreakpoint.i"; sourceTree = ""; }; + 4CCB54F6142D62A50059177B /* SBBreakpointLocation.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBreakpointLocation.i; path = "../lldb-clean/scripts/Python/interface/SBBreakpointLocation.i"; sourceTree = ""; }; + 4CCB54F7142D62A60059177B /* SBBroadcaster.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBroadcaster.i; path = "../lldb-clean/scripts/Python/interface/SBBroadcaster.i"; sourceTree = ""; }; + 4CCB54F8142D62A60059177B /* SBCommandInterpreter.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommandInterpreter.i; path = "../lldb-clean/scripts/Python/interface/SBCommandInterpreter.i"; sourceTree = ""; }; + 4CCB54F9142D62A60059177B /* SBCommandReturnObject.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommandReturnObject.i; path = "../lldb-clean/scripts/Python/interface/SBCommandReturnObject.i"; sourceTree = ""; }; + 4CCB54FA142D62A60059177B /* SBCommunication.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommunication.i; path = "../lldb-clean/scripts/Python/interface/SBCommunication.i"; sourceTree = ""; }; + 4CCB54FB142D62A70059177B /* SBCompileUnit.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCompileUnit.i; path = "../lldb-clean/scripts/Python/interface/SBCompileUnit.i"; sourceTree = ""; }; + 4CCB54FC142D62A80059177B /* SBData.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBData.i; path = "../lldb-clean/scripts/Python/interface/SBData.i"; sourceTree = ""; }; + 4CCB54FD142D62A80059177B /* SBDebugger.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBDebugger.i; path = "../lldb-clean/scripts/Python/interface/SBDebugger.i"; sourceTree = ""; }; + 4CCB54FE142D62A80059177B /* SBError.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBError.i; path = "../lldb-clean/scripts/Python/interface/SBError.i"; sourceTree = ""; }; + 4CCB54FF142D62A80059177B /* SBEvent.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBEvent.i; path = "../lldb-clean/scripts/Python/interface/SBEvent.i"; sourceTree = ""; }; + 4CCB5500142D62A80059177B /* SBFileSpec.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFileSpec.i; path = "../lldb-clean/scripts/Python/interface/SBFileSpec.i"; sourceTree = ""; }; + 4CCB5501142D62AA0059177B /* SBFileSpecList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFileSpecList.i; path = "../lldb-clean/scripts/Python/interface/SBFileSpecList.i"; sourceTree = ""; }; + 4CCB5503142D62AB0059177B /* SBFrame.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFrame.i; path = "../lldb-clean/scripts/Python/interface/SBFrame.i"; sourceTree = ""; }; + 4CCB5504142D62AB0059177B /* SBFunction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFunction.i; path = "../lldb-clean/scripts/Python/interface/SBFunction.i"; sourceTree = ""; }; + 4CCB5505142D62AB0059177B /* SBHostOS.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBHostOS.i; path = "../lldb-clean/scripts/Python/interface/SBHostOS.i"; sourceTree = ""; }; + 4CCB5506142D62AB0059177B /* SBInputReader.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInputReader.i; path = "../lldb-clean/scripts/Python/interface/SBInputReader.i"; sourceTree = ""; }; + 4CCB5507142D62AB0059177B /* SBInstruction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInstruction.i; path = "../lldb-clean/scripts/Python/interface/SBInstruction.i"; sourceTree = ""; }; + 4CCB5508142D62AC0059177B /* SBInstructionList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInstructionList.i; path = "../lldb-clean/scripts/Python/interface/SBInstructionList.i"; sourceTree = ""; }; + 4CCB5509142D62AC0059177B /* SBLineEntry.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBLineEntry.i; path = "../lldb-clean/scripts/Python/interface/SBLineEntry.i"; sourceTree = ""; }; + 4CCB550A142D62AC0059177B /* SBListener.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBListener.i; path = "../lldb-clean/scripts/Python/interface/SBListener.i"; sourceTree = ""; }; + 4CCB550B142D62AC0059177B /* SBModule.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBModule.i; path = "../lldb-clean/scripts/Python/interface/SBModule.i"; sourceTree = ""; }; + 4CCB550C142D62AC0059177B /* SBProcess.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBProcess.i; path = "../lldb-clean/scripts/Python/interface/SBProcess.i"; sourceTree = ""; }; + 4CCB550D142D62AC0059177B /* SBSourceManager.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSourceManager.i; path = "../lldb-clean/scripts/Python/interface/SBSourceManager.i"; sourceTree = ""; }; + 4CCB550E142D62AD0059177B /* SBStream.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBStream.i; path = "../lldb-clean/scripts/Python/interface/SBStream.i"; sourceTree = ""; }; + 4CCB550F142D62B00059177B /* SBStringList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBStringList.i; path = "../lldb-clean/scripts/Python/interface/SBStringList.i"; sourceTree = ""; }; + 4CCB5510142D62B10059177B /* SBSymbol.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbol.i; path = "../lldb-clean/scripts/Python/interface/SBSymbol.i"; sourceTree = ""; }; + 4CCB5511142D62B10059177B /* SBSymbolContext.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbolContext.i; path = "../lldb-clean/scripts/Python/interface/SBSymbolContext.i"; sourceTree = ""; }; + 4CCB5512142D62B10059177B /* SBSymbolContextList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbolContextList.i; path = "../lldb-clean/scripts/Python/interface/SBSymbolContextList.i"; sourceTree = ""; }; + 4CCB5513142D62B20059177B /* SBTarget.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBTarget.i; path = "../lldb-clean/scripts/Python/interface/SBTarget.i"; sourceTree = ""; }; + 4CCB5514142D62B20059177B /* SBThread.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBThread.i; path = "../lldb-clean/scripts/Python/interface/SBThread.i"; sourceTree = ""; }; + 4CCB5515142D62B20059177B /* SBType.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBType.i; path = "../lldb-clean/scripts/Python/interface/SBType.i"; sourceTree = ""; }; + 4CCB5516142D62B20059177B /* SBValue.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBValue.i; path = "../lldb-clean/scripts/Python/interface/SBValue.i"; sourceTree = ""; }; + 4CCB5517142D62B20059177B /* SBValueList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBValueList.i; path = "../lldb-clean/scripts/Python/interface/SBValueList.i"; sourceTree = ""; }; 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectDynamicValue.h; path = include/lldb/Core/ValueObjectDynamicValue.h; sourceTree = ""; }; 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; @@ -1673,79 +1709,115 @@ 26B42C4C1187ABA50079C8C8 /* LLDB.h */, 9A9830FC1125FC5800A56CB0 /* SBDefines.h */, 26DE204211618ACA00A093E2 /* SBAddress.h */, + 4CCB54F3142D62A40059177B /* SBAddress.i */, 26DE204411618ADA00A093E2 /* SBAddress.cpp */, 26DE205611618FC500A093E2 /* SBBlock.h */, 26DE20601161902600A093E2 /* SBBlock.cpp */, + 4CCB54F4142D62A40059177B /* SBBlock.i */, 9AF16A9E11402D69007A7B3F /* SBBreakpoint.h */, 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */, + 4CCB54F5142D62A50059177B /* SBBreakpoint.i */, 9AF16CC611408686007A7B3F /* SBBreakpointLocation.h */, 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */, + 4CCB54F6142D62A50059177B /* SBBreakpointLocation.i */, 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */, 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */, + 4CCB54F7142D62A60059177B /* SBBroadcaster.i */, 9A9830F71125FC5800A56CB0 /* SBCommandInterpreter.h */, 9A9830F61125FC5800A56CB0 /* SBCommandInterpreter.cpp */, + 4CCB54F8142D62A60059177B /* SBCommandInterpreter.i */, 9A9830F91125FC5800A56CB0 /* SBCommandReturnObject.h */, 9A9830F81125FC5800A56CB0 /* SBCommandReturnObject.cpp */, + 4CCB54F9142D62A60059177B /* SBCommandReturnObject.i */, 260223E7115F06D500A601A2 /* SBCommunication.h */, 260223E8115F06E500A601A2 /* SBCommunication.cpp */, + 4CCB54FA142D62A60059177B /* SBCommunication.i */, 26DE205411618FB800A093E2 /* SBCompileUnit.h */, 26DE205E1161901B00A093E2 /* SBCompileUnit.cpp */, + 4CCB54FB142D62A70059177B /* SBCompileUnit.i */, 9443B120140C18A90013457C /* SBData.h */, 9443B121140C18C10013457C /* SBData.cpp */, + 4CCB54FC142D62A80059177B /* SBData.i */, 9A9830FB1125FC5800A56CB0 /* SBDebugger.h */, 9A9830FA1125FC5800A56CB0 /* SBDebugger.cpp */, + 4CCB54FD142D62A80059177B /* SBDebugger.i */, 2682F286115EF3BD00CCFF99 /* SBError.h */, 2682F284115EF3A700CCFF99 /* SBError.cpp */, + 4CCB54FE142D62A80059177B /* SBError.i */, 9A9830FE1125FC5800A56CB0 /* SBEvent.h */, 9A9830FD1125FC5800A56CB0 /* SBEvent.cpp */, + 4CCB54FF142D62A80059177B /* SBEvent.i */, 26022531115F27FA00A601A2 /* SBFileSpec.h */, 26022532115F281400A601A2 /* SBFileSpec.cpp */, + 4CCB5500142D62A80059177B /* SBFileSpec.i */, 4CF52AF41428291E0051E832 /* SBFileSpecList.h */, 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */, + 4CCB5501142D62AA0059177B /* SBFileSpecList.i */, 9A633FE8112DCE3C001A7E43 /* SBFrame.h */, 9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */, + 4CCB5503142D62AB0059177B /* SBFrame.i */, 26DE205211618FAC00A093E2 /* SBFunction.h */, 26DE205C1161901400A093E2 /* SBFunction.cpp */, + 4CCB5504142D62AB0059177B /* SBFunction.i */, 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */, 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */, + 4CCB5505142D62AB0059177B /* SBHostOS.i */, 9AA69DAE118A023300D753A0 /* SBInputReader.h */, 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */, + 4CCB5506142D62AB0059177B /* SBInputReader.i */, 9AC7038D117674EB0086C050 /* SBInstruction.h */, 9AC703AE117675410086C050 /* SBInstruction.cpp */, + 4CCB5507142D62AB0059177B /* SBInstruction.i */, 9AC7038F117675270086C050 /* SBInstructionList.h */, 9AC703B0117675490086C050 /* SBInstructionList.cpp */, + 4CCB5508142D62AC0059177B /* SBInstructionList.i */, 26DE205811618FE700A093E2 /* SBLineEntry.h */, 26DE20621161904200A093E2 /* SBLineEntry.cpp */, + 4CCB5509142D62AC0059177B /* SBLineEntry.i */, 9A9831021125FC5800A56CB0 /* SBListener.h */, 9A9831011125FC5800A56CB0 /* SBListener.cpp */, + 4CCB550A142D62AC0059177B /* SBListener.i */, 26DE204E11618E9800A093E2 /* SBModule.h */, 26DE204C11618E7A00A093E2 /* SBModule.cpp */, + 4CCB550B142D62AC0059177B /* SBModule.i */, 9A9831041125FC5800A56CB0 /* SBProcess.h */, 9A9831031125FC5800A56CB0 /* SBProcess.cpp */, + 4CCB550C142D62AC0059177B /* SBProcess.i */, 26B8283C142D01E9002DBC64 /* SBSection.h */, 26B8283F142D020F002DBC64 /* SBSection.cpp */, 9A9831061125FC5800A56CB0 /* SBSourceManager.h */, 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp */, + 4CCB550D142D62AC0059177B /* SBSourceManager.i */, 26C72C93124322890068DC16 /* SBStream.h */, 26C72C951243229A0068DC16 /* SBStream.cpp */, + 4CCB550E142D62AD0059177B /* SBStream.i */, 9A357670116E7B5200E8ED2F /* SBStringList.h */, 9A357672116E7B6400E8ED2F /* SBStringList.cpp */, + 4CCB550F142D62B00059177B /* SBStringList.i */, 26DE205A11618FF600A093E2 /* SBSymbol.h */, 26DE20641161904E00A093E2 /* SBSymbol.cpp */, + 4CCB5510142D62B10059177B /* SBSymbol.i */, 26DE204011618AB900A093E2 /* SBSymbolContext.h */, 26DE204611618AED00A093E2 /* SBSymbolContext.cpp */, + 4CCB5511142D62B10059177B /* SBSymbolContext.i */, 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */, 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */, + 4CCB5512142D62B10059177B /* SBSymbolContextList.i */, 9A9831081125FC5800A56CB0 /* SBTarget.h */, 9A9831071125FC5800A56CB0 /* SBTarget.cpp */, + 4CCB5513142D62B20059177B /* SBTarget.i */, 9A98310A1125FC5800A56CB0 /* SBThread.h */, 9A9831091125FC5800A56CB0 /* SBThread.cpp */, + 4CCB5514142D62B20059177B /* SBThread.i */, 2617447911685869005ADD65 /* SBType.h */, 261744771168585B005ADD65 /* SBType.cpp */, + 4CCB5515142D62B20059177B /* SBType.i */, 9A19A6A51163BB7E00E0D453 /* SBValue.h */, 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */, + 4CCB5516142D62B20059177B /* SBValue.i */, 9A357582116CFDEE00E8ED2F /* SBValueList.h */, 9A35758D116CFE0F00E8ED2F /* SBValueList.cpp */, + 4CCB5517142D62B20059177B /* SBValueList.i */, ); name = API; sourceTree = ""; Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=140440&r1=140439&r2=140440&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Fri Sep 23 20:04:57 2011 @@ -70,6 +70,15 @@ return m_opaque_sp.get() != NULL; } +SBAddress +SBBreakpointLocation::GetAddress () +{ + if (m_opaque_sp) + return SBAddress(&m_opaque_sp->GetAddress()); + else + return SBAddress(); +} + addr_t SBBreakpointLocation::GetLoadAddress () { From gclayton at apple.com Fri Sep 23 20:32:22 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 24 Sep 2011 01:32:22 -0000 Subject: [Lldb-commits] [lldb] r140442 - /lldb/trunk/scripts/Python/interface/SBSection.i Message-ID: <20110924013222.75BD92A6C12C@llvm.org> Author: gclayton Date: Fri Sep 23 20:32:22 2011 New Revision: 140442 URL: http://llvm.org/viewvc/llvm-project?rev=140442&view=rev Log: Added missing file. Added: lldb/trunk/scripts/Python/interface/SBSection.i Added: lldb/trunk/scripts/Python/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=140442&view=auto ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i (added) +++ lldb/trunk/scripts/Python/interface/SBSection.i Fri Sep 23 20:32:22 2011 @@ -0,0 +1,65 @@ +//===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents an executable image section." +) SBSection; + +class SBSection +{ +public: + + SBSection (); + + SBSection (const lldb::SBSection &rhs); + + ~SBSection (); + + bool + IsValid () const; + + lldb::SBSection + FindSubSection (const char *sect_name); + + size_t + GetNumSubSections (); + + lldb::SBSection + GetSubSectionAtIndex (size_t idx); + + lldb::addr_t + GetFileAddress (); + + lldb::addr_t + GetByteSize (); + + uint64_t + GetFileOffset (); + + uint64_t + GetFileByteSize (); + + lldb::SBData + GetSectionData (uint64_t offset, + uint64_t size); + + SectionType + GetSectionType (); + + bool + GetDescription (lldb::SBStream &description); + +private: + + std::auto_ptr m_opaque_ap; +}; + +} // namespace lldb From gclayton at apple.com Fri Sep 23 20:37:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 24 Sep 2011 01:37:21 -0000 Subject: [Lldb-commits] [lldb] r140444 - in /lldb/trunk: include/lldb/API/SBSection.h scripts/Python/interface/SBSection.i source/API/SBBreakpointLocation.cpp source/API/SBSection.cpp Message-ID: <20110924013721.3717B2A6C12C@llvm.org> Author: gclayton Date: Fri Sep 23 20:37:21 2011 New Revision: 140444 URL: http://llvm.org/viewvc/llvm-project?rev=140444&view=rev Log: Fixed build issues after recent checkin. Added the ability to get the name of the SBSection. Modified: lldb/trunk/include/lldb/API/SBSection.h lldb/trunk/scripts/Python/interface/SBSection.i lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/API/SBSection.cpp Modified: lldb/trunk/include/lldb/API/SBSection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=140444&r1=140443&r2=140444&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSection.h (original) +++ lldb/trunk/include/lldb/API/SBSection.h Fri Sep 23 20:37:21 2011 @@ -32,6 +32,9 @@ bool IsValid () const; + const char * + GetName (); + lldb::SBSection FindSubSection (const char *sect_name); Modified: lldb/trunk/scripts/Python/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=140444&r1=140443&r2=140444&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i (original) +++ lldb/trunk/scripts/Python/interface/SBSection.i Fri Sep 23 20:37:21 2011 @@ -26,6 +26,9 @@ bool IsValid () const; + const char * + GetName (); + lldb::SBSection FindSubSection (const char *sect_name); Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=140444&r1=140443&r2=140444&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Fri Sep 23 20:37:21 2011 @@ -9,6 +9,7 @@ #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBStream.h" Modified: lldb/trunk/source/API/SBSection.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=140444&r1=140443&r2=140444&view=diff ============================================================================== --- lldb/trunk/source/API/SBSection.cpp (original) +++ lldb/trunk/source/API/SBSection.cpp Fri Sep 23 20:37:21 2011 @@ -128,6 +128,15 @@ return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); } +const char * +SBSection::GetName () +{ + if (IsValid()) + return m_opaque_ap->GetSection()->GetName().GetCString(); + return NULL; +} + + lldb::SBSection SBSection::FindSubSection (const char *sect_name) { From jmolenda at apple.com Fri Sep 23 21:47:39 2011 From: jmolenda at apple.com (Jason Molenda) Date: Sat, 24 Sep 2011 02:47:39 -0000 Subject: [Lldb-commits] [lldb] r140447 - /lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Message-ID: <20110924024739.4268A2A6C12C@llvm.org> Author: jmolenda Date: Fri Sep 23 21:47:39 2011 New Revision: 140447 URL: http://llvm.org/viewvc/llvm-project?rev=140447&view=rev Log: Adjust kext load messages in DynamicLoaderDarwinKernel::ParseKextSummaries so we print result information if a kext fails to be located or loaded for some reason. Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=140447&r1=140446&r2=140447&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Fri Sep 23 21:47:39 2011 @@ -511,14 +511,14 @@ const uint8_t *u = (const uint8_t *)kext_summaries[i].uuid.GetBytes(); if (u) { - s->Printf("Loading kext: %2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X 0x%16.16llx \"%s\"...\n", + s->Printf("Loading kext: %2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X 0x%16.16llx \"%s\"...", u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6], u[ 7], u[ 8], u[ 9], u[10], u[11], u[12], u[13], u[14], u[15], kext_summaries[i].address, kext_summaries[i].name); } else { - s->Printf("0x%16.16llx \"%s\"...\n", kext_summaries[i].address, kext_summaries[i].name); + s->Printf("0x%16.16llx \"%s\"...", kext_summaries[i].address, kext_summaries[i].name); } } @@ -531,9 +531,11 @@ if (s) { if (kext_summaries[i].module_sp) - s->Printf(" found kext: %s/%s\n", + s->Printf("\n found kext: %s/%s\n", kext_summaries[i].module_sp->GetFileSpec().GetDirectory().AsCString(), kext_summaries[i].module_sp->GetFileSpec().GetFilename().AsCString()); + else + s->Printf (" failed to locate/load.\n"); } if (log) From johnny.chen at apple.com Fri Sep 23 23:51:43 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 24 Sep 2011 04:51:43 -0000 Subject: [Lldb-commits] [lldb] r140449 - in /lldb/trunk/scripts/Python: interface/SBModule.i interface/SBSection.i modify-python-lldb.py Message-ID: <20110924045143.C26462A6C12C@llvm.org> Author: johnny Date: Fri Sep 23 23:51:43 2011 New Revision: 140449 URL: http://llvm.org/viewvc/llvm-project?rev=140449&view=rev Log: SBSection supports iteration through its subsections, represented as SBSection as well. SBModule supports an additional SBSection iteration, besides the original SBSymbol iteration. Add docstrings and implement the two SBSection iteration protocols. Modified: lldb/trunk/scripts/Python/interface/SBModule.i lldb/trunk/scripts/Python/interface/SBSection.i lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/interface/SBModule.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=140449&r1=140448&r2=140449&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBModule.i (original) +++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Sep 23 23:51:43 2011 @@ -31,7 +31,8 @@ if thisModule == thatModule: print 'This module is the same as that module' -to test module equality." +to test module equality. A module also contains object file sections, namely +SBSection. SBModule supports section iteration through section_iter()." ) SBModule; class SBModule { Modified: lldb/trunk/scripts/Python/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=140449&r1=140448&r2=140449&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i (original) +++ lldb/trunk/scripts/Python/interface/SBSection.i Fri Sep 23 23:51:43 2011 @@ -10,7 +10,10 @@ namespace lldb { %feature("docstring", -"Represents an executable image section." +"Represents an executable image section. + +SBSection supports iteration through its subsection, represented as SBSection +as well." ) SBSection; class SBSection Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140449&r1=140448&r2=140449&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Fri Sep 23 23:51:43 2011 @@ -150,6 +150,7 @@ iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" +section_iter = " def section_iter(self): return lldb_iter(self, '%s', '%s')" # Called to implement the built-in function len(). # Eligible objects are those containers with unambiguous iteration support. @@ -172,6 +173,7 @@ 'SBDebugger': ('GetNumTargets', 'GetTargetAtIndex'), 'SBModule': ('GetNumSymbols', 'GetSymbolAtIndex'), 'SBProcess': ('GetNumThreads', 'GetThreadAtIndex'), + 'SBSection': ('GetNumSubSections', 'GetSubSectionAtIndex'), 'SBThread': ('GetNumFrames', 'GetFrameAtIndex'), 'SBInstructionList': ('GetSize', 'GetInstructionAtIndex'), @@ -186,7 +188,10 @@ # SBTarget needs special processing, see below. 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex') - } + }, + + # SBModule has an additional section_iter(), see below. + 'SBModule-extra': ('GetNumSections', 'GetSectionAtIndex') } # @@ -332,6 +337,9 @@ new_content.add_line(eq_def % (cls, list_to_frag(e[cls]))) new_content.add_line(ne_def) + # SBModule has an extra SBSection iterator! + if cls == "SBModule": + new_content.add_line(section_iter % d[cls+'-extra']) # This special purpose iterator is for SBValue only!!! if cls == "SBValue": new_content.add_line(linked_list_iter_def) From johnny.chen at apple.com Sat Sep 24 00:01:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 24 Sep 2011 05:01:54 -0000 Subject: [Lldb-commits] [lldb] r140450 - /lldb/trunk/test/python_api/watchpoint/main.c Message-ID: <20110924050154.17DF92A6C12C@llvm.org> Author: johnny Date: Sat Sep 24 00:01:53 2011 New Revision: 140450 URL: http://llvm.org/viewvc/llvm-project?rev=140450&view=rev Log: Fix comment. Modified: lldb/trunk/test/python_api/watchpoint/main.c Modified: lldb/trunk/test/python_api/watchpoint/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/main.c?rev=140450&r1=140449&r2=140450&view=diff ============================================================================== --- lldb/trunk/test/python_api/watchpoint/main.c (original) +++ lldb/trunk/test/python_api/watchpoint/main.c Sat Sep 24 00:01:53 2011 @@ -15,7 +15,7 @@ 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 write. + // When stopped, watch 'global' for read&write. global = 20; local += argc; ++local; From gclayton at apple.com Sat Sep 24 00:04:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 24 Sep 2011 05:04:41 -0000 Subject: [Lldb-commits] [lldb] r140451 - in /lldb/trunk: include/lldb/API/SBData.h include/lldb/API/SBSection.h include/lldb/API/SBStream.h lldb.xcodeproj/project.pbxproj scripts/Python/interface/SBData.i scripts/Python/interface/SBSection.i scripts/Python/python-extensions.swig source/API/SBData.cpp source/API/SBSection.cpp source/Symbol/Symbol.cpp Message-ID: <20110924050441.328A52A6C12C@llvm.org> Author: gclayton Date: Sat Sep 24 00:04:40 2011 New Revision: 140451 URL: http://llvm.org/viewvc/llvm-project?rev=140451&view=rev Log: Added the ability to get all section contents, or the section contents starting at an offset (2 separate methods). This helps the scripting interface stay more natural by allowing both from Python. Added the ability to dump data with address annotations when call SBData::GetDescription(). Hooked up the SBSection to the __repr__ so you can print section objects from within python. Improved the dumping of symbols from python. Fixed the .i interface references which were set to "Relative to this Group" which somehow included Jim's "lldb-clean" root directory in the path. The interfaces are now in a folder called "interfaces" withing the Xcode API subfolder. Modified: lldb/trunk/include/lldb/API/SBData.h lldb/trunk/include/lldb/API/SBSection.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/interface/SBData.i lldb/trunk/scripts/Python/interface/SBSection.i lldb/trunk/scripts/Python/python-extensions.swig lldb/trunk/source/API/SBData.cpp lldb/trunk/source/API/SBSection.cpp lldb/trunk/source/Symbol/Symbol.cpp Modified: lldb/trunk/include/lldb/API/SBData.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBData.h?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBData.h (original) +++ lldb/trunk/include/lldb/API/SBData.h Sat Sep 24 00:04:40 2011 @@ -90,7 +90,7 @@ size_t size); bool - GetDescription (lldb::SBStream &description); + GetDescription (lldb::SBStream &description, lldb::addr_t base_addr = LLDB_INVALID_ADDRESS); // it would be nice to have SetData(SBError, const void*, size_t) when endianness and address size can be // inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where Modified: lldb/trunk/include/lldb/API/SBSection.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSection.h (original) +++ lldb/trunk/include/lldb/API/SBSection.h Sat Sep 24 00:04:40 2011 @@ -57,9 +57,12 @@ GetFileByteSize (); lldb::SBData - GetSectionData (uint64_t offset = 0, - uint64_t size = UINT64_MAX); + GetSectionData (); + lldb::SBData + GetSectionData (uint64_t offset, + uint64_t size); + SectionType GetSectionType (); Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Sat Sep 24 00:04:40 2011 @@ -69,6 +69,7 @@ friend class SBInstruction; friend class SBInstructionList; friend class SBModule; + friend class SBSection; friend class SBSourceManager_impl; friend class SBSymbol; friend class SBSymbolContext; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Sep 24 00:04:40 2011 @@ -598,6 +598,43 @@ 260E07C9136FABAC00CF21D3 /* OptionGroupFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionGroupFile.h; path = include/lldb/Interpreter/OptionGroupFile.h; sourceTree = ""; }; 26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LogChannelDWARF.cpp; sourceTree = ""; }; 26109B3C1155D70100CC3529 /* LogChannelDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogChannelDWARF.h; sourceTree = ""; }; + 2611FEEF142D83060017FEA3 /* SBAddress.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBAddress.i; sourceTree = ""; }; + 2611FEF0142D83060017FEA3 /* SBBlock.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBBlock.i; sourceTree = ""; }; + 2611FEF1142D83060017FEA3 /* SBBreakpoint.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBBreakpoint.i; sourceTree = ""; }; + 2611FEF2142D83060017FEA3 /* SBBreakpointLocation.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBBreakpointLocation.i; sourceTree = ""; }; + 2611FEF3142D83060017FEA3 /* SBBroadcaster.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBBroadcaster.i; sourceTree = ""; }; + 2611FEF4142D83060017FEA3 /* SBCommandInterpreter.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBCommandInterpreter.i; sourceTree = ""; }; + 2611FEF5142D83060017FEA3 /* SBCommandReturnObject.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBCommandReturnObject.i; sourceTree = ""; }; + 2611FEF6142D83060017FEA3 /* SBCommunication.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBCommunication.i; sourceTree = ""; }; + 2611FEF7142D83060017FEA3 /* SBCompileUnit.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBCompileUnit.i; sourceTree = ""; }; + 2611FEF8142D83060017FEA3 /* SBData.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBData.i; sourceTree = ""; }; + 2611FEF9142D83060017FEA3 /* SBDebugger.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBDebugger.i; sourceTree = ""; }; + 2611FEFA142D83060017FEA3 /* SBError.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBError.i; sourceTree = ""; }; + 2611FEFB142D83060017FEA3 /* SBEvent.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBEvent.i; sourceTree = ""; }; + 2611FEFC142D83060017FEA3 /* SBFileSpec.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBFileSpec.i; sourceTree = ""; }; + 2611FEFD142D83060017FEA3 /* SBFileSpecList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBFileSpecList.i; sourceTree = ""; }; + 2611FEFE142D83060017FEA3 /* SBFrame.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBFrame.i; sourceTree = ""; }; + 2611FEFF142D83060017FEA3 /* SBFunction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBFunction.i; sourceTree = ""; }; + 2611FF00142D83060017FEA3 /* SBHostOS.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBHostOS.i; sourceTree = ""; }; + 2611FF01142D83060017FEA3 /* SBInputReader.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBInputReader.i; sourceTree = ""; }; + 2611FF02142D83060017FEA3 /* SBInstruction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBInstruction.i; sourceTree = ""; }; + 2611FF03142D83060017FEA3 /* SBInstructionList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBInstructionList.i; sourceTree = ""; }; + 2611FF04142D83060017FEA3 /* SBLineEntry.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBLineEntry.i; sourceTree = ""; }; + 2611FF05142D83060017FEA3 /* SBListener.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBListener.i; sourceTree = ""; }; + 2611FF06142D83060017FEA3 /* SBModule.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBModule.i; sourceTree = ""; }; + 2611FF07142D83060017FEA3 /* SBProcess.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBProcess.i; sourceTree = ""; }; + 2611FF08142D83060017FEA3 /* SBSection.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBSection.i; sourceTree = ""; }; + 2611FF09142D83060017FEA3 /* SBSourceManager.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBSourceManager.i; sourceTree = ""; }; + 2611FF0A142D83060017FEA3 /* SBStream.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBStream.i; sourceTree = ""; }; + 2611FF0B142D83060017FEA3 /* SBStringList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBStringList.i; sourceTree = ""; }; + 2611FF0C142D83060017FEA3 /* SBSymbol.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBSymbol.i; sourceTree = ""; }; + 2611FF0D142D83060017FEA3 /* SBSymbolContext.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBSymbolContext.i; sourceTree = ""; }; + 2611FF0E142D83060017FEA3 /* SBSymbolContextList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBSymbolContextList.i; sourceTree = ""; }; + 2611FF0F142D83060017FEA3 /* SBTarget.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBTarget.i; sourceTree = ""; }; + 2611FF10142D83060017FEA3 /* SBThread.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBThread.i; sourceTree = ""; }; + 2611FF11142D83060017FEA3 /* SBType.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBType.i; sourceTree = ""; }; + 2611FF12142D83060017FEA3 /* SBValue.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBValue.i; sourceTree = ""; }; + 2611FF13142D83060017FEA3 /* SBValueList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; path = SBValueList.i; sourceTree = ""; }; 2615DB841208A9C90021781D /* StopInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StopInfo.h; path = include/lldb/Target/StopInfo.h; sourceTree = ""; }; 2615DB861208A9E40021781D /* StopInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StopInfo.cpp; path = source/Target/StopInfo.cpp; sourceTree = ""; }; 2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StopInfoMachException.cpp; path = Utility/StopInfoMachException.cpp; sourceTree = ""; }; @@ -1194,42 +1231,6 @@ 4CCA644913B40B82003BDF98 /* AppleObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleObjCTrampolineHandler.h; sourceTree = ""; }; 4CCA644A13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppleThreadPlanStepThroughObjCTrampoline.cpp; sourceTree = ""; }; 4CCA644B13B40B82003BDF98 /* AppleThreadPlanStepThroughObjCTrampoline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleThreadPlanStepThroughObjCTrampoline.h; sourceTree = ""; }; - 4CCB54F3142D62A40059177B /* SBAddress.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBAddress.i; path = "../lldb-clean/scripts/Python/interface/SBAddress.i"; sourceTree = ""; }; - 4CCB54F4142D62A40059177B /* SBBlock.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBlock.i; path = "../lldb-clean/scripts/Python/interface/SBBlock.i"; sourceTree = ""; }; - 4CCB54F5142D62A50059177B /* SBBreakpoint.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBreakpoint.i; path = "../lldb-clean/scripts/Python/interface/SBBreakpoint.i"; sourceTree = ""; }; - 4CCB54F6142D62A50059177B /* SBBreakpointLocation.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBreakpointLocation.i; path = "../lldb-clean/scripts/Python/interface/SBBreakpointLocation.i"; sourceTree = ""; }; - 4CCB54F7142D62A60059177B /* SBBroadcaster.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBBroadcaster.i; path = "../lldb-clean/scripts/Python/interface/SBBroadcaster.i"; sourceTree = ""; }; - 4CCB54F8142D62A60059177B /* SBCommandInterpreter.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommandInterpreter.i; path = "../lldb-clean/scripts/Python/interface/SBCommandInterpreter.i"; sourceTree = ""; }; - 4CCB54F9142D62A60059177B /* SBCommandReturnObject.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommandReturnObject.i; path = "../lldb-clean/scripts/Python/interface/SBCommandReturnObject.i"; sourceTree = ""; }; - 4CCB54FA142D62A60059177B /* SBCommunication.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCommunication.i; path = "../lldb-clean/scripts/Python/interface/SBCommunication.i"; sourceTree = ""; }; - 4CCB54FB142D62A70059177B /* SBCompileUnit.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBCompileUnit.i; path = "../lldb-clean/scripts/Python/interface/SBCompileUnit.i"; sourceTree = ""; }; - 4CCB54FC142D62A80059177B /* SBData.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBData.i; path = "../lldb-clean/scripts/Python/interface/SBData.i"; sourceTree = ""; }; - 4CCB54FD142D62A80059177B /* SBDebugger.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBDebugger.i; path = "../lldb-clean/scripts/Python/interface/SBDebugger.i"; sourceTree = ""; }; - 4CCB54FE142D62A80059177B /* SBError.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBError.i; path = "../lldb-clean/scripts/Python/interface/SBError.i"; sourceTree = ""; }; - 4CCB54FF142D62A80059177B /* SBEvent.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBEvent.i; path = "../lldb-clean/scripts/Python/interface/SBEvent.i"; sourceTree = ""; }; - 4CCB5500142D62A80059177B /* SBFileSpec.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFileSpec.i; path = "../lldb-clean/scripts/Python/interface/SBFileSpec.i"; sourceTree = ""; }; - 4CCB5501142D62AA0059177B /* SBFileSpecList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFileSpecList.i; path = "../lldb-clean/scripts/Python/interface/SBFileSpecList.i"; sourceTree = ""; }; - 4CCB5503142D62AB0059177B /* SBFrame.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFrame.i; path = "../lldb-clean/scripts/Python/interface/SBFrame.i"; sourceTree = ""; }; - 4CCB5504142D62AB0059177B /* SBFunction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBFunction.i; path = "../lldb-clean/scripts/Python/interface/SBFunction.i"; sourceTree = ""; }; - 4CCB5505142D62AB0059177B /* SBHostOS.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBHostOS.i; path = "../lldb-clean/scripts/Python/interface/SBHostOS.i"; sourceTree = ""; }; - 4CCB5506142D62AB0059177B /* SBInputReader.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInputReader.i; path = "../lldb-clean/scripts/Python/interface/SBInputReader.i"; sourceTree = ""; }; - 4CCB5507142D62AB0059177B /* SBInstruction.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInstruction.i; path = "../lldb-clean/scripts/Python/interface/SBInstruction.i"; sourceTree = ""; }; - 4CCB5508142D62AC0059177B /* SBInstructionList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBInstructionList.i; path = "../lldb-clean/scripts/Python/interface/SBInstructionList.i"; sourceTree = ""; }; - 4CCB5509142D62AC0059177B /* SBLineEntry.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBLineEntry.i; path = "../lldb-clean/scripts/Python/interface/SBLineEntry.i"; sourceTree = ""; }; - 4CCB550A142D62AC0059177B /* SBListener.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBListener.i; path = "../lldb-clean/scripts/Python/interface/SBListener.i"; sourceTree = ""; }; - 4CCB550B142D62AC0059177B /* SBModule.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBModule.i; path = "../lldb-clean/scripts/Python/interface/SBModule.i"; sourceTree = ""; }; - 4CCB550C142D62AC0059177B /* SBProcess.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBProcess.i; path = "../lldb-clean/scripts/Python/interface/SBProcess.i"; sourceTree = ""; }; - 4CCB550D142D62AC0059177B /* SBSourceManager.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSourceManager.i; path = "../lldb-clean/scripts/Python/interface/SBSourceManager.i"; sourceTree = ""; }; - 4CCB550E142D62AD0059177B /* SBStream.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBStream.i; path = "../lldb-clean/scripts/Python/interface/SBStream.i"; sourceTree = ""; }; - 4CCB550F142D62B00059177B /* SBStringList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBStringList.i; path = "../lldb-clean/scripts/Python/interface/SBStringList.i"; sourceTree = ""; }; - 4CCB5510142D62B10059177B /* SBSymbol.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbol.i; path = "../lldb-clean/scripts/Python/interface/SBSymbol.i"; sourceTree = ""; }; - 4CCB5511142D62B10059177B /* SBSymbolContext.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbolContext.i; path = "../lldb-clean/scripts/Python/interface/SBSymbolContext.i"; sourceTree = ""; }; - 4CCB5512142D62B10059177B /* SBSymbolContextList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBSymbolContextList.i; path = "../lldb-clean/scripts/Python/interface/SBSymbolContextList.i"; sourceTree = ""; }; - 4CCB5513142D62B20059177B /* SBTarget.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBTarget.i; path = "../lldb-clean/scripts/Python/interface/SBTarget.i"; sourceTree = ""; }; - 4CCB5514142D62B20059177B /* SBThread.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBThread.i; path = "../lldb-clean/scripts/Python/interface/SBThread.i"; sourceTree = ""; }; - 4CCB5515142D62B20059177B /* SBType.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBType.i; path = "../lldb-clean/scripts/Python/interface/SBType.i"; sourceTree = ""; }; - 4CCB5516142D62B20059177B /* SBValue.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBValue.i; path = "../lldb-clean/scripts/Python/interface/SBValue.i"; sourceTree = ""; }; - 4CCB5517142D62B20059177B /* SBValueList.i */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c.preprocessed; name = SBValueList.i; path = "../lldb-clean/scripts/Python/interface/SBValueList.i"; sourceTree = ""; }; 4CD0BD0C134BFAB600CB44D4 /* ValueObjectDynamicValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectDynamicValue.h; path = include/lldb/Core/ValueObjectDynamicValue.h; sourceTree = ""; }; 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; @@ -1679,6 +1680,51 @@ path = MacOSX; sourceTree = ""; }; + 2611FEEE142D83060017FEA3 /* interface */ = { + isa = PBXGroup; + children = ( + 2611FEEF142D83060017FEA3 /* SBAddress.i */, + 2611FEF0142D83060017FEA3 /* SBBlock.i */, + 2611FEF1142D83060017FEA3 /* SBBreakpoint.i */, + 2611FEF2142D83060017FEA3 /* SBBreakpointLocation.i */, + 2611FEF3142D83060017FEA3 /* SBBroadcaster.i */, + 2611FEF4142D83060017FEA3 /* SBCommandInterpreter.i */, + 2611FEF5142D83060017FEA3 /* SBCommandReturnObject.i */, + 2611FEF6142D83060017FEA3 /* SBCommunication.i */, + 2611FEF7142D83060017FEA3 /* SBCompileUnit.i */, + 2611FEF8142D83060017FEA3 /* SBData.i */, + 2611FEF9142D83060017FEA3 /* SBDebugger.i */, + 2611FEFA142D83060017FEA3 /* SBError.i */, + 2611FEFB142D83060017FEA3 /* SBEvent.i */, + 2611FEFC142D83060017FEA3 /* SBFileSpec.i */, + 2611FEFD142D83060017FEA3 /* SBFileSpecList.i */, + 2611FEFE142D83060017FEA3 /* SBFrame.i */, + 2611FEFF142D83060017FEA3 /* SBFunction.i */, + 2611FF00142D83060017FEA3 /* SBHostOS.i */, + 2611FF01142D83060017FEA3 /* SBInputReader.i */, + 2611FF02142D83060017FEA3 /* SBInstruction.i */, + 2611FF03142D83060017FEA3 /* SBInstructionList.i */, + 2611FF04142D83060017FEA3 /* SBLineEntry.i */, + 2611FF05142D83060017FEA3 /* SBListener.i */, + 2611FF06142D83060017FEA3 /* SBModule.i */, + 2611FF07142D83060017FEA3 /* SBProcess.i */, + 2611FF08142D83060017FEA3 /* SBSection.i */, + 2611FF09142D83060017FEA3 /* SBSourceManager.i */, + 2611FF0A142D83060017FEA3 /* SBStream.i */, + 2611FF0B142D83060017FEA3 /* SBStringList.i */, + 2611FF0C142D83060017FEA3 /* SBSymbol.i */, + 2611FF0D142D83060017FEA3 /* SBSymbolContext.i */, + 2611FF0E142D83060017FEA3 /* SBSymbolContextList.i */, + 2611FF0F142D83060017FEA3 /* SBTarget.i */, + 2611FF10142D83060017FEA3 /* SBThread.i */, + 2611FF11142D83060017FEA3 /* SBType.i */, + 2611FF12142D83060017FEA3 /* SBValue.i */, + 2611FF13142D83060017FEA3 /* SBValueList.i */, + ); + name = interface; + path = scripts/Python/interface; + sourceTree = SOURCE_ROOT; + }; 26274F9F14030EEF006BA130 /* Darwin-Kernel */ = { isa = PBXGroup; children = ( @@ -1700,6 +1746,7 @@ 262D3190111B4341004E6F88 /* API */ = { isa = PBXGroup; children = ( + 2611FEEE142D83060017FEA3 /* interface */, 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */, 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */, 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */, @@ -1709,115 +1756,79 @@ 26B42C4C1187ABA50079C8C8 /* LLDB.h */, 9A9830FC1125FC5800A56CB0 /* SBDefines.h */, 26DE204211618ACA00A093E2 /* SBAddress.h */, - 4CCB54F3142D62A40059177B /* SBAddress.i */, 26DE204411618ADA00A093E2 /* SBAddress.cpp */, 26DE205611618FC500A093E2 /* SBBlock.h */, 26DE20601161902600A093E2 /* SBBlock.cpp */, - 4CCB54F4142D62A40059177B /* SBBlock.i */, 9AF16A9E11402D69007A7B3F /* SBBreakpoint.h */, 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */, - 4CCB54F5142D62A50059177B /* SBBreakpoint.i */, 9AF16CC611408686007A7B3F /* SBBreakpointLocation.h */, 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */, - 4CCB54F6142D62A50059177B /* SBBreakpointLocation.i */, 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */, 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */, - 4CCB54F7142D62A60059177B /* SBBroadcaster.i */, 9A9830F71125FC5800A56CB0 /* SBCommandInterpreter.h */, 9A9830F61125FC5800A56CB0 /* SBCommandInterpreter.cpp */, - 4CCB54F8142D62A60059177B /* SBCommandInterpreter.i */, 9A9830F91125FC5800A56CB0 /* SBCommandReturnObject.h */, 9A9830F81125FC5800A56CB0 /* SBCommandReturnObject.cpp */, - 4CCB54F9142D62A60059177B /* SBCommandReturnObject.i */, 260223E7115F06D500A601A2 /* SBCommunication.h */, 260223E8115F06E500A601A2 /* SBCommunication.cpp */, - 4CCB54FA142D62A60059177B /* SBCommunication.i */, 26DE205411618FB800A093E2 /* SBCompileUnit.h */, 26DE205E1161901B00A093E2 /* SBCompileUnit.cpp */, - 4CCB54FB142D62A70059177B /* SBCompileUnit.i */, 9443B120140C18A90013457C /* SBData.h */, 9443B121140C18C10013457C /* SBData.cpp */, - 4CCB54FC142D62A80059177B /* SBData.i */, 9A9830FB1125FC5800A56CB0 /* SBDebugger.h */, 9A9830FA1125FC5800A56CB0 /* SBDebugger.cpp */, - 4CCB54FD142D62A80059177B /* SBDebugger.i */, 2682F286115EF3BD00CCFF99 /* SBError.h */, 2682F284115EF3A700CCFF99 /* SBError.cpp */, - 4CCB54FE142D62A80059177B /* SBError.i */, 9A9830FE1125FC5800A56CB0 /* SBEvent.h */, 9A9830FD1125FC5800A56CB0 /* SBEvent.cpp */, - 4CCB54FF142D62A80059177B /* SBEvent.i */, 26022531115F27FA00A601A2 /* SBFileSpec.h */, 26022532115F281400A601A2 /* SBFileSpec.cpp */, - 4CCB5500142D62A80059177B /* SBFileSpec.i */, 4CF52AF41428291E0051E832 /* SBFileSpecList.h */, 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */, - 4CCB5501142D62AA0059177B /* SBFileSpecList.i */, 9A633FE8112DCE3C001A7E43 /* SBFrame.h */, 9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */, - 4CCB5503142D62AB0059177B /* SBFrame.i */, 26DE205211618FAC00A093E2 /* SBFunction.h */, 26DE205C1161901400A093E2 /* SBFunction.cpp */, - 4CCB5504142D62AB0059177B /* SBFunction.i */, 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */, 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */, - 4CCB5505142D62AB0059177B /* SBHostOS.i */, 9AA69DAE118A023300D753A0 /* SBInputReader.h */, 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */, - 4CCB5506142D62AB0059177B /* SBInputReader.i */, 9AC7038D117674EB0086C050 /* SBInstruction.h */, 9AC703AE117675410086C050 /* SBInstruction.cpp */, - 4CCB5507142D62AB0059177B /* SBInstruction.i */, 9AC7038F117675270086C050 /* SBInstructionList.h */, 9AC703B0117675490086C050 /* SBInstructionList.cpp */, - 4CCB5508142D62AC0059177B /* SBInstructionList.i */, 26DE205811618FE700A093E2 /* SBLineEntry.h */, 26DE20621161904200A093E2 /* SBLineEntry.cpp */, - 4CCB5509142D62AC0059177B /* SBLineEntry.i */, 9A9831021125FC5800A56CB0 /* SBListener.h */, 9A9831011125FC5800A56CB0 /* SBListener.cpp */, - 4CCB550A142D62AC0059177B /* SBListener.i */, 26DE204E11618E9800A093E2 /* SBModule.h */, 26DE204C11618E7A00A093E2 /* SBModule.cpp */, - 4CCB550B142D62AC0059177B /* SBModule.i */, 9A9831041125FC5800A56CB0 /* SBProcess.h */, 9A9831031125FC5800A56CB0 /* SBProcess.cpp */, - 4CCB550C142D62AC0059177B /* SBProcess.i */, 26B8283C142D01E9002DBC64 /* SBSection.h */, 26B8283F142D020F002DBC64 /* SBSection.cpp */, 9A9831061125FC5800A56CB0 /* SBSourceManager.h */, 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp */, - 4CCB550D142D62AC0059177B /* SBSourceManager.i */, 26C72C93124322890068DC16 /* SBStream.h */, 26C72C951243229A0068DC16 /* SBStream.cpp */, - 4CCB550E142D62AD0059177B /* SBStream.i */, 9A357670116E7B5200E8ED2F /* SBStringList.h */, 9A357672116E7B6400E8ED2F /* SBStringList.cpp */, - 4CCB550F142D62B00059177B /* SBStringList.i */, 26DE205A11618FF600A093E2 /* SBSymbol.h */, 26DE20641161904E00A093E2 /* SBSymbol.cpp */, - 4CCB5510142D62B10059177B /* SBSymbol.i */, 26DE204011618AB900A093E2 /* SBSymbolContext.h */, 26DE204611618AED00A093E2 /* SBSymbolContext.cpp */, - 4CCB5511142D62B10059177B /* SBSymbolContext.i */, 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */, 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */, - 4CCB5512142D62B10059177B /* SBSymbolContextList.i */, 9A9831081125FC5800A56CB0 /* SBTarget.h */, 9A9831071125FC5800A56CB0 /* SBTarget.cpp */, - 4CCB5513142D62B20059177B /* SBTarget.i */, 9A98310A1125FC5800A56CB0 /* SBThread.h */, 9A9831091125FC5800A56CB0 /* SBThread.cpp */, - 4CCB5514142D62B20059177B /* SBThread.i */, 2617447911685869005ADD65 /* SBType.h */, 261744771168585B005ADD65 /* SBType.cpp */, - 4CCB5515142D62B20059177B /* SBType.i */, 9A19A6A51163BB7E00E0D453 /* SBValue.h */, 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */, - 4CCB5516142D62B20059177B /* SBValue.i */, 9A357582116CFDEE00E8ED2F /* SBValueList.h */, 9A35758D116CFE0F00E8ED2F /* SBValueList.cpp */, - 4CCB5517142D62B20059177B /* SBValueList.i */, ); name = API; sourceTree = ""; Modified: lldb/trunk/scripts/Python/interface/SBData.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBData.i?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBData.i (original) +++ lldb/trunk/scripts/Python/interface/SBData.i Sat Sep 24 00:04:40 2011 @@ -75,7 +75,7 @@ GetString (lldb::SBError& error, uint32_t offset); bool - GetDescription (lldb::SBStream &description); + GetDescription (lldb::SBStream &description, lldb::addr_t base_addr); size_t ReadRawData (lldb::SBError& error, Modified: lldb/trunk/scripts/Python/interface/SBSection.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBSection.i (original) +++ lldb/trunk/scripts/Python/interface/SBSection.i Sat Sep 24 00:04:40 2011 @@ -54,6 +54,9 @@ GetFileByteSize (); lldb::SBData + GetSectionData (); + + lldb::SBData GetSectionData (uint64_t offset, uint64_t size); Modified: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (original) +++ lldb/trunk/scripts/Python/python-extensions.swig Sat Sep 24 00:04:40 2011 @@ -118,6 +118,13 @@ return PyString_FromString (description.GetData()); } } +%extend lldb::SBSection { + PyObject *lldb::SBSection::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} %extend lldb::SBSymbol { PyObject *lldb::SBSymbol::__repr__ (){ lldb::SBStream description; Modified: lldb/trunk/source/API/SBData.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBData.cpp?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/source/API/SBData.cpp (original) +++ lldb/trunk/source/API/SBData.cpp Sat Sep 24 00:04:40 2011 @@ -412,7 +412,7 @@ } bool -SBData::GetDescription (lldb::SBStream &description) +SBData::GetDescription (lldb::SBStream &description, lldb::addr_t base_addr) { if (m_opaque_sp) { @@ -423,7 +423,7 @@ 1, m_opaque_sp->GetByteSize(), 16, - LLDB_INVALID_ADDRESS, + base_addr, 0, 0); } Modified: lldb/trunk/source/API/SBSection.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/source/API/SBSection.cpp (original) +++ lldb/trunk/source/API/SBSection.cpp Sat Sep 24 00:04:40 2011 @@ -12,8 +12,9 @@ #include "lldb/Core/DataBuffer.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Log.h" -#include "lldb/Core/Section.h" #include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" +#include "lldb/Core/StreamString.h" namespace lldb_private { @@ -238,6 +239,12 @@ } SBData +SBSection::GetSectionData () +{ + return GetSectionData (0, UINT64_MAX); +} + +SBData SBSection::GetSectionData (uint64_t offset, uint64_t size) { SBData sb_data; @@ -319,9 +326,12 @@ bool SBSection::GetDescription (SBStream &description) { - if (m_opaque_ap.get()) + if (IsValid()) { - description.Printf ("SBSection"); + const Section *section = m_opaque_ap->GetSection(); + const addr_t file_addr = section->GetFileAddress(); + description.Printf ("[0x%16.16llx-0x%16.16llx) ", file_addr, file_addr + section->GetByteSize()); + section->DumpName(description.get()); } else { Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=140451&r1=140450&r2=140451&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Sat Sep 24 00:04:40 2011 @@ -177,6 +177,7 @@ Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const { *s << "id = " << (const UserID&)*this << ", name = \"" << m_mangled.GetName() << '"'; + const Section *section = m_addr_range.GetBaseAddress().GetSection(); if (section != NULL) { @@ -194,12 +195,14 @@ } } else - { - if (m_size_is_sibling) - s->Printf (", sibling = %5llu", m_addr_range.GetBaseAddress().GetOffset()); - else - s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset()); - } + s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset()); + } + else + { + if (m_size_is_sibling) + s->Printf (", sibling = %5llu", m_addr_range.GetBaseAddress().GetOffset()); + else + s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset()); } }