From gclayton at apple.com Mon Dec 12 12:51:14 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 12 Dec 2011 18:51:14 -0000 Subject: [Lldb-commits] [lldb] r146394 - in /lldb/trunk/tools/debugserver/source: DNB.cpp DNB.h MacOSX/MachVMMemory.cpp MacOSX/MachVMMemory.h MacOSX/MachVMRegion.cpp MacOSX/MachVMRegion.h RNBRemote.cpp Message-ID: <20111212185114.AC6BF1BE003@llvm.org> Author: gclayton Date: Mon Dec 12 12:51:14 2011 New Revision: 146394 URL: http://llvm.org/viewvc/llvm-project?rev=146394&view=rev Log: Always return a valid answer for qMemoryRegionInfo if the packet is supported. We will return a valid range when possible and omit the "permissions" key when the memory is not readable, writeable or executeable. This will help us know the difference between an error back from this packet and unsupported, from just "this address isn't in a valid region". Modified: lldb/trunk/tools/debugserver/source/DNB.cpp lldb/trunk/tools/debugserver/source/DNB.h lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Mon Dec 12 12:51:14 2011 @@ -1139,7 +1139,7 @@ // //---------------------------------------------------------------------- int -DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) +DNBProcessMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) { MachProcessSP procSP; if (GetProcessSP (pid, procSP)) Modified: lldb/trunk/tools/debugserver/source/DNB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.h (original) +++ lldb/trunk/tools/debugserver/source/DNB.h Mon Dec 12 12:51:14 2011 @@ -64,9 +64,9 @@ nub_bool_t DNBProcessKill (nub_process_t pid) DNB_EXPORT; nub_size_t DNBProcessMemoryRead (nub_process_t pid, nub_addr_t addr, nub_size_t size, void *buf) DNB_EXPORT; nub_size_t DNBProcessMemoryWrite (nub_process_t pid, nub_addr_t addr, nub_size_t size, const void *buf) DNB_EXPORT; -nub_addr_t DNBProcessMemoryAllocate (nub_process_t pid, nub_size_t size, uint32_t permissions) DNB_EXPORT; -nub_bool_t DNBProcessMemoryDeallocate (nub_process_t pid, nub_addr_t addr) DNB_EXPORT; -int DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) DNB_EXPORT; +nub_addr_t DNBProcessMemoryAllocate (nub_process_t pid, nub_size_t size, uint32_t permissions) DNB_EXPORT; +nub_bool_t DNBProcessMemoryDeallocate (nub_process_t pid, nub_addr_t addr) DNB_EXPORT; +int DNBProcessMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) DNB_EXPORT; //---------------------------------------------------------------------- // Process status Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp Mon Dec 12 12:51:14 2011 @@ -52,7 +52,7 @@ return count; } -int +nub_bool_t MachVMMemory::GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info) { MachVMRegion vmRegion(task); @@ -62,12 +62,30 @@ region_info->addr = vmRegion.StartAddress(); region_info->size = vmRegion.GetByteSize(); region_info->permissions = vmRegion.GetDNBPermissions(); - return 1; } - region_info->addr = 0; - region_info->size = 0; - region_info->permissions = 0; - return 0; + else + { + region_info->addr = address; + region_info->size = 0; + if (vmRegion.GetError().Success()) + { + // vmRegion.GetRegionForAddress() return false, indicating that "address" + // wasn't in a valid region, but the "vmRegion" info was successfully + // read from the task which means the info describes the next valid + // region from which we can infer the size of this invalid region + mach_vm_address_t start_addr = vmRegion.StartAddress(); + if (address < start_addr) + region_info->size = start_addr - address; + } + // If we can't get any infor about the size from the next region, just fill + // 1 in as the byte size + if (region_info->size == 0) + region_info->size = 1; + + // Not readable, writeable or executable + region_info->permissions = 0; + } + return true; } nub_size_t Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h Mon Dec 12 12:51:14 2011 @@ -27,7 +27,7 @@ nub_size_t Read(task_t task, nub_addr_t address, void *data, nub_size_t data_count); nub_size_t Write(task_t task, nub_addr_t address, const void *data, nub_size_t data_count); nub_size_t PageSize(); - int GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info); + nub_bool_t GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info); protected: nub_size_t MaxBytesLeftInPage(nub_addr_t addr, nub_size_t count); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp Mon Dec 12 12:51:14 2011 @@ -128,66 +128,59 @@ { // Restore any original protections and clear our vars Clear(); + m_err.Clear(); m_addr = addr; m_start = addr; m_depth = 1024; mach_msg_type_number_t info_size = kRegionInfoSize; assert(sizeof(info_size) == 4); m_err = ::mach_vm_region_recurse (m_task, &m_start, &m_size, &m_depth, (vm_region_recurse_info_t)&m_data, &info_size); - const bool log_protections = DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS); - if (m_err.Success()) - { - if ((addr < m_start) || (addr >= (m_start + m_size))) - { - m_err.SetErrorString("no region for address"); - m_err.SetError(-1, DNBError::Generic); - if (log_protections) - m_err.LogThreaded("::mach_vm_region_recurse ( task = 0x%4.4x, address => 0x%8.8llx, size => %llu, nesting_depth => %d, info => %p, infoCnt => %d) addr = 0x%8.8llx not in range [0x%8.8llx - 0x%8.8llx)", - m_task, (uint64_t)m_start, (uint64_t)m_size, m_depth, &m_data, info_size, (uint64_t)addr, (uint64_t)m_start, (uint64_t)m_start + m_size); - return false; - } - } - if (log_protections || m_err.Fail()) + const bool failed = m_err.Fail(); + const bool log_protections = DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS); + + if (log_protections || failed) m_err.LogThreaded("::mach_vm_region_recurse ( task = 0x%4.4x, address => 0x%8.8llx, size => %llu, nesting_depth => %d, info => %p, infoCnt => %d) addr = 0x%8.8llx ", m_task, (uint64_t)m_start, (uint64_t)m_size, m_depth, &m_data, info_size, (uint64_t)addr); - if (m_err.Fail()) - { + + if (failed) return false; - } - else + if (log_protections) { - if (log_protections) - { - DNBLogThreaded("info = { prot = %u, " - "max_prot = %u, " - "inheritance = 0x%8.8x, " - "offset = 0x%8.8llx, " - "user_tag = 0x%8.8x, " - "ref_count = %u, " - "shadow_depth = %u, " - "ext_pager = %u, " - "share_mode = %u, " - "is_submap = %d, " - "behavior = %d, " - "object_id = 0x%8.8x, " - "user_wired_count = 0x%4.4x }", - m_data.protection, - m_data.max_protection, - m_data.inheritance, - (uint64_t)m_data.offset, - m_data.user_tag, - m_data.ref_count, - m_data.shadow_depth, - m_data.external_pager, - m_data.share_mode, - m_data.is_submap, - m_data.behavior, - m_data.object_id, - m_data.user_wired_count); - } + DNBLogThreaded("info = { prot = %u, " + "max_prot = %u, " + "inheritance = 0x%8.8x, " + "offset = 0x%8.8llx, " + "user_tag = 0x%8.8x, " + "ref_count = %u, " + "shadow_depth = %u, " + "ext_pager = %u, " + "share_mode = %u, " + "is_submap = %d, " + "behavior = %d, " + "object_id = 0x%8.8x, " + "user_wired_count = 0x%4.4x }", + m_data.protection, + m_data.max_protection, + m_data.inheritance, + (uint64_t)m_data.offset, + m_data.user_tag, + m_data.ref_count, + m_data.shadow_depth, + m_data.external_pager, + m_data.share_mode, + m_data.is_submap, + m_data.behavior, + m_data.object_id, + m_data.user_wired_count); } - m_curr_protection = m_data.protection; + + // We make a request for an address and got no error back, but this + // doesn't mean that "addr" is in the range. The data in this object will + // be valid though, so you could see where the next region begins. So we + // return false, yet leave "m_err" with a successfull return code. + if ((addr < m_start) || (addr >= (m_start + m_size))) + return false; return true; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h Mon Dec 12 12:51:14 2011 @@ -47,6 +47,11 @@ uint32_t GetDNBPermissions () const; + const DNBError & + GetError () + { + return m_err; + } protected: #if defined (VM_REGION_SUBMAP_SHORT_INFO_COUNT_64) typedef vm_region_submap_short_info_data_64_t RegionInfo; Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=146394&r1=146393&r2=146394&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Dec 12 12:51:14 2011 @@ -3283,52 +3283,28 @@ } DNBRegionInfo region_info = { 0, 0, 0 }; - int ret = DNBMemoryRegionInfo (m_ctx.ProcessID(), address, ®ion_info); + DNBProcessMemoryRegionInfo (m_ctx.ProcessID(), address, ®ion_info); std::ostringstream ostrm; - if (ret == 1 && region_info.size > 0) - { // start:3a50000,size:100000,permissions:rwx - ostrm << "start:" << std::hex << region_info.addr << ';' - << "size:" << std::hex << region_info.size << ';'; + ostrm << "start:" << std::hex << region_info.addr << ';'; + + if (region_info.size > 0) + ostrm << "size:" << std::hex << region_info.size << ';'; - if (region_info.permissions) - { - ostrm << "permissions:"; - - if (region_info.permissions & eMemoryPermissionsReadable) - ostrm << 'r'; - if (region_info.permissions & eMemoryPermissionsWritable) - ostrm << 'w'; - if (region_info.permissions & eMemoryPermissionsExecutable) - ostrm << 'x'; - ostrm << ';'; - } - return SendPacket (ostrm.str()); - } - else + if (region_info.permissions) { - ostrm << std::hex << "error:"; - const char *error_message = NULL; - if (ret == -1) - { - error_message = "region lookup cannot be performed"; - } - else - { - error_message = "address in unmapped region"; - } - // hex encode the error message so we can send any characters we want in - // the future since this is text - const int error_message_len = strlen (error_message); - const uint8_t *u_error_message = (const uint8_t *)error_message; - for (int i = 0; i < error_message_len; i++) - ostrm << RAWHEX8(u_error_message[i]); + ostrm << "permissions:"; + + if (region_info.permissions & eMemoryPermissionsReadable) + ostrm << 'r'; + if (region_info.permissions & eMemoryPermissionsWritable) + ostrm << 'w'; + if (region_info.permissions & eMemoryPermissionsExecutable) + ostrm << 'x'; ostrm << ';'; - return SendPacket (ostrm.str()); } - - return SendPacket ("E68"); + return SendPacket (ostrm.str()); } From gclayton at apple.com Mon Dec 12 15:50:19 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 12 Dec 2011 21:50:19 -0000 Subject: [Lldb-commits] [lldb] r146418 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111212215019.C08EE1BE003@llvm.org> Author: gclayton Date: Mon Dec 12 15:50:19 2011 New Revision: 146418 URL: http://llvm.org/viewvc/llvm-project?rev=146418&view=rev Log: Use forward types where possible to avoid having to parse extra DWARF when it is not required. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 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=146418&r1=146417&r2=146418&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Dec 12 15:50:19 2011 @@ -1444,10 +1444,10 @@ member_accessibilities.push_back(accessibility); field_decl = GetClangASTContext().AddFieldToRecordType (class_clang_type, - name, - member_type->GetClangLayoutType(), - accessibility, - bit_size); + name, + member_type->GetClangLayoutType(), + accessibility, + bit_size); } else { @@ -3341,7 +3341,9 @@ { function_param_types.push_back (type->GetClangForwardType()); - clang::ParmVarDecl *param_var_decl = GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage); + clang::ParmVarDecl *param_var_decl = GetClangASTContext().CreateParameterDeclaration (name, + type->GetClangForwardType(), + storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } @@ -4793,7 +4795,7 @@ func_type = ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetClangLayoutType(); + return_clang_type = func_type->GetClangForwardType(); else return_clang_type = ast.GetBuiltInType_void(); @@ -5116,7 +5118,7 @@ element_orders.push_back (1); if (byte_stride == 0 && bit_stride == 0) byte_stride = element_type->GetByteSize(); - clang_type_t array_element_type = element_type->GetClangFullType(); + clang_type_t array_element_type = element_type->GetClangForwardType(); uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride; uint64_t num_elements = 0; std::vector::const_reverse_iterator pos; @@ -6002,7 +6004,7 @@ Type *matching_type = ResolveType (dwarf_cu, die); - lldb::clang_type_t type = matching_type->GetClangFullType(); + lldb::clang_type_t type = matching_type->GetClangForwardType(); clang::QualType qual_type = clang::QualType::getFromOpaquePtr(type); if (const clang::TagType *tag_type = llvm::dyn_cast(qual_type.getTypePtr())) From johnny.chen at apple.com Mon Dec 12 15:59:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 12 Dec 2011 21:59:29 -0000 Subject: [Lldb-commits] [lldb] r146422 - in /lldb/trunk: include/lldb/Target/PathMappingList.h source/Core/SourceManager.cpp source/Target/PathMappingList.cpp source/Target/Target.cpp test/source-manager/TestSourceManager.py Message-ID: <20111212215929.326641BE003@llvm.org> Author: johnny Date: Mon Dec 12 15:59:28 2011 New Revision: 146422 URL: http://llvm.org/viewvc/llvm-project?rev=146422&view=rev Log: rdar://problem/10227672 There were two problems associated with this radar: 1. "settings show target.source-map" failed to show the source-map after, for example, "settings set target.source-map /Volumes/data/lldb/svn/trunk/test/source-manager /Volumes/data/lldb/svn/trunk/test/source-manager/hidden" has been executed to set the source-map. 2. "list -n main" failed to display the source of the main() function after we properly set the source-map. The first was fixed by adding the missing functionality to TargetInstanceSettings::GetInstanceSettingsValue (Target.cpp) and updating the support files PathMappingList.h/.cpp; the second by modifying SourceManager.cpp to fix several places with incorrect logic. Also added a test case test_move_and_then_display_source() to TestSourceManager.py, which moves main.c to hidden/main.c, sets target.source-map to perform the directory mapping, and then verifies that "list -n main" can still show the main() function. Modified: lldb/trunk/include/lldb/Target/PathMappingList.h lldb/trunk/source/Core/SourceManager.cpp lldb/trunk/source/Target/PathMappingList.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/source-manager/TestSourceManager.py Modified: lldb/trunk/include/lldb/Target/PathMappingList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/PathMappingList.h?rev=146422&r1=146421&r2=146422&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/PathMappingList.h (original) +++ lldb/trunk/include/lldb/Target/PathMappingList.h Mon Dec 12 15:59:28 2011 @@ -48,8 +48,9 @@ void Clear (bool notify); + // By default, dump all pairs. void - Dump (Stream *s); + Dump (Stream *s, int pair_index=-1); size_t GetSize (); Modified: lldb/trunk/source/Core/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=146422&r1=146421&r2=146422&view=diff ============================================================================== --- lldb/trunk/source/Core/SourceManager.cpp (original) +++ lldb/trunk/source/Core/SourceManager.cpp Mon Dec 12 15:59:28 2011 @@ -86,7 +86,8 @@ { FileSP file_sp; file_sp = m_debugger->GetSourceFileCache().FindSourceFile (file_spec); - if (!file_sp) + // If file_sp is no good or it points to a non-existent file, reset it. + if (!file_sp || !file_sp->GetFileSpec().Exists()) { file_sp.reset (new File (file_spec, m_target)); @@ -336,10 +337,17 @@ } } } - else + // Try remapping if m_file_spec does not correspond to an existing file. + if (!m_file_spec.Exists()) { - if (target->GetSourcePathMap().RemapPath(file_spec.GetDirectory(), m_file_spec.GetDirectory())) - m_mod_time = file_spec.GetModificationTime(); + ConstString new_path; + if (target->GetSourcePathMap().RemapPath(m_file_spec.GetDirectory(), new_path)) + { + char resolved_path[PATH_MAX]; + ::snprintf(resolved_path, PATH_MAX, "%s/%s", new_path.AsCString(), m_file_spec.GetFilename().AsCString()); + m_file_spec = new FileSpec(resolved_path, true); + m_mod_time = m_file_spec.GetModificationTime(); + } } } } @@ -387,13 +395,18 @@ // source cache and only update when we determine a file has been updated. // For now we check each time we want to display info for the file. TimeValue curr_mod_time (m_file_spec.GetModificationTime()); - if (m_mod_time != curr_mod_time) + + if (curr_mod_time.IsValid() && m_mod_time != curr_mod_time) { m_mod_time = curr_mod_time; m_data_sp = m_file_spec.ReadFileContents (); m_offsets.clear(); } + // Sanity check m_data_sp before proceeding. + if (!m_data_sp) + return 0; + const uint32_t start_line = line <= context_before ? 1 : line - context_before; const uint32_t start_line_offset = GetLineOffset (start_line); if (start_line_offset != UINT32_MAX) Modified: lldb/trunk/source/Target/PathMappingList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/PathMappingList.cpp?rev=146422&r1=146421&r2=146422&view=diff ============================================================================== --- lldb/trunk/source/Target/PathMappingList.cpp (original) +++ lldb/trunk/source/Target/PathMappingList.cpp Mon Dec 12 15:59:28 2011 @@ -101,16 +101,25 @@ return true; } +// For clients which do not need the pair index dumped, pass a pair_index >= 0 +// to only dump the indicated pair. void -PathMappingList::Dump (Stream *s) +PathMappingList::Dump (Stream *s, int pair_index) { unsigned int numPairs = m_pairs.size(); - unsigned int index; - for (index = 0; index < numPairs; ++index) + if (pair_index < 0) { - s->Printf("[%d] \"%s\" -> \"%s\"\n", - index, m_pairs[index].first.GetCString(), m_pairs[index].second.GetCString()); + unsigned int index; + for (index = 0; index < numPairs; ++index) + s->Printf("[%d] \"%s\" -> \"%s\"\n", + index, m_pairs[index].first.GetCString(), m_pairs[index].second.GetCString()); + } + else + { + if (pair_index < numPairs) + s->Printf("%s -> %s", + m_pairs[pair_index].first.GetCString(), m_pairs[pair_index].second.GetCString()); } } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=146422&r1=146421&r2=146422&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Dec 12 15:59:28 2011 @@ -2486,6 +2486,15 @@ } else if (var_name == GetSettingNameForSourcePathMap ()) { + if (m_source_map.GetSize()) + { + size_t i; + for (i = 0; i < m_source_map.GetSize(); ++i) { + StreamString sstr; + m_source_map.Dump(&sstr, i); + value.AppendString(sstr.GetData()); + } + } } else if (var_name == GetSettingNameForMaxChildren()) { Modified: lldb/trunk/test/source-manager/TestSourceManager.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/source-manager/TestSourceManager.py?rev=146422&r1=146421&r2=146422&view=diff ============================================================================== --- lldb/trunk/test/source-manager/TestSourceManager.py (original) +++ lldb/trunk/test/source-manager/TestSourceManager.py Mon Dec 12 15:59:28 2011 @@ -22,6 +22,7 @@ TestBase.setUp(self) # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') + lldb.skip_build_and_cleanup = False @python_api_test def test_display_source_python(self): @@ -29,6 +30,11 @@ self.buildDefault() self.display_source_python() + def test_move_and_then_display_source(self): + """Test that target.source-map settings work by moving main.c to hidden/main.c.""" + self.buildDefault() + self.move_and_then_display_source() + def test_modify_source_file_while_debugging(self): """Modify a source file while debugging the executable.""" self.buildDefault() @@ -70,6 +76,33 @@ exe=False, patterns = ['=> %d.*Hello world' % self.line]) + def move_and_then_display_source(self): + """Test that target.source-map settings work by moving main.c to hidden/main.c.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Move main.c to hidden/main.c. + main_c = "main.c" + main_c_hidden = os.path.join("hidden", main_c) + os.rename(main_c, main_c_hidden) + + if self.TraceOn(): + system(["ls"]) + system(["ls", "hidden"]) + + # Restore main.c after the test. + self.addTearDownHook(lambda: os.rename(main_c_hidden, main_c)) + + # Set target.source-map settings. + self.runCmd("settings set target.source-map %s %s" % (os.getcwd(), os.path.join(os.getcwd(), "hidden"))) + # And verify that the settings work. + self.expect("settings show target.source-map", + substrs = [os.getcwd(), os.path.join(os.getcwd(), "hidden")]) + + # Display main() and verify that the source mapping has been kicked in. + self.expect("list -n main", SOURCE_DISPLAYED_CORRECTLY, + substrs = ['Hello world']) + def modify_source_file_while_debugging(self): """Modify a source file while debugging the executable.""" exe = os.path.join(os.getcwd(), "a.out") From johnny.chen at apple.com Mon Dec 12 16:07:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 12 Dec 2011 22:07:36 -0000 Subject: [Lldb-commits] [lldb] r146427 - /lldb/trunk/test/lang/cpp/this/TestCPPThis.py Message-ID: <20111212220736.D80251BE003@llvm.org> Author: johnny Date: Mon Dec 12 16:07:36 2011 New Revision: 146427 URL: http://llvm.org/viewvc/llvm-project?rev=146427&view=rev Log: Commenting out the two @expectedFailureClang decorators as the tests have been passing for a while with the recent clang compilers. The latest I tried is: Apple clang version 3.1 (tags/Apple/clang-318.0.9) (based on LLVM 3.1svn) Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py Modified: lldb/trunk/test/lang/cpp/this/TestCPPThis.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/this/TestCPPThis.py?rev=146427&r1=146426&r2=146427&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/this/TestCPPThis.py (original) +++ lldb/trunk/test/lang/cpp/this/TestCPPThis.py Mon Dec 12 16:07:36 2011 @@ -10,14 +10,14 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") #rdar://problem/9962849 - @expectedFailureClang + #@expectedFailureClang def test_with_dsym_and_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.buildDsym() self.static_method_commands() #rdar://problem/9962849 - @expectedFailureClang + #@expectedFailureClang def test_with_dwarf_and_run_command(self): """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods""" self.buildDwarf() From johnny.chen at apple.com Mon Dec 12 16:26:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 12 Dec 2011 22:26:27 -0000 Subject: [Lldb-commits] [lldb] r146429 - /lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py Message-ID: <20111212222627.849C31BE003@llvm.org> Author: johnny Date: Mon Dec 12 16:26:27 2011 New Revision: 146429 URL: http://llvm.org/viewvc/llvm-project?rev=146429&view=rev Log: Rename some test methods, with no functionality change. Modified: lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py Modified: lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py?rev=146429&r1=146428&r2=146429&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py (original) +++ lldb/trunk/test/lang/objc/real-definition/TestRealDefinition.py Mon Dec 12 16:26:27 2011 @@ -9,22 +9,22 @@ mydir = os.path.join("lang", "objc", "real-definition") - def test_expr_with_dsym(self): + def test_frame_var_after_stop_at_interface_with_dsym(self): """Test that we can find the implementation for an objective C type""" self.buildDsym() self.stop_at_interface() - def test_expr_with_dwarf(self): + def test_frame_var_after_stop_at_interface_with_dwarf(self): """Test that we can find the implementation for an objective C type""" self.buildDwarf() self.stop_at_interface() - def test_frame_variable_with_dsym(self): + def test_frame_var_after_stop_at_implementation_with_dsym(self): """Test that we can find the implementation for an objective C type""" self.buildDsym() self.stop_at_implementation() - def test_frame_variable_with_dwarf(self): + def test_frame_var_after_stop_at_implementation_with_dwarf(self): """Test that we can find the implementation for an objective C type""" self.buildDwarf() self.stop_at_implementation() From gclayton at apple.com Mon Dec 12 19:12:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 13 Dec 2011 01:12:21 -0000 Subject: [Lldb-commits] [lldb] r146462 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20111213011221.66DE91BE003@llvm.org> Author: gclayton Date: Mon Dec 12 19:12:21 2011 New Revision: 146462 URL: http://llvm.org/viewvc/llvm-project?rev=146462&view=rev Log: Fixed the Xcode project to correctly not strip anything for Debug and Release builds. Modified the Xcode project to not strip liblldb-core.a for BuildAndIntegration builds and to correctly strip only debug symbols from the command line binaries. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=146462&r1=146461&r2=146462&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Dec 12 19:12:21 2011 @@ -11,7 +11,6 @@ 260E07C8136FAB9200CF21D3 /* OptionGroupFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260E07C7136FAB9200CF21D3 /* OptionGroupFile.cpp */; }; 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2626B6AE143E1BEA00EF935C /* RangeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2626B6AD143E1BEA00EF935C /* RangeMap.h */; }; 26274FA214030EEF006BA130 /* OperatingSystemDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA014030EEF006BA130 /* OperatingSystemDarwinKernel.cpp */; }; 26274FA714030F79006BA130 /* DynamicLoaderDarwinKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26274FA514030F79006BA130 /* DynamicLoaderDarwinKernel.cpp */; }; 2628A4D513D4977900F5487A /* ThreadKDP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2628A4D313D4977900F5487A /* ThreadKDP.cpp */; }; @@ -77,7 +76,6 @@ 26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* GDBRemoteCommunicationServer.cpp */; }; 267C012B136880DF006E963E /* OptionGroupValueObjectDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 267C012A136880DF006E963E /* OptionGroupValueObjectDisplay.cpp */; }; 267C01371368C49C006E963E /* OptionGroupOutputFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BCFC531368B3E4006DC050 /* OptionGroupOutputFile.cpp */; }; - 2682100D143A59AE004BCF2D /* MappedHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 2682100C143A59AE004BCF2D /* MappedHash.h */; }; 2686536C1370ACB200D186A3 /* OptionGroupBoolean.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536B1370ACB200D186A3 /* OptionGroupBoolean.cpp */; }; 268653701370AE7200D186A3 /* OptionGroupUInt64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2686536F1370AE7200D186A3 /* OptionGroupUInt64.cpp */; }; 2689000113353DB600698AC0 /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; @@ -348,7 +346,6 @@ 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, ); }; }; 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; - 26CF992514428766001E4138 /* AnsiTerminal.h in Headers */ = {isa = PBXBuildFile; fileRef = 26CF992414428766001E4138 /* AnsiTerminal.h */; }; 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */ = {isa = PBXBuildFile; fileRef = 26651A14133BEC76005B64B7 /* lldb-public.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26D5E15F135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D5E15E135BAEA2006EA0A7 /* OptionGroupArchitecture.cpp */; }; @@ -388,7 +385,6 @@ 26F73062139D8FDB00FD51C7 /* History.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26F73061139D8FDB00FD51C7 /* History.cpp */; }; 494260DA14579144003C1C78 /* VerifyDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 494260D914579144003C1C78 /* VerifyDecl.cpp */; }; 4966DCC4148978A10028481B /* ClangExternalASTSourceCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4966DCC3148978A10028481B /* ClangExternalASTSourceCommon.cpp */; }; - 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 496B015A1406DEB100F830D5 /* IRInterpreter.h */; }; 49A1CAC51430E8DE00306AC9 /* ExpressionSourceCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A1CAC31430E8BD00306AC9 /* ExpressionSourceCode.cpp */; }; 49A71FE7141FFA5C00D59478 /* IRInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 496B01581406DE8900F830D5 /* IRInterpreter.cpp */; }; 49A71FE8141FFACF00D59478 /* DataEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268ED0A4140FF54200DE830F /* DataEncoder.cpp */; }; @@ -2879,10 +2875,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 496B015B1406DEB100F830D5 /* IRInterpreter.h in Headers */, - 2682100D143A59AE004BCF2D /* MappedHash.h in Headers */, - 2626B6AE143E1BEA00EF935C /* RangeMap.h in Headers */, - 26CF992514428766001E4138 /* AnsiTerminal.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3056,7 +3048,7 @@ ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; - shellScript = "xcode_dir=\"${DSTROOT}/Applications/Xcode.app/Contents/Developer/usr/bin\"\n\nif [ ! -d \"${xcode_dir}\" ]; then\n mkdir -p \"${xcode_dir}\"\nfi\n\nditto \"$TARGET_BUILD_DIR/$EXECUTABLE_PATH\" \"${xcode_dir}\"\n"; + shellScript = "xcode_dir=\"${DSTROOT}/Applications/Xcode.app/Contents/Developer/usr/bin\"\n\nif [ ! -d \"${xcode_dir}\" ]; then\n mkdir -p \"${xcode_dir}\"\nfi\n\nditto \"$TARGET_BUILD_DIR/$EXECUTABLE_PATH\" \"${xcode_dir}\"\nstrip -S \"${xcode_dir}/${EXECUTABLE_PATH}\""; }; 2613F2F2146880EE00BFE551 /* Copy to Xcode.app */ = { isa = PBXShellScriptBuildPhase; @@ -3070,7 +3062,7 @@ ); runOnlyForDeploymentPostprocessing = 1; shellPath = "/bin/sh -x"; - shellScript = "xcode_dir=\"${DSTROOT}/Applications/Xcode.app/Contents/SharedFrameworks\"\n\nif [ ! -d \"${xcode_dir}\" ]; then\n mkdir -p \"${xcode_dir}\"\nfi\n\nditto \"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\" \"${xcode_dir}/${WRAPPER_NAME}\"\n"; + shellScript = "xcode_dir=\"${DSTROOT}/Applications/Xcode.app/Contents/SharedFrameworks\"\n\nif [ ! -d \"${xcode_dir}\" ]; then\n mkdir -p \"${xcode_dir}\"\nfi\n\nditto \"${TARGET_BUILD_DIR}/${WRAPPER_NAME}\" \"${xcode_dir}/${WRAPPER_NAME}\"\nstrip -S \"${xcode_dir}/${EXECUTABLE_PATH}\""; }; 261B5A7511C3FA6F00AABD0A /* Fixup Framework Headers */ = { isa = PBXShellScriptBuildPhase; @@ -3604,6 +3596,7 @@ x86_64, i386, ); + COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; @@ -3640,6 +3633,8 @@ "-flimit-debug-info", "-Wparentheses", ); + STRIP_INSTALLED_PRODUCT = NO; + STRIP_STYLE = debugging; VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; }; name = Debug; @@ -3654,6 +3649,7 @@ x86_64, i386, ); + COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -3688,6 +3684,8 @@ "-flimit-debug-info", "-Wparentheses", ); + STRIP_INSTALLED_PRODUCT = NO; + STRIP_STYLE = debugging; VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; }; name = Release; @@ -3695,7 +3693,6 @@ 26579F6A126A25920007C5CB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = /System/Library/PrivateFrameworks; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; @@ -3710,7 +3707,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = /System/Library/PrivateFrameworks; INSTALL_PATH = "$(DEVELOPER_DIR)/usr/bin"; ONLY_ACTIVE_ARCH = NO; @@ -3723,11 +3719,13 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = /System/Library/PrivateFrameworks; INSTALL_PATH = "$(DEVELOPER_DIR)/usr/bin"; ONLY_ACTIVE_ARCH = NO; PRODUCT_NAME = "darwin-debug"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = YES; }; name = BuildAndIntegration; }; @@ -3735,7 +3733,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 94; @@ -3796,7 +3793,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3856,7 +3852,6 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; DYLIB_CURRENT_VERSION = 94; EXECUTABLE_EXTENSION = a; @@ -3886,7 +3881,6 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; DYLIB_CURRENT_VERSION = 94; EXECUTABLE_EXTENSION = a; @@ -3916,7 +3910,6 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; DYLIB_CURRENT_VERSION = 94; EXECUTABLE_EXTENSION = a; @@ -3953,6 +3946,7 @@ x86_64, i386, ); + COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -3987,6 +3981,8 @@ "-flimit-debug-info", "-Wparentheses", ); + STRIP_INSTALLED_PRODUCT = NO; + STRIP_STYLE = debugging; VALID_ARCHS = "armv4t armv5 armv6 armv7 i386 ppc ppc64 ppc7400 ppc970 x86_64"; }; name = BuildAndIntegration; @@ -4015,6 +4011,7 @@ "-Wl,-rpath, at loader_path/../../System/Library/PrivateFrameworks", ); PRODUCT_NAME = lldb; + STRIP_INSTALLED_PRODUCT = YES; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -4076,6 +4073,7 @@ Foundation, ); PRODUCT_NAME = LLDB; + STRIP_INSTALLED_PRODUCT = YES; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -4086,7 +4084,6 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4151,7 +4148,6 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - COPY_PHASE_STRIP = YES; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4212,6 +4208,7 @@ 26DC6A141337FE6A00FF7998 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { + COPY_PHASE_STRIP = YES; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4264,6 +4261,7 @@ ); PRODUCT_NAME = "lldb-platform"; SKIP_INSTALL = YES; + STRIP_INSTALLED_PRODUCT = YES; USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/include $(SRCROOT)/source $(LLVM_SOURCE_DIR)/include $(LLVM_SOURCE_DIR)/tools/clang/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/include $(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include"; }; name = BuildAndIntegration; @@ -4271,7 +4269,6 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 94; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4302,7 +4299,6 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 94; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", From scallanan at apple.com Mon Dec 12 19:42:04 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 13 Dec 2011 01:42:04 -0000 Subject: [Lldb-commits] [lldb] r146465 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h source/Expression/ClangUserExpression.cpp Message-ID: <20111213014204.8C62A1BE003@llvm.org> Author: spyffe Date: Mon Dec 12 19:42:04 2011 New Revision: 146465 URL: http://llvm.org/viewvc/llvm-project?rev=146465&view=rev Log: I have modified the part of the code that finds and validates the "self," "this," and "_cmd" pointers that get passed into expressions. It used to check them aggressively for validity before allowing the expression to run as an object method; now, this functionality is gated by a bool and off by default. Now the default is that when LLDB is stopped in a method of a class, code entered using "expr" will always masquerade as an instance method. If for some reason "self," "this," or "_cmd" is unavailable it will be reported as NULL. This may cause the expression to crash if it relies on those pointers, but for example getting the addresses of ivars will now work as the user would expect. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=146465&r1=146464&r2=146465&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Dec 12 19:42:04 2011 @@ -354,6 +354,7 @@ std::auto_ptr m_result_synthesizer; ///< The result synthesizer, if one is needed. + bool m_enforce_valid_object; ///< True if the expression parser should enforce the presence of a valid class pointer in order to generate the expression as a method. bool m_cplusplus; ///< True if the expression is compiled as a C++ member function (true if it was parsed when exe_ctx was in a C++ method). bool m_objectivec; ///< True if the expression is compiled as an Objective-C method (true if it was parsed when exe_ctx was in an Objective-C method). bool m_static_method; ///< True if the expression is compiled as a static (or class) method (currently true if it was parsed when exe_ctx was in an Objective-C class method). Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=146465&r1=146464&r2=146465&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Dec 12 19:42:04 2011 @@ -59,7 +59,8 @@ m_static_method(false), m_target (NULL), m_evaluated_statically (false), - m_const_result () + m_const_result (), + m_enforce_valid_object (false) { switch (m_language) { @@ -128,26 +129,29 @@ { if (m_allow_cxx && method_decl->isInstance()) { - VariableList *vars = frame->GetVariableList(false); - - const char *thisErrorString = "Stopped in a C++ method, but 'this' isn't available; pretending we are in a generic context"; - - if (!vars) - { - err.SetErrorToGenericError(); - err.SetErrorString(thisErrorString); - return; - } - - lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); - - if (!this_var || - !this_var->IsInScope(frame) || - !this_var->LocationIsValidForFrame (frame)) + if (m_enforce_valid_object) { - err.SetErrorToGenericError(); - err.SetErrorString(thisErrorString); - return; + VariableList *vars = frame->GetVariableList(false); + + const char *thisErrorString = "Stopped in a C++ method, but 'this' isn't available; pretending we are in a generic context"; + + if (!vars) + { + err.SetErrorToGenericError(); + err.SetErrorString(thisErrorString); + return; + } + + lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); + + if (!this_var || + !this_var->IsInScope(frame) || + !this_var->LocationIsValidForFrame (frame)) + { + err.SetErrorToGenericError(); + err.SetErrorString(thisErrorString); + return; + } } m_cplusplus = true; @@ -169,26 +173,29 @@ { if (m_allow_objc) { - VariableList *vars = frame->GetVariableList(false); - - const char *selfErrorString = "Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context"; - - if (!vars) + if (m_enforce_valid_object) { - err.SetErrorToGenericError(); - err.SetErrorString(selfErrorString); - return; - } - - lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); - - if (!self_var || - !self_var->IsInScope(frame) || - !self_var->LocationIsValidForFrame (frame)) - { - err.SetErrorToGenericError(); - err.SetErrorString(selfErrorString); - return; + VariableList *vars = frame->GetVariableList(false); + + const char *selfErrorString = "Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context"; + + if (!vars) + { + err.SetErrorToGenericError(); + err.SetErrorString(selfErrorString); + return; + } + + lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); + + if (!self_var || + !self_var->IsInScope(frame) || + !self_var->LocationIsValidForFrame (frame)) + { + err.SetErrorToGenericError(); + err.SetErrorString(selfErrorString); + return; + } } m_objectivec = true; @@ -400,8 +407,8 @@ if (!(m_expr_decl_map->GetObjectPointer(object_ptr, object_name, exe_ctx, materialize_error))) { - error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); - return false; + error_stream.Printf("warning: couldn't get required object pointer (substituting NULL): %s\n", materialize_error.AsCString()); + object_ptr = 0; } if (m_objectivec) @@ -410,8 +417,8 @@ if (!(m_expr_decl_map->GetObjectPointer(cmd_ptr, cmd_name, exe_ctx, materialize_error, true))) { - error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); - return false; + error_stream.Printf("warning: couldn't get object pointer (substituting NULL): %s\n", materialize_error.AsCString()); + cmd_ptr = 0; } } } From jingham at apple.com Mon Dec 12 22:04:44 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 13 Dec 2011 04:04:44 -0000 Subject: [Lldb-commits] [lldb] r146471 - in /lldb/trunk/test/functionalities/expr-doesnt-deadlock: ./ Makefile TestExprDoesntBlock.py locking.c Message-ID: <20111213040445.05C301BE003@llvm.org> Author: jingham Date: Mon Dec 12 22:04:44 2011 New Revision: 146471 URL: http://llvm.org/viewvc/llvm-project?rev=146471&view=rev Log: Add a pthreads testcase to make sure the two-step of running and expression, having the block, then timing out & letting all threads run actually works. Added: lldb/trunk/test/functionalities/expr-doesnt-deadlock/ lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c Added: lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile?rev=146471&view=auto ============================================================================== --- lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile (added) +++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/Makefile Mon Dec 12 22:04:44 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := locking.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py?rev=146471&view=auto ============================================================================== --- lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py (added) +++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Mon Dec 12 22:04:44 2011 @@ -0,0 +1,66 @@ +""" +Test that expr will time out and allow other threads to run if it blocks. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class ExprDoesntDeadlockTestCase(TestBase): + + mydir = os.path.join("functionalities", "expr-doesnt-deadlock") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test that expr will time out and allow other threads to run if it blocks - with dsym.""" + self.buildDsym() + self.expr_doesnt_deadlock() + + def test_with_dwarf_and_run_command(self): + """Test that expr will time out and allow other threads to run if it blocks.""" + self.buildDwarf() + self.expr_doesnt_deadlock() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + def expr_doesnt_deadlock (self): + """Test that expr will time out and allow other threads to run if it blocks.""" + 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 at source line before call_me_to_get_lock gets called. + + main_file_spec = lldb.SBFileSpec ("locking.c") + breakpoint = target.BreakpointCreateBySourceRegex('Break here', main_file_spec) + print "breakpoint:", breakpoint + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Frame #0 should be on self.line1 and the break condition should hold. + from lldbutil import get_stopped_thread + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") + + frame0 = thread.GetFrameAtIndex(0) + + var = frame0.EvaluateExpression ("call_me_to_get_lock()") + self.assertTrue (var.IsValid()) + self.assertTrue (var.GetValueAsSigned (0) == 567) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c?rev=146471&view=auto ============================================================================== --- lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c (added) +++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/locking.c Mon Dec 12 22:04:44 2011 @@ -0,0 +1,80 @@ +#include +#include +#include +#include + +pthread_mutex_t contended_mutex = PTHREAD_MUTEX_INITIALIZER; + +pthread_mutex_t control_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t control_condition; + +pthread_mutex_t thread_started_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t thread_started_condition; + +// This function runs in a thread. The locking dance is to make sure that +// by the time the main thread reaches the pthread_join below, this thread +// has for sure acquired the contended_mutex. So then the call_me_to_get_lock +// function will block trying to get the mutex, and only succeed once it +// signals this thread, then lets it run to wake up from the cond_wait and +// release the mutex. + +void * +lock_acquirer_1 (void *input) +{ + pthread_mutex_lock (&contended_mutex); + + // Grab this mutex, that will ensure that the main thread + // is in its cond_wait for it (since that's when it drops the mutex. + + pthread_mutex_lock (&thread_started_mutex); + pthread_mutex_unlock(&thread_started_mutex); + + // Now signal the main thread that it can continue, we have the contended lock + // so the call to call_me_to_get_lock won't make any progress till this + // thread gets a chance to run. + + pthread_mutex_lock (&control_mutex); + + pthread_cond_signal (&thread_started_condition); + + pthread_cond_wait (&control_condition, &control_mutex); + + pthread_mutex_unlock (&contended_mutex); + return NULL; +} + +int +call_me_to_get_lock () +{ + pthread_cond_signal (&control_condition); + pthread_mutex_lock (&contended_mutex); + return 567; +} + +int main () +{ + pthread_t thread_1; + + pthread_cond_init (&control_condition, NULL); + pthread_cond_init (&thread_started_condition, NULL); + + pthread_mutex_lock (&thread_started_mutex); + + pthread_create (&thread_1, NULL, lock_acquirer_1, NULL); + + pthread_cond_wait (&thread_started_condition, &thread_started_mutex); + + pthread_mutex_lock (&control_mutex); + pthread_mutex_unlock (&control_mutex); + + // Break here. At this point the other thread will have the contended_mutex, + // and be sitting in its cond_wait for the control condition. So there is + // no way that our by-hand calling of call_me_to_get_lock will proceed + // without running the first thread at least somewhat. + + call_me_to_get_lock(); + pthread_join (thread_1, NULL); + + return 0; + +} From gclayton at apple.com Mon Dec 12 22:34:06 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 13 Dec 2011 04:34:06 -0000 Subject: [Lldb-commits] [lldb] r146473 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111213043406.6D8681BE003@llvm.org> Author: gclayton Date: Mon Dec 12 22:34:06 2011 New Revision: 146473 URL: http://llvm.org/viewvc/llvm-project?rev=146473&view=rev Log: Use forward declarations more of the time to save on things that we need to parse. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 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=146473&r1=146472&r2=146473&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Dec 12 22:34:06 2011 @@ -4902,7 +4902,7 @@ // prototype off of, so we need this type to be completed so that the // m_die_to_decl_ctx for the method in the specification has a valid // clang decl context. - class_type->GetClangFullType(); + class_type->GetClangForwardType(); // If we have a specification, then the function type should have been // made with the specification and not with this die. DWARFCompileUnitSP spec_cu_sp; @@ -4926,7 +4926,7 @@ // prototype off of, so we need this type to be completed so that the // m_die_to_decl_ctx for the method in the abstract origin has a valid // clang decl context. - class_type->GetClangFullType(); + class_type->GetClangForwardType(); DWARFCompileUnitSP abs_cu_sp; const DWARFDebugInfoEntry* abs_die = DebugInfo()->GetDIEPtr(abstract_origin_die_offset, &abs_cu_sp); From jmolenda at apple.com Mon Dec 12 23:08:51 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 13 Dec 2011 05:08:51 -0000 Subject: [Lldb-commits] [lldb] r146474 - /lldb/trunk/test/ Message-ID: <20111213050851.6CC3D1BE003@llvm.org> Author: jmolenda Date: Mon Dec 12 23:08:51 2011 New Revision: 146474 URL: http://llvm.org/viewvc/llvm-project?rev=146474&view=rev Log: Try to add a svn:ignore property to ignore the testsuite run directories. I'm not sure I have this right but it looks correct. Modified: lldb/trunk/test/ (props changed) Propchange: lldb/trunk/test/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Dec 12 23:08:51 2011 @@ -0,0 +1 @@ +20[1-9][0-9]-[01][0-9]-[0-3][0-9]_[0-2][0-9]_[0-5][0-9]_[0-6][0-9] From jmolenda at apple.com Mon Dec 12 23:39:38 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 13 Dec 2011 05:39:38 -0000 Subject: [Lldb-commits] [lldb] r146477 - in /lldb/trunk: docs/lldb-gdb-remote.txt include/lldb/Target/Process.h source/Plugins/Process/Utility/RegisterContextLLDB.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Message-ID: <20111213053939.039251BE003@llvm.org> Author: jmolenda Date: Mon Dec 12 23:39:38 2011 New Revision: 146477 URL: http://llvm.org/viewvc/llvm-project?rev=146477&view=rev Log: When unwinding from the first frame, try to ask the remote debugserver if this is a mapped/executable region of memory. If it isn't, we've jumped through a bad pointer and we know how to unwind the stack correctly based on the ABI. Previously I had 0x0 special cased but if you jumped to 0x2 on x86_64 one frame would be skipped because the unwinder would try using the x86_64 ArchDefaultUnwindPlan which relied on the rbp. Fixes Modified: lldb/trunk/docs/lldb-gdb-remote.txt lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Modified: lldb/trunk/docs/lldb-gdb-remote.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/lldb-gdb-remote.txt?rev=146477&r1=146476&r2=146477&view=diff ============================================================================== --- lldb/trunk/docs/lldb-gdb-remote.txt (original) +++ lldb/trunk/docs/lldb-gdb-remote.txt Mon Dec 12 23:39:38 2011 @@ -592,6 +592,18 @@ // a hex encoded string value that // contains an error string +If the address requested is not in a mapped region (e.g. we've jumped through +a NULL pointer and are at 0x0) currently lldb expects to get back the size +of the unmapped region -- that is, the distance to the next valid region. +For instance, with a Mac OS X process which has nothing mapped in the first +4GB of its address space, if we're asking about address 0x2, + + qMemoryRegionInfo:2 + start:2;size:fffffffe; + +The lack of 'permissions:' indicates that none of read/write/execute are valid +for this region. + //---------------------------------------------------------------------- // Stop reply packet extensions // Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=146477&r1=146476&r2=146477&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Dec 12 23:39:38 2011 @@ -1177,10 +1177,18 @@ { public: typedef Range RangeType; - + + enum OptionalBool { + eDontKnow = -1, + eNo = 0, + eYes = 1 + }; + MemoryRegionInfo () : m_range (), - m_permissions (0) + m_read (eDontKnow), + m_write (eDontKnow), + m_execute (eDontKnow) { } @@ -1198,7 +1206,7 @@ Clear() { m_range.Clear(); - m_permissions = 0; + m_read = m_write = m_execute = eDontKnow; } const RangeType & @@ -1206,42 +1214,48 @@ { return m_range; } - - // Pass in a uint32_t permissions with one or more lldb::Permissions - // enumeration values logical OR'ed together. - bool - TestPermissions (uint32_t permissions) const + + OptionalBool + GetReadable () const { - return m_permissions.AllSet(permissions); + return m_read; } - - const Flags & - GetPermissions () const + + OptionalBool + GetWritable () const { - return m_permissions; + return m_write; + } + + OptionalBool + GetExecutable () const + { + return m_execute; } void - SetPermissions (uint32_t permissions) + SetReadable (OptionalBool val) { - m_permissions.Reset(permissions); + m_read = val; } - + void - AddPermissions (uint32_t permissions) + SetWritable (OptionalBool val) { - m_permissions.Set (permissions); + m_write = val; } void - RemovePermissions (uint32_t permissions) + SetExecutable (OptionalBool val) { - m_permissions.Clear (permissions); + m_execute = val; } protected: RangeType m_range; - Flags m_permissions; // Uses lldb::Permissions enumeration values logical OR'ed together + OptionalBool m_read; + OptionalBool m_write; + OptionalBool m_execute; }; //---------------------------------------------------------------------- @@ -2558,17 +2572,56 @@ error.SetErrorString ("Process::GetMemoryRegionInfo() not supported"); return error; } - - virtual uint32_t - GetLoadAddressPermissions (lldb::addr_t load_addr) + + //------------------------------------------------------------------ + /// Attempt to get the attributes for a region of memory in the process. + /// + /// It may be possible for the remote debug server to inspect attributes + /// for a region of memory in the process, such as whether there is a + /// valid page of memory at a given address or whether that page is + /// readable/writable/executable by the process. + /// + /// @param[in] load_addr + /// The address of interest in the process. + /// + /// @param[out] permissions + /// If this call returns successfully, this bitmask will have + /// its Permissions bits set to indicate whether the region is + /// readable/writable/executable. If this call fails, the + /// bitmask values are undefined. + /// + /// @return + /// Returns true if it was able to determine the attributes of the + /// memory region. False if not. + //------------------------------------------------------------------ + + virtual bool + GetLoadAddressPermissions (lldb::addr_t load_addr, uint32_t &permissions) { MemoryRegionInfo range_info; + permissions = 0; Error error (GetMemoryRegionInfo (load_addr, range_info)); - if (error.Success()) - return range_info.GetPermissions().Get(); - return 0; + if (!error.Success()) + return false; + if (range_info.GetReadable() == MemoryRegionInfo::eDontKnow + || range_info.GetWritable() == MemoryRegionInfo::eDontKnow + || range_info.GetExecutable() == MemoryRegionInfo::eDontKnow) + { + return false; + } + + if (range_info.GetReadable() == MemoryRegionInfo::eYes) + permissions |= lldb::ePermissionsReadable; + + if (range_info.GetWritable() == MemoryRegionInfo::eYes) + permissions |= lldb::ePermissionsWritable; + + if (range_info.GetExecutable() == MemoryRegionInfo::eYes) + permissions |= lldb::ePermissionsExecutable; + + return true; } - + //------------------------------------------------------------------ /// Determines whether executing JIT-compiled code in this process /// is possible. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=146477&r1=146476&r2=146477&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Dec 12 23:39:38 2011 @@ -562,8 +562,7 @@ UnwindPlanSP unwind_plan_sp; LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); UnwindPlanSP arch_default_unwind_plan_sp; - - + ABI *abi = m_thread.GetProcess().GetABI().get(); if (abi) { @@ -584,14 +583,22 @@ // If we've done a jmp 0x0 / bl 0x0 (called through a null function pointer) so the pc is 0x0 // in the zeroth frame, we need to use the "unwind at first instruction" arch default UnwindPlan - if (behaves_like_zeroth_frame - && m_current_pc.IsValid() - && m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()) == 0) + // Also, if this Process can report on memory region attributes, any non-executable region means + // we jumped through a bad function pointer - handle the same way as 0x0. + + if (behaves_like_zeroth_frame && m_current_pc.IsValid()) { - unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); - abi->CreateFunctionEntryUnwindPlan(*unwind_plan_sp); - m_frame_type = eNormalFrame; - return unwind_plan_sp; + uint32_t permissions; + addr_t current_pc_addr = m_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()); + if (current_pc_addr == 0 + || (m_thread.GetProcess().GetLoadAddressPermissions(current_pc_addr, permissions) + && (permissions & ePermissionsExecutable) == 0)) + { + unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); + abi->CreateFunctionEntryUnwindPlan(*unwind_plan_sp); + m_frame_type = eNormalFrame; + return unwind_plan_sp; + } } // No Module fm_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()or the current pc, try using the architecture default unwind. 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=146477&r1=146476&r2=146477&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Dec 12 23:39:38 2011 @@ -1108,6 +1108,7 @@ std::string value; addr_t addr_value; bool success = true; + bool saw_permissions = false; while (success && response.GetNameColonValue(name, value)) { if (name.compare ("start") == 0) @@ -1122,14 +1123,33 @@ if (success) region_info.GetRange().SetByteSize (addr_value); } - else if (name.compare ("permissions") == 0) + else if (name.compare ("permissions") == 0 && region_info.GetRange().IsValid()) { - if (value.find('r') != std::string::npos) - region_info.AddPermissions (ePermissionsReadable); - if (value.find('w') != std::string::npos) - region_info.AddPermissions (ePermissionsWritable); - if (value.find('x') != std::string::npos) - region_info.AddPermissions (ePermissionsExecutable); + saw_permissions = true; + if (region_info.GetRange().Contains (addr)) + { + if (value.find('r') != std::string::npos) + region_info.SetReadable (MemoryRegionInfo::eYes); + else + region_info.SetReadable (MemoryRegionInfo::eNo); + + if (value.find('w') != std::string::npos) + region_info.SetWritable (MemoryRegionInfo::eYes); + else + region_info.SetWritable (MemoryRegionInfo::eNo); + + if (value.find('x') != std::string::npos) + region_info.SetExecutable (MemoryRegionInfo::eYes); + else + region_info.SetExecutable (MemoryRegionInfo::eNo); + } + else + { + // The reported region does not contain this address -- we're looking at an unmapped page + region_info.SetReadable (MemoryRegionInfo::eNo); + region_info.SetWritable (MemoryRegionInfo::eNo); + region_info.SetExecutable (MemoryRegionInfo::eNo); + } } else if (name.compare ("error") == 0) { @@ -1141,6 +1161,14 @@ error.SetErrorString(value.c_str()); } } + + // We got a valid address range back but no permissions -- which means this is an unmapped page + if (region_info.GetRange().IsValid() && saw_permissions == false) + { + region_info.SetReadable (MemoryRegionInfo::eNo); + region_info.SetWritable (MemoryRegionInfo::eNo); + region_info.SetExecutable (MemoryRegionInfo::eNo); + } } else { From jmolenda at apple.com Tue Dec 13 00:00:49 2011 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 13 Dec 2011 06:00:49 -0000 Subject: [Lldb-commits] [lldb] r146478 - /lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Message-ID: <20111213060049.99AFD1BE003@llvm.org> Author: jmolenda Date: Tue Dec 13 00:00:49 2011 New Revision: 146478 URL: http://llvm.org/viewvc/llvm-project?rev=146478&view=rev Log: Add two new memory region based checks to the Unwinder: Check that the pc value for frames up the stack is in a mapped+executable region of memory. Check that the stack pointer for frames up the stack is in a mapped+readable region of memory. If the unwinder ever makes a mistake walking the stack, these checks will help to keep it from going too far into the weeds. These aren't fixing any bugs that I know of, but they add extra robustness to a complicated task. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=146478&r1=146477&r2=146478&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Dec 13 00:00:49 2011 @@ -236,6 +236,17 @@ m_frame_type = eNotAValidFrame; return; } + + // Test the pc value to see if we know it's in an unmapped/non-executable region of memory. + // If so, our unwind has made a mistake somewhere and we should stop. + uint32_t permissions; + if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions) + && (permissions & ePermissionsExecutable) == 0) + { + m_frame_type = eNotAValidFrame; + return; + } + m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc); // If we don't have a Module for some reason, we're not going to find symbol/function information - just @@ -287,6 +298,15 @@ m_frame_type = eNotAValidFrame; return; } + + // cfa_regval should point into the stack memory; if we can query memory region permissions, + // see if the memory is allocated & readable. + if (m_thread.GetProcess().GetLoadAddressPermissions(cfa_regval, permissions) + && (permissions & ePermissionsReadable) == 0) + { + m_frame_type = eNotAValidFrame; + return; + } } else { From bugzilla-daemon at llvm.org Tue Dec 13 18:25:51 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Wed, 14 Dec 2011 00:25:51 +0000 Subject: [Lldb-commits] [Bug 11560] New: lldb::SBTarget::FindFirstType crashes when passed None Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11560 Bug #: 11560 Summary: lldb::SBTarget::FindFirstType crashes when passed None Product: lldb Version: unspecified Platform: Macintosh OS/Version: MacOS X Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: nathanhowell at hotmail.com Classification: Unclassified Looks like a missing null check somewhere. I'm running r146478. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 [Switching to process 50838 thread 0x4707] 0x00007fff84fa7642 in strstr () (gdb) where #0 0x00007fff84fa7642 in strstr () #1 0x0000000100f30144 in StripTypeName (name_cstr=0x0) at /Source/lldb/source/Core/Module.cpp:509 #2 0x0000000100f30051 in lldb_private::Module::FindTypes (this=0x1029ba9a0, sc=@0x1222079d8, name=@0x122207990, namespace_decl=0x0, append=false, max_matches=1, types=@0x1222079a0) at /Source/lldb/source/Core/Module.cpp:529 #3 0x00000001000b6b4b in lldb::SBModule::FindFirstType (this=0x122207ad8, name_cstr=0x0) at /Source/lldb/source/API/SBModule.cpp:402 #4 0x0000000100084310 in lldb::SBTarget::FindFirstType (this=0x11a45ed90, type=0x0) at /Source/lldb/source/API/SBTarget.cpp:1211 #5 0x000000010012a584 in _wrap_SBTarget_FindFirstType (args=0x10397d680) at /Source/lldb/source/LLDBWrapPython.cpp:23303 #6 0x000000010273df63 in PyObject_Call () #7 0x00000001027bd55e in PyEval_EvalFrameEx () #8 0x00000001027bdcde in PyEval_EvalCodeEx () #9 0x00000001027bc36e in PyEval_EvalFrameEx () #10 0x00000001027bc2f1 in PyEval_EvalFrameEx () #11 0x00000001027bdcde in PyEval_EvalCodeEx () #12 0x00000001027ba36d in PyEval_EvalFrameEx () #13 0x00000001027bdcde in PyEval_EvalCodeEx () #14 0x00000001027bc36e in PyEval_EvalFrameEx () #15 0x00000001027bdcde in PyEval_EvalCodeEx () #16 0x00000001027bc36e in PyEval_EvalFrameEx () #17 0x00000001027bc2f1 in PyEval_EvalFrameEx () #18 0x00000001027bc2f1 in PyEval_EvalFrameEx () #19 0x00000001027bc2f1 in PyEval_EvalFrameEx () #20 0x00000001027bc2f1 in PyEval_EvalFrameEx () #21 0x00000001027bdcde in PyEval_EvalCodeEx () #22 0x00000001027bdd71 in PyEval_EvalCode () #23 0x00000001027d565e in Py_CompileString () #24 0x00000001027d5809 in PyRun_StringFlags () #25 0x00000001027d6f2b in PyRun_SimpleStringFlags () #26 0x000000010108abdd in lldb_private::ScriptInterpreterPython::RunEmbeddedPythonInterpreter (baton=0x10292f930) at /Source/lldb/source/Interpreter/ScriptInterpreterPython.cpp:1621 #27 0x00000001010352ca in ThreadCreateTrampoline (arg=0x121b50b50) at /Source/lldb/source/Host/common/Host.cpp:533 #28 0x00007fff84fa7fd6 in _pthread_start () #29 0x00007fff84fa7e89 in thread_start () (gdb) frame 5 #5 0x000000010012a584 in _wrap_SBTarget_FindFirstType (args=0x10397d680) at /Source/lldb/source/LLDBWrapPython.cpp:23303 23303 result = (arg1)->FindFirstType((char const *)arg2); Current language: auto; currently c++ (gdb) print arg2 $1 = 0x0 (gdb) -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From scallanan at apple.com Tue Dec 13 19:13:04 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 14 Dec 2011 01:13:04 -0000 Subject: [Lldb-commits] [lldb] r146537 - in /lldb/trunk/source/Expression: ASTResultSynthesizer.cpp ClangASTSource.cpp ClangUserExpression.cpp IRForTarget.cpp Message-ID: <20111214011304.CA0B42A6C12C@llvm.org> Author: spyffe Date: Tue Dec 13 19:13:04 2011 New Revision: 146537 URL: http://llvm.org/viewvc/llvm-project?rev=146537&view=rev Log: This commit is the result of a general audit of the expression parser to locate instances where dyn_cast<>() and isa<>() are used on types, and replace them with getAs<>() as appropriate. The difference is that dyn_cast<>() and isa<>() are essentially LLVM/Clang's equivalent of RTTI -- that is, they try to downcast the object and return NULL if they cannot -- but getAs<>() can traverse typedefs to perform a semantic cast. Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=146537&r1=146536&r2=146537&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Tue Dec 13 19:13:04 2011 @@ -333,7 +333,7 @@ QualType ptr_qual_type; - if (isa(expr_qual_type)) + if (expr_qual_type->getAs() != NULL) ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type); else ptr_qual_type = Ctx.getPointerType(expr_qual_type); Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=146537&r1=146536&r2=146537&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Dec 13 19:13:04 2011 @@ -220,7 +220,7 @@ if (!opaque_type) continue; - const TagType *tag_type = dyn_cast(QualType::getFromOpaquePtr(opaque_type).getTypePtr()); + const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs(); if (!tag_type) continue; @@ -258,7 +258,7 @@ if (!opaque_type) continue; - const TagType *tag_type = dyn_cast(QualType::getFromOpaquePtr(opaque_type).getTypePtr()); + const TagType *tag_type = QualType::getFromOpaquePtr(opaque_type)->getAs(); if (!tag_type) continue; @@ -677,7 +677,7 @@ QualType backing_qual_type = QualType::getFromOpaquePtr(backing_type); - const ObjCInterfaceType *backing_interface_type = dyn_cast(backing_qual_type.getTypePtr()); + const ObjCInterfaceType *backing_interface_type = backing_qual_type.getTypePtr()->getAs(); if (!backing_interface_type) continue; @@ -1067,7 +1067,7 @@ // this, we raid the function's FunctionProtoType for types. QualType qual_type (QualType::getFromOpaquePtr(type)); - const FunctionProtoType *func_proto_type = dyn_cast(qual_type.getTypePtr()); + const FunctionProtoType *func_proto_type = qual_type.getTypePtr()->getAs(); if (func_proto_type) { @@ -1128,7 +1128,7 @@ { QualType qual_type = QualType::getFromOpaquePtr(type); - if (const TagType *tag_type = dyn_cast(qual_type)) + if (const TagType *tag_type = qual_type->getAs()) { TagDecl *tag_decl = tag_type->getDecl(); @@ -1136,7 +1136,7 @@ return tag_decl; } - else if (const ObjCObjectType *objc_object_type = dyn_cast(qual_type)) + else if (const ObjCObjectType *objc_object_type = qual_type->getAs()) { ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface(); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=146537&r1=146536&r2=146537&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Dec 13 19:13:04 2011 @@ -160,7 +160,7 @@ do { clang::QualType this_type = method_decl->getThisType(decl_context->getParentASTContext()); - const clang::PointerType *this_pointer_type = llvm::dyn_cast(this_type.getTypePtr()); + const clang::PointerType *this_pointer_type = this_type->getAs(); if (!this_pointer_type) break; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=146537&r1=146536&r2=146537&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Dec 13 19:13:04 2011 @@ -632,8 +632,8 @@ clang::QualType pointer_qual_type = result_var->getType(); const clang::Type *pointer_type = pointer_qual_type.getTypePtr(); - const clang::PointerType *pointer_pointertype = dyn_cast(pointer_type); - const clang::ObjCObjectPointerType *pointer_objcobjpointertype = dyn_cast(pointer_type); + const clang::PointerType *pointer_pointertype = pointer_type->getAs(); + const clang::ObjCObjectPointerType *pointer_objcobjpointertype = pointer_type->getAs(); if (pointer_pointertype) { From johnny.chen at apple.com Tue Dec 13 19:36:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Dec 2011 01:36:05 -0000 Subject: [Lldb-commits] [lldb] r146539 - /lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Message-ID: <20111214013605.2A4932A6C12C@llvm.org> Author: johnny Date: Tue Dec 13 19:36:04 2011 New Revision: 146539 URL: http://llvm.org/viewvc/llvm-project?rev=146539&view=rev Log: Print out the breakpoint description only if self.TraceOn() is True. Modified: lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Modified: lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py?rev=146539&r1=146538&r2=146539&view=diff ============================================================================== --- lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py (original) +++ lldb/trunk/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py Tue Dec 13 19:36:04 2011 @@ -39,7 +39,8 @@ main_file_spec = lldb.SBFileSpec ("locking.c") breakpoint = target.BreakpointCreateBySourceRegex('Break here', main_file_spec) - print "breakpoint:", breakpoint + if self.TraceOn(): + print "breakpoint:", breakpoint self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) From johnny.chen at apple.com Tue Dec 13 19:43:31 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Dec 2011 01:43:31 -0000 Subject: [Lldb-commits] [lldb] r146540 - in /lldb/trunk: source/API/SBTarget.cpp source/Core/Module.cpp test/python_api/default-constructor/sb_target.py test/python_api/type/TestTypeList.py Message-ID: <20111214014332.0A0D92A6C12C@llvm.org> Author: johnny Date: Tue Dec 13 19:43:31 2011 New Revision: 146540 URL: http://llvm.org/viewvc/llvm-project?rev=146540&view=rev Log: http://llvm.org/bugs/show_bug.cgi?id=11560 lldb::SBTarget::FindFirstType crashes when passed None Add null checks to several functions. Plus add test scenario for passing None to SBTarget.FindFirstType(None) and friends. Modified: lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/test/python_api/default-constructor/sb_target.py lldb/trunk/test/python_api/type/TestTypeList.py Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=146540&r1=146539&r2=146540&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Dec 13 19:43:31 2011 @@ -1188,7 +1188,7 @@ { if (!append) sc_list.Clear(); - if (m_opaque_sp) + if (name && m_opaque_sp) { const bool symbols_ok = true; return m_opaque_sp->GetImages().FindFunctions (ConstString(name), @@ -1203,7 +1203,7 @@ lldb::SBType SBTarget::FindFirstType (const char* type) { - if (m_opaque_sp) + if (type && m_opaque_sp) { size_t count = m_opaque_sp->GetImages().GetSize(); for (size_t idx = 0; idx < count; idx++) @@ -1223,7 +1223,7 @@ SBTypeList retval; - if (m_opaque_sp) + if (type && m_opaque_sp) { ModuleList& images = m_opaque_sp->GetImages(); ConstString name_const(type); @@ -1251,7 +1251,7 @@ { SBValueList sb_value_list; - if (m_opaque_sp) + if (name && m_opaque_sp) { VariableList variable_list; const bool append = true; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=146540&r1=146539&r2=146540&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Tue Dec 13 19:43:31 2011 @@ -506,6 +506,9 @@ static const char* StripTypeName(const char* name_cstr) { + // Protect against null c string. + if (!name_cstr) + return name_cstr; const char* skip_namespace = strstr(name_cstr, "::"); const char* template_arg_char = strchr(name_cstr, '<'); while (skip_namespace != NULL) Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=146540&r1=146539&r2=146540&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_target.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_target.py Tue Dec 13 19:43:31 2011 @@ -24,6 +24,7 @@ obj.FindFunctions("the_func", 0xff, True, contextlist) obj.FindFirstType("dont_care") obj.FindTypes("dont_care") + obj.FindFirstType(None) obj.GetSourceManager() obj.FindGlobalVariables("my_global_var", 1) address = obj.ResolveLoadAddress(0xffff) Modified: lldb/trunk/test/python_api/type/TestTypeList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/type/TestTypeList.py?rev=146540&r1=146539&r2=146540&view=diff ============================================================================== --- lldb/trunk/test/python_api/type/TestTypeList.py (original) +++ lldb/trunk/test/python_api/type/TestTypeList.py Tue Dec 13 19:43:31 2011 @@ -69,6 +69,10 @@ self.assertTrue(type) self.DebugSBType(type) + # Pass an empty string. LLDB should not crash. :-) + fuzz_types = target.FindTypes(None) + fuzz_type = target.FindFirstType(None) + # Now use the SBTarget.FindFirstType() API to find 'Task'. task_type = target.FindFirstType('Task') self.assertTrue(task_type) From bugzilla-daemon at llvm.org Tue Dec 13 19:44:50 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Wed, 14 Dec 2011 01:44:50 +0000 Subject: [Lldb-commits] [Bug 11560] lldb::SBTarget::FindFirstType crashes when passed None In-Reply-To: References: Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11560 johnny.chen at apple.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #2 from johnny.chen at apple.com 2011-12-13 19:44:50 CST --- Checked in http://llvm.org/viewvc/llvm-project?rev=146540&view=rev. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From jmolenda at apple.com Tue Dec 13 22:22:18 2011 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 14 Dec 2011 04:22:18 -0000 Subject: [Lldb-commits] [lldb] r146551 - in /lldb/trunk: include/lldb/Target/DynamicLoader.h source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h source/Plugins/Process/Utility/RegisterContextLLDB.cpp Message-ID: <20111214042219.033A32A6C12C@llvm.org> Author: jmolenda Date: Tue Dec 13 22:22:18 2011 New Revision: 146551 URL: http://llvm.org/viewvc/llvm-project?rev=146551&view=rev Log: On Mac OS X the Objective-C runtime (libobjc) has many critical dispatch functions that are implemented in hand-written assembly. There is also hand-written eh_frame instructions for unwinding from these functions. Normally we don't use eh_frame instructions for the currently executing function, prefering the assembly instruction profiling method. But in these hand-written dispatch functions, the profiling is doomed and we should use the eh_frame instructions. Unfortunately there's no easy way to flag/extend the eh_frame/debug_frame sections to annotate if the unwind instructions are accurate at all addresses ("asynchronous") or if they are only accurate at locations that can throw an exception ("synchronous" and the normal case for gcc/clang generated eh_frame/debug_frame CFI). Modified: lldb/trunk/include/lldb/Target/DynamicLoader.h lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Modified: lldb/trunk/include/lldb/Target/DynamicLoader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/DynamicLoader.h?rev=146551&r1=146550&r2=146551&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/DynamicLoader.h (original) +++ lldb/trunk/include/lldb/Target/DynamicLoader.h Tue Dec 13 22:22:18 2011 @@ -166,7 +166,7 @@ { return 0; } - + //------------------------------------------------------------------ /// Ask if it is ok to try and load or unload an shared library /// (image). @@ -177,12 +177,40 @@ /// sure it is an ok time to load a shared library. /// /// @return - /// \b True if it is currently ok to try and load a shared + /// \b true if it is currently ok to try and load a shared /// library into the process, \b false otherwise. //------------------------------------------------------------------ virtual Error CanLoadImage () = 0; + //------------------------------------------------------------------ + /// Ask if the eh_frame information for the given SymbolContext should + /// be relied on even when it's the first frame in a stack unwind. + /// + /// The CFI instructions from the eh_frame section are normally only + /// valid at call sites -- places where a program could throw an + /// exception and need to unwind out. But some Modules may be known + /// to the system as having reliable eh_frame information at all call + /// sites. This would be the case if the Module's contents are largely + /// hand-written assembly with hand-written eh_frame information. + /// Normally when unwinding from a function at the beginning of a stack + /// unwind lldb will examine the assembly instructions to understand + /// how the stack frame is set up and where saved registers are stored. + /// But with hand-written assembly this is not reliable enough -- we need + /// to consult those function's hand-written eh_frame information. + /// + /// @return + /// \b True if the symbol context should use eh_frame instructions + /// unconditionally when unwinding from this frame. Else \b false, + /// the normal lldb unwind behavior of only using eh_frame when the + /// function appears in the middle of the stack. + //------------------------------------------------------------------ + virtual bool + AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx) + { + return false; + } + protected: //------------------------------------------------------------------ // Member variables. 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=146551&r1=146550&r2=146551&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Dec 13 22:22:18 2011 @@ -1230,6 +1230,50 @@ } //---------------------------------------------------------------------- +// On Mac OS X libobjc (the Objective-C runtime) has several critical dispatch +// functions written in hand-written assembly, and also have hand-written unwind +// information in the eh_frame section. Normally we prefer analyzing the +// assembly instructions of a curently executing frame to unwind from that frame -- +// but on hand-written functions this profiling can fail. We should use the +// eh_frame instructions for these functions all the time. +// +// As an aside, it would be better if the eh_frame entries had a flag (or were +// extensible so they could have an Apple-specific flag) which indicates that +// the instructions are asynchronous -- accurate at every instruction, instead +// of our normal default assumption that they are not. +//---------------------------------------------------------------------- + +bool +DynamicLoaderMacOSXDYLD::AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx) +{ + ModuleSP module_sp; + if (sym_ctx.symbol) + { + AddressRange *ar = sym_ctx.symbol->GetAddressRangePtr(); + if (ar) + { + module_sp = ar->GetBaseAddress().GetModule(); + } + } + if (module_sp.get() == NULL && sym_ctx.function) + { + module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModule(); + } + if (module_sp.get() == NULL) + return false; + + ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(); + if (objc_runtime != NULL && objc_runtime->IsModuleObjCLibrary (module_sp)) + { + return true; + } + + return false; +} + + + +//---------------------------------------------------------------------- // Dump a Segment to the file handle provided. //---------------------------------------------------------------------- void Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=146551&r1=146550&r2=146551&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Tue Dec 13 22:22:18 2011 @@ -86,6 +86,9 @@ virtual uint32_t GetPluginVersion(); + virtual bool + AlwaysRelyOnEHUnwindInfo (lldb_private::SymbolContext &sym_ctx); + protected: void PrivateInitialize (lldb_private::Process *process); Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=146551&r1=146550&r2=146551&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Dec 13 22:22:18 2011 @@ -26,6 +26,7 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/DynamicLoader.h" #include "RegisterContextLLDB.h" @@ -621,7 +622,7 @@ } } - // No Module fm_current_pc.GetLoadAddress (&m_thread.GetProcess().GetTarget()or the current pc, try using the architecture default unwind. + // No Module for the current pc, try using the architecture default unwind. if (!m_current_pc.IsValid() || m_current_pc.GetModule() == NULL || m_current_pc.GetModule()->GetObjectFile() == NULL) { m_frame_type = eNormalFrame; @@ -653,7 +654,28 @@ return unwind_plan_sp; } - + // Ask the DynamicLoader if the eh_frame CFI should be trusted in this frame even when it's frame zero + // This comes up if we have hand-written functions in a Module and hand-written eh_frame. The assembly + // instruction inspection may fail and the eh_frame CFI were probably written with some care to do the + // right thing. It'd be nice if there was a way to ask the eh_frame directly if it is asynchronous + // (can be trusted at every instruction point) or synchronous (the normal case - only at call sites). + // But there is not. + if (m_thread.GetProcess().GetDynamicLoader() + && m_thread.GetProcess().GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo (m_sym_ctx)) + { + unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) + { + if (log && log->GetVerbose()) + { + log->Printf("%*sFrame %u frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + unwind_plan_sp->GetSourceName().GetCString()); + } + return unwind_plan_sp; + } + } + // Typically the NonCallSite UnwindPlan is the unwind created by inspecting the assembly language instructions if (behaves_like_zeroth_frame) { From bugzilla-daemon at llvm.org Wed Dec 14 11:36:42 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Wed, 14 Dec 2011 17:36:42 +0000 Subject: [Lldb-commits] [Bug 11569] New: LLDBSwigPythonCallCommand crashes when a command script returns an object Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11569 Bug #: 11569 Summary: LLDBSwigPythonCallCommand crashes when a command script returns an object Product: lldb Version: unspecified Platform: Macintosh OS/Version: MacOS X Status: NEW Severity: enhancement Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: nathanhowell at hotmail.com Classification: Unclassified Running r146566. LLDB seems to expect a string as the return result from a command script but does not check that it is a string before using it. Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000 0x00007fff84f71c00 in strlen () (gdb) where #0 0x00007fff84f71c00 in strlen () #1 0x00007fff81378a46 in std::string::assign () #2 0x00000001000dd998 in LLDBSwigPythonCallCommand (python_function_name=0x11e9c7d78 "ghc.print_obj_dbg", session_dictionary_name=0x102988588 "debugger_1_dict", debugger=@0x7fff5fbfc9f0, args=0x120fe67b8 "$r14", err_msg=@0x7fff5fbfc9d0, cmd_retobj=@0x120fed2e0) at /Source/lldb/source/LLDBWrapPython.cpp:30249 #3 0x000000010108fb0b in lldb_private::ScriptInterpreterPython::RunScriptBasedCommand (this=0x10292f930, impl_function=0x11e9c7d78 "ghc.print_obj_dbg", args=0x120fe67b8 "$r14", synchronicity=lldb_private::eScriptedCommandSynchronicitySynchronous, cmd_retobj=@0x120fed2e0, error=@0x7fff5fbfcaa8) at /Source/lldb/source/Interpreter/ScriptInterpreterPython.cpp:1890 #4 0x0000000100e7dc73 in CommandObjectPythonFunction::ExecuteRawCommandString (this=0x11e9c7dc0, raw_command_line=0x120fe67b8 "$r14", result=@0x120fed2e0) at /Source/lldb/source/Commands/CommandObjectCommands.cpp:1192 #5 0x000000010105cbf7 in lldb_private::CommandInterpreter::HandleCommand (this=0x102914fe0, command_line=0x1051a22f8 "printObj $r14", add_to_history=true, result=@0x120fed2e0, override_context=0x0, repeat_on_empty_command=true, no_context_switching=false) at /Source/lldb/source/Interpreter/CommandInterpreter.cpp:1503 #6 0x00000001000a9869 in lldb::SBCommandInterpreter::HandleCommand (this=0x7fff5fbfd5e0, command_line=0x1051a22f8 "printObj $r14", result=@0x7fff5fbfd5e8, add_to_history=true) at /Source/lldb/source/API/SBCommandInterpreter.cpp:97 #7 0x0000000100004ac3 in Driver::HandleIOEvent (this=0x7fff5fbfec30, event=@0x7fff5fbfda40) at /Source/lldb/tools/driver/Driver.cpp:933 #8 0x0000000100006790 in Driver::MainLoop (this=0x7fff5fbfec30) at /Source/lldb/tools/driver/Driver.cpp:1341 #9 0x00000001000070aa in main (argc=2, argv=0x7fff5fbfed60, envp=0x7fff5fbfed78) at /Source/lldb/tools/driver/Driver.cpp:1460 (gdb) frame 2 #2 0x00000001000dd998 in LLDBSwigPythonCallCommand (python_function_name=0x11e9c7d78 "ghc.print_obj_dbg", session_dictionary_name=0x102988588 "debugger_1_dict", debugger=@0x7fff5fbfc9f0, args=0x120fe67b8 "$r14", err_msg=@0x7fff5fbfc9d0, cmd_retobj=@0x120fed2e0) at /Source/lldb/source/LLDBWrapPython.cpp:30249 30249 err_msg.assign(PyString_AsString(pvalue)); Current language: auto; currently c++ (gdb) print pvalue $1 = (PyObject *) 0x102e4d790 (gdb) print pvalue[0] $2 = { ob_refcnt = 1, ob_type = 0x1029c3260 } -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From johnny.chen at apple.com Wed Dec 14 14:40:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Dec 2011 20:40:27 -0000 Subject: [Lldb-commits] [lldb] r146584 - in /lldb/trunk: scripts/Python/python-wrapper.swig test/functionalities/command_script/TestCommandScript.py test/functionalities/command_script/bug11569.py test/functionalities/command_script/py_import Message-ID: <20111214204027.7F90A2A6C12C@llvm.org> Author: johnny Date: Wed Dec 14 14:40:27 2011 New Revision: 146584 URL: http://llvm.org/viewvc/llvm-project?rev=146584&view=rev Log: http://llvm.org/bugs/show_bug.cgi?id=11569 LLDBSwigPythonCallCommand crashes when a command script returns an object Add more robustness to LLDBSwigPythonCallCommand. It should check whether the returned Python object is a string, and only assign it as the error msg when the check holds. Also add a regression test. Added: lldb/trunk/test/functionalities/command_script/bug11569.py Modified: lldb/trunk/scripts/Python/python-wrapper.swig lldb/trunk/test/functionalities/command_script/TestCommandScript.py lldb/trunk/test/functionalities/command_script/py_import Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=146584&r1=146583&r2=146584&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Wed Dec 14 14:40:27 2011 @@ -645,9 +645,11 @@ err_msg.clear(); retval = true; } - else // return value is an error string + else { - err_msg.assign(PyString_AsString(pvalue)); + // return value is an error string + if (PyString_CheckExact(pvalue)) + err_msg.assign(PyString_AsString(pvalue)); retval = false; } Py_DECREF (pvalue); Modified: lldb/trunk/test/functionalities/command_script/TestCommandScript.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/TestCommandScript.py?rev=146584&r1=146583&r2=146584&view=diff ============================================================================== --- lldb/trunk/test/functionalities/command_script/TestCommandScript.py (original) +++ lldb/trunk/test/functionalities/command_script/TestCommandScript.py Wed Dec 14 14:40:27 2011 @@ -37,6 +37,7 @@ self.runCmd('command script delete tell_sync', check=False) self.runCmd('command script delete tell_async', check=False) self.runCmd('command script delete tell_curr', check=False) + self.runCmd('command script delete bug11569', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -115,6 +116,12 @@ self.expect('command script add -f foobar frame', error=True, substrs = ['cannot add command']) + # http://llvm.org/bugs/show_bug.cgi?id=11569 + # LLDBSwigPythonCallCommand crashes when a command script returns an object + self.runCmd('command script add -f bug11569 bug11569') + # This should not crash. + self.runCmd('bug11569', check=False) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Added: lldb/trunk/test/functionalities/command_script/bug11569.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/bug11569.py?rev=146584&view=auto ============================================================================== --- lldb/trunk/test/functionalities/command_script/bug11569.py (added) +++ lldb/trunk/test/functionalities/command_script/bug11569.py Wed Dec 14 14:40:27 2011 @@ -0,0 +1,7 @@ +def bug11569(debugger, args, result, dict): + """ + http://llvm.org/bugs/show_bug.cgi?id=11569 + LLDBSwigPythonCallCommand crashes when a command script returns an object. + """ + return ["return", "a", "non-string", "should", "not", "crash", "LLDB"]; + Modified: lldb/trunk/test/functionalities/command_script/py_import URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/command_script/py_import?rev=146584&r1=146583&r2=146584&view=diff ============================================================================== --- lldb/trunk/test/functionalities/command_script/py_import (original) +++ lldb/trunk/test/functionalities/command_script/py_import Wed Dec 14 14:40:27 2011 @@ -1,6 +1,7 @@ script import sys, os script sys.path.append(os.path.join(os.getcwd(), os.pardir)) script import welcome +script import bug11569 command script add welcome --function welcome.welcome_impl command script add targetname --function welcome.target_name_impl command script add longwait --function welcome.print_wait_impl From bugzilla-daemon at llvm.org Wed Dec 14 14:44:49 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Wed, 14 Dec 2011 20:44:49 +0000 Subject: [Lldb-commits] [Bug 11569] LLDBSwigPythonCallCommand crashes when a command script returns an object In-Reply-To: References: Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11569 johnny.chen at apple.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |johnny.chen at apple.com Resolution| |FIXED --- Comment #1 from johnny.chen at apple.com 2011-12-14 14:44:49 CST --- Checked in http://llvm.org/viewvc/llvm-project?rev=146584&view=rev. thanks! Add more robustness to LLDBSwigPythonCallCommand. It should check whether the returned Python object is a string, and only assign it as the error msg when the check holds. Also add a regression test. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From bugzilla-daemon at llvm.org Wed Dec 14 15:32:40 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Wed, 14 Dec 2011 21:32:40 +0000 Subject: [Lldb-commits] [Bug 11574] New: lldb:SBTarget::FindFirstType and FindTypes return different results Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11574 Bug #: 11574 Summary: lldb:SBTarget::FindFirstType and FindTypes return different results Product: lldb Version: unspecified Platform: Macintosh OS/Version: MacOS X Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: nathanhowell at hotmail.com Classification: Unclassified Created attachment 7732 --> http://llvm.org/bugs/attachment.cgi?id=7732 Repro app compiled with GHC 7.2.1 x86_64 I've hit an unexpected case where target.FindFirstType returns None but FindTypes returns a singleton list containing the correct type. The offending object, executable and source code are attached. Current executable set to './foo' (x86_64). (lldb) breakpoint set -n Main_main_info Breakpoint created: 1: name = 'Main_main_info', locations = 1 (lldb) run Process 52668 launched: '/private/tmp/repro/foo' (x86_64) Process 52668 stopped * thread #1: tid = 0x2c03, 0x0000000100000fb8 foo`Main_main_info, stop reason = breakpoint 1.1 frame #0: 0x0000000100000fb8 foo`Main_main_info foo`Main_main_info: -> 0x100000fb8: leaq -32(%rbp), %rax 0x100000fbc: cmpq %r15, %rax 0x100000fbf: jb 0x0000000100001054 ; Main_main_info + 156 0x100000fc5: addq $16, %r12 (lldb) target modules lookup -t StgConInfoTable_ 1 match found in /private/tmp/repro/foo: id = {0xe0000081c}, name = "StgConInfoTable_", byte-size = 24, decl = InfoTables.h:342, clang_type = "struct StgConInfoTable_ { StgHalfInt con_desc; StgHalfWord __pad_con_desc; StgInfoTable i; }" (lldb) script Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D. >>> target = lldb.debugger.GetSelectedTarget() >>> target.FindFirstType('StgConInfoTable_') No value <-- unexpected result >>> tl = target.FindTypes('StgConInfoTable_') >>> tl.GetSize() 1 >>> tl.GetTypeAtIndex(0) struct StgConInfoTable_ { StgHalfInt con_desc; StgHalfWord __pad_con_desc; StgInfoTable i; } -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From johnny.chen at apple.com Wed Dec 14 17:27:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 14 Dec 2011 23:27:54 -0000 Subject: [Lldb-commits] [lldb] r146606 - /lldb/trunk/scripts/Python/python-wrapper.swig Message-ID: <20111214232754.317112A6C12C@llvm.org> Author: johnny Date: Wed Dec 14 17:27:53 2011 New Revision: 146606 URL: http://llvm.org/viewvc/llvm-project?rev=146606&view=rev Log: Add more robustness - use PyString_CheckExact(pvalue) to check whether pvalue is a Python string before calling PyString_AsString(pvalue). Similar to http://llvm.org/viewvc/llvm-project?rev=146584&view=rev. Modified: lldb/trunk/scripts/Python/python-wrapper.swig Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=146606&r1=146605&r2=146606&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Wed Dec 14 17:27:53 2011 @@ -234,7 +234,7 @@ if (pvalue != NULL) { - if (pvalue != Py_None) + if (pvalue != Py_None && PyString_CheckExact(pvalue)) retval = std::string(PyString_AsString(pvalue)); else retval = "None"; From scallanan at apple.com Wed Dec 14 17:49:37 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 14 Dec 2011 23:49:37 -0000 Subject: [Lldb-commits] [lldb] r146611 - in /lldb/trunk: include/lldb/API/SBInstructionList.h include/lldb/API/SBTarget.h include/lldb/Core/Disassembler.h scripts/Python/interface/SBTarget.i scripts/Python/python-typemaps.swig source/API/SBTarget.cpp source/Core/Disassembler.cpp test/api/disassemble-raw-data/ test/api/disassemble-raw-data/TestDisassembleRawData.py Message-ID: <20111214234938.09DCE2A6C12C@llvm.org> Author: spyffe Date: Wed Dec 14 17:49:37 2011 New Revision: 146611 URL: http://llvm.org/viewvc/llvm-project?rev=146611&view=rev Log: I have added a function to SBTarget that allows clients to disassemble a series of raw bytes as demonstrated by a new testcase. In the future, this API will also allow clients to provide a callback that adds comments for addresses in the disassembly. I also modified the SWIG harness to ensure that Python ByteArrays work as well as strings as sources of raw data. Added: lldb/trunk/test/api/disassemble-raw-data/ lldb/trunk/test/api/disassemble-raw-data/TestDisassembleRawData.py Modified: lldb/trunk/include/lldb/API/SBInstructionList.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/scripts/Python/interface/SBTarget.i lldb/trunk/scripts/Python/python-typemaps.swig lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Core/Disassembler.cpp Modified: lldb/trunk/include/lldb/API/SBInstructionList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstructionList.h?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstructionList.h (original) +++ lldb/trunk/include/lldb/API/SBInstructionList.h Wed Dec 14 17:49:37 2011 @@ -58,6 +58,7 @@ protected: friend class SBFunction; friend class SBSymbol; + friend class SBTarget; void SetDisassembler (const lldb::DisassemblerSP &opaque_sp); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Dec 14 17:49:37 2011 @@ -494,6 +494,12 @@ SBSourceManager GetSourceManager(); + + lldb::SBInstructionList + GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); + + lldb::SBInstructionList + GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size); #ifndef SWIG bool Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Wed Dec 14 17:49:37 2011 @@ -261,6 +261,13 @@ const char *plugin_name, const ExecutionContext &exe_ctx, const AddressRange &disasm_range); + + static lldb::DisassemblerSP + DisassembleBytes (const ArchSpec &arch, + const char *plugin_name, + const Address &start, + const void *bytes, + size_t length); static bool Disassemble (Debugger &debugger, Modified: lldb/trunk/scripts/Python/interface/SBTarget.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBTarget.i (original) +++ lldb/trunk/scripts/Python/interface/SBTarget.i Wed Dec 14 17:49:37 2011 @@ -470,7 +470,10 @@ lldb::SBBroadcaster GetBroadcaster () const; - + + lldb::SBInstructionList + GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); + bool GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); }; Modified: lldb/trunk/scripts/Python/python-typemaps.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-typemaps.swig (original) +++ lldb/trunk/scripts/Python/python-typemaps.swig Wed Dec 14 17:49:37 2011 @@ -69,30 +69,48 @@ // typemap for an outgoing buffer // See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len). %typemap(in) (const char *cstr, uint32_t cstr_len) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + if (PyString_Check($input)) { + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (char *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; } - $1 = (char *) PyString_AsString($input); - $2 = PyString_Size($input); } // Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len). %typemap(in) (const char *src, size_t src_len) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + if (PyString_Check($input)) { + $1 = (char *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (char *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; } - $1 = (char *) PyString_AsString($input); - $2 = PyString_Size($input); } // And SBProcess::WriteMemory. %typemap(in) (const void *buf, size_t size) { - if (!PyString_Check($input)) { - PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + if (PyString_Check($input)) { + $1 = (void *) PyString_AsString($input); + $2 = PyString_Size($input); + } + else if(PyByteArray_Check($input)) { + $1 = (void *) PyByteArray_AsString($input); + $2 = PyByteArray_Size($input); + } + else { + PyErr_SetString(PyExc_ValueError, "Expecting a string"); + return NULL; } - $1 = (void *) PyString_AsString($input); - $2 = PyString_Size($input); } // typemap for an incoming buffer Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Dec 14 17:49:37 2011 @@ -1285,6 +1285,33 @@ return source_manager; } +lldb::SBInstructionList +SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size) +{ + SBInstructionList sb_instructions; + + if (m_opaque_sp) + { + Address addr; + + if (base_addr.get()) + addr = *base_addr.get(); + + sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (m_opaque_sp->GetArchitecture(), + NULL, + addr, + buf, + size)); + } + + return sb_instructions; +} + +lldb::SBInstructionList +SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size) +{ + return GetInstructions (ResolveLoadAddress(base_addr), buf, size); +} SBError SBTarget::SetSectionLoadAddress (lldb::SBSection section, Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=146611&r1=146610&r2=146611&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Wed Dec 14 17:49:37 2011 @@ -230,6 +230,37 @@ return disasm_sp; } +lldb::DisassemblerSP +Disassembler::DisassembleBytes +( + const ArchSpec &arch, + const char *plugin_name, + const Address &start, + const void *bytes, + size_t length +) +{ + lldb::DisassemblerSP disasm_sp; + + if (bytes) + { + disasm_sp.reset(Disassembler::FindPlugin(arch, plugin_name)); + + if (disasm_sp) + { + DataExtractor data(bytes, length, arch.GetByteOrder(), arch.GetAddressByteSize()); + + (void)disasm_sp->DecodeInstructions (start, + data, + 0, + UINT32_MAX, + false); + } + } + + return disasm_sp; +} + bool Disassembler::Disassemble Added: lldb/trunk/test/api/disassemble-raw-data/TestDisassembleRawData.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/api/disassemble-raw-data/TestDisassembleRawData.py?rev=146611&view=auto ============================================================================== --- lldb/trunk/test/api/disassemble-raw-data/TestDisassembleRawData.py (added) +++ lldb/trunk/test/api/disassemble-raw-data/TestDisassembleRawData.py Wed Dec 14 17:49:37 2011 @@ -0,0 +1,40 @@ +""" +Use lldb Python API to disassemble raw machine code bytes +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class DisassembleRawDataTestCase(TestBase): + + mydir = os.path.join("api", "disassemble-raw-data") + + @python_api_test + def test_disassemble_raw_data(self): + """Test disassembling raw bytes with the API.""" + self.disassemble_raw_data() + + def disassemble_raw_data(self): + """Test disassembling raw bytes with the API.""" + # Create a target from the debugger. + + target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64-apple-darwin") + self.assertTrue(target, VALID_TARGET) + + raw_bytes = bytearray([0x48, 0x89, 0xe5]) + + insts = target.GetInstructions(lldb.SBAddress(), raw_bytes) + + inst = insts.GetInstructionAtIndex(0) + + self.assertTrue (inst.GetMnemonic(target) == "movq") + self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp") + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From bugzilla-daemon at llvm.org Wed Dec 14 18:47:27 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 15 Dec 2011 00:47:27 +0000 Subject: [Lldb-commits] [Bug 11579] New: lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11579 Bug #: 11579 Summary: lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds Product: lldb Version: unspecified Platform: Macintosh OS/Version: MacOS X Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: nathanhowell at hotmail.com Classification: Unclassified And triggers another segfault. (gdb) where #0 lldb_private::IntrusiveSharingPtr::get (this=0x18) at /Source/lldb/include/lldb/Utility/SharingPtr.h:697 #1 0x00000001000c8bee in lldb_private::TypeImpl::IsValid (this=0x0) at /Source/lldb/include/lldb/Symbol/Type.h:372 #2 0x00000001011e9ac9 in lldb_private::TypeImpl::GetASTContext (this=0x0) at /Source/lldb/source/Symbol/Type.cpp:775 #3 0x00000001000bde2d in lldb::SBValue::CreateValueFromAddress (this=0x1050c0660, name=0x102f876e4 "$0_closure", address=4379757008, type={m_opaque_sp = {ptr_ = 0x7fff5fbfbae8, cntrl_ = 0x7fff5fbfbaf8}}) at /Source/lldb/source/API/SBValue.cpp:420 #4 0x000000010013a105 in _wrap_SBValue_CreateValueFromAddress (args=0x102b19db8) at /Source/lldb/source/LLDBWrapPython.cpp:27815 #5 0x000000010273df63 in PyObject_Call () #6 0x00000001027bd55e in PyEval_EvalFrameEx () #7 0x00000001027bdcde in PyEval_EvalCodeEx () #8 0x00000001027bc36e in PyEval_EvalFrameEx () #9 0x00000001027bc2f1 in PyEval_EvalFrameEx () #10 0x00000001027bc2f1 in PyEval_EvalFrameEx () #11 0x00000001027bdcde in PyEval_EvalCodeEx () #12 0x000000010275f865 in PyClassMethod_New () #13 0x000000010273df63 in PyObject_Call () #14 0x00000001027b79eb in PyEval_CallObjectWithKeywords () #15 0x00000001000dd8bf in LLDBSwigPythonCallCommand (python_function_name=0x103b09d48 "ghc.print_obj_dbg", session_dictionary_name=0x1029779a8 "debugger_1_dict", debugger=@0x7fff5fbfca00, args=0x1029d4578 "(\"$r14\")", err_msg=@0x7fff5fbfc9e0, cmd_retobj=@0x1029d4710) at /Source/lldb/source/LLDBWrapPython.cpp:30237 #16 0x000000010108fb0b in lldb_private::ScriptInterpreterPython::RunScriptBasedCommand (this=0x10292f8e0, impl_function=0x103b09d48 "ghc.print_obj_dbg", args=0x1029d4578 "(\"$r14\")", synchronicity=lldb_private::eScriptedCommandSynchronicitySynchronous, cmd_retobj=@0x1029d4710, error=@0x7fff5fbfcab8) at /Source/lldb/source/Interpreter/ScriptInterpreterPython.cpp:1890 #17 0x0000000100e7dc73 in CommandObjectPythonFunction::ExecuteRawCommandString (this=0x103b08580, raw_command_line=0x1029d4578 "(\"$r14\")", result=@0x1029d4710) at /Source/lldb/source/Commands/CommandObjectCommands.cpp:1192 #18 0x000000010105cbf7 in lldb_private::CommandInterpreter::HandleCommand (this=0x102914f90, command_line=0x1050c6508 "printObj (\"$r14\")", add_to_history=true, result=@0x1029d4710, override_context=0x0, repeat_on_empty_command=true, no_context_switching=false) at /Source/lldb/source/Interpreter/CommandInterpreter.cpp:1503 #19 0x00000001000a9869 in lldb::SBCommandInterpreter::HandleCommand (this=0x7fff5fbfd5f0, command_line=0x1050c6508 "printObj (\"$r14\")", result=@0x7fff5fbfd5f8, add_to_history=true) at /Source/lldb/source/API/SBCommandInterpreter.cpp:97 #20 0x0000000100004ac3 in Driver::HandleIOEvent (this=0x7fff5fbfec40, event=@0x7fff5fbfda50) at /Source/lldb/tools/driver/Driver.cpp:933 #21 0x0000000100006790 in Driver::MainLoop (this=0x7fff5fbfec40) at /Source/lldb/tools/driver/Driver.cpp:1341 #22 0x00000001000070aa in main (argc=2, argv=0x7fff5fbfed70, envp=0x7fff5fbfed88) at /Source/lldb/tools/driver/Driver.cpp:1460 (gdb) print type $4 = { m_opaque_sp = { ptr_ = 0x7fff5fbfbae8, cntrl_ = 0x7fff5fbfbaf8 } } (gdb) print real_type $5 = { m_opaque_sp = { ptr_ = 0x0, cntrl_ = 0x0 } } -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From johnny.chen at apple.com Wed Dec 14 19:55:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Dec 2011 01:55:36 -0000 Subject: [Lldb-commits] [lldb] r146629 - in /lldb/trunk: source/API/SBValue.cpp test/python_api/sbdata/TestSBData.py Message-ID: <20111215015536.876F62A6C12C@llvm.org> Author: johnny Date: Wed Dec 14 19:55:36 2011 New Revision: 146629 URL: http://llvm.org/viewvc/llvm-project?rev=146629&view=rev Log: http://llvm.org/bugs/show_bug.cgi?id=11579 lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type before using it. Add a test case. Modified: lldb/trunk/source/API/SBValue.cpp lldb/trunk/test/python_api/sbdata/TestSBData.py Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=146629&r1=146628&r2=146629&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Wed Dec 14 19:55:36 2011 @@ -404,9 +404,8 @@ SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType type) { lldb::SBValue result; - if (m_opaque_sp) + if (m_opaque_sp && type.IsValid() && type.GetPointerType().IsValid()) { - SBType real_type(type.GetPointerType()); lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t))); Modified: lldb/trunk/test/python_api/sbdata/TestSBData.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/sbdata/TestSBData.py?rev=146629&r1=146628&r2=146629&view=diff ============================================================================== --- lldb/trunk/test/python_api/sbdata/TestSBData.py (original) +++ lldb/trunk/test/python_api/sbdata/TestSBData.py Wed Dec 14 19:55:36 2011 @@ -112,6 +112,11 @@ foobar_addr = star_foobar.GetLoadAddress() foobar_addr += 12 + # http://llvm.org/bugs/show_bug.cgi?id=11579 + # lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds + # This should not crash LLDB. + nothing = foobar.CreateValueFromAddress("nothing", foobar_addr, star_foobar.GetType().GetBasicType(lldb.eBasicTypeInvalid)) + new_foobar = foobar.CreateValueFromAddress("f00", foobar_addr, star_foobar.GetType()) if self.TraceOn(): From bugzilla-daemon at llvm.org Wed Dec 14 19:56:50 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 15 Dec 2011 01:56:50 +0000 Subject: [Lldb-commits] [Bug 11579] lldb::SBValue::CreateValueFromAddress does not verify SBType::GetPointerType succeeds In-Reply-To: References: Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11579 johnny.chen at apple.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |johnny.chen at apple.com Resolution| |FIXED --- Comment #1 from johnny.chen at apple.com 2011-12-14 19:56:50 CST --- Checked in http://llvm.org/viewvc/llvm-project?rev=146629&view=rev, thanks. SBValue::CreateValueFromAddress() should check the validity of type and its derived pointer type before using it. Add a test case. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From gclayton at apple.com Wed Dec 14 21:14:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 15 Dec 2011 03:14:23 -0000 Subject: [Lldb-commits] [lldb] r146636 - in /lldb/trunk: include/lldb/API/SBProcess.h include/lldb/Target/Process.h scripts/Python/interface/SBProcess.i source/API/SBProcess.cpp source/Host/macosx/Host.mm source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp source/Target/Process.cpp Message-ID: <20111215031423.85EA92A6C12C@llvm.org> Author: gclayton Date: Wed Dec 14 21:14:23 2011 New Revision: 146636 URL: http://llvm.org/viewvc/llvm-project?rev=146636&view=rev Log: Expose new read memory fucntion through python in SBProcess: size_t SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); uint64_t SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); lldb::addr_t SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &error); These ReadCStringFromMemory() has some SWIG type magic that makes it return the python string directly and the "buf" is not needed: error = SBError() max_cstr_len = 256 cstr = lldb.process.ReadCStringFromMemory (0x1000, max_cstr_len, error) if error.Success(): .... The other two functions behave as expteced. This will make it easier to get integer values from the inferior process that are correctly byte swapped. Also for pointers, the correct pointer byte size will be used. Also cleaned up a few printf style warnings for the 32 bit lldb build on darwin. Modified: lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/scripts/Python/interface/SBProcess.i lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/Host/macosx/Host.mm 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/AppleObjCRuntimeV2.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Wed Dec 14 21:14:23 2011 @@ -155,6 +155,15 @@ size_t WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); + size_t + ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + uint64_t + ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); + + lldb::addr_t + ReadPointerFromMemory (addr_t addr, lldb::SBError &error); + // Events static lldb::StateType GetStateFromEvent (const lldb::SBEvent &event); Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Dec 14 21:14:23 2011 @@ -2373,7 +2373,8 @@ size_t ReadCStringFromMemory (lldb::addr_t vm_addr, char *cstr, - size_t cstr_max_len); + size_t cstr_max_len, + Error &error); size_t ReadMemoryFromInferior (lldb::addr_t vm_addr, Modified: lldb/trunk/scripts/Python/interface/SBProcess.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBProcess.i (original) +++ lldb/trunk/scripts/Python/interface/SBProcess.i Wed Dec 14 21:14:23 2011 @@ -208,6 +208,57 @@ size_t WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); + %feature("autodoc", " + Reads a NULL terminated C string from the current process's address space. + It returns a python string of the exact length, or truncates the string if + the maximum character limit is reached. Example: + + # Read a C string of at most 256 bytes from address '0x1000' + error = lldb.SBError() + cstring = process.ReadMemory(0x1000, 256, error) + if error.Success(): + print 'cstring: ', cstring + else + print 'error: ', error + ") ReadCStringFromMemory; + + size_t + ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + %feature("autodoc", " + Reads an unsigned integer from memory given a byte size and an address. + Returns the unsigned integer that was read. Example: + + # Read a 4 byte unsigned integer from address 0x1000 + error = lldb.SBError() + uint = ReadUnsignedFromMemory(0x1000, 4, error) + if error.Success(): + print 'integer: %u' % uint + else + print 'error: ', error + + ") ReadUnsignedFromMemory; + + uint64_t + ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); + + %feature("autodoc", " + Reads a pointer from memory from an address and returns the value. Example: + + # Read a pointer from address 0x1000 + error = lldb.SBError() + ptr = ReadPointerFromMemory(0x1000, error) + if error.Success(): + print 'pointer: 0x%x' % ptr + else + print 'error: ', error + + ") ReadPointerFromMemory; + + lldb::addr_t + ReadPointerFromMemory (addr_t addr, lldb::SBError &error); + + // Events static lldb::StateType GetStateFromEvent (const lldb::SBEvent &event); Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Dec 14 21:14:23 2011 @@ -766,6 +766,60 @@ } size_t +SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) +{ + size_t bytes_read = 0; + if (m_opaque_sp) + { + Error error; + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + bytes_read = m_opaque_sp->ReadCStringFromMemory (addr, (char *)buf, size, error); + sb_error.SetError (error); + } + else + { + sb_error.SetErrorString ("SBProcess is invalid"); + } + return bytes_read; +} + +uint64_t +SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) +{ + if (m_opaque_sp) + { + Error error; + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + uint64_t value = m_opaque_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, error); + sb_error.SetError (error); + return value; + } + else + { + sb_error.SetErrorString ("SBProcess is invalid"); + } + return 0; +} + +lldb::addr_t +SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error) +{ + lldb::addr_t ptr = LLDB_INVALID_ADDRESS; + if (m_opaque_sp) + { + Error error; + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + ptr = m_opaque_sp->ReadPointerFromMemory (addr, error); + sb_error.SetError (error); + } + else + { + sb_error.SetErrorString ("SBProcess is invalid"); + } + return ptr; +} + +size_t SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error) { size_t bytes_written = 0; Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Wed Dec 14 21:14:23 2011 @@ -657,7 +657,7 @@ if (log) log->Printf("Sending source file: \"%s\" and line: %d to external editor.\n", file_path, line_no); - OSStatus error; + long error; BabelAESelInfo file_and_line_info = { 0, // reserved0 @@ -678,7 +678,7 @@ if (error != noErr) { if (log) - log->Printf("Error creating AEDesc: %d.\n", error); + log->Printf("Error creating AEDesc: %ld.\n", error); return false; } @@ -713,7 +713,7 @@ if (error != noErr) { if (log) - log->Printf("Could not find External Editor application, error: %d.\n", error); + log->Printf("Could not find External Editor application, error: %ld.\n", error); return false; } @@ -735,7 +735,7 @@ if (error != noErr) { if (log) - log->Printf("LSOpenURLsWithRole failed, error: %d.\n", error); + log->Printf("LSOpenURLsWithRole failed, error: %ld.\n", error); return false; } @@ -750,7 +750,7 @@ if (error != noErr) { if (log) - log->Printf("GetProcessInformation failed, error: %d.\n", error); + log->Printf("GetProcessInformation failed, error: %ld.\n", error); using_xcode = false; } else @@ -807,7 +807,7 @@ if (error != noErr) { if (log) - log->Printf("Failed to create AEDesc for Xcode AppleEvent: %d.\n", error); + log->Printf("Failed to create AEDesc for Xcode AppleEvent: %ld.\n", error); return false; } @@ -825,7 +825,7 @@ if (error != noErr) { if (log) - log->Printf("Sending AppleEvent to Xcode failed, error: %d.\n", error); + log->Printf("Sending AppleEvent to Xcode failed, error: %ld.\n", error); return false; } } 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=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Dec 14 21:14:23 2011 @@ -918,10 +918,13 @@ image_infos[i].mod_date = info_data_ref.GetPointer(&info_data_offset); char raw_path[PATH_MAX]; - m_process->ReadCStringFromMemory (path_addr, raw_path, sizeof(raw_path)); + m_process->ReadCStringFromMemory (path_addr, raw_path, sizeof(raw_path), error); // don't resolve the path - const bool resolve_path = false; - image_infos[i].file_spec.SetFile(raw_path, resolve_path); + if (error.Success()) + { + const bool resolve_path = false; + image_infos[i].file_spec.SetFile(raw_path, resolve_path); + } } return true; } 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=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Wed Dec 14 21:14:23 2011 @@ -145,7 +145,8 @@ size_t curr_len = full_buffer_len; while (curr_len == full_buffer_len) { - curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); + Error error; + curr_len = process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf), error); strm.Write (buf, curr_len); cstr_len += curr_len; } 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=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Dec 14 21:14:23 2011 @@ -220,10 +220,11 @@ } addr_t result_ptr = void_ptr_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - size_t chars_read = m_process->ReadCStringFromMemory (result_ptr, name_dst, max_name_len); + Error error; + size_t chars_read = m_process->ReadCStringFromMemory (result_ptr, name_dst, max_name_len, error); // If we exhausted our buffer before finding a NULL we're probably off in the weeds somewhere... - if (chars_read == max_name_len) + if (error.Fail() || chars_read == max_name_len) return false; else return true; @@ -686,8 +687,8 @@ return g_unknown; //printf("name_pointer: %llx\n", name_pointer); - char* cstr = new char[512]; - if (m_process->ReadCStringFromMemory(name_pointer, cstr, 512) > 0) + char cstr[512]; + if (m_process->ReadCStringFromMemory(name_pointer, cstr, sizeof(cstr), error) > 0) { if (::strstr(cstr, "NSKVONotify") == cstr) { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=146636&r1=146635&r2=146636&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Dec 14 21:14:23 2011 @@ -1856,11 +1856,12 @@ size_t -Process::ReadCStringFromMemory (addr_t addr, char *dst, size_t dst_max_len) +Process::ReadCStringFromMemory (addr_t addr, char *dst, size_t dst_max_len, Error &result_error) { size_t total_cstr_len = 0; if (dst && dst_max_len) { + result_error.Clear(); // NULL out everything just to be safe memset (dst, 0, dst_max_len); Error error; @@ -1877,6 +1878,7 @@ if (bytes_read == 0) { + result_error = error; dst[total_cstr_len] = '\0'; break; } @@ -1892,6 +1894,13 @@ bytes_left -= bytes_read; } } + else + { + if (dst == NULL) + result_error.SetErrorString("invalid arguments"); + else + result_error.Clear(); + } return total_cstr_len; } From gclayton at apple.com Wed Dec 14 22:38:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 15 Dec 2011 04:38:41 -0000 Subject: [Lldb-commits] [lldb] r146640 - in /lldb/trunk: include/lldb/API/SBDebugger.h scripts/Python/interface/SBDebugger.i source/API/SBDebugger.cpp Message-ID: <20111215043841.7B9852A6C12C@llvm.org> Author: gclayton Date: Wed Dec 14 22:38:41 2011 New Revision: 146640 URL: http://llvm.org/viewvc/llvm-project?rev=146640&view=rev Log: Added a static memory pressure function in SBDebugger: void SBDebugger::MemoryPressureDetected () This can be called by applications that detect memory pressure to cause LLDB to release cached information. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/scripts/Python/interface/SBDebugger.i lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=146640&r1=146639&r2=146640&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Wed Dec 14 22:38:41 2011 @@ -35,6 +35,9 @@ static void Destroy (lldb::SBDebugger &debugger); + static void + MemoryPressureDetected (); + SBDebugger(); SBDebugger(const lldb::SBDebugger &rhs); Modified: lldb/trunk/scripts/Python/interface/SBDebugger.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBDebugger.i?rev=146640&r1=146639&r2=146640&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBDebugger.i (original) +++ lldb/trunk/scripts/Python/interface/SBDebugger.i Wed Dec 14 22:38:41 2011 @@ -122,6 +122,9 @@ static void Destroy (lldb::SBDebugger &debugger); + static void + MemoryPressureDetected(); + SBDebugger(); SBDebugger(const lldb::SBDebugger &rhs); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=146640&r1=146639&r2=146640&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Dec 14 22:38:41 2011 @@ -124,6 +124,12 @@ debugger.m_opaque_sp.reset(); } +void +SBDebugger::MemoryPressureDetected () +{ + ModuleList::RemoveOrphanSharedModules(); +} + SBDebugger::SBDebugger () : m_opaque_sp () { From gclayton at apple.com Wed Dec 14 23:23:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 15 Dec 2011 05:23:23 -0000 Subject: [Lldb-commits] [lldb] r146643 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111215052323.A635F2A6C12C@llvm.org> Author: gclayton Date: Wed Dec 14 23:23:23 2011 New Revision: 146643 URL: http://llvm.org/viewvc/llvm-project?rev=146643&view=rev Log: Bumped Xcode project version to lldb-95 and debugserver-155. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=146643&r1=146642&r2=146643&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Dec 14 23:23:23 2011 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 94; + DYLIB_CURRENT_VERSION = 95; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 94; + DYLIB_CURRENT_VERSION = 95; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 94; - DYLIB_CURRENT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; + DYLIB_CURRENT_VERSION = 95; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 94; - DYLIB_CURRENT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; + DYLIB_CURRENT_VERSION = 95; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 94; - DYLIB_CURRENT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; + DYLIB_CURRENT_VERSION = 95; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 94; + DYLIB_CURRENT_VERSION = 95; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=146643&r1=146642&r2=146643&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Dec 14 23:23:23 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 94 + 95 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=146643&r1=146642&r2=146643&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed Dec 14 23:23:23 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 154; + CURRENT_PROJECT_VERSION = 155; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Wed Dec 14 23:35:21 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 15 Dec 2011 05:35:21 -0000 Subject: [Lldb-commits] [lldb] r146645 - /lldb/tags/lldb-95/ Message-ID: <20111215053521.AA2B42A6C12C@llvm.org> Author: gclayton Date: Wed Dec 14 23:35:21 2011 New Revision: 146645 URL: http://llvm.org/viewvc/llvm-project?rev=146645&view=rev Log: lldb-95 Added: lldb/tags/lldb-95/ - copied from r146644, lldb/trunk/ From bugzilla-daemon at llvm.org Thu Dec 15 13:51:50 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Thu, 15 Dec 2011 19:51:50 +0000 Subject: [Lldb-commits] [Bug 11588] New: valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11588 Bug #: 11588 Summary: valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider Product: lldb Version: unspecified Platform: Macintosh OS/Version: All Status: NEW Severity: normal Priority: P Component: All Bugs AssignedTo: lldb-commits at cs.uiuc.edu ReportedBy: nathanhowell at hotmail.com Classification: Unclassified Getting the address of a SBValue in a SyntheticChildrenProvider is required in situations where a member field specifies an object relative offset (common even in C/C++) or where the lower pointer bits are used to store object information or garbage collection state. Since this seems to work in the expression evaluator, it looks as though the address is not preserved for synthetic formatters. # there is an object in r14 uses the lower two bits for pointer tagging (lldb) print ((StgClosure_*)$r14) (StgClosure_ *) $0 = 0x0000000100404151 # dereferencing it directly will give invalid results (lldb) print *((StgClosure_*)$r14) (StgClosure_) $1 = { (StgHeader) header = { (const StgInfoTable *) info = 0xf100000001000011 } (StgClosure_ *[1]) payload = { (StgClosure_ *) [0] = 0x0100000001000f28 } } # because the low bits need to be cleared before printing. the referenced closure # in the payload field also has the low bit set and it will need to be cleared as well (lldb) print *((StgClosure_*)($r14-1)) (StgClosure_) $3 = { (StgHeader) header = { (const StgInfoTable *) info = 0x0000000100001138 } (StgClosure_ *[1]) payload = { (StgClosure_ *) [0] = 0x00000001000f28f1 } } # so i thought the AddressOf operator would give me the original value back in a SyntheticProvider # like it does in the lldb expression evaluator (lldb) print &*((StgClosure_*)($r14-1)) (StgClosure_ *) $4 = 0x0000000100404150 # but AddressOf fails in the provider (lldb) type synthetic add StgClosure_ --python-class synth.SyntheticClosureProvider (lldb) print *((StgClosure_*)($r14-1)) AddressOf: No value GetAddress: No value GetLoadAddress: 18446744073709551615 (StgClosure_) $7 = {} The referenced python code: class SyntheticClosureProvider(object): def __init__(self, valobj, dict): self.valobj = valobj addrOf = valobj.AddressOf() print 'AddressOf: ' + str(addrOf) addr = valobj.GetAddress() print 'GetAddress: ' + str(addr) load_address = valobj.GetLoadAddress() print 'GetLoadAddress: ' + str(load_address) -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From johnny.chen at apple.com Thu Dec 15 13:56:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Dec 2011 19:56:28 -0000 Subject: [Lldb-commits] [lldb] r146676 - in /lldb/trunk/test: api/disassemble-raw-data/ python_api/disassemble-raw-data/ python_api/disassemble-raw-data/TestDisassembleRawData.py Message-ID: <20111215195628.DDA972A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 13:56:28 2011 New Revision: 146676 URL: http://llvm.org/viewvc/llvm-project?rev=146676&view=rev Log: Move disassemble-raw-data dir to reside under test/python_api where they belong. Add debug statements for the raw bytes and the disassembled instruction. Added: lldb/trunk/test/python_api/disassemble-raw-data/ - copied from r146670, lldb/trunk/test/api/disassemble-raw-data/ Removed: lldb/trunk/test/api/disassemble-raw-data/ Modified: lldb/trunk/test/python_api/disassemble-raw-data/TestDisassembleRawData.py Modified: lldb/trunk/test/python_api/disassemble-raw-data/TestDisassembleRawData.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/disassemble-raw-data/TestDisassembleRawData.py?rev=146676&r1=146670&r2=146676&view=diff ============================================================================== --- lldb/trunk/test/python_api/disassemble-raw-data/TestDisassembleRawData.py (original) +++ lldb/trunk/test/python_api/disassemble-raw-data/TestDisassembleRawData.py Thu Dec 15 13:56:28 2011 @@ -10,7 +10,7 @@ class DisassembleRawDataTestCase(TestBase): - mydir = os.path.join("api", "disassemble-raw-data") + mydir = os.path.join("python_api", "disassemble-raw-data") @python_api_test def test_disassemble_raw_data(self): @@ -32,6 +32,11 @@ self.assertTrue (inst.GetMnemonic(target) == "movq") self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp") + + if self.TraceOn(): + print + print "Raw bytes: ", [hex(x) for x in raw_bytes] + print "Disassembled:", inst if __name__ == '__main__': import atexit From johnny.chen at apple.com Thu Dec 15 16:35:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Dec 2011 22:35:00 -0000 Subject: [Lldb-commits] [lldb] r146695 - in /lldb/trunk: scripts/Python/interface/SBProcess.i test/python_api/default-constructor/sb_process.py Message-ID: <20111215223501.209FA2A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 16:34:59 2011 New Revision: 146695 URL: http://llvm.org/viewvc/llvm-project?rev=146695&view=rev Log: Add fuzz calls for newly added SBProcess methods. Fix a typo in the audodoc of SBProcess.ReadCStringFromMemory(). Modified: lldb/trunk/scripts/Python/interface/SBProcess.i lldb/trunk/test/python_api/default-constructor/sb_process.py Modified: lldb/trunk/scripts/Python/interface/SBProcess.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=146695&r1=146694&r2=146695&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBProcess.i (original) +++ lldb/trunk/scripts/Python/interface/SBProcess.i Thu Dec 15 16:34:59 2011 @@ -215,7 +215,7 @@ # Read a C string of at most 256 bytes from address '0x1000' error = lldb.SBError() - cstring = process.ReadMemory(0x1000, 256, error) + cstring = process.ReadCStringFromMemory(0x1000, 256, error) if error.Success(): print 'cstring: ', cstring else Modified: lldb/trunk/test/python_api/default-constructor/sb_process.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_process.py?rev=146695&r1=146694&r2=146695&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_process.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_process.py Thu Dec 15 16:34:59 2011 @@ -36,6 +36,9 @@ obj.Signal(7) obj.ReadMemory(0x0000ffff, 10, error) obj.WriteMemory(0x0000ffff, "hi data", error) + obj.ReadCStringFromMemory(0x0, 128, error) + obj.ReadUnsignedFromMemory(0xff, 4, error) + obj.ReadPointerFromMemory(0xff, error) obj.GetBroadcaster() obj.GetDescription(lldb.SBStream()) obj.LoadImage(lldb.SBFileSpec(), error) From johnny.chen at apple.com Thu Dec 15 16:45:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Dec 2011 22:45:30 -0000 Subject: [Lldb-commits] [lldb] r146696 - /lldb/trunk/test/python_api/default-constructor/sb_target.py Message-ID: <20111215224530.ACF592A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 16:45:30 2011 New Revision: 146696 URL: http://llvm.org/viewvc/llvm-project?rev=146696&view=rev Log: Add fuzz call for newly added method SBTarget.GetInstructions(). Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=146696&r1=146695&r2=146696&view=diff ============================================================================== --- lldb/trunk/test/python_api/default-constructor/sb_target.py (original) +++ lldb/trunk/test/python_api/default-constructor/sb_target.py Thu Dec 15 16:45:30 2011 @@ -25,6 +25,7 @@ obj.FindFirstType("dont_care") obj.FindTypes("dont_care") obj.FindFirstType(None) + obj.GetInstructions(lldb.SBAddress(), bytearray()) obj.GetSourceManager() obj.FindGlobalVariables("my_global_var", 1) address = obj.ResolveLoadAddress(0xffff) From johnny.chen at apple.com Thu Dec 15 17:30:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 15 Dec 2011 23:30:06 -0000 Subject: [Lldb-commits] [lldb] r146704 - in /lldb/trunk/test/python_api/process: TestProcessAPI.py main.cpp Message-ID: <20111215233006.3AD8F2A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 17:30:05 2011 New Revision: 146704 URL: http://llvm.org/viewvc/llvm-project?rev=146704&view=rev Log: Add test scenario for newly added SBProcess APIs: ReadCStringFromMemory() and ReadUnsignedFromMemory(). Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py lldb/trunk/test/python_api/process/main.cpp Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=146704&r1=146703&r2=146704&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Thu Dec 15 17:30:05 2011 @@ -105,6 +105,51 @@ exe=False, startstr = 'x') + # Get the SBValue for the global variable 'my_cstring'. + val = frame.FindValue("my_cstring", lldb.eValueTypeVariableGlobal) + self.DebugSBValue(val) + + # If the variable does not have a load address, there's no sense continuing. + if not val.GetLocation().startswith("0x"): + return + + # OK, let's get the hex location of the variable. + location = int(val.GetLocation(), 16) + + # Due to the typemap magic (see lldb.swig), we pass in 256 to read at most 256 bytes + # from the address, and expect to get a Python string as the result object! + cstring = process.ReadCStringFromMemory(location, 256, error) + if not error.Success(): + self.fail("SBProcess.ReadCStringFromMemory() failed") + if self.TraceOn(): + print "cstring read is:", cstring + + self.expect(cstring, "Result from SBProcess.ReadCStringFromMemory() matches our expected output", + exe=False, + startstr = 'lldb.SBProcess.ReadCStringFromMemory() works!') + + # Get the SBValue for the global variable 'my_uint32'. + val = frame.FindValue("my_uint32", lldb.eValueTypeVariableGlobal) + self.DebugSBValue(val) + + # If the variable does not have a load address, there's no sense continuing. + if not val.GetLocation().startswith("0x"): + return + + # OK, let's get the hex location of the variable. + location = int(val.GetLocation(), 16) + + # Due to the typemap magic (see lldb.swig), we pass in 4 to read at 4 bytes + # from the address, and expect to get an int as the result! + my_uint32 = process.ReadUnsignedFromMemory(location, 4, error) + if not error.Success(): + self.fail("SBProcess.ReadCStringFromMemory() failed") + if self.TraceOn(): + print "uint32 read is:", my_uint32 + + if my_uint32 != 12345: + self.fail("Result from SBProcess.ReadUnsignedFromMemory() does not match our expected output") + def write_memory(self): """Test Python SBProcess.WriteMemory() API.""" exe = os.path.join(os.getcwd(), "a.out") Modified: lldb/trunk/test/python_api/process/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/main.cpp?rev=146704&r1=146703&r2=146704&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/main.cpp (original) +++ lldb/trunk/test/python_api/process/main.cpp Thu Dec 15 17:30:05 2011 @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// #include +#include // This simple program is to test the lldb Python API related to process. char my_char = 'u'; +char my_cstring[] = "lldb.SBProcess.ReadCStringFromMemory() works!"; +uint32_t my_uint32 = 12345; int my_int = 0; int main (int argc, char const *argv[]) From jingham at apple.com Thu Dec 15 18:05:58 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 16 Dec 2011 00:05:58 -0000 Subject: [Lldb-commits] [lldb] r146712 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20111216000558.E31DA2A6C12C@llvm.org> Author: jingham Date: Thu Dec 15 18:05:58 2011 New Revision: 146712 URL: http://llvm.org/viewvc/llvm-project?rev=146712&view=rev Log: Fix a bug where when debugging with .o files, we end up with two symbols for each real OBJC_CLASS_$_whatever, one of which is correctly classified as an ObjCClass symbol, and the other is just a data symbol. This was messing up the ObjC dynamic type detection. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 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=146712&r1=146711&r2=146712&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Dec 15 18:05:58 2011 @@ -876,10 +876,26 @@ case StabGlobalSymbol: // N_GSYM -- global symbol: name,,NO_SECT,type,0 // Sometimes the N_GSYM value contains the address. - sym[sym_idx].SetExternal(true); - if (nlist.n_value != 0) - symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); - type = eSymbolTypeData; + + // FIXME: In the .o files, we have a GSYM and a debug symbol for all the ObjC data. They + // have the same address, but we want to ensure that we always find only the real symbol, + // 'cause we don't currently correctly attribute the GSYM one to the ObjCClass/Ivar/MetaClass + // symbol type. This is a temporary hack to make sure the ObjectiveC symbols get treated + // correctly. To do this right, we should coalesce all the GSYM & global symbols that have the + // same address. + + if (symbol_name && symbol_name[0] == '_' && symbol_name[1] == 'O' + && (strncmp (symbol_name, "_OBJC_IVAR_$_", strlen ("_OBJC_IVAR_$_")) == 0 + || strncmp (symbol_name, "_OBJC_CLASS_$_", strlen ("_OBJC_CLASS_$_")) == 0 + || strncmp (symbol_name, "_OBJC_METACLASS_$_", strlen ("_OBJC_METACLASS_$_")) == 0)) + add_nlist = false; + else + { + sym[sym_idx].SetExternal(true); + if (nlist.n_value != 0) + symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); + type = eSymbolTypeData; + } break; case StabFunctionName: From johnny.chen at apple.com Thu Dec 15 18:25:30 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 16 Dec 2011 00:25:30 -0000 Subject: [Lldb-commits] [lldb] r146716 - in /lldb/trunk/test/python_api/process: TestProcessAPI.py main.cpp Message-ID: <20111216002530.7A0962A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 18:25:30 2011 New Revision: 146716 URL: http://llvm.org/viewvc/llvm-project?rev=146716&view=rev Log: Add a test sequence of SBProcess.ReadCStringFromMemory() with (char *)my_char_ptr as the address to read from. char *my_char_ptr = (char *)"Does it work?"; Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py lldb/trunk/test/python_api/process/main.cpp Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=146716&r1=146715&r2=146716&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Thu Dec 15 18:25:30 2011 @@ -105,6 +105,19 @@ exe=False, startstr = 'x') + # Read (char *)my_char_ptr. + val = frame.FindValue("my_char_ptr", lldb.eValueTypeVariableGlobal) + self.DebugSBValue(val) + cstring = process.ReadCStringFromMemory(val.GetValueAsUnsigned(), 256, error) + if not error.Success(): + self.fail("SBProcess.ReadCStringFromMemory() failed") + if self.TraceOn(): + print "cstring read is:", cstring + + self.expect(cstring, "Result from SBProcess.ReadCStringFromMemory() matches our expected output", + exe=False, + startstr = 'Does it work?') + # Get the SBValue for the global variable 'my_cstring'. val = frame.FindValue("my_cstring", lldb.eValueTypeVariableGlobal) self.DebugSBValue(val) Modified: lldb/trunk/test/python_api/process/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/main.cpp?rev=146716&r1=146715&r2=146716&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/main.cpp (original) +++ lldb/trunk/test/python_api/process/main.cpp Thu Dec 15 18:25:30 2011 @@ -13,6 +13,7 @@ char my_char = 'u'; char my_cstring[] = "lldb.SBProcess.ReadCStringFromMemory() works!"; +char *my_char_ptr = (char *)"Does it work?"; uint32_t my_uint32 = 12345; int my_int = 0; From jingham at apple.com Thu Dec 15 18:46:12 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 16 Dec 2011 00:46:12 -0000 Subject: [Lldb-commits] [lldb] r146717 - in /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime: AppleObjCRuntimeV1.cpp AppleObjCRuntimeV2.cpp Message-ID: <20111216004612.E58A52A6C12C@llvm.org> Author: jingham Date: Thu Dec 15 18:46:12 2011 New Revision: 146717 URL: http://llvm.org/viewvc/llvm-project?rev=146717&view=rev Log: Remove unnecessary #include. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp 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=146717&r1=146716&r2=146717&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu Dec 15 18:46:12 2011 @@ -27,7 +27,6 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" 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=146717&r1=146716&r2=146717&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Dec 15 18:46:12 2011 @@ -33,7 +33,6 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -299,15 +298,13 @@ { if (sc.symbol->GetType() == eSymbolTypeObjCClass) class_name = sc.symbol->GetName().GetCString(); - else - return false; } } } } char class_buffer[1024]; - if (class_name == NULL && use_dynamic != eDynamicDontRunTarget) + if (class_name == NULL && use_dynamic == eDynamicCanRunTarget) { // If the class address didn't point into the binary, or // it points into the right section but there wasn't a symbol From johnny.chen at apple.com Thu Dec 15 19:56:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 16 Dec 2011 01:56:27 -0000 Subject: [Lldb-commits] [lldb] r146719 - /lldb/trunk/test/python_api/process/TestProcessAPI.py Message-ID: <20111216015627.80E1F2A6C12C@llvm.org> Author: johnny Date: Thu Dec 15 19:56:27 2011 New Revision: 146719 URL: http://llvm.org/viewvc/llvm-project?rev=146719&view=rev Log: Simplify the setup leading to the testing of ReadMemory(), ReadCStringFromMemory(), and ReadUnsignedFromMemory(). Instead of getting the location of the variable and converting the hex string to an int, just use val.AddressOf().GetValueAsUnsigned() to compute the address of the memory region to read from. Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=146719&r1=146718&r2=146719&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Thu Dec 15 19:56:27 2011 @@ -85,17 +85,11 @@ val = frame.FindValue("my_char", lldb.eValueTypeVariableGlobal) self.DebugSBValue(val) - # If the variable does not have a load address, there's no sense continuing. - if not val.GetLocation().startswith("0x"): - return - - # OK, let's get the hex location of the variable. - location = int(val.GetLocation(), 16) - # Due to the typemap magic (see lldb.swig), we pass in 1 to ReadMemory and # expect to get a Python string as the result object! error = lldb.SBError() - content = process.ReadMemory(location, 1, error) + self.assertFalse(val.TypeIsPointerType()) + content = process.ReadMemory(val.AddressOf().GetValueAsUnsigned(), 1, error) if not error.Success(): self.fail("SBProcess.ReadMemory() failed") if self.TraceOn(): @@ -122,16 +116,10 @@ val = frame.FindValue("my_cstring", lldb.eValueTypeVariableGlobal) self.DebugSBValue(val) - # If the variable does not have a load address, there's no sense continuing. - if not val.GetLocation().startswith("0x"): - return - - # OK, let's get the hex location of the variable. - location = int(val.GetLocation(), 16) - # Due to the typemap magic (see lldb.swig), we pass in 256 to read at most 256 bytes # from the address, and expect to get a Python string as the result object! - cstring = process.ReadCStringFromMemory(location, 256, error) + self.assertFalse(val.TypeIsPointerType()) + cstring = process.ReadCStringFromMemory(val.AddressOf().GetValueAsUnsigned(), 256, error) if not error.Success(): self.fail("SBProcess.ReadCStringFromMemory() failed") if self.TraceOn(): @@ -145,16 +133,10 @@ val = frame.FindValue("my_uint32", lldb.eValueTypeVariableGlobal) self.DebugSBValue(val) - # If the variable does not have a load address, there's no sense continuing. - if not val.GetLocation().startswith("0x"): - return - - # OK, let's get the hex location of the variable. - location = int(val.GetLocation(), 16) - - # Due to the typemap magic (see lldb.swig), we pass in 4 to read at 4 bytes + # Due to the typemap magic (see lldb.swig), we pass in 4 to read 4 bytes # from the address, and expect to get an int as the result! - my_uint32 = process.ReadUnsignedFromMemory(location, 4, error) + self.assertFalse(val.TypeIsPointerType()) + my_uint32 = process.ReadUnsignedFromMemory(val.AddressOf().GetValueAsUnsigned(), 4, error) if not error.Success(): self.fail("SBProcess.ReadCStringFromMemory() failed") if self.TraceOn(): From jmolenda at apple.com Thu Dec 15 22:30:32 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 16 Dec 2011 04:30:32 -0000 Subject: [Lldb-commits] [lldb] r146723 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp RegisterContextLLDB.h Message-ID: <20111216043032.1EF8F2A6C12C@llvm.org> Author: jmolenda Date: Thu Dec 15 22:30:31 2011 New Revision: 146723 URL: http://llvm.org/viewvc/llvm-project?rev=146723&view=rev Log: When we're unwinding out of frame 0 and we end up with a bogus frame 1 -- an address pointing off into non-executable memory -- don't abort the unwind. We'll use the ABI's default UnwindPlan to try to get out of frame 1 and on many platforms with a standard frame chain stack layout we can get back on track and get a valid frame 2. This preserves the lldb behavior to-date; the change last week to require the memory region to be executable broke it. I'd like to mark this frame specially when displayed to the user; I tried to override the places where the frame's pc value is returned to change it to a sentinel value (e.g. LLDB_INVALID_ADDRESS) but couldn't get that to work cleanly so I backed that part out for now. When this happens we'll often miss one of the user's actual frames, the one that's of most interest to the user, so I'd like to make this visually distinctive. Note that a frame in non-executable memory region is only allowed for frame 1. After that we should be solid on the unwind and any pc address in non-executable memory indicates a failure and we should stop unwinding. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=146723&r1=146722&r2=146723&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Dec 15 22:30:31 2011 @@ -203,6 +203,7 @@ RegisterContextLLDB::InitializeNonZerothFrame() { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + if (IsFrameZero ()) { m_frame_type = eNotAValidFrame; @@ -231,7 +232,8 @@ m_frame_type = eNotAValidFrame; return; } - // A pc value of 0 up on the stack indicates we've hit the end of the stack + + // A pc of 0x0 means it's the end of the stack crawl if (pc == 0) { m_frame_type = eNotAValidFrame; @@ -239,13 +241,29 @@ } // Test the pc value to see if we know it's in an unmapped/non-executable region of memory. - // If so, our unwind has made a mistake somewhere and we should stop. uint32_t permissions; if (m_thread.GetProcess().GetLoadAddressPermissions(pc, permissions) && (permissions & ePermissionsExecutable) == 0) { - m_frame_type = eNotAValidFrame; - return; + // If this is the second frame off the stack, we may have unwound the first frame + // incorrectly. But using the architecture default unwind plan may get us back on + // track -- albeit possibly skipping a real frame. Give this frame a clearly-invalid + // pc and see if we can get any further. + if (GetNextFrame().get() && GetNextFrame()->IsValid() && GetNextFrame()->IsFrameZero()) + { + if (log) + { + log->Printf("%*sFrame %u had a pc of 0x%llx which is not in executable memory but on frame 1 -- allowing it once.", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, (uint64_t) pc); + } + m_frame_type = eSkipFrame; + } + else + { + // anywhere other than the second frame, a non-executable pc means we're off in the weeds -- stop now. + m_frame_type = eNotAValidFrame; + return; + } } m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc); @@ -265,7 +283,10 @@ m_fast_unwind_plan_sp.reset (); m_full_unwind_plan_sp.reset (new UnwindPlan (lldb::eRegisterKindGeneric)); abi->CreateDefaultUnwindPlan(*m_full_unwind_plan_sp); - m_frame_type = eNormalFrame; + if (m_frame_type != eSkipFrame) // don't override eSkipFrame + { + m_frame_type = eNormalFrame; + } m_all_registers_available = false; m_current_offset = -1; m_current_offset_backed_up_one = -1; @@ -283,7 +304,10 @@ log->Printf("%*sFrame %u failed to get cfa value", m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number); } - m_frame_type = eNormalFrame; + if (m_frame_type != eSkipFrame) // don't override eSkipFrame + { + m_frame_type = eNormalFrame; + } return; } m_cfa = cfa_regval + cfa_offset; @@ -408,7 +432,10 @@ else { // FIXME: Detect eDebuggerFrame here. - m_frame_type = eNormalFrame; + if (m_frame_type != eSkipFrame) // don't override eSkipFrame + { + m_frame_type = eNormalFrame; + } } // We've set m_frame_type and m_sym_ctx before this call. @@ -869,6 +896,18 @@ return m_frame_type != eNotAValidFrame; } +// A skip frame is a bogus frame on the stack -- but one where we're likely to find a real frame farther +// up the stack if we keep looking. It's always the second frame in an unwind (i.e. the first frame after +// frame zero) where unwinding can be the trickiest. Ideally we'll mark up this frame in some way so the +// user knows we're displaying bad data and we may have skipped one frame of their real program in the +// process of getting back on track. + +bool +RegisterContextLLDB::IsSkipFrame () const +{ + return m_frame_type == eSkipFrame; +} + // Answer the question: Where did THIS frame save the CALLER frame ("previous" frame)'s register value? bool @@ -1312,6 +1351,13 @@ return m_parent_unwind.GetRegisterContextForFrameNum (m_frame_number - 1); } +RegisterContextLLDB::SharedPtr +RegisterContextLLDB::GetPrevFrame () const +{ + RegisterContextLLDB::SharedPtr regctx; + return m_parent_unwind.GetRegisterContextForFrameNum (m_frame_number + 1); +} + // Retrieve the address of the start of the function of THIS frame bool @@ -1319,6 +1365,7 @@ { if (!IsValid()) return false; + if (!m_start_pc.IsValid()) { return ReadPC (start_pc); @@ -1334,6 +1381,7 @@ { if (!IsValid()) return false; + if (ReadGPRValue (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, pc)) { // A pc value of 0 or 1 is impossible in the middle of the stack -- it indicates the end of a stack walk. @@ -1356,4 +1404,3 @@ return false; } } - Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=146723&r1=146722&r2=146723&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Thu Dec 15 22:30:31 2011 @@ -88,6 +88,7 @@ eNormalFrame, eSigtrampFrame, eDebuggerFrame, // a debugger inferior function call frame; we get caller's registers from debugger + eSkipFrame, // The unwind resulted in a bogus frame but may get back on track so we don't want to give up yet eNotAValidFrame // this frame is invalid for some reason - most likely it is past the top (end) of the stack }; @@ -108,6 +109,17 @@ SharedPtr GetNextFrame () const; + SharedPtr + GetPrevFrame () const; + + // A SkipFrame occurs when the unwind out of frame 0 didn't go right -- we've got one bogus frame at frame #1. + // There is a good chance we'll get back on track if we follow the frame pointer chain (or whatever is appropriate + // on this ABI) so we allow one invalid frame to be in the stack. Ideally we'll mark this frame specially at some + // point and indicate to the user that the unwinder had a hiccup. Often when this happens we will miss a frame of + // the program's actual stack in the unwind and we want to flag that for the user somehow. + bool + IsSkipFrame () const; + // Provide a location for where THIS function saved the CALLER's register value // Or a frame "below" this one saved it, i.e. a function called by this one, preserved a register that this // function didn't modify/use. From gclayton at apple.com Fri Dec 16 12:15:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 16 Dec 2011 18:15:52 -0000 Subject: [Lldb-commits] [lldb] r146746 - in /lldb/trunk: include/lldb/Core/ArchSpec.h source/Core/ArchSpec.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20111216181552.AAD362A6C12C@llvm.org> Author: gclayton Date: Fri Dec 16 12:15:52 2011 New Revision: 146746 URL: http://llvm.org/viewvc/llvm-project?rev=146746&view=rev Log: Handle all of the "thumb" target triple architecture variants that llvm handles. Modified: lldb/trunk/include/lldb/Core/ArchSpec.h lldb/trunk/source/Core/ArchSpec.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/include/lldb/Core/ArchSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=146746&r1=146745&r2=146746&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ArchSpec.h (original) +++ lldb/trunk/include/lldb/Core/ArchSpec.h Fri Dec 16 12:15:52 2011 @@ -38,6 +38,7 @@ eCore_arm_armv4, eCore_arm_armv4t, eCore_arm_armv5, + eCore_arm_armv5e, eCore_arm_armv5t, eCore_arm_armv6, eCore_arm_armv7, @@ -45,7 +46,15 @@ eCore_arm_armv7k, eCore_arm_armv7s, eCore_arm_xscale, - eCore_thumb_generic, + eCore_thumb, + eCore_thumbv4t, + eCore_thumbv5, + eCore_thumbv5e, + eCore_thumbv6, + eCore_thumbv7, + eCore_thumbv7f, + eCore_thumbv7k, + eCore_thumbv7s, eCore_ppc_generic, eCore_ppc_ppc601, Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=146746&r1=146745&r2=146746&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Fri Dec 16 12:15:52 2011 @@ -47,6 +47,7 @@ { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4 , "armv4" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv4t , "armv4t" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5 , "armv5" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5e , "armv5e" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv5t , "armv5t" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv6 , "armv6" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7 , "armv7" }, @@ -54,7 +55,16 @@ { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7k , "armv7k" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_armv7s , "armv7s" }, { eByteOrderLittle, 4, 2, 4, llvm::Triple::arm , ArchSpec::eCore_arm_xscale , "xscale" }, - { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumb_generic , "thumb" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumb , "thumb" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv4t , "thumbv4t" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv5 , "thumbv5" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv5e , "thumbv5e" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv6 , "thumbv6" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7 , "thumbv7" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7f , "thumbv7f" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7k , "thumbv7k" }, + { eByteOrderLittle, 4, 2, 4, llvm::Triple::thumb , ArchSpec::eCore_thumbv7s , "thumbv7s" }, + { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_generic , "ppc" }, { eByteOrderLittle, 4, 4, 4, llvm::Triple::ppc , ArchSpec::eCore_ppc_ppc601 , "ppc601" }, @@ -135,14 +145,25 @@ { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , CPU_ANY }, { ArchSpec::eCore_arm_generic , llvm::MachO::CPUTypeARM , 0 }, { ArchSpec::eCore_arm_armv4 , llvm::MachO::CPUTypeARM , 5 }, + { ArchSpec::eCore_arm_armv4t , llvm::MachO::CPUTypeARM , 5 }, { ArchSpec::eCore_arm_armv6 , llvm::MachO::CPUTypeARM , 6 }, { ArchSpec::eCore_arm_armv5 , llvm::MachO::CPUTypeARM , 7 }, + { ArchSpec::eCore_arm_armv5e , llvm::MachO::CPUTypeARM , 7 }, + { ArchSpec::eCore_arm_armv5t , llvm::MachO::CPUTypeARM , 7 }, { ArchSpec::eCore_arm_xscale , llvm::MachO::CPUTypeARM , 8 }, { ArchSpec::eCore_arm_armv7 , llvm::MachO::CPUTypeARM , 9 }, { ArchSpec::eCore_arm_armv7f , llvm::MachO::CPUTypeARM , 10 }, { ArchSpec::eCore_arm_armv7k , llvm::MachO::CPUTypeARM , 12 }, { ArchSpec::eCore_arm_armv7s , llvm::MachO::CPUTypeARM , 11 }, - { ArchSpec::eCore_thumb_generic , llvm::MachO::CPUTypeARM , 0 }, + { ArchSpec::eCore_thumb , llvm::MachO::CPUTypeARM , 0 }, + { ArchSpec::eCore_thumbv4t , llvm::MachO::CPUTypeARM , 5 }, + { ArchSpec::eCore_thumbv5 , llvm::MachO::CPUTypeARM , 7 }, + { ArchSpec::eCore_thumbv5e , llvm::MachO::CPUTypeARM , 7 }, + { ArchSpec::eCore_thumbv6 , llvm::MachO::CPUTypeARM , 6 }, + { ArchSpec::eCore_thumbv7 , llvm::MachO::CPUTypeARM , 9 }, + { ArchSpec::eCore_thumbv7f , llvm::MachO::CPUTypeARM , 10 }, + { ArchSpec::eCore_thumbv7k , llvm::MachO::CPUTypeARM , 12 }, + { ArchSpec::eCore_thumbv7s , llvm::MachO::CPUTypeARM , 11 }, { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , CPU_ANY }, { ArchSpec::eCore_ppc_generic , llvm::MachO::CPUTypePowerPC , 0 }, { ArchSpec::eCore_ppc_ppc601 , llvm::MachO::CPUTypePowerPC , 1 }, 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=146746&r1=146745&r2=146746&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri Dec 16 12:15:52 2011 @@ -693,7 +693,7 @@ // addresses. if (llvm_arch == llvm::Triple::arm) { - if (EDGetDisassembler(&m_disassembler_thumb, "thumb-apple-darwin", kEDAssemblySyntaxARMUAL)) + if (EDGetDisassembler(&m_disassembler_thumb, "thumbv7-apple-darwin", kEDAssemblySyntaxARMUAL)) m_disassembler_thumb = NULL; } } From johnny.chen at apple.com Fri Dec 16 17:04:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 16 Dec 2011 23:04:52 -0000 Subject: [Lldb-commits] [lldb] r146768 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectConstResult.h include/lldb/Core/ValueObjectConstResultImpl.h source/Core/ValueObjectConstResult.cpp source/Core/ValueObjectConstResultImpl.cpp source/Expression/ClangExpressionDeclMap.cpp test/expression_command/issue_11588/ test/expression_command/issue_11588/Makefile test/expression_command/issue_11588/Test11588.py test/expression_command/issue_11588/main.cpp test/expression_command/issue_11588/s11588.py Message-ID: <20111216230452.BB7DA2A6C12C@llvm.org> Author: johnny Date: Fri Dec 16 17:04:52 2011 New Revision: 146768 URL: http://llvm.org/viewvc/llvm-project?rev=146768&view=rev Log: http://llvm.org/bugs/show_bug.cgi?id=11588 valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider Patch from Enrico Granata: The problem was that the frozen object created by the expression parser was a copy of the contents of the StgClosure, rather than a pointer to it. Thus, the expression parser was correctly computing the result of the arithmetic&cast operation along with its address, but only saving it in the live object. This meant that the frozen copy acted as an address-less variable, hence the problem. The fix attached to this email lets the expression parser store the "live address" in the frozen copy of the address when the object is built without a valid address of its own. Doing so, along with delegating ValueObjectConstResult to calculate its own address when necessary, solves the issue. I have also added a new test case to check for regressions in this area, and checked that existing test cases pass correctly. Added: lldb/trunk/test/expression_command/issue_11588/ lldb/trunk/test/expression_command/issue_11588/Makefile lldb/trunk/test/expression_command/issue_11588/Test11588.py lldb/trunk/test/expression_command/issue_11588/main.cpp lldb/trunk/test/expression_command/issue_11588/s11588.py Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h lldb/trunk/source/Core/ValueObjectConstResult.cpp lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Dec 16 17:04:52 2011 @@ -696,7 +696,7 @@ void SetName (const ConstString &name); - lldb::addr_t + virtual lldb::addr_t GetAddressOf (bool scalar_is_load_address = true, AddressType *address_type = NULL); @@ -747,6 +747,18 @@ virtual lldb::ValueObjectSP AddressOf (Error &error); + + virtual lldb::addr_t + GetLiveAddress() + { + return LLDB_INVALID_ADDRESS; + } + + virtual void + SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, + AddressType address_type = eAddressTypeLoad) + { + } virtual lldb::ValueObjectSP CastPointerType (const char *name, Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Fri Dec 16 17:04:52 2011 @@ -109,11 +109,29 @@ virtual lldb::ValueObjectSP AddressOf (Error &error); + virtual lldb::addr_t + GetAddressOf (bool scalar_is_load_address = true, + AddressType *address_type = NULL); + virtual size_t GetPointeeData (DataExtractor& data, uint32_t item_idx = 0, uint32_t item_count = 1); + virtual lldb::addr_t + GetLiveAddress() + { + return m_impl.GetLiveAddress(); + } + + virtual void + SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, + AddressType address_type = eAddressTypeLoad) + { + m_impl.SetLiveAddress(addr, + address_type); + } + protected: virtual bool UpdateValue (); Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResultImpl.h Fri Dec 16 17:04:52 2011 @@ -61,14 +61,20 @@ } void - SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS) + SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, + AddressType address_type = eAddressTypeLoad) { m_live_address = addr; + m_live_address_type = address_type; } lldb::ValueObjectSP DerefOnTarget(); + virtual lldb::addr_t + GetAddressOf (bool scalar_is_load_address = true, + AddressType *address_type = NULL); + virtual size_t GetPointeeData (DataExtractor& data, uint32_t item_idx = 0, @@ -78,6 +84,7 @@ ValueObject *m_impl_backend; lldb::addr_t m_live_address; + AddressType m_live_address_type; lldb::ValueObjectSP m_load_addr_backend; lldb::ValueObjectSP m_address_of_backend; Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Fri Dec 16 17:04:52 2011 @@ -324,6 +324,13 @@ return m_impl.AddressOf(error); } +lldb::addr_t +ValueObjectConstResult::GetAddressOf (bool scalar_is_load_address, + AddressType *address_type) +{ + return m_impl.GetAddressOf(scalar_is_load_address, address_type); +} + ValueObject * ValueObjectConstResult::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index) { Modified: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp Fri Dec 16 17:04:52 2011 @@ -40,7 +40,8 @@ ValueObjectConstResultImpl::ValueObjectConstResultImpl (ValueObject* valobj, lldb::addr_t live_address) : m_impl_backend(valobj), - m_live_address(live_address), + m_live_address(live_address), + m_live_address_type(eAddressTypeLoad), m_load_addr_backend(), m_address_of_backend() { @@ -201,6 +202,26 @@ return lldb::ValueObjectSP(); } +lldb::addr_t +ValueObjectConstResultImpl::GetAddressOf (bool scalar_is_load_address, + AddressType *address_type) +{ + + if (m_impl_backend == NULL) + return 0; + + if (m_live_address == LLDB_INVALID_ADDRESS) + { + return m_impl_backend->ValueObject::GetAddressOf (scalar_is_load_address, + address_type); + } + + if (address_type) + *address_type = m_live_address_type; + + return m_live_address; +} + size_t ValueObjectConstResultImpl::GetPointeeData (DataExtractor& data, uint32_t item_idx, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=146768&r1=146767&r2=146768&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Dec 16 17:04:52 2011 @@ -396,13 +396,23 @@ { // The reference comes from the program. We need to set up a live SP for it. + unsigned long long address = value.GetScalar().ULongLong(); + AddressType address_type = value.GetValueAddressType(); + pvar_sp->m_live_sp = ValueObjectConstResult::Create(m_parser_vars->m_exe_ctx->GetBestExecutionContextScope(), pvar_sp->GetTypeFromUser().GetASTContext(), pvar_sp->GetTypeFromUser().GetOpaqueQualType(), pvar_sp->GetName(), - value.GetScalar().ULongLong(), - value.GetValueAddressType(), + address, + address_type, pvar_sp->GetByteSize()); + + // if the frozen object does not yet have a valid live address we replicate the live_sp address + // to it. this solves the issue where synthetic children providers are unable to access + // the address-of result for objects obtained by casting the result of pointer arithmetic + // performed by the expression parser, as in: print *((ClassType*)(value-1)) + if (pvar_sp->m_frozen_sp->GetLiveAddress() == LLDB_INVALID_ADDRESS) + pvar_sp->m_frozen_sp->SetLiveAddress(address); } if (pvar_sp->m_flags & ClangExpressionVariable::EVNeedsFreezeDry) Added: lldb/trunk/test/expression_command/issue_11588/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/Makefile?rev=146768&view=auto ============================================================================== --- lldb/trunk/test/expression_command/issue_11588/Makefile (added) +++ lldb/trunk/test/expression_command/issue_11588/Makefile Fri Dec 16 17:04:52 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/issue_11588/Test11588.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/Test11588.py?rev=146768&view=auto ============================================================================== --- lldb/trunk/test/expression_command/issue_11588/Test11588.py (added) +++ lldb/trunk/test/expression_command/issue_11588/Test11588.py Fri Dec 16 17:04:52 2011 @@ -0,0 +1,54 @@ +""" +Test the solution to issue 11581. +valobj.AddressOf() returns None when an address is +expected in a SyntheticChildrenProvider +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class Issue11581TestCase(TestBase): + + mydir = os.path.join("expression_command", "issue_11588") + + def test_11581_commands(self): + # This is the function to remove the custom commands in order to have a + # clean slate for the next test case. + def cleanup(): + self.runCmd('type synthetic clear', check=False) + + # Execute the cleanup function during test case tear down. + self.addTearDownHook(cleanup) + + """valobj.AddressOf() should return correct values.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.runCmd("breakpoint set --name main") + + self.runCmd("run", RUN_SUCCEEDED) + + self.runCmd("next", RUN_SUCCEEDED) + self.runCmd("next", RUN_SUCCEEDED) + self.runCmd("next", RUN_SUCCEEDED) + self.runCmd("next", RUN_SUCCEEDED) + self.runCmd("next", RUN_SUCCEEDED) + + self.runCmd("command script import s11588.py") + self.runCmd("type synthetic add --python-class s11588.Issue11581SyntheticProvider StgClosure") + + self.expect("print *((StgClosure*)(r14-1))", + substrs = ["(StgClosure) $", + "(StgClosure *) &$0 = 0x", + "(long) addr = ", + "(long) load_address = "]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/issue_11588/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/main.cpp?rev=146768&view=auto ============================================================================== --- lldb/trunk/test/expression_command/issue_11588/main.cpp (added) +++ lldb/trunk/test/expression_command/issue_11588/main.cpp Fri Dec 16 17:04:52 2011 @@ -0,0 +1,54 @@ +// +// 11588.cpp +// + +#include + +class StgInfoTable {}; + +class StgHeader +{ +private: + StgInfoTable* info; +public: + StgHeader() + { + info = new StgInfoTable(); + } + ~StgHeader() + { + delete info; + } +}; + +class StgClosure +{ +private: + StgHeader header; + StgClosure* payload[1]; +public: + StgClosure(bool make_payload = true) + { + if (make_payload) + payload[0] = new StgClosure(false); + else + payload[0] = NULL; + } + ~StgClosure() + { + if (payload[0]) + delete payload[0]; + } +}; + +typedef unsigned long long int ptr_type; + +int main() +{ + StgClosure* r14_ = new StgClosure(); + r14_ = (StgClosure*)(((ptr_type)r14_ | 0x01)); // set the LSB to 1 for tagging + ptr_type r14 = (ptr_type)r14_; + int x = 0; + x = 3; + return (x-1); +} Added: lldb/trunk/test/expression_command/issue_11588/s11588.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/issue_11588/s11588.py?rev=146768&view=auto ============================================================================== --- lldb/trunk/test/expression_command/issue_11588/s11588.py (added) +++ lldb/trunk/test/expression_command/issue_11588/s11588.py Fri Dec 16 17:04:52 2011 @@ -0,0 +1,26 @@ +class Issue11581SyntheticProvider(object): + def __init__(self, valobj, dict): + self.valobj = valobj + self.addrOf = valobj.AddressOf() + self.addr = valobj.GetAddress() + self.load_address = valobj.GetLoadAddress() + + def num_children(self): + return 3; + + def get_child_at_index(self, index): + if index == 0: + return self.addrOf + if index == 1: + return self.valobj.CreateValueFromExpression("addr", str(self.addr)) + if index == 2: + return self.valobj.CreateValueFromExpression("load_address", str(self.load_address)) + + def get_child_index(self, name): + if name == "addrOf": + return 0 + if name == "addr": + return 1 + if name == "load_address": + return 2 + From bugzilla-daemon at llvm.org Fri Dec 16 17:06:47 2011 From: bugzilla-daemon at llvm.org (bugzilla-daemon at llvm.org) Date: Fri, 16 Dec 2011 23:06:47 +0000 Subject: [Lldb-commits] [Bug 11588] valobj.AddressOf() returns None when an address is expected in a SyntheticChildrenProvider In-Reply-To: References: Message-ID: http://llvm.org/bugs/show_bug.cgi?id=11588 johnny.chen at apple.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |johnny.chen at apple.com Resolution| |FIXED --- Comment #1 from johnny.chen at apple.com 2011-12-16 17:06:47 CST --- Checked in http://llvm.org/viewvc/llvm-project?rev=146768&view=rev. Patch from Enrico Granata: The problem was that the frozen object created by the expression parser was a copy of the contents of the StgClosure, rather than a pointer to it. Thus, the expression parser was correctly computing the result of the arithmetic&cast operation along with its address, but only saving it in the live object. This meant that the frozen copy acted as an address-less variable, hence the problem. The fix attached to this email lets the expression parser store the "live address" in the frozen copy of the address when the object is built without a valid address of its own. Doing so, along with delegating ValueObjectConstResult to calculate its own address when necessary, solves the issue. I have also added a new test case to check for regressions in this area, and checked that existing test cases pass correctly. -- Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. From jingham at apple.com Fri Dec 16 17:24:58 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 16 Dec 2011 23:24:58 -0000 Subject: [Lldb-commits] [lldb] r146777 - in /lldb/trunk/test/lang/objc/objc-dynamic-value: TestObjCDynamicValue.py dynamic-value.m Message-ID: <20111216232458.E7CF12A6C12C@llvm.org> Author: jingham Date: Fri Dec 16 17:24:58 2011 New Revision: 146777 URL: http://llvm.org/viewvc/llvm-project?rev=146777&view=rev Log: Make the objc-dynamic-value test a little trickier (still passes) and test the GetDynamicValue API. Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py lldb/trunk/test/lang/objc/objc-dynamic-value/dynamic-value.m Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py?rev=146777&r1=146776&r2=146777&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Fri Dec 16 17:24:58 2011 @@ -92,6 +92,16 @@ myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) self.examine_SourceDerived_ptr (myObserver_source) + # + # Make sure a static value can be correctly turned into a dynamic value. + + frame = thread.GetFrameAtIndex(0) + myObserver_static = frame.FindVariable('myObserver', lldb.eNoDynamicValues) + self.assertTrue (myObserver_static) + myObserver = myObserver_static.GetDynamicValue (lldb.eDynamicCanRunTarget) + myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) + self.examine_SourceDerived_ptr (myObserver_source) + # The "frame var" code uses another path to get into children, so let's # make sure that works as well: Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/dynamic-value.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-dynamic-value/dynamic-value.m?rev=146777&r1=146776&r2=146777&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-dynamic-value/dynamic-value.m (original) +++ lldb/trunk/test/lang/objc/objc-dynamic-value/dynamic-value.m Fri Dec 16 17:24:58 2011 @@ -125,7 +125,7 @@ int main () { - SourceDerived *mySource; + Source *mySource; Observer *myObserver; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; From jingham at apple.com Fri Dec 16 18:58:46 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 17 Dec 2011 00:58:46 -0000 Subject: [Lldb-commits] [lldb] r146798 - /lldb/trunk/source/Expression/ClangFunction.cpp Message-ID: <20111217005846.7BD752A6C12C@llvm.org> Author: jingham Date: Fri Dec 16 18:58:46 2011 New Revision: 146798 URL: http://llvm.org/viewvc/llvm-project?rev=146798&view=rev Log: Remove an unnecessary #include. Modified: lldb/trunk/source/Expression/ClangFunction.cpp Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=146798&r1=146797&r2=146798&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Fri Dec 16 18:58:46 2011 @@ -36,7 +36,6 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" -#include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" From gclayton at apple.com Fri Dec 16 19:16:40 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 17 Dec 2011 01:16:40 -0000 Subject: [Lldb-commits] [lldb] r146802 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Message-ID: <20111217011640.1B28E2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 16 19:16:39 2011 New Revision: 146802 URL: http://llvm.org/viewvc/llvm-project?rev=146802&view=rev Log: Modified LLDB to be able to handle our updated __apple_types accelerator tables which have the dwarf DIE tag (DW_TAG_XXX enum) and TypeFlags for each type. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=146802&r1=146801&r2=146802&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Fri Dec 16 19:16:39 2011 @@ -12,6 +12,7 @@ #include +#include "DWARFDefines.h" #include "DWARFFormValue.h" #include "lldb/lldb-defines.h" @@ -29,12 +30,20 @@ struct DIEInfo { dw_offset_t offset; // The DIE offset + dw_tag_t tag; uint32_t type_flags; // Any flags for this DIEInfo - - DIEInfo (dw_offset_t _offset = DW_INVALID_OFFSET, - uint32_t _type_flags = 0) : - offset(_offset), - type_flags (_type_flags) + + DIEInfo () : + offset (DW_INVALID_OFFSET), + tag (0), + type_flags (0) + { + } + + DIEInfo (dw_offset_t o, dw_tag_t t, uint32_t f) : + offset(o), + tag (t), + type_flags (f) { } @@ -42,6 +51,7 @@ Clear() { offset = DW_INVALID_OFFSET; + tag = 0; type_flags = 0; } }; @@ -84,35 +94,16 @@ eAtomTypeTypeFlags = 5u // Flags from enum TypeFlags }; - // Held in bits[3:0] of the eAtomTypeTypeFlags value to help us know what kind of type - // the name is describing - enum TypeFlagsTypeClass - { - eTypeClassInvalid = 0u, // An invalid type class, this might happend when type flags were not correctly set - eTypeClassOther = 1u, // A type other than any listed below - eTypeClassBuiltIn = 2u, // Language built in type - eTypeClassClassOrStruct = 3u, // A class or structure, just not an objective C class - eTypeClassClassOBJC = 4u, - eTypeClassEnum = 5u, - eTypeClassTypedef = 7u, - eTypeClassUnion = 8u - }; - - // Other type bits for the eAtomTypeTypeFlags flags - + // Bit definitions for the eAtomTypeTypeFlags flags enum TypeFlags { - // Make bits [3:0] of the eAtomTypeTypeFlags value and see TypeFlagsTypeClass - eTypeFlagClassMask = 0x0000000fu, - // If the name contains the namespace and class scope or the type // exists in the global namespace, then this bits should be set - eTypeFlagNameIsFullyQualified = ( 1u << 4 ), + eTypeFlagNameIsFullyQualified = ( 1u << 0 ), // Always set for C++, only set for ObjC if this is the // @implementation for class - eTypeFlagClassIsImplementation = ( 1u << 5 ), - + eTypeFlagClassIsImplementation = ( 1u << 1 ), }; struct Atom @@ -334,6 +325,10 @@ case eAtomTypeDIEOffset: // DIE offset, check form for encoding hash_data.offset = form_value.Reference (header_data.die_base_offset); break; + + case eAtomTypeTag: // DW_TAG value for the DIE + hash_data.tag = form_value.Unsigned (); + case eAtomTypeTypeFlags: // Flags from enum TypeFlags hash_data.type_flags = form_value.Unsigned (); break; @@ -358,34 +353,31 @@ switch (header_data.atoms[i].type) { case eAtomTypeDIEOffset: // DIE offset, check form for encoding - strm.Printf ("0x%8.8x", hash_data.offset); + strm.Printf ("{0x%8.8x}", hash_data.offset); break; - + + case eAtomTypeTag: // DW_TAG value for the DIE + { + const char *tag_cstr = lldb_private::DW_TAG_value_to_name (hash_data.tag); + if (tag_cstr) + strm.PutCString (tag_cstr); + else + strm.Printf ("DW_TAG_(0x%4.4x)", hash_data.tag); + } + break; + case eAtomTypeTypeFlags: // Flags from enum TypeFlags - strm.Printf ("0x%2.2x ( type = ", hash_data.type_flags); - switch (hash_data.type_flags & eTypeFlagClassMask) - { - case eTypeClassInvalid: strm.PutCString ("invalid"); break; - case eTypeClassOther: strm.PutCString ("other"); break; - case eTypeClassBuiltIn: strm.PutCString ("built-in"); break; - case eTypeClassClassOrStruct: strm.PutCString ("class-struct"); break; - case eTypeClassClassOBJC: strm.PutCString ("class-objc"); break; - case eTypeClassEnum: strm.PutCString ("enum"); break; - case eTypeClassTypedef: strm.PutCString ("typedef"); break; - case eTypeClassUnion: strm.PutCString ("union"); break; - default: strm.PutCString ("???"); break; - } - - if (hash_data.type_flags & ~eTypeFlagClassMask) + strm.Printf ("0x%2.2x", hash_data.type_flags); + if (hash_data.type_flags) { - strm.PutCString (", flags ="); + strm.PutCString (" ("); if (hash_data.type_flags & eTypeFlagNameIsFullyQualified) strm.PutCString (" qualified"); if (hash_data.type_flags & eTypeFlagClassIsImplementation) strm.PutCString (" implementation"); + strm.PutCString (" )"); } - strm.PutCString (" )"); break; default: @@ -671,7 +663,7 @@ // efficiently. DWARFMappedHash::ExtractTypesFromDIEArray (die_info_array, UINT32_MAX, - eTypeFlagNameIsFullyQualified | eTypeFlagClassIsImplementation | eTypeClassClassOBJC, + eTypeFlagNameIsFullyQualified | eTypeFlagClassIsImplementation, die_offsets); } else From jingham at apple.com Fri Dec 16 19:35:58 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 17 Dec 2011 01:35:58 -0000 Subject: [Lldb-commits] [lldb] r146806 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Target/ scripts/Python/interface/ source/API/ source/Commands/ source/Core/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ www/ Message-ID: <20111217013558.80FEA2A6C12C@llvm.org> Author: jingham Date: Fri Dec 16 19:35:57 2011 New Revision: 146806 URL: http://llvm.org/viewvc/llvm-project?rev=146806&view=rev Log: Add the ability to capture the return value in a thread's stop info, and print it as part of the thread format output. Currently this is only done for the ThreadPlanStepOut. Add a convenience API ABI::GetReturnValueObject. Change the ValueObject::EvaluationPoint to BE an ExecutionContextScope, rather than trying to hand out one of its subsidiary object's pointers. That way this will always be good. Modified: lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/StopInfo.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h lldb/trunk/scripts/Python/interface/SBThread.i lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectConstResult.cpp lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Target/ABI.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanStepOut.cpp lldb/trunk/www/formats.html Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Fri Dec 16 19:35:57 2011 @@ -63,6 +63,9 @@ size_t GetStopDescription (char *dst, size_t dst_len); + + SBValue + GetStopReturnValue (); lldb::tid_t GetThreadID () const; Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Dec 16 19:35:57 2011 @@ -336,7 +336,7 @@ }; - class EvaluationPoint + class EvaluationPoint : public ExecutionContextScope { public: @@ -348,9 +348,6 @@ ~EvaluationPoint (); - ExecutionContextScope * - GetExecutionContextScope (); - const lldb::TargetSP & GetTargetSP () const { @@ -443,6 +440,20 @@ } + // If this EvaluationPoint is created without a target, then we could have it + // hand out a NULL ExecutionContextScope. But then everybody would have to check that before + // calling through it, which is annoying. So instead, we make the EvaluationPoint BE an + // ExecutionContextScope, and it hands out the right things. + virtual Target *CalculateTarget (); + + virtual Process *CalculateProcess (); + + virtual Thread *CalculateThread (); + + virtual StackFrame *CalculateStackFrame (); + + virtual void CalculateExecutionContext (ExecutionContext &exe_ctx); + private: bool SyncWithProcessState () @@ -479,7 +490,7 @@ ExecutionContextScope * GetExecutionContextScope () { - return m_update_point.GetExecutionContextScope(); + return &m_update_point; } void Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Fri Dec 16 19:35:57 2011 @@ -59,6 +59,12 @@ AddressType address_type, uint8_t addr_byte_size); + static lldb::ValueObjectSP + Create (ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + Value &value, + const ConstString &name); + // When an expression fails to evaluate, we return an error static lldb::ValueObjectSP Create (ExecutionContextScope *exe_scope, @@ -181,6 +187,11 @@ uint8_t addr_byte_size); ValueObjectConstResult (ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + const Value &value, + const ConstString &name); + + ValueObjectConstResult (ExecutionContextScope *exe_scope, const Error& error); DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult); Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Fri Dec 16 19:35:57 2011 @@ -48,6 +48,10 @@ virtual bool GetReturnValue (Thread &thread, Value &value) const = 0; + + virtual lldb::ValueObjectSP + GetReturnValueObject (Thread &thread, + ClangASTType &type) const; virtual bool CreateFunctionEntryUnwindPlan (UnwindPlan &unwind_plan) = 0; Modified: lldb/trunk/include/lldb/Target/StopInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StopInfo.h (original) +++ lldb/trunk/include/lldb/Target/StopInfo.h Fri Dec 16 19:35:57 2011 @@ -126,10 +126,13 @@ CreateStopReasonToTrace (Thread &thread); static lldb::StopInfoSP - CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan); + CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan, lldb::ValueObjectSP return_valobj_sp); static lldb::StopInfoSP CreateStopReasonWithException (Thread &thread, const char *description); + + static lldb::ValueObjectSP + GetReturnValueObject (lldb::StopInfoSP &stop_info_sp); protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Fri Dec 16 19:35:57 2011 @@ -604,7 +604,7 @@ public: //------------------------------------------------------------------ - /// Gets the inner-most plan that was popped off the plan stack in the + /// Gets the outer-most plan that was popped off the plan stack in the /// most recent stop. Useful for printing the stop reason accurately. /// /// @return @@ -614,6 +614,16 @@ GetCompletedPlan (); //------------------------------------------------------------------ + /// Gets the outer-most return value from the completed plans + /// + /// @return + /// A ValueObjectSP, either empty if there is no return value, + /// or containing the return value. + //------------------------------------------------------------------ + lldb::ValueObjectSP + GetReturnValueObject (); + + //------------------------------------------------------------------ /// Checks whether the given plan is in the completed plans for this /// stop. /// Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Fri Dec 16 19:35:57 2011 @@ -387,6 +387,12 @@ return m_thread.GetStopInfo (); } + virtual lldb::ValueObjectSP + GetReturnValueObject () + { + return lldb::ValueObjectSP(); + } + protected: //------------------------------------------------------------------ // Classes that inherit from ThreadPlan can see and modify these Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h Fri Dec 16 19:35:57 2011 @@ -42,6 +42,11 @@ virtual bool WillStop (); virtual bool MischiefManaged (); virtual void DidPush(); + + virtual lldb::ValueObjectSP GetReturnValueObject() + { + return m_return_valobj_sp; + } protected: bool QueueInlinedStepPlan (bool queue_now); @@ -56,6 +61,8 @@ bool m_stop_others; lldb::ThreadPlanSP m_step_through_inline_plan_sp; lldb::ThreadPlanSP m_step_out_plan_sp; + Function *m_immediate_step_from_function; + lldb::ValueObjectSP m_return_valobj_sp; friend ThreadPlan * Thread::QueueThreadPlanForStepOut (bool abort_other_plans, @@ -69,6 +76,9 @@ // Need an appropriate marker for the current stack so we can tell step out // from step in. + void + CalculateReturnValue(); + DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOut); }; Modified: lldb/trunk/scripts/Python/interface/SBThread.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBThread.i (original) +++ lldb/trunk/scripts/Python/interface/SBThread.i Fri Dec 16 19:35:57 2011 @@ -82,6 +82,9 @@ size_t GetStopDescription (char *dst, size_t dst_len); + SBValue + GetStopReturnValue (); + lldb::tid_t GetThreadID () const; Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Fri Dec 16 19:35:57 2011 @@ -31,10 +31,10 @@ #include "lldb/API/SBAddress.h" -#include "lldb/API/SBFrame.h" -// DONT THINK THIS IS NECESSARY: #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBDebugger.h" +#include "lldb/API/SBFrame.h" #include "lldb/API/SBProcess.h" +#include "lldb/API/SBValue.h" using namespace lldb; using namespace lldb_private; @@ -316,6 +316,30 @@ return 0; } +SBValue +SBThread::GetStopReturnValue () +{ + ValueObjectSP return_valobj_sp; + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); + StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); + if (stop_info_sp) + { + return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp); + } + } + + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBThread(%p)::GetStopReturnValue () => %s", m_opaque_sp.get(), + return_valobj_sp.get() + ? return_valobj_sp->GetValueAsCString() + : ""); + + return SBValue (return_valobj_sp); +} + void SBThread::SetThread (const ThreadSP& lldb_object_sp) { Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri Dec 16 19:35:57 2011 @@ -380,7 +380,7 @@ { ValueObjectSP result_valobj_sp; m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression (expression, - m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(), + m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame(), eExecutionPolicyOnlyWhenNeeded, true, // unwind on error true, // keep in memory @@ -410,7 +410,7 @@ lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t))); - ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(), + ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (m_opaque_sp->GetExecutionContextScope(), real_type.m_opaque_sp->GetASTContext(), real_type.m_opaque_sp->GetOpaqueQualType(), ConstString(name), @@ -871,9 +871,9 @@ SBThread result; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) + if (m_opaque_sp->GetExecutionContextScope()) { - result = SBThread(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()->GetSP()); + result = SBThread(m_opaque_sp->GetExecutionContextScope()->CalculateThread()->GetSP()); } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -893,9 +893,9 @@ SBFrame result; if (m_opaque_sp) { - if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) + if (m_opaque_sp->GetExecutionContextScope()) { - result.SetFrame (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()->GetSP()); + result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->GetSP()); } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Dec 16 19:35:57 2011 @@ -1246,7 +1246,7 @@ LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( interpreter, "thread step-out", - "Finish executing the current function and return to its call site in specified thread (current thread, if none specified).", + "Finish executing the function of the currently selected frame and return to its call site in specified thread (current thread, if none specified).", NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Dec 16 19:35:57 2011 @@ -1701,6 +1701,23 @@ } } } + else if (::strncmp (var_name_begin, "return-value}", strlen("return-value}")) == 0) + { + StopInfoSP stop_info_sp = thread->GetStopInfo (); + if (stop_info_sp) + { + ValueObjectSP return_valobj_sp = StopInfo::GetReturnValueObject (stop_info_sp); + if (return_valobj_sp) + { + cstr = return_valobj_sp->GetValueAsCString (); + if (cstr && cstr[0]) + { + s.PutCString(cstr); + var_success = true; + } + } + } + } } } } @@ -2562,6 +2579,7 @@ MODULE_WITH_FUNC\ FILE_AND_LINE\ "{, stop reason = ${thread.stop-reason}}"\ + "{, return value = ${thread.return-value}}"\ "\\n" //#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Dec 16 19:35:57 2011 @@ -707,7 +707,7 @@ AddressType addr_type; lldb::addr_t addr = IsPointerType() ? GetPointerValue(&addr_type) : GetAddressOf(true, &addr_type); - ExecutionContextScope *exe_scope = m_update_point.GetExecutionContextScope(); + ExecutionContextScope *exe_scope = GetExecutionContextScope(); switch (addr_type) @@ -3428,12 +3428,14 @@ } ValueObject::EvaluationPoint::EvaluationPoint () : + ExecutionContextScope(), m_thread_id (LLDB_INVALID_UID), m_mod_id () { } ValueObject::EvaluationPoint::EvaluationPoint (ExecutionContextScope *exe_scope, bool use_selected): + ExecutionContextScope (), m_needs_update (true), m_first_update (true), m_thread_id (LLDB_INVALID_THREAD_ID), @@ -3500,14 +3502,47 @@ { } -ExecutionContextScope * -ValueObject::EvaluationPoint::GetExecutionContextScope () +Target * +ValueObject::EvaluationPoint::CalculateTarget () { - // We have to update before giving out the scope, or we could be handing out stale pointers. - ExecutionContextScope *exe_scope; + return m_target_sp.get(); +} + +Process * +ValueObject::EvaluationPoint::CalculateProcess () +{ + return m_process_sp.get(); +} + +Thread * +ValueObject::EvaluationPoint::CalculateThread () +{ + ExecutionContextScope *exe_scope; SyncWithProcessState(exe_scope); - - return exe_scope; + if (exe_scope) + return exe_scope->CalculateThread(); + else + return NULL; +} + +StackFrame * +ValueObject::EvaluationPoint::CalculateStackFrame () +{ + ExecutionContextScope *exe_scope; + SyncWithProcessState(exe_scope); + if (exe_scope) + return exe_scope->CalculateStackFrame(); + else + return NULL; +} + +void +ValueObject::EvaluationPoint::CalculateExecutionContext (ExecutionContext &exe_ctx) +{ + ExecutionContextScope *exe_scope; + SyncWithProcessState(exe_scope); + if (exe_scope) + return exe_scope->CalculateExecutionContext (exe_ctx); } // This function checks the EvaluationPoint against the current process state. If the current @@ -3520,12 +3555,18 @@ bool ValueObject::EvaluationPoint::SyncWithProcessState(ExecutionContextScope *&exe_scope) { + + // Start with the target, if it is NULL, then we're obviously not going to get any further: + exe_scope = m_target_sp.get(); + + if (exe_scope == NULL) + return false; + // If we don't have a process nothing can change. if (!m_process_sp) - { - exe_scope = m_target_sp.get(); return false; - } + + exe_scope = m_process_sp.get(); // If our stop id is the current stop ID, nothing has changed: ProcessModID current_mod_id = m_process_sp->GetModID(); @@ -3533,10 +3574,7 @@ // If the current stop id is 0, either we haven't run yet, or the process state has been cleared. // In either case, we aren't going to be able to sync with the process state. if (current_mod_id.GetStopID() == 0) - { - exe_scope = m_target_sp.get(); return false; - } bool changed; @@ -3555,10 +3593,10 @@ changed = true; } } - exe_scope = m_process_sp.get(); - // Something has changed, so we will return true. Now make sure the thread & frame still exist, and if either - // doesn't, mark ourselves as invalid. + // Now re-look up the thread and frame in case the underlying objects have gone away & been recreated. + // That way we'll be sure to return a valid exe_scope. + // If we used to have a thread or a frame but can't find it anymore, then mark ourselves as invalid. if (m_thread_id != LLDB_INVALID_THREAD_ID) { Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Fri Dec 16 19:35:57 2011 @@ -130,6 +130,15 @@ address))->GetSP(); } +ValueObjectSP +ValueObjectConstResult::Create (ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + Value &value, + const ConstString &name) +{ + return (new ValueObjectConstResult (exe_scope, clang_ast, value, name))->GetSP(); +} + ValueObjectConstResult::ValueObjectConstResult ( ExecutionContextScope *exe_scope, @@ -239,6 +248,21 @@ SetIsConstant (); } +ValueObjectConstResult::ValueObjectConstResult ( + ExecutionContextScope *exe_scope, + clang::ASTContext *clang_ast, + const Value &value, + const ConstString &name) : + ValueObject (exe_scope), + m_type_name (), + m_byte_size (0), + m_clang_ast (clang_ast), + m_impl(this) +{ + m_value = value; + m_value.GetData(m_data); +} + ValueObjectConstResult::~ValueObjectConstResult() { } Modified: lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResultImpl.cpp Fri Dec 16 19:35:57 2011 @@ -185,7 +185,7 @@ std::string new_name("&"); new_name.append(m_impl_backend->GetName().AsCString("")); - m_address_of_backend = ValueObjectConstResult::Create(m_impl_backend->GetUpdatePoint().GetExecutionContextScope(), + m_address_of_backend = ValueObjectConstResult::Create(m_impl_backend->GetExecutionContextScope(), type.GetASTContext(), type.GetPointerType(), ConstString(new_name.c_str()), 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=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Fri Dec 16 19:35:57 2011 @@ -309,7 +309,7 @@ // If the class address didn't point into the binary, or // it points into the right section but there wasn't a symbol // there, try to look it up by calling the class method in the target. - ExecutionContextScope *exe_scope = in_value.GetUpdatePoint().GetExecutionContextScope(); + ExecutionContextScope *exe_scope = in_value.GetExecutionContextScope(); Thread *thread_to_use; if (exe_scope) thread_to_use = exe_scope->CalculateThread(); Modified: lldb/trunk/source/Target/ABI.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ABI.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Target/ABI.cpp (original) +++ lldb/trunk/source/Target/ABI.cpp Fri Dec 16 19:35:57 2011 @@ -9,6 +9,10 @@ #include "lldb/Target/ABI.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObjectConstResult.h" +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; @@ -97,3 +101,28 @@ } return false; } + +ValueObjectSP +ABI::GetReturnValueObject (Thread &thread, + ClangASTType &ast_type) const +{ + if (!ast_type.IsValid()) + return ValueObjectSP(); + + Value ret_value; + ret_value.SetContext(Value::eContextTypeClangType, + ast_type.GetOpaqueQualType()); + if (GetReturnValue (thread, ret_value)) + { + return ValueObjectConstResult::Create( + thread.GetStackFrameAtIndex(0).get(), + ast_type.GetASTContext(), + ret_value, + ConstString("FunctionReturn")); + + } + else + return ValueObjectSP(); +} + + Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Fri Dec 16 19:35:57 2011 @@ -722,9 +722,10 @@ { public: - StopInfoThreadPlan (ThreadPlanSP &plan_sp) : + StopInfoThreadPlan (ThreadPlanSP &plan_sp, ValueObjectSP &return_valobj_sp) : StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID), - m_plan_sp (plan_sp) + m_plan_sp (plan_sp), + m_return_valobj_sp (return_valobj_sp) { } @@ -749,9 +750,16 @@ } return m_description.c_str(); } + + ValueObjectSP + GetReturnValueObject() + { + return m_return_valobj_sp; + } private: ThreadPlanSP m_plan_sp; + ValueObjectSP m_return_valobj_sp; }; } // namespace lldb_private @@ -786,9 +794,9 @@ } StopInfoSP -StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp) +StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp, ValueObjectSP return_valobj_sp) { - return StopInfoSP (new StopInfoThreadPlan (plan_sp)); + return StopInfoSP (new StopInfoThreadPlan (plan_sp, return_valobj_sp)); } StopInfoSP @@ -796,3 +804,15 @@ { return StopInfoSP (new StopInfoException (thread, description)); } + +ValueObjectSP +StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp) +{ + if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonPlanComplete) + { + StopInfoThreadPlan *plan_stop_info = static_cast(stop_info_sp.get()); + return plan_stop_info->GetReturnValueObject(); + } + else + return ValueObjectSP(); +} Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Dec 16 19:35:57 2011 @@ -95,7 +95,7 @@ { ThreadPlanSP plan_sp (GetCompletedPlan()); if (plan_sp) - return StopInfo::CreateStopReasonWithPlan (plan_sp); + return StopInfo::CreateStopReasonWithPlan (plan_sp, GetReturnValueObject()); else { if (m_actual_stop_info_sp @@ -551,6 +551,22 @@ return empty_plan_sp; } +ValueObjectSP +Thread::GetReturnValueObject () +{ + if (!m_completed_plan_stack.empty()) + { + for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) + { + ValueObjectSP return_valobj_sp; + return_valobj_sp = m_completed_plan_stack[i]->GetReturnValueObject(); + if (return_valobj_sp) + return return_valobj_sp; + } + } + return ValueObjectSP(); +} + bool Thread::IsThreadPlanDone (ThreadPlan *plan) { Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Fri Dec 16 19:35:57 2011 @@ -16,6 +16,8 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/lldb-private-log.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Value.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" @@ -47,7 +49,8 @@ m_first_insn (first_insn), m_stop_others (stop_others), m_step_through_inline_plan_sp(), - m_step_out_plan_sp () + m_step_out_plan_sp (), + m_immediate_step_from_function(NULL) { m_step_from_insn = m_thread.GetRegisterContext()->GetPC(0); @@ -88,6 +91,15 @@ return_bp->SetThreadID(m_thread.GetID()); m_return_bp_id = return_bp->GetID(); } + + if (immediate_return_from_sp) + { + const SymbolContext &sc = immediate_return_from_sp->GetSymbolContext(eSymbolContextFunction); + if (sc.function) + { + m_immediate_step_from_function = sc.function; + } + } } } @@ -152,6 +164,7 @@ if (m_step_out_plan_sp->MischiefManaged()) { // If this one is done, then we are all done. + CalculateReturnValue(); SetPlanComplete(); return true; } @@ -183,7 +196,10 @@ { const uint32_t num_frames = m_thread.GetStackFrameCount(); if (m_stack_depth > num_frames) + { + CalculateReturnValue(); SetPlanComplete(); + } // If there was only one owner, then we're done. But if we also hit some // user breakpoint on our way out, we should mark ourselves as done, but @@ -217,6 +233,7 @@ } else if (m_stack_depth > m_thread.GetStackFrameCount()) { + CalculateReturnValue(); SetPlanComplete(); return true; } @@ -233,6 +250,7 @@ } else { + CalculateReturnValue(); SetPlanComplete (); return true; } @@ -244,6 +262,10 @@ { if (m_step_through_inline_plan_sp->MischiefManaged()) { + // We don't calculate the return value here because we don't know how to. + // But in case we had a return value sitting around from our process in + // getting here, let's clear it out. + m_return_valobj_sp.reset(); SetPlanComplete(); return true; } @@ -387,3 +409,26 @@ return false; } + +void +ThreadPlanStepOut::CalculateReturnValue () +{ + if (m_return_valobj_sp) + return; + + if (m_immediate_step_from_function != NULL) + { + Type *return_type = m_immediate_step_from_function->GetType(); + lldb::clang_type_t return_clang_type = m_immediate_step_from_function->GetReturnClangType(); + if (return_type && return_clang_type) + { + ClangASTType ast_type (return_type->GetClangAST(), return_clang_type); + + lldb::ABISP abi_sp = m_thread.GetProcess().GetABI(); + if (abi_sp) + { + m_return_valobj_sp = abi_sp->GetReturnValueObject(m_thread, ast_type); + } + } + } +} Modified: lldb/trunk/www/formats.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/formats.html?rev=146806&r1=146805&r2=146806&view=diff ============================================================================== --- lldb/trunk/www/formats.html (original) +++ lldb/trunk/www/formats.html Fri Dec 16 19:35:57 2011 @@ -97,6 +97,7 @@ thread.nameThe name of the thread if the target OS supports naming threads thread.queueThe queue name of the thread if the target OS supports dispatch queues thread.stop-reasonA textual reason each thread stopped + thread.return-valueThe return value of the latest step operation (currently only for step-out.) target.archThe architecture of the current target From scallanan at apple.com Fri Dec 16 19:43:51 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 17 Dec 2011 01:43:51 -0000 Subject: [Lldb-commits] [lldb] r146808 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111217014351.6B2A12A6C12C@llvm.org> Author: spyffe Date: Fri Dec 16 19:43:50 2011 New Revision: 146808 URL: http://llvm.org/viewvc/llvm-project?rev=146808&view=rev Log: Updating Xcode project version numbers for LLDB-96 and debugserver-156. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=146808&r1=146807&r2=146808&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 16 19:43:50 2011 @@ -3733,9 +3733,9 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 95; + DYLIB_CURRENT_VERSION = 96; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3793,10 +3793,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 95; + DYLIB_CURRENT_VERSION = 96; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3852,8 +3852,8 @@ 2689FFD513353D7A00698AC0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 95; - DYLIB_CURRENT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; + DYLIB_CURRENT_VERSION = 96; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3881,8 +3881,8 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 95; - DYLIB_CURRENT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; + DYLIB_CURRENT_VERSION = 96; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3910,8 +3910,8 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 95; - DYLIB_CURRENT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; + DYLIB_CURRENT_VERSION = 96; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3991,7 +3991,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4022,10 +4022,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 95; + DYLIB_CURRENT_VERSION = 96; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4269,7 +4269,7 @@ 26F5C26C10F3D9A5009D5894 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4299,7 +4299,7 @@ 26F5C26D10F3D9A5009D5894 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 95; + CURRENT_PROJECT_VERSION = 96; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=146808&r1=146807&r2=146808&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Dec 16 19:43:50 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 95 + 96 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=146808&r1=146807&r2=146808&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Dec 16 19:43:50 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 155; + CURRENT_PROJECT_VERSION = 156; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From scallanan at apple.com Fri Dec 16 19:44:21 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 17 Dec 2011 01:44:21 -0000 Subject: [Lldb-commits] [lldb] r146809 - /lldb/tags/lldb-96/ Message-ID: <20111217014421.53ABE2A6C12C@llvm.org> Author: spyffe Date: Fri Dec 16 19:44:21 2011 New Revision: 146809 URL: http://llvm.org/viewvc/llvm-project?rev=146809&view=rev Log: LLDB-96 Added: lldb/tags/lldb-96/ - copied from r146808, lldb/trunk/ From scallanan at apple.com Fri Dec 16 20:00:57 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 17 Dec 2011 02:00:57 -0000 Subject: [Lldb-commits] [lldb] r146811 - /lldb/trunk/scripts/build-lldb-llvm-clang Message-ID: <20111217020057.724FF2A6C12C@llvm.org> Author: spyffe Date: Fri Dec 16 20:00:57 2011 New Revision: 146811 URL: http://llvm.org/viewvc/llvm-project?rev=146811&view=rev Log: Added a version of the LLVM/Clang checkout and build script that applies any local patches to LLVM/Clang. Added: lldb/trunk/scripts/build-lldb-llvm-clang (with props) Added: lldb/trunk/scripts/build-lldb-llvm-clang URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-lldb-llvm-clang?rev=146811&view=auto ============================================================================== --- lldb/trunk/scripts/build-lldb-llvm-clang (added) +++ lldb/trunk/scripts/build-lldb-llvm-clang Fri Dec 16 20:00:57 2011 @@ -0,0 +1,73 @@ +#!/bin/sh -x + +# Usage: +# build-lldb-llvm-clang [Debug|Release] +# build-lldb-llvm-clang [Debug|Release] + +LLVM_REVISION=$1 +CLANG_REVISION=$2 +LLVM_CONFIGURATION=$3 + +if [ "$LLVM_REVISION" = "" ]; then + echo "Usage:\n build-lldb-llvm-clang [ Debug|Release]" + exit 1 +fi + +if [ "$CLANG_REVISION" = "" ]; then + $CLANG_REVISION = $LLVM_REVISION +fi + +# Checkout LLVM +svn co -q -r $LLVM_REVISION http://llvm.org/svn/llvm-project/llvm/trunk llvm + +# change directory to "./llvm" +cd llvm +rm -rf test + +# Checkout Clang +# change directory to "./llvm/tools" +cd tools +svn co -q -r $CLANG_REVISION http://llvm.org/svn/llvm-project/cfe/trunk clang +rm -rf clang/test + +# change directory to "./llvm" +cd .. +for patch_file in ../scripts/llvm.*.diff +do + echo "Applying patch from '$patch_file'" + patch -p0 < "$patch_file" +done + +# change directory to "./llvm/tools/clang" +cd tools/clang +for patch_file in ../../../scripts/clang.*.diff +do + echo "Applying patch from '$patch_file'" + patch -p0 < "$patch_file" +done + +# change directory to "./" +cd ../../.. +pwd + +if [ "$LLVM_CONFIGURATION" = "Debug" ]; then + # Configure "Debug+Asserts" build + mkdir llvm-debug + cd llvm-debug + ../llvm/configure --enable-targets=x86_64,arm + make -j8 clang-only VERBOSE=1 PROJECT_NAME='llvm' + make -j8 tools-only VERBOSE=1 PROJECT_NAME='llvm' EDIS_VERSION=1 +elif [ "$LLVM_CONFIGURATION" = "Release" ]; then + # Configure "Release" build + mkdir llvm-release + cd llvm-release + ../llvm/configure --enable-targets=x86_64,arm --enable-optimized --disable-assertions + make -j8 clang-only VERBOSE=1 PROJECT_NAME='llvm' + make -j8 tools-only VERBOSE=1 PROJECT_NAME='llvm' EDIS_VERSION=1 +elif [ "$LLVM_CONFIGURATION" = "BuildAndIntegration" ]; then + # Configure "BuildAndIntegration" build + rm -rf ./scripts/*.diff +else + echo "checked out llvm (revision $LLVM_REVISION) and clang (revision $CLANG_REVISION)." + exit 0 +fi Propchange: lldb/trunk/scripts/build-lldb-llvm-clang ------------------------------------------------------------------------------ svn:executable = * From echristo at apple.com Fri Dec 16 20:10:59 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 16 Dec 2011 18:10:59 -0800 Subject: [Lldb-commits] [lldb] r146811 - /lldb/trunk/scripts/build-lldb-llvm-clang In-Reply-To: <20111217020057.724FF2A6C12C@llvm.org> References: <20111217020057.724FF2A6C12C@llvm.org> Message-ID: On Dec 16, 2011, at 6:00 PM, Sean Callanan wrote: > make -j8 Instead of hardcoding in the -j8 you may wish to use something like: SYSCTL=`sysctl -n hw.ncpu` and then use $SYSCTL in place of the 8. This will only work on darwin, but it's probably better than guessing and there are similar things for most unixes. :) -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20111216/dc449f12/attachment.html From johnny.chen at apple.com Fri Dec 16 20:07:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 17 Dec 2011 02:07:52 -0000 Subject: [Lldb-commits] [lldb] r146812 - in /lldb/trunk: include/lldb/API/SBThread.h scripts/Python/interface/SBThread.i source/API/SBThread.cpp Message-ID: <20111217020752.A6E4B2A6C12C@llvm.org> Author: johnny Date: Fri Dec 16 20:07:52 2011 New Revision: 146812 URL: http://llvm.org/viewvc/llvm-project?rev=146812&view=rev Log: Fixed code rot pointed out by Jim. SBThread::GetStopReasonDataCount/GetStopReasonDataAtIndex() need to handle eStopReasonWatchpoint. Modified: lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/scripts/Python/interface/SBThread.i lldb/trunk/source/API/SBThread.cpp Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=146812&r1=146811&r2=146812&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Fri Dec 16 20:07:52 2011 @@ -53,7 +53,7 @@ /// eStopReasonNone 0 /// eStopReasonTrace 0 /// eStopReasonBreakpoint N duple: {breakpoint id, location id} - /// eStopReasonWatchpoint N duple: {watchpoint id, location id} + /// eStopReasonWatchpoint 1 watchpoint id /// eStopReasonSignal 1 unix signal number /// eStopReasonException N exception data /// eStopReasonPlanComplete 0 Modified: lldb/trunk/scripts/Python/interface/SBThread.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBThread.i?rev=146812&r1=146811&r2=146812&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBThread.i (original) +++ lldb/trunk/scripts/Python/interface/SBThread.i Fri Dec 16 20:07:52 2011 @@ -70,7 +70,7 @@ /// eStopReasonNone 0 /// eStopReasonTrace 0 /// eStopReasonBreakpoint N duple: {breakpoint id, location id} - /// eStopReasonWatchpoint N duple: {watchpoint id, location id} + /// eStopReasonWatchpoint 1 watchpoint id /// eStopReasonSignal 1 unix signal number /// eStopReasonException N exception data /// eStopReasonPlanComplete 0 Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=146812&r1=146811&r2=146812&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Fri Dec 16 20:07:52 2011 @@ -141,8 +141,7 @@ break; case eStopReasonWatchpoint: - assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()"); - return 0; // We don't have watchpoint support yet... + return 1; case eStopReasonSignal: return 1; @@ -201,8 +200,7 @@ break; case eStopReasonWatchpoint: - assert (!"implement watchpoint support in SBThread::GetStopReasonDataCount ()"); - return 0; // We don't have watchpoint support yet... + return stop_info_sp->GetValue(); case eStopReasonSignal: return stop_info_sp->GetValue();