From johnny.chen at apple.com Mon May 23 13:00:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 23 May 2011 18:00:40 -0000 Subject: [Lldb-commits] [lldb] r131910 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110523180041.680102A6C12D@llvm.org> Author: johnny Date: Mon May 23 13:00:40 2011 New Revision: 131910 URL: http://llvm.org/viewvc/llvm-project?rev=131910&view=rev Log: Fix the Align() utility which tries to align the raw disassembly with the edis'ed disassembly so that both the opcode and the operands are aligned with the rest of output. Comment out the code related to force_raw mode when disassembling arm or thumb for now. It testing goes ok, we will remove the section of code related to force_raw. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp 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=131910&r1=131909&r2=131910&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon May 23 13:00:40 2011 @@ -109,11 +109,15 @@ Str = Str.substr(0, Str.size()-1); } static void -Align(Stream *s, const char *str) +Align(Stream *s, const char *str, size_t opcodeColWidth, size_t operandColWidth) { llvm::StringRef raw_disasm(str); StripSpaces(raw_disasm); - s->PutCString(raw_disasm.str().c_str()); + // Split the raw disassembly into opcode and operands. + std::pair p = raw_disasm.split('\t'); + PadString(s, p.first, opcodeColWidth); + if (!p.second.empty()) + PadString(s, p.second, operandColWidth); } void @@ -173,10 +177,12 @@ // FIXME!!! /* Remove the following section of code related to force_raw .... */ + /* bool force_raw = m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb; if (!raw) raw = force_raw; + */ /* .... when we fix the edis for arm/thumb. */ if (!raw) @@ -349,7 +355,7 @@ if (EDGetInstString(&str, m_inst)) return; - Align(s, str); + Align(s, str, opcodeColumnWidth, operandColumnWidth); } else { @@ -380,7 +386,7 @@ { // EDis fails to parse the tokens of this inst. Need to align this // raw disassembly's opcode with the rest of output. - Align(s, str); + Align(s, str, opcodeColumnWidth, operandColumnWidth); } } } From gclayton at apple.com Mon May 23 13:04:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 23 May 2011 18:04:09 -0000 Subject: [Lldb-commits] [lldb] r131911 - in /lldb/trunk: source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp source/Plugins/Instruction/ARM/EmulateInstructionARM.h source/Plugins/Process/Utility/StopInfoMachException.cpp source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp tools/debugserver/source/RNBRemote.cpp tools/debugserver/source/debugserver.cpp Message-ID: <20110523180409.DA4082A6C12C@llvm.org> Author: gclayton Date: Mon May 23 13:04:09 2011 New Revision: 131911 URL: http://llvm.org/viewvc/llvm-project?rev=131911&view=rev Log: Fixed an issue in the EmulateInstructionARM there the IT opcode was trying to parse NOP instructions. I added the new table entries for the NOP for the plain NOP, Yield, WFE, WFI, and SEV variants. Modified the opcode emulation function EmulateInstructionARM::EmulateMOVRdSP(...) to notify us when it is creating a frame. Also added an abtract way to detect the frame pointer register for both the standard ARM ABI and for Darwin. Fixed GDBRemoteRegisterContext::WriteAllRegisterValues(...) to correctly be able to individually write register values back if case the 'G' packet is not implemented or returns an error. Modified the StopInfoMachException to "trace" stop reasons. On ARM we currently use the BVR/BCR register pairs to say "stop when the PC is not equal to the current PC value", and this results in a EXC_BREAKPOINT mach exception that has 0x102 in the code. Modified debugserver to create the short option string from long option definitions to make sure it doesn't get out of date. The short option string was missing many of the newer short option values due to a modification of the long options defs, and not modifying the short option string. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/RNBRemote.cpp lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Mon May 23 13:04:09 2011 @@ -42,9 +42,10 @@ // A8.6.50 // Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition. -static unsigned short CountITSize(unsigned ITMask) { +static uint32_t +CountITSize (uint32_t ITMask) { // First count the trailing zeros of the IT mask. - unsigned TZ = llvm::CountTrailingZeros_32(ITMask); + uint32_t TZ = llvm::CountTrailingZeros_32(ITMask); if (TZ > 3) { printf("Encoding error: IT Mask '0000'\n"); @@ -54,7 +55,7 @@ } // Init ITState. Note that at least one bit is always 1 in mask. -bool ITSession::InitIT(unsigned short bits7_0) +bool ITSession::InitIT(uint32_t bits7_0) { ITCounter = CountITSize(Bits32(bits7_0, 3, 0)); if (ITCounter == 0) @@ -138,6 +139,7 @@ #define ARMV5J_ABOVE (ARMv5TEJ|ARMv6|ARMv6K|ARMv6T2|ARMv7|ARMv8) #define ARMV6_ABOVE (ARMv6|ARMv6K|ARMv6T2|ARMv7|ARMv8) #define ARMV6T2_ABOVE (ARMv6T2|ARMv7|ARMv8) +#define ARMV7_ABOVE (ARMv7|ARMv8) #define No_VFP 0 #define VFPv1 (1u << 1) @@ -274,6 +276,24 @@ return false; } +uint32_t +EmulateInstructionARM::GetFramePointerRegisterNumber () const +{ + if (m_opcode_mode == eModeThumb || m_arch.GetTriple().getOS() == llvm::Triple::Darwin) + return 7; + else + return 11; +} + +uint32_t +EmulateInstructionARM::GetFramePointerDWARFRegisterNumber () const +{ + if (m_opcode_mode == eModeThumb || m_arch.GetTriple().getOS() == llvm::Triple::Darwin) + return dwarf_r7; + else + return dwarf_r11; +} + // Push Multiple Registers stores multiple registers to the stack, storing to // consecutive memory locations ending just below the address in SP, and updates // SP to point to the start of the stored data. @@ -630,7 +650,10 @@ } EmulateInstruction::Context context; - context.type = EmulateInstruction::eContextRegisterPlusOffset; + if (Rd == GetFramePointerRegisterNumber()) + context.type = EmulateInstruction::eContextSetFramePointer; + else + context.type = EmulateInstruction::eContextRegisterPlusOffset; RegisterInfo sp_reg; GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); context.SetRegisterPlusOffset (sp_reg, 0); @@ -2153,6 +2176,13 @@ return true; } +bool +EmulateInstructionARM::EmulateNop (const uint32_t opcode, const ARMEncoding encoding) +{ + // NOP, nothing to do... + return true; +} + // Branch causes a branch to a target address. bool EmulateInstructionARM::EmulateB (const uint32_t opcode, const ARMEncoding encoding) @@ -12377,7 +12407,13 @@ //---------------------------------------------------------------------- // If Then makes up to four following instructions conditional. //---------------------------------------------------------------------- - { 0xffffff00, 0x0000bf00, ARMvAll, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateIT, "it{{{}}} "}, + // The next 5 opcode _must_ come before the if then instruction + { 0xffffffff, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop"}, + { 0xffffffff, 0x0000bf10, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop YIELD (yield hint)"}, + { 0xffffffff, 0x0000bf20, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop WFE (wait for event hint)"}, + { 0xffffffff, 0x0000bf30, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop WFI (wait for interrupt hint)"}, + { 0xffffffff, 0x0000bf40, ARMV7_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateNop, "nop SEV (send event hint)"}, + { 0xffffff00, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16, &EmulateInstructionARM::EmulateIT, "it{{{}}} "}, //---------------------------------------------------------------------- // Branch instructions Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h Mon May 23 13:04:09 2011 @@ -25,7 +25,7 @@ ~ITSession() {} // InitIT - Initializes ITCounter/ITState. - bool InitIT(unsigned short bits7_0); + bool InitIT(uint32_t bits7_0); // ITAdvance - Updates ITCounter/ITState as IT Block progresses. void ITAdvance(); @@ -370,6 +370,11 @@ const char *name; } ARMOpcode; + uint32_t + GetFramePointerRegisterNumber () const; + + uint32_t + GetFramePointerDWARFRegisterNumber () const; static ARMOpcode* GetARMOpcodeForInstruction (const uint32_t opcode, uint32_t isa_mask); @@ -461,6 +466,10 @@ bool EmulateIT (const uint32_t opcode, const ARMEncoding encoding); + // NOP + bool + EmulateNop (const uint32_t opcode, const ARMEncoding encoding); + // A8.6.16 B bool EmulateB (const uint32_t opcode, const ARMEncoding encoding); Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Mon May 23 13:04:09 2011 @@ -177,6 +177,8 @@ case llvm::Triple::arm: switch (m_exc_code) { + case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break; + case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break; case 1: code_desc = "EXC_ARM_BREAKPOINT"; break; } break; @@ -311,7 +313,13 @@ break; case llvm::Triple::arm: - is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT + if (exc_code == 0x102) + { + // EXC_ARM_DA_DEBUG seems to be reused for EXC_BREAKPOINT as well as EXC_BAD_ACCESS + return StopInfo::CreateStopReasonToTrace(thread); + } + else + is_software_breakpoint = exc_code == 1; // EXC_ARM_BREAKPOINT break; default: Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon May 23 13:04:09 2011 @@ -425,14 +425,16 @@ //ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data) const RegisterInfo *reg_info; - for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx) + // We have to march the offset of each register along in the + // buffer to make sure we get the right offset. + uint32_t reg_byte_offset = 0; + for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx, reg_byte_offset += reg_info->byte_size) { const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; // Only write down the registers that need to be written // if we are going to be doing registers individually. bool write_reg = true; - const uint32_t reg_byte_offset = reg_info->byte_offset; const uint32_t reg_byte_size = reg_info->byte_size; const char *restore_src = (const char *)restore_data.PeekData(reg_byte_offset, reg_byte_size); Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Mon May 23 13:04:09 2011 @@ -2572,7 +2572,7 @@ DEFINE_GPR_IDX ( 4, r4, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX ( 5, r5, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX ( 6, r6, NULL, INVALID_NUB_REGNUM ), - DEFINE_GPR_IDX ( 7, r7, NULL, GENERIC_REGNUM_FP ), + DEFINE_GPR_IDX ( 7, r7, "fp", GENERIC_REGNUM_FP ), DEFINE_GPR_IDX ( 8, r8, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX ( 9, r9, NULL, INVALID_NUB_REGNUM ), DEFINE_GPR_IDX (10, r10, NULL, INVALID_NUB_REGNUM ), Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon May 23 13:04:09 2011 @@ -877,7 +877,23 @@ { 55, 4, "s29", {0}, NULL, 0}, { 56, 4, "s30", {0}, NULL, 0}, { 57, 4, "s31", {0}, NULL, 0}, - { 58, 4, "fpscr", {0}, NULL, 0} + { 58, 4, "fpscr", {0}, NULL, 0}, + { 59, 8, "d16", {0}, NULL, 0}, + { 60, 8, "d17", {0}, NULL, 0}, + { 61, 8, "d18", {0}, NULL, 0}, + { 62, 8, "d19", {0}, NULL, 0}, + { 63, 8, "d20", {0}, NULL, 0}, + { 64, 8, "d21", {0}, NULL, 0}, + { 65, 8, "d22", {0}, NULL, 0}, + { 66, 8, "d23", {0}, NULL, 0}, + { 67, 8, "d24", {0}, NULL, 0}, + { 68, 8, "d25", {0}, NULL, 0}, + { 69, 8, "d26", {0}, NULL, 0}, + { 70, 8, "d27", {0}, NULL, 0}, + { 71, 8, "d28", {0}, NULL, 0}, + { 72, 8, "d29", {0}, NULL, 0}, + { 73, 8, "d30", {0}, NULL, 0}, + { 74, 8, "d31", {0}, NULL, 0} }; register_map_entry_t Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=131911&r1=131910&r2=131911&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Mon May 23 13:04:09 2011 @@ -831,7 +831,36 @@ RNBRunLoopMode start_mode = eRNBRunLoopModeExit; - while ((ch = getopt_long(argc, argv, "a:A:d:gi:vktl:f:w:x:rs:nu:", g_long_options, &long_option_index)) != -1) + char short_options[512]; + uint32_t short_options_idx = 0; + + // Handle the two case that don't have short options in g_long_options + short_options[short_options_idx++] = 'k'; + short_options[short_options_idx++] = 't'; + + for (i=0; g_long_options[i].name != NULL; ++i) + { + if (isalpha(g_long_options[i].val)) + { + short_options[short_options_idx++] = g_long_options[i].val; + switch (g_long_options[i].has_arg) + { + default: + case no_argument: + break; + + case optional_argument: + short_options[short_options_idx++] = ':'; + // Fall through to required_argument case below... + case required_argument: + short_options[short_options_idx++] = ':'; + break; + } + } + } + // NULL terminate the short option string. + short_options[short_options_idx++] = '\0'; + while ((ch = getopt_long(argc, argv, short_options, g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, From johnny.chen at apple.com Mon May 23 14:41:31 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 23 May 2011 19:41:31 -0000 Subject: [Lldb-commits] [lldb] r131913 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110523194131.961062A6C12C@llvm.org> Author: johnny Date: Mon May 23 14:41:31 2011 New Revision: 131913 URL: http://llvm.org/viewvc/llvm-project?rev=131913&view=rev Log: Add more workarounds for "bl #..." and "blx #..." where the ARMAsmParser fails to parse/recognize the (PC-relative) immediate operand. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp 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=131913&r1=131912&r2=131913&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon May 23 14:41:31 2011 @@ -328,6 +328,7 @@ if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "b") { const char *inst_str; const char *pos = NULL; + operands.Clear(); comment.Clear(); if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { uint64_t operand_value = PC + atoi(++pos); operands.Printf("0x%llx ", operand_value); @@ -345,6 +346,33 @@ } } } + // Yet more workaround for "bl #..." and "blx #...". + if ((m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb) && + (opcode.GetString() == "bl" || opcode.GetString() == "blx")) { + const char *inst_str; + const char *pos = NULL; + operands.Clear(); comment.Clear(); + if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { + uint64_t operand_value = PC + atoi(++pos); + // Put the address value into the comment + comment.Printf("0x%llx ", operand_value); + llvm::StringRef string_ref(pos - 1); + llvm::StringRef operand_string_ref = string_ref.split('\n').first; + operands.PutCString(operand_string_ref.str().c_str()); + + lldb_private::Address so_addr; + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) { + if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } else { + Module *module = GetAddress().GetModule(); + if (module) { + if (module->ResolveFileAddress (operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } + } + } + } // END of workaround. // If both operands and comment are empty, we will just print out From gclayton at apple.com Mon May 23 15:06:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 23 May 2011 20:06:52 -0000 Subject: [Lldb-commits] [lldb] r131914 - in /lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD: DynamicLoaderMacOSXDYLD.cpp DynamicLoaderMacOSXDYLD.h Message-ID: <20110523200652.A723B2A6C12C@llvm.org> Author: gclayton Date: Mon May 23 15:06:52 2011 New Revision: 131914 URL: http://llvm.org/viewvc/llvm-project?rev=131914&view=rev Log: Calculate the dyld slide from all in memory info without having to use the lldb module. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h 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=131914&r1=131913&r2=131914&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon May 23 15:06:52 2011 @@ -360,40 +360,6 @@ SectionList *section_list = image_object_file->GetSectionList (); if (section_list) { - // All sections listed in the dyld image info structure will all - // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. - - // Determine the slide amount (if any) - info.slide = 0; - const size_t num_sections = section_list->GetSize(); - size_t sect_idx = 0; - for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) - { - // Iterate through the object file sections to find the - // first section that starts of file offset zero and that - // has bytes in the file... - Section *section = section_list->GetSectionAtIndex (sect_idx).get(); - if (section) - { - // Find the first section that begins at file offset zero - // a file size (skip page zero). - if (section->GetFileOffset() == 0 && section->GetFileSize() > 0) - { - // We have now found the section, lets match it up - // with the section in the dyld image info structure. - const Segment *dyld_segment = info.FindSegment (section->GetName()); - if (dyld_segment) - info.slide = info.address - dyld_segment->addr; - // We have found the slide amount, so we can exit - // this for loop. - break; - } - } - } - // We now know the slide amount, so go through all sections // and update the load addresses with the correct values. uint32_t num_segments = info.segments.size(); @@ -401,7 +367,7 @@ { SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name)); assert (section_sp.get() != NULL); - const addr_t new_section_load_addr = info.segments[i].addr + info.slide; + const addr_t new_section_load_addr = info.segments[i].vmaddr + info.slide; const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get()); if (old_section_load_addr == LLDB_INVALID_ADDRESS || old_section_load_addr != new_section_load_addr) @@ -437,7 +403,7 @@ { SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name)); assert (section_sp.get() != NULL); - const addr_t old_section_load_addr = info.segments[i].addr + info.slide; + const addr_t old_section_load_addr = info.segments[i].vmaddr + info.slide; if (m_process->GetTarget().GetSectionLoadList().SetSectionUnloaded (section_sp.get(), old_section_load_addr)) changed = true; } @@ -912,8 +878,14 @@ case llvm::MachO::LoadCommandSegment32: { segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); - segment.addr = data.GetU32 (&offset); - segment.size = data.GetU32 (&offset); + // We are putting 4 uint32_t values 4 uint64_t values so + // we have to use multiple 32 bit gets below. + segment.vmaddr = data.GetU32 (&offset); + segment.vmsize = data.GetU32 (&offset); + segment.fileoff = data.GetU32 (&offset); + segment.filesize = data.GetU32 (&offset); + // Extract maxprot, initprot, nsects and flags all at once + data.GetU32(&offset, &segment.maxprot, 4); dylib_info.segments.push_back (segment); } break; @@ -921,8 +893,10 @@ case llvm::MachO::LoadCommandSegment64: { segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); - segment.addr = data.GetU64 (&offset); - segment.size = data.GetU64 (&offset); + // Extract vmaddr, vmsize, fileoff, and filesize all at once + data.GetU64(&offset, &segment.vmaddr, 4); + // Extract maxprot, initprot, nsects and flags all at once + data.GetU32(&offset, &segment.maxprot, 4); dylib_info.segments.push_back (segment); } break; @@ -947,6 +921,28 @@ offset = load_cmd_offset + load_cmd.cmdsize; } } + + // All sections listed in the dyld image info structure will all + // either be fixed up already, or they will all be off by a single + // slide amount that is determined by finding the first segment + // that is at file offset zero which also has bytes (a file size + // that is greater than zero) in the object file. + + // Determine the slide amount (if any) + const size_t num_sections = dylib_info.segments.size(); + for (size_t i = 0; i < num_sections; ++i) + { + // Iterate through the object file sections to find the + // first section that starts of file offset zero and that + // has bytes in the file... + if (dylib_info.segments[i].fileoff == 0 && dylib_info.segments[i].filesize > 0) + { + dylib_info.slide = dylib_info.address - dylib_info.segments[i].vmaddr; + // We have found the slide amount, so we can exit + // this for loop. + break; + } + } return cmd_idx; } @@ -1011,7 +1007,19 @@ DynamicLoaderMacOSXDYLD::Segment::PutToLog (Log *log, lldb::addr_t slide) const { if (log) - log->Printf("\t\t%16s [0x%16.16llx - 0x%16.16llx)", name.AsCString(""), addr + slide, addr + slide + size); + { + if (slide == 0) + log->Printf ("\t\t%16s [0x%16.16llx - 0x%16.16llx)", + name.AsCString(""), + vmaddr + slide, + vmaddr + slide + vmsize); + else + log->Printf ("\t\t%16s [0x%16.16llx - 0x%16.16llx) slide = 0x%llx", + name.AsCString(""), + vmaddr + slide, + vmaddr + slide + vmsize, + slide); + } } const DynamicLoaderMacOSXDYLD::Segment * 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=131914&r1=131913&r2=131914&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Mon May 23 15:06:52 2011 @@ -168,19 +168,31 @@ Segment() : name(), - addr(LLDB_INVALID_ADDRESS), - size(0) + vmaddr(LLDB_INVALID_ADDRESS), + vmsize(0), + fileoff(0), + filesize(0), + maxprot(0), + initprot(0), + nsects(0), + flags(0) { } lldb_private::ConstString name; - lldb::addr_t addr; - lldb::addr_t size; + lldb::addr_t vmaddr; + lldb::addr_t vmsize; + lldb::addr_t fileoff; + lldb::addr_t filesize; + uint32_t maxprot; + uint32_t initprot; + uint32_t nsects; + uint32_t flags; bool operator==(const Segment& rhs) const { - return name == rhs.name && addr == rhs.addr && size == rhs.size; + return name == rhs.name && vmaddr == rhs.vmaddr && vmsize == rhs.vmsize; } void From scallanan at apple.com Mon May 23 16:40:23 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 23 May 2011 21:40:23 -0000 Subject: [Lldb-commits] [lldb] r131923 - in /lldb/trunk: ./ include/lldb/Expression/ lldb.xcodeproj/ scripts/ source/Expression/ Message-ID: <20110523214023.AA1E12A6C12C@llvm.org> Author: spyffe Date: Mon May 23 16:40:23 2011 New Revision: 131923 URL: http://llvm.org/viewvc/llvm-project?rev=131923&view=rev Log: This commit integrates support for the LLVM MCJIT into the mainline LLDB codebase. MCJIT introduces API improvements and better architectural support. This commit adds a new subsystem, the ProcessDataAllocator, which is responsible for performing static data allocations on behalf of the IR transformer. MCJIT currently does not support the relocations required to store the constant pool in the same allocation as the function body, so we allocate a heap region separately and redirect static data references from the expression to that heap region in a new IR modification pass. This patch also fixes bugs in the IR transformations that were exposed by the transition to the MCJIT. Finally, the patch also pulls in a more recent revision of LLVM so that the MCJIT is available for use. Added: lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h lldb/trunk/source/Expression/ProcessDataAllocator.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/scripts/checkpoint-llvm.pl lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Mon May 23 16:40:23 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/Error.h" +#include "lldb/Expression/IRForTarget.h" #include #include @@ -102,6 +103,9 @@ /// @param[in] exe_ctx /// The execution context to write the function into. /// + /// @param[in] data_allocator + /// If non-NULL, he static data allocator to use for literal strings. + /// /// @param[out] const_result /// If the result of the expression is constant, and the /// expression has no side effects, this is set to the result of the @@ -120,6 +124,7 @@ lldb::addr_t &func_addr, lldb::addr_t &func_end, ExecutionContext &exe_ctx, + IRForTarget::StaticDataAllocator *data_allocator, lldb::ClangExpressionVariableSP &const_result, bool jit_only_if_needed = false); Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon May 23 16:40:23 2011 @@ -25,6 +25,8 @@ #include "lldb/Core/ClangForward.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionVariable.h" +#include "lldb/Expression/IRForTarget.h" +#include "lldb/Expression/ProcessDataAllocator.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Process.h" @@ -285,6 +287,7 @@ //------------------------------------------------------------------ /// Populate m_cplusplus and m_objetivec based on the environment. //------------------------------------------------------------------ + void ScanContext(ExecutionContext &exe_ctx); @@ -303,6 +306,7 @@ std::auto_ptr m_expr_decl_map; ///< The map to use when parsing and materializing the expression. std::auto_ptr m_local_variables; ///< The local expression variables, if the expression is DWARF. std::auto_ptr m_dwarf_opcodes; ///< The DWARF opcodes for the expression. May be NULL. + std::auto_ptr m_data_allocator; ///< The allocator that the parser uses to place strings for use by JIT-compiled code. 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). Modified: lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h Mon May 23 16:40:23 2011 @@ -24,6 +24,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/ClangForward.h" #include "lldb/Expression/ClangExpression.h" +#include "lldb/Expression/ProcessDataAllocator.h" namespace lldb_private { @@ -179,6 +180,7 @@ private: std::auto_ptr m_expr_decl_map; ///< The map to use when parsing and materializing the expression. + std::auto_ptr m_data_allocator; ///< The allocator for static data used in the expression. std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit. std::string m_function_name; ///< The name of the function. Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Mon May 23 16:40:23 2011 @@ -20,12 +20,14 @@ class BasicBlock; class CallInst; class Constant; + class ConstantInt; class Function; class GlobalValue; class GlobalVariable; class Instruction; class Module; class StoreInst; + class Type; class Value; } @@ -50,6 +52,14 @@ class IRForTarget : public llvm::ModulePass { public: + class StaticDataAllocator { + public: + StaticDataAllocator(); + virtual ~StaticDataAllocator(); + virtual lldb_private::StreamString &GetStream() = 0; + virtual lldb::addr_t Allocate() = 0; + }; + //------------------------------------------------------------------ /// Constructor /// @@ -68,6 +78,9 @@ /// of the function, if it has no side-effects and the result can /// be computed statically. /// + /// @param[in] data_allocator + /// If non-NULL, the static data allocator to use for literal strings. + /// /// @param[in] error_stream /// If non-NULL, a stream on which errors can be printed. /// @@ -77,6 +90,7 @@ IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, bool resolve_vars, lldb::ClangExpressionVariableSP &const_result, + StaticDataAllocator *data_allocator, lldb_private::Stream *error_stream, const char* func_name = "$__lldb_expr"); @@ -122,6 +136,19 @@ private: //------------------------------------------------------------------ + /// Ensures that the current function's linkage is set to external. + /// Otherwise the JIT may not return an address for it. + /// + /// @param[in] llvm_function + /// The function whose linkage is to be fixed. + /// + /// @return + /// True on success; false otherwise. + //------------------------------------------------------------------ + bool + FixFunctionLinkage (llvm::Function &llvm_function); + + //------------------------------------------------------------------ /// A function-level pass to check whether the function has side /// effects. //------------------------------------------------------------------ @@ -129,9 +156,6 @@ //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] llvm_function /// The function currently being processed. /// @@ -140,8 +164,7 @@ /// be determined); false otherwise. //------------------------------------------------------------------ bool - HasSideEffects (llvm::Module &llvm_module, - llvm::Function &llvm_function); + HasSideEffects (llvm::Function &llvm_function); //------------------------------------------------------------------ /// A function-level pass to take the generated global value @@ -154,9 +177,6 @@ /// constant, assuming it can be evaluated. The result variable /// will be reset to NULL later if the expression has side effects. /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] global /// The global entity to search for /// @@ -164,8 +184,7 @@ /// The corresponding variable declaration //------------------------------------------------------------------ clang::NamedDecl * - DeclForGlobal (llvm::Module &llvm_module, - llvm::GlobalValue *global); + DeclForGlobal (llvm::GlobalValue *global); //------------------------------------------------------------------ /// Set the constant result variable m_const_result to the provided @@ -191,22 +210,15 @@ /// to the result of the cast. The result variable will be reset to /// NULL latger if the expression has side effects. /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] type /// The Clang type of the result variable. //------------------------------------------------------------------ void - MaybeSetCastResult (llvm::Module &llvm_module, - lldb_private::TypeFromParser type); + MaybeSetCastResult (lldb_private::TypeFromParser type); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] llvm_function /// The function currently being processed. /// @@ -214,8 +226,7 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - CreateResultVariable (llvm::Module &llvm_module, - llvm::Function &llvm_function); + CreateResultVariable (llvm::Function &llvm_function); //------------------------------------------------------------------ /// A function-level pass to find Objective-C constant strings and @@ -225,9 +236,6 @@ //------------------------------------------------------------------ /// Rewrite a single Objective-C constant string. /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] NSStr /// The constant NSString to be transformed /// @@ -246,17 +254,13 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - RewriteObjCConstString (llvm::Module &llvm_module, - llvm::GlobalVariable *NSStr, + RewriteObjCConstString (llvm::GlobalVariable *NSStr, llvm::GlobalVariable *CStr, llvm::Instruction *FirstEntryInstruction); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] llvm_function /// The function currently being processed. /// @@ -264,8 +268,7 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - RewriteObjCConstStrings (llvm::Module &llvm_module, - llvm::Function &llvm_function); + RewriteObjCConstStrings (llvm::Function &llvm_function); //------------------------------------------------------------------ /// A basic block-level pass to find all Objective-C method calls and @@ -284,22 +287,15 @@ /// @param[in] selector_load /// The load of the statically-allocated selector. /// - /// @param[in] llvm_module - /// The module containing the load. - /// /// @return /// True on success; false otherwise //------------------------------------------------------------------ bool - RewriteObjCSelector (llvm::Instruction* selector_load, - llvm::Module &llvm_module); + RewriteObjCSelector (llvm::Instruction* selector_load); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] basic_block /// The basic block currently being processed. /// @@ -307,8 +303,7 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - RewriteObjCSelectors (llvm::Module &llvm_module, - llvm::BasicBlock &basic_block); + RewriteObjCSelectors (llvm::BasicBlock &basic_block); //------------------------------------------------------------------ /// A basic block-level pass to find all newly-declared persistent @@ -327,28 +322,20 @@ /// @param[in] persistent_alloc /// The allocation of the persistent variable. /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @return /// True on success; false otherwise //------------------------------------------------------------------ bool - RewritePersistentAlloc (llvm::Instruction *persistent_alloc, - llvm::Module &llvm_module); + RewritePersistentAlloc (llvm::Instruction *persistent_alloc); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] basic_block /// The basic block currently being processed. //------------------------------------------------------------------ bool - RewritePersistentAllocs (llvm::Module &llvm_module, - llvm::BasicBlock &basic_block); + RewritePersistentAllocs (llvm::BasicBlock &basic_block); //------------------------------------------------------------------ /// A function-level pass to find all external variables and functions @@ -361,9 +348,6 @@ //------------------------------------------------------------------ /// Handle a single externally-defined variable /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] value /// The variable. /// @@ -371,15 +355,11 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - MaybeHandleVariable (llvm::Module &llvm_module, - llvm::Value *value); + MaybeHandleVariable (llvm::Value *value); //------------------------------------------------------------------ /// Handle a single externally-defined symbol /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] symbol /// The symbol. /// @@ -387,15 +367,11 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - HandleSymbol (llvm::Module &llvm_module, - llvm::Value *symbol); + HandleSymbol (llvm::Value *symbol); //------------------------------------------------------------------ /// Handle all the arguments to a function call /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] C /// The call instruction. /// @@ -403,15 +379,11 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - MaybeHandleCallArguments (llvm::Module &llvm_module, - llvm::CallInst *call_inst); + MaybeHandleCallArguments (llvm::CallInst *call_inst); //------------------------------------------------------------------ /// Handle a single external function call /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] C /// The call instruction. /// @@ -419,15 +391,11 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - MaybeHandleCall (llvm::Module &llvm_module, - llvm::CallInst *C); + MaybeHandleCall (llvm::CallInst *C); //------------------------------------------------------------------ /// Resolve calls to external functions /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] basic_block /// The basic block currently being processed. /// @@ -435,15 +403,11 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - ResolveCalls (llvm::Module &llvm_module, - llvm::BasicBlock &basic_block); + ResolveCalls (llvm::BasicBlock &basic_block); //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] basic_block /// The function currently being processed. /// @@ -451,8 +415,7 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - ResolveExternals (llvm::Module &llvm_module, - llvm::Function &llvm_function); + ResolveExternals (llvm::Function &llvm_function); //------------------------------------------------------------------ /// A basic block-level pass to excise guard variables from the code. @@ -462,10 +425,48 @@ //------------------------------------------------------------------ //------------------------------------------------------------------ + /// Rewrite a load to a guard variable to return constant 0. + /// + /// @param[in] guard_load + /// The load instruction to zero out. + //------------------------------------------------------------------ + void + TurnGuardLoadIntoZero(llvm::Instruction* guard_load); + + //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. + /// @param[in] basic_block + /// The basic block currently being processed. + /// + /// @return + /// True on success; false otherwise + //------------------------------------------------------------------ + bool + RemoveGuards (llvm::BasicBlock &basic_block); + + //------------------------------------------------------------------ + /// A module-level pass to allocate all string literals in a separate + /// allocation and redirect references to them. + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + /// The top-level pass implementation + /// + /// @return + /// True on success; false otherwise + //------------------------------------------------------------------ + bool + ReplaceStrings (); + + //------------------------------------------------------------------ + /// A basick block-level pass to find all literals that will be + /// allocated as statics by the JIT (in contrast to the Strings, + /// which already are statics) and synthesize loads for them. + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + /// The top-level pass implementation /// /// @param[in] basic_block /// The basic block currently being processed. @@ -474,8 +475,7 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - RemoveGuards (llvm::Module &llvm_module, - llvm::BasicBlock &basic_block); + ReplaceStaticLiterals (llvm::BasicBlock &basic_block); //------------------------------------------------------------------ /// A function-level pass to make all external variable references @@ -487,9 +487,6 @@ //------------------------------------------------------------------ /// The top-level pass implementation /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] llvm_function /// The function currently being processed. /// @@ -497,14 +494,15 @@ /// True on success; false otherwise //------------------------------------------------------------------ bool - ReplaceVariables (llvm::Module &llvm_module, - llvm::Function &llvm_function); + ReplaceVariables (llvm::Function &llvm_function); /// Flags bool m_resolve_vars; ///< True if external variable references and persistent variable references should be resolved std::string m_func_name; ///< The name of the function to translate lldb_private::ConstString m_result_name; ///< The name of the result variable ($0, $1, ...) + llvm::Module *m_module; ///< The module being processed, or NULL if that has not been determined yet. lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls + StaticDataAllocator *m_data_allocator; ///< If non-NULL, the allocator to use for constant strings llvm::Constant *m_CFStringCreateWithBytes; ///< The address of the function CFStringCreateWithBytes, cast to the appropriate function pointer type llvm::Constant *m_sel_registerName; ///< The address of the function sel_registerName, cast to the appropriate function pointer type lldb::ClangExpressionVariableSP &m_const_result; ///< This value should be set to the return value of the expression if it is constant and the expression has no side effects @@ -514,7 +512,8 @@ llvm::StoreInst *m_result_store; ///< If non-NULL, the store instruction that writes to the result variable. If m_has_side_effects is true, this is NULL. bool m_result_is_pointer; ///< True if the function's result in the AST is a pointer (see comments in ASTResultSynthesizer::SynthesizeBodyResult) -private: + llvm::GlobalVariable *m_reloc_placeholder; ///< A placeholder that will be replaced by a pointer to the final location of the static allocation. + //------------------------------------------------------------------ /// UnfoldConstant operates on a constant [Old] which has just been /// replaced with a value [New]. We assume that new_value has @@ -529,9 +528,6 @@ /// FirstEntryInstruction. These instructions replace the constant /// uses, so UnfoldConstant calls itself recursively for those. /// - /// @param[in] llvm_module - /// The module currently being processed. - /// /// @param[in] llvm_function /// The function currently being processed. /// @@ -542,6 +538,38 @@ UnfoldConstant (llvm::Constant *old_constant, llvm::Value *new_constant, llvm::Instruction *first_entry_inst); + + //------------------------------------------------------------------ + /// Construct a reference to m_reloc_placeholder with a given type + /// and offset. This typically happens after inserting data into + /// m_data_allocator. + /// + /// @param[in] type + /// The type of the value being loaded. + /// + /// @param[in] offset + /// The offset of the value from the base of m_data_allocator. + /// + /// @return + /// The Constant for the reference, usually a ConstantExpr. + //------------------------------------------------------------------ + llvm::Constant * + BuildRelocation(const llvm::Type *type, + uint64_t offset); + + //------------------------------------------------------------------ + /// Commit the allocation in m_data_allocator and use its final + /// location to replace m_reloc_placeholder. + /// + /// @param[in] module + /// The module that m_data_allocator resides in + /// + /// @return + /// True on success; false otherwise + //------------------------------------------------------------------ + bool + CompleteDataAllocation (); + }; #endif Added: lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h?rev=131923&view=auto ============================================================================== --- lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h (added) +++ lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h Mon May 23 16:40:23 2011 @@ -0,0 +1,74 @@ +//===-- ProcessDataAllocator.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ProcessDataAllocator_h_ +#define liblldb_ProcessDataAllocator_h_ + +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private.h" +#include "lldb/Expression/IRForTarget.h" +#include "lldb/Target/Process.h" + +namespace lldb_private +{ + +class ProcessDataAllocator : public IRForTarget::StaticDataAllocator { +public: + ProcessDataAllocator(Process &process) : + IRForTarget::StaticDataAllocator(), + m_process(process), + m_stream_string(StreamString::eBinary, process.GetAddressByteSize(), process.GetByteOrder()), + m_allocation(NULL) + { + } + + ~ProcessDataAllocator() + { + if (m_allocation) + m_process.DeallocateMemory(m_allocation); + } + + lldb_private::StreamString &GetStream() + { + return m_stream_string; + } + + lldb::addr_t Allocate() + { + Error err; + + if (m_allocation) + m_process.DeallocateMemory(m_allocation); + + m_allocation = NULL; + + m_allocation = m_process.AllocateMemory(m_stream_string.GetSize(), lldb::ePermissionsReadable | lldb::ePermissionsWritable, err); + + if (!err.Success()) + return NULL; + + if (m_allocation) + m_process.WriteMemory(m_allocation, m_stream_string.GetData(), m_stream_string.GetSize(), err); + + if (!err.Success()) + return NULL; + + return m_allocation; + } + + void Dump(lldb_private::Stream &stream); +private: + Process &m_process; + StreamString m_stream_string; + lldb::addr_t m_allocation; +}; + +} // namespace lldb_private + +#endif \ No newline at end of file Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon May 23 16:40:23 2011 @@ -393,6 +393,8 @@ 26F5C32D10F3DFDD009D5894 /* libtermcap.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C32B10F3DFDD009D5894 /* libtermcap.dylib */; }; 26F5C37510F3F61B009D5894 /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C37410F3F61B009D5894 /* libobjc.dylib */; }; 26F5C39110F3FA26009D5894 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26F5C39010F3FA26009D5894 /* CoreFoundation.framework */; }; + 49C850771384A02F007DB519 /* ProcessDataAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C850761384A02F007DB519 /* ProcessDataAllocator.h */; }; + 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */; }; 4C74CB6312288704006A8171 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C74CB6212288704006A8171 /* Carbon.framework */; }; 4CABA9E0134A8BCD00539BDD /* ValueObjectMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CABA9DF134A8BCD00539BDD /* ValueObjectMemory.cpp */; }; 4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */; }; @@ -1073,6 +1075,8 @@ 49A8A39F11D568A300AD3B68 /* ASTResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTResultSynthesizer.cpp; path = source/Expression/ASTResultSynthesizer.cpp; sourceTree = ""; }; 49A8A3A311D568BF00AD3B68 /* ASTResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTResultSynthesizer.h; path = include/lldb/Expression/ASTResultSynthesizer.h; sourceTree = ""; }; 49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = ""; }; + 49C850761384A02F007DB519 /* ProcessDataAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessDataAllocator.h; path = include/lldb/Expression/ProcessDataAllocator.h; sourceTree = ""; }; + 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProcessDataAllocator.cpp; path = source/Expression/ProcessDataAllocator.cpp; sourceTree = ""; }; 49CF9829122C70BD007A0B96 /* IRDynamicChecks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRDynamicChecks.cpp; path = source/Expression/IRDynamicChecks.cpp; sourceTree = ""; }; 49CF9833122C718B007A0B96 /* IRDynamicChecks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRDynamicChecks.h; path = include/lldb/Expression/IRDynamicChecks.h; sourceTree = ""; }; 49D4FE821210B5FB00CDB854 /* ClangPersistentVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangPersistentVariables.h; path = include/lldb/Expression/ClangPersistentVariables.h; sourceTree = ""; }; @@ -2155,6 +2159,8 @@ 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */, 4C98D3E1118FB98F00E575D0 /* RecordingMemoryManager.h */, 4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */, + 49C850761384A02F007DB519 /* ProcessDataAllocator.h */, + 49C850781384A0CA007DB519 /* ProcessDataAllocator.cpp */, ); name = Expression; sourceTree = ""; @@ -2605,6 +2611,7 @@ 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */, 26D265A2136B40EE002EEE45 /* SharingPtr.h in Headers */, 26D265BC136B4269002EEE45 /* lldb-public.h in Headers */, + 49C850771384A02F007DB519 /* ProcessDataAllocator.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2894,6 +2901,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 49C8507C1384A786007DB519 /* ProcessDataAllocator.cpp in Sources */, 2689FFDA13353D9D00698AC0 /* lldb.cpp in Sources */, 2689FFDB13353DA300698AC0 /* lldb-log.cpp in Sources */, 2689FFEF13353DB600698AC0 /* Breakpoint.cpp in Sources */, Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Mon May 23 16:40:23 2011 @@ -26,7 +26,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "131389"; +our $llvm_revision = "131657"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); @@ -70,6 +70,9 @@ "$llvm_configuration/lib/libLLVMMC.a", "$llvm_configuration/lib/libLLVMMCParser.a", "$llvm_configuration/lib/libLLVMMCDisassembler.a", + "$llvm_configuration/lib/libLLVMMCJIT.a", + "$llvm_configuration/lib/libLLVMObject.a", + "$llvm_configuration/lib/libLLVMRuntimeDyld.a", "$llvm_configuration/lib/libLLVMScalarOpts.a", "$llvm_configuration/lib/libLLVMSelectionDAG.a", "$llvm_configuration/lib/libLLVMSupport.a", Modified: lldb/trunk/scripts/checkpoint-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/checkpoint-llvm.pl?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/scripts/checkpoint-llvm.pl (original) +++ lldb/trunk/scripts/checkpoint-llvm.pl Mon May 23 16:40:23 2011 @@ -97,5 +97,5 @@ else { print "USAGE\n\tcheckpoint-llvm.pl \n\n"; - print "EXAMPLE\n\tcd lldb\n\t./scripts/checkpoint-llvm.pl llvm build/lldb.build/BuildAndIntegration/lldb-core.build/DerivedSources/llvm.build build/BuildAndIntegration llvm.zip\n"; + print "EXAMPLE\n\tcd lldb\n\t./scripts/checkpoint-llvm.pl llvm build/llvm build/BuildAndIntegration llvm.zip\n"; } Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Mon May 23 16:40:23 2011 @@ -19,7 +19,6 @@ #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/IRDynamicChecks.h" -#include "lldb/Expression/IRForTarget.h" #include "lldb/Expression/IRToDWARF.h" #include "lldb/Expression/RecordingMemoryManager.h" #include "lldb/Target/ExecutionContext.h" @@ -53,7 +52,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#define USE_STANDARD_JIT +//#define USE_STANDARD_JIT #if defined (USE_STANDARD_JIT) #include "llvm/ExecutionEngine/JIT.h" #else @@ -472,6 +471,7 @@ lldb::addr_t &func_addr, lldb::addr_t &func_end, ExecutionContext &exe_ctx, + IRForTarget::StaticDataAllocator *data_allocator, lldb::ClangExpressionVariableSP &const_result, bool jit_only_if_needed) { @@ -519,6 +519,7 @@ IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(), const_result, + data_allocator, error_stream, function_name.c_str()); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon May 23 16:40:23 2011 @@ -253,7 +253,7 @@ lldb::ClangExpressionVariableSP const_result; - Error jit_error (m_parser->MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, const_result)); + Error jit_error (m_parser->MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, NULL, const_result)); if (!jit_error.Success()) return false; Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon May 23 16:40:23 2011 @@ -1,4 +1,4 @@ -//===-- ClangUserExpression.cpp -------------------------------------*- C++ -*-===// +//===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -284,7 +284,17 @@ m_dwarf_opcodes.reset(); - Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, m_const_result, true); + m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process)); + + Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, m_data_allocator.get(), m_const_result, true); + + if (log) + { + StreamString dump_string; + m_data_allocator->Dump(dump_string); + + log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str()); + } m_expr_decl_map->DidParse(); Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Mon May 23 16:40:23 2011 @@ -16,6 +16,7 @@ // C++ Includes #include "lldb/Core/ConstString.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Expression/ClangExpressionDeclMap.h" @@ -64,6 +65,8 @@ ClangUtilityFunction::Install (Stream &error_stream, ExecutionContext &exe_ctx) { + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + if (m_jit_start_addr != LLDB_INVALID_ADDRESS) { error_stream.PutCString("error: already installed\n"); @@ -81,6 +84,14 @@ error_stream.PutCString ("error: invalid target\n"); return false; } + + Process *process = exe_ctx.process; + + if (!process) + { + error_stream.PutCString ("error: invalid process\n"); + return false; + } ////////////////////////// // Parse the expression @@ -90,6 +101,8 @@ m_expr_decl_map.reset(new ClangExpressionDeclMap(keep_result_in_memory)); + m_data_allocator.reset(new ProcessDataAllocator(*exe_ctx.process)); + m_expr_decl_map->WillParse(exe_ctx); ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this); @@ -110,8 +123,17 @@ // lldb::ClangExpressionVariableSP const_result; + + + Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, m_data_allocator.get(), const_result); + + if (log) + { + StreamString dump_string; + m_data_allocator->Dump(dump_string); - Error jit_error = parser.MakeJIT (m_jit_alloc, m_jit_start_addr, m_jit_end_addr, exe_ctx, const_result); + log->Printf("Data buffer contents:\n%s", dump_string.GetString().c_str()); + } if (exe_ctx.process && m_jit_start_addr != LLDB_INVALID_ADDRESS) m_jit_process_sp = exe_ctx.process->GetSP(); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=131923&r1=131922&r2=131923&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Mon May 23 16:40:23 2011 @@ -26,6 +26,7 @@ #include "lldb/Core/Scalar.h" #include "lldb/Core/StreamString.h" #include "lldb/Expression/ClangExpressionDeclMap.h" +#include "lldb/Host/Endian.h" #include "lldb/Symbol/ClangASTContext.h" #include @@ -34,22 +35,34 @@ static char ID; +IRForTarget::StaticDataAllocator::StaticDataAllocator() +{ +} + +IRForTarget::StaticDataAllocator::~StaticDataAllocator() +{ +} + IRForTarget::IRForTarget (lldb_private::ClangExpressionDeclMap *decl_map, bool resolve_vars, lldb::ClangExpressionVariableSP &const_result, + StaticDataAllocator *data_allocator, lldb_private::Stream *error_stream, const char *func_name) : ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name), m_decl_map(decl_map), + m_module(NULL), m_CFStringCreateWithBytes(NULL), m_sel_registerName(NULL), m_error_stream(error_stream), m_has_side_effects(false), m_result_store(NULL), m_result_is_pointer(false), - m_const_result(const_result) + m_const_result(const_result), + m_data_allocator(data_allocator), + m_reloc_placeholder(NULL) { } @@ -83,9 +96,20 @@ { } +bool +IRForTarget::FixFunctionLinkage(llvm::Function &llvm_function) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + llvm_function.setLinkage(GlobalValue::ExternalLinkage); + + std::string name = llvm_function.getNameStr(); + + return true; +} + bool -IRForTarget::HasSideEffects (llvm::Module &llvm_module, - llvm::Function &llvm_function) +IRForTarget::HasSideEffects (llvm::Function &llvm_function) { llvm::Function::iterator bbi; BasicBlock::iterator ii; @@ -146,11 +170,11 @@ } clang::NamedDecl * -IRForTarget::DeclForGlobal (llvm::Module &module, GlobalValue *global_val) +IRForTarget::DeclForGlobal (GlobalValue *global_val) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - NamedMDNode *named_metadata = module.getNamedMetadata("clang.global.decl.ptrs"); + NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs"); if (!named_metadata) return NULL; @@ -209,7 +233,7 @@ } void -IRForTarget::MaybeSetCastResult (llvm::Module &llvm_module, lldb_private::TypeFromParser type) +IRForTarget::MaybeSetCastResult (lldb_private::TypeFromParser type) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -253,7 +277,7 @@ if (!loaded_global) return; - clang::NamedDecl *loaded_decl = DeclForGlobal(llvm_module, loaded_global); + clang::NamedDecl *loaded_decl = DeclForGlobal(loaded_global); if (!loaded_decl) return; @@ -275,7 +299,7 @@ } bool -IRForTarget::CreateResultVariable (llvm::Module &llvm_module, llvm::Function &llvm_function) +IRForTarget::CreateResultVariable (llvm::Function &llvm_function) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -284,7 +308,7 @@ // Find the result variable. If it doesn't exist, we can give up right here. - ValueSymbolTable& value_symbol_table = llvm_module.getValueSymbolTable(); + ValueSymbolTable& value_symbol_table = m_module->getValueSymbolTable(); const char *result_name = NULL; @@ -320,7 +344,7 @@ if (log) log->Printf("Result name: \"%s\"", result_name); - Value *result_value = llvm_module.getNamedValue(result_name); + Value *result_value = m_module->getNamedValue(result_name); if (!result_value) { @@ -349,7 +373,7 @@ return false; } - clang::NamedDecl *result_decl = DeclForGlobal (llvm_module, result_global); + clang::NamedDecl *result_decl = DeclForGlobal (result_global); if (!result_decl) { if (log) @@ -433,7 +457,7 @@ // Construct a new result global and set up its metadata - GlobalVariable *new_result_global = new GlobalVariable(llvm_module, + GlobalVariable *new_result_global = new GlobalVariable((*m_module), result_global->getType()->getElementType(), false, /* not constant */ GlobalValue::ExternalLinkage, @@ -447,7 +471,7 @@ // ClangExpressionDeclMap::DoMaterialize, and the name of the variable is // fixed up. - ConstantInt *new_constant_int = ConstantInt::get(llvm::Type::getInt64Ty(llvm_module.getContext()), + ConstantInt *new_constant_int = ConstantInt::get(llvm::Type::getInt64Ty(m_module->getContext()), reinterpret_cast(result_decl), false); @@ -457,8 +481,8 @@ ArrayRef value_ref(values, 2); - MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), value_ref); - NamedMDNode *named_metadata = llvm_module.getNamedMetadata("clang.global.decl.ptrs"); + MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); + NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs"); named_metadata->addOperand(persistent_global_md); if (log) @@ -511,7 +535,7 @@ { if (!m_has_side_effects && lldb_private::ClangASTContext::IsPointerType (result_decl_type.GetOpaqueQualType())) { - MaybeSetCastResult (llvm_module, result_decl_type); + MaybeSetCastResult (result_decl_type); } result_global->replaceAllUsesWith(new_result_global); @@ -550,18 +574,19 @@ } bool -IRForTarget::RewriteObjCConstString (llvm::Module &llvm_module, - llvm::GlobalVariable *ns_str, +IRForTarget::RewriteObjCConstString (llvm::GlobalVariable *ns_str, llvm::GlobalVariable *cstr, Instruction *FirstEntryInstruction) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - const Type *i8_ptr_ty = Type::getInt8PtrTy(llvm_module.getContext()); - const IntegerType *intptr_ty = Type::getIntNTy(llvm_module.getContext(), - (llvm_module.getPointerSize() == Module::Pointer64) ? 64 : 32); - const Type *i32_ty = Type::getInt32Ty(llvm_module.getContext()); - const Type *i8_ty = Type::getInt8Ty(llvm_module.getContext()); + const Type *ns_str_ty = ns_str->getType(); + + const Type *i8_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + const Type *i32_ty = Type::getInt32Ty(m_module->getContext()); + const Type *i8_ty = Type::getInt8Ty(m_module->getContext()); if (!m_CFStringCreateWithBytes) { @@ -608,7 +633,7 @@ CFSCWB_arg_types.push_back(intptr_ty); CFSCWB_arg_types.push_back(i32_ty); CFSCWB_arg_types.push_back(i8_ty); - llvm::Type *CFSCWB_ty = FunctionType::get(i8_ptr_ty, CFSCWB_arg_types, false); + llvm::Type *CFSCWB_ty = FunctionType::get(ns_str_ty, CFSCWB_arg_types, false); // Build the constant containing the pointer to the function PointerType *CFSCWB_ptr_ty = PointerType::getUnqual(CFSCWB_ty); @@ -660,11 +685,11 @@ } bool -IRForTarget::RewriteObjCConstStrings(Module &llvm_module, Function &llvm_function) +IRForTarget::RewriteObjCConstStrings(Function &llvm_function) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - ValueSymbolTable& value_symbol_table = llvm_module.getValueSymbolTable(); + ValueSymbolTable& value_symbol_table = m_module->getValueSymbolTable(); BasicBlock &entry_block(llvm_function.getEntryBlock()); Instruction *FirstEntryInstruction(entry_block.getFirstNonPHIOrDbg()); @@ -845,7 +870,7 @@ if (!cstr_array) cstr_global = NULL; - if (!RewriteObjCConstString(llvm_module, nsstring_global, cstr_global, FirstEntryInstruction)) + if (!RewriteObjCConstString(nsstring_global, cstr_global, FirstEntryInstruction)) { if (log) log->PutCString("Error rewriting the constant string"); @@ -897,7 +922,7 @@ // This function does not report errors; its callers are responsible. bool -IRForTarget::RewriteObjCSelector (Instruction* selector_load, Module &llvm_module) +IRForTarget::RewriteObjCSelector (Instruction* selector_load) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -970,17 +995,17 @@ // Build the function type: struct objc_selector *sel_registerName(uint8_t*) // The below code would be "more correct," but in actuality what's required is uint8_t* - //Type *sel_type = StructType::get(llvm_module.getContext()); + //Type *sel_type = StructType::get(m_module->getContext()); //Type *sel_ptr_type = PointerType::getUnqual(sel_type); - const Type *sel_ptr_type = Type::getInt8PtrTy(llvm_module.getContext()); + const Type *sel_ptr_type = Type::getInt8PtrTy(m_module->getContext()); std::vector srN_arg_types; - srN_arg_types.push_back(Type::getInt8PtrTy(llvm_module.getContext())); + srN_arg_types.push_back(Type::getInt8PtrTy(m_module->getContext())); llvm::Type *srN_type = FunctionType::get(sel_ptr_type, srN_arg_types, false); // Build the constant containing the pointer to the function - const IntegerType *intptr_ty = Type::getIntNTy(llvm_module.getContext(), - (llvm_module.getPointerSize() == Module::Pointer64) ? 64 : 32); + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type); Constant *srN_addr_int = ConstantInt::get(intptr_ty, sel_registerName_addr, false); m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty); @@ -988,7 +1013,7 @@ SmallVector srN_arguments; - Constant *omvn_pointer = ConstantExpr::getBitCast(_objc_meth_var_name_, Type::getInt8PtrTy(llvm_module.getContext())); + Constant *omvn_pointer = ConstantExpr::getBitCast(_objc_meth_var_name_, Type::getInt8PtrTy(m_module->getContext())); srN_arguments.push_back(omvn_pointer); @@ -1008,7 +1033,7 @@ } bool -IRForTarget::RewriteObjCSelectors (Module &llvm_module, BasicBlock &basic_block) +IRForTarget::RewriteObjCSelectors (BasicBlock &basic_block) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1036,7 +1061,7 @@ iter != selector_loads.end(); ++iter) { - if (!RewriteObjCSelector(*iter, llvm_module)) + if (!RewriteObjCSelector(*iter)) { if (m_error_stream) m_error_stream->Printf("Internal error [IRForTarget]: Couldn't change a static reference to an Objective-C selector to a dynamic reference\n"); @@ -1053,8 +1078,7 @@ // This function does not report errors; its callers are responsible. bool -IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc, - llvm::Module &llvm_module) +IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1084,7 +1108,7 @@ if (!m_decl_map->AddPersistentVariable(decl, persistent_variable_name, result_decl_type, false, false)) return false; - GlobalVariable *persistent_global = new GlobalVariable(llvm_module, + GlobalVariable *persistent_global = new GlobalVariable((*m_module), alloc->getType(), false, /* not constant */ GlobalValue::ExternalLinkage, @@ -1094,7 +1118,7 @@ // What we're going to do here is make believe this was a regular old external // variable. That means we need to make the metadata valid. - NamedMDNode *named_metadata = llvm_module.getNamedMetadata("clang.global.decl.ptrs"); + NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs"); llvm::Value* values[2]; values[0] = persistent_global; @@ -1102,7 +1126,7 @@ ArrayRef value_ref(values, 2); - MDNode *persistent_global_md = MDNode::get(llvm_module.getContext(), value_ref); + MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); named_metadata->addOperand(persistent_global_md); // Now, since the variable is a pointer variable, we will drop in a load of that @@ -1122,7 +1146,7 @@ } bool -IRForTarget::RewritePersistentAllocs(llvm::Module &llvm_module, llvm::BasicBlock &basic_block) +IRForTarget::RewritePersistentAllocs(llvm::BasicBlock &basic_block) { if (!m_resolve_vars) return true; @@ -1171,7 +1195,7 @@ iter != pvar_allocs.end(); ++iter) { - if (!RewritePersistentAlloc(*iter, llvm_module)) + if (!RewritePersistentAlloc(*iter)) { if (m_error_stream) m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite the creation of a persistent variable\n"); @@ -1188,7 +1212,7 @@ // This function does not report errors; its callers are responsible. bool -IRForTarget::MaybeHandleVariable (Module &llvm_module, Value *llvm_value_ptr) +IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1204,13 +1228,13 @@ case Instruction::GetElementPtr: case Instruction::BitCast: Value *s = constant_expr->getOperand(0); - if (!MaybeHandleVariable(llvm_module, s)) + if (!MaybeHandleVariable(s)) return false; } } else if (GlobalVariable *global_variable = dyn_cast(llvm_value_ptr)) { - clang::NamedDecl *named_decl = DeclForGlobal(llvm_module, global_variable); + clang::NamedDecl *named_decl = DeclForGlobal(global_variable); if (!named_decl) { @@ -1297,8 +1321,7 @@ // This function does not report errors; its callers are responsible. bool -IRForTarget::HandleSymbol (Module &llvm_module, - Value *symbol) +IRForTarget::HandleSymbol (Value *symbol) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1319,8 +1342,8 @@ const Type *symbol_type = symbol->getType(); - const IntegerType *intptr_ty = Type::getIntNTy(llvm_module.getContext(), - (llvm_module.getPointerSize() == Module::Pointer64) ? 64 : 32); + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); Constant *symbol_addr_int = ConstantInt::get(intptr_ty, symbol_addr, false); @@ -1335,7 +1358,7 @@ } bool -IRForTarget::MaybeHandleCallArguments (Module &llvm_module, CallInst *Old) +IRForTarget::MaybeHandleCallArguments (CallInst *Old) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1345,7 +1368,7 @@ for (unsigned op_index = 0, num_ops = Old->getNumArgOperands(); op_index < num_ops; ++op_index) - if (!MaybeHandleVariable(llvm_module, Old->getArgOperand(op_index))) // conservatively believe that this is a store + if (!MaybeHandleVariable(Old->getArgOperand(op_index))) // conservatively believe that this is a store { if (m_error_stream) m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite one of the arguments of a function call.\n"); @@ -1357,7 +1380,7 @@ } bool -IRForTarget::MaybeHandleCall (Module &llvm_module, CallInst *llvm_call_inst) +IRForTarget::MaybeHandleCall (CallInst *llvm_call_inst) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1431,7 +1454,7 @@ str.SetCStringWithLength (fun->getName().data(), fun->getName().size()); } - clang::NamedDecl *fun_decl = DeclForGlobal (llvm_module, fun); + clang::NamedDecl *fun_decl = DeclForGlobal (fun); lldb::addr_t fun_addr = LLDB_INVALID_ADDRESS; Value **fun_value_ptr = NULL; @@ -1474,8 +1497,8 @@ if (!fun_value_ptr || !*fun_value_ptr) { - const IntegerType *intptr_ty = Type::getIntNTy(llvm_module.getContext(), - (llvm_module.getPointerSize() == Module::Pointer64) ? 64 : 32); + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); const FunctionType *fun_ty = fun->getFunctionType(); PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); Constant *fun_addr_int = ConstantInt::get(intptr_ty, fun_addr, false); @@ -1490,13 +1513,13 @@ llvm_call_inst->setCalledFunction(fun_addr_ptr); - ConstantArray *func_name = (ConstantArray*)ConstantArray::get(llvm_module.getContext(), str.GetCString()); + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(m_module->getContext(), str.GetCString()); Value *values[1]; values[0] = func_name; ArrayRef value_ref(values, 1); - MDNode *func_metadata = MDNode::get(llvm_module.getContext(), value_ref); + MDNode *func_metadata = MDNode::get(m_module->getContext(), value_ref); llvm_call_inst->setMetadata("lldb.call.realName", func_metadata); @@ -1507,7 +1530,7 @@ } bool -IRForTarget::ResolveCalls(Module &llvm_module, BasicBlock &basic_block) +IRForTarget::ResolveCalls(BasicBlock &basic_block) { ///////////////////////////////////////////////////////////////////////// // Prepare the current basic block for execution in the remote process @@ -1524,11 +1547,11 @@ CallInst *call = dyn_cast(&inst); // MaybeHandleCall handles error reporting; we are silent here - if (call && !MaybeHandleCall(llvm_module, call)) + if (call && !MaybeHandleCall(call)) return false; // MaybeHandleCallArguments handles error reporting; we are silent here - if (call && !MaybeHandleCallArguments(llvm_module, call)) + if (call && !MaybeHandleCallArguments(call)) return false; } @@ -1536,22 +1559,22 @@ } bool -IRForTarget::ResolveExternals (Module &llvm_module, Function &llvm_function) +IRForTarget::ResolveExternals (Function &llvm_function) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - for (Module::global_iterator global = llvm_module.global_begin(), end = llvm_module.global_end(); + for (Module::global_iterator global = m_module->global_begin(), end = m_module->global_end(); global != end; ++global) { if (log) log->Printf("Examining %s, DeclForGlobalValue returns %p", (*global).getName().str().c_str(), - DeclForGlobal(llvm_module, global)); + DeclForGlobal(global)); if ((*global).getName().str().find("OBJC_IVAR") == 0) { - if (!HandleSymbol(llvm_module, global)) + if (!HandleSymbol(global)) { if (m_error_stream) m_error_stream->Printf("Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol %s\n", (*global).getName().str().c_str()); @@ -1559,9 +1582,9 @@ return false; } } - else if (DeclForGlobal(llvm_module, global)) + else if (DeclForGlobal(global)) { - if (!MaybeHandleVariable (llvm_module, global)) + if (!MaybeHandleVariable (global)) { if (m_error_stream) m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite external variable %s\n", (*global).getName().str().c_str()); @@ -1574,6 +1597,216 @@ return true; } +bool +IRForTarget::ReplaceStrings () +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (!m_data_allocator) + return true; // hope for the best; some clients may not want static allocation! + + typedef std::map OffsetsTy; + + OffsetsTy offsets; + + for (Module::global_iterator gi = m_module->global_begin(), ge = m_module->global_end(); + gi != ge; + ++gi) + { + GlobalVariable *gv = gi; + + if (!gv->hasInitializer()) + continue; + + Constant *gc = gv->getInitializer(); + + ConstantArray *gc_array = dyn_cast(gc); + + if (!gc_array) + continue; + + if (!gc_array->isCString()) + continue; + + if (log) + log->Printf("Found a GlobalVariable with string initializer %s", PrintValue(gc).c_str()); + + std::string str = gc_array->getAsString(); + + offsets[gv] = m_data_allocator->GetStream().GetSize(); + + m_data_allocator->GetStream().Write(str.c_str(), str.length() + 1); + } + + const Type *char_ptr_ty = Type::getInt8PtrTy(m_module->getContext()); + + for (OffsetsTy::iterator oi = offsets.begin(), oe = offsets.end(); + oi != oe; + ++oi) + { + GlobalVariable *gv = oi->first; + size_t offset = oi->second; + + Constant *new_initializer = BuildRelocation(char_ptr_ty, offset); + + if (log) + log->Printf("Replacing GV %s with %s", PrintValue(gv).c_str(), PrintValue(new_initializer).c_str()); + + for (GlobalVariable::use_iterator ui = gv->use_begin(), ue = gv->use_end(); + ui != ue; + ++ui) + { + if (log) + log->Printf("Found use %s", PrintValue(*ui).c_str()); + + ConstantExpr *const_expr = dyn_cast(*ui); + StoreInst *store_inst = dyn_cast(*ui); + + if (const_expr) + { + if (const_expr->getOpcode() != Instruction::GetElementPtr) + { + if (log) + log->Printf("Use (%s) of string variable is not a GetElementPtr constant", PrintValue(const_expr).c_str()); + + return false; + } + + const_expr->replaceAllUsesWith(new_initializer); + } + else if (store_inst) + { + Constant *bit_cast = ConstantExpr::getBitCast(new_initializer, store_inst->getValueOperand()->getType()); + + store_inst->setOperand(0, bit_cast); + } + else + { + if (log) + log->Printf("Use (%s) of string variable is neither a constant nor a store", PrintValue(const_expr).c_str()); + + return false; + } + } + + gv->eraseFromParent(); + } + + return true; +} + +bool +IRForTarget::ReplaceStaticLiterals (llvm::BasicBlock &basic_block) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (!m_data_allocator) + return true; + + typedef SmallVector ConstantList; + typedef SmallVector UserList; + typedef ConstantList::iterator ConstantIterator; + typedef UserList::iterator UserIterator; + + ConstantList static_constants; + UserList static_users; + + for (BasicBlock::iterator ii = basic_block.begin(), ie = basic_block.end(); + ii != ie; + ++ii) + { + llvm::Instruction &inst = *ii; + + for (Instruction::op_iterator oi = inst.op_begin(), oe = inst.op_end(); + oi != oe; + ++oi) + { + Value *operand_val = oi->get(); + + ConstantFP *operand_constant_fp = dyn_cast(operand_val); + + if (operand_constant_fp && operand_constant_fp->getType()->isX86_FP80Ty()) + { + static_constants.push_back(operand_val); + static_users.push_back(ii); + } + } + } + + ConstantIterator constant_iter; + UserIterator user_iter; + + const Type *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + + for (constant_iter = static_constants.begin(), user_iter = static_users.begin(); + constant_iter != static_constants.end(); + ++constant_iter, ++user_iter) + { + Value *operand_val = *constant_iter; + llvm::Instruction *inst = *user_iter; + + ConstantFP *operand_constant_fp = dyn_cast(operand_val); + + if (operand_constant_fp) + { + APFloat operand_apfloat = operand_constant_fp->getValueAPF(); + APInt operand_apint = operand_apfloat.bitcastToAPInt(); + + const uint8_t* operand_raw_data = (const uint8_t*)operand_apint.getRawData(); + size_t operand_data_size = operand_apint.getBitWidth() / 8; + + if (log) + { + std::string s; + raw_string_ostream ss(s); + for (size_t index = 0; + index < operand_data_size; + ++index) + { + ss << (uint32_t)operand_raw_data[index]; + ss << " "; + } + ss.flush(); + + log->Printf("Found ConstantFP with size %d and raw data %s", operand_data_size, s.c_str()); + } + + lldb_private::DataBufferHeap data(operand_data_size, 0); + + if (lldb::endian::InlHostByteOrder() != m_data_allocator->GetStream().GetByteOrder()) + { + uint8_t *data_bytes = data.GetBytes(); + + for (size_t index = 0; + index < operand_data_size; + ++index) + { + data_bytes[index] = operand_raw_data[operand_data_size - (1 + index)]; + } + } + else + { + memcpy(data.GetBytes(), operand_raw_data, operand_data_size); + } + + uint64_t offset = m_data_allocator->GetStream().GetSize(); + + m_data_allocator->GetStream().Write(data.GetBytes(), operand_data_size); + + const llvm::Type *fp_ptr_ty = operand_constant_fp->getType()->getPointerTo(); + + Constant *new_pointer = BuildRelocation(fp_ptr_ty, offset); + + llvm::LoadInst *fp_load = new llvm::LoadInst(new_pointer, "fp_load", inst); + + operand_constant_fp->replaceAllUsesWith(fp_load); + } + } + + return true; +} + static bool isGuardVariableRef(Value *V) { Constant *Old; @@ -1599,9 +1832,10 @@ return true; } -static void TurnGuardLoadIntoZero(Instruction* guard_load, Module &llvm_module) +void +IRForTarget::TurnGuardLoadIntoZero(llvm::Instruction* guard_load) { - Constant* zero(ConstantInt::get(Type::getInt8Ty(llvm_module.getContext()), 0, true)); + Constant* zero(ConstantInt::get(Type::getInt8Ty(m_module->getContext()), 0, true)); Value::use_iterator ui; @@ -1628,7 +1862,7 @@ } bool -IRForTarget::RemoveGuards(Module &llvm_module, BasicBlock &basic_block) +IRForTarget::RemoveGuards(BasicBlock &basic_block) { /////////////////////////////////////////////////////// // Eliminate any reference to guard variables found. @@ -1662,7 +1896,7 @@ for (iter = guard_loads.begin(); iter != guard_loads.end(); ++iter) - TurnGuardLoadIntoZero(*iter, llvm_module); + TurnGuardLoadIntoZero(*iter); for (iter = guard_stores.begin(); iter != guard_stores.end(); @@ -1717,7 +1951,7 @@ if (s == old_constant) s = new_constant; - BitCastInst *bit_cast(new BitCastInst(s, old_constant->getType(), "", first_entry_inst)); + BitCastInst *bit_cast(new BitCastInst(s, constant_expr->getType(), "", first_entry_inst)); UnfoldConstant(constant_expr, bit_cast, first_entry_inst); } @@ -1775,7 +2009,7 @@ } bool -IRForTarget::ReplaceVariables (Module &llvm_module, Function &llvm_function) +IRForTarget::ReplaceVariables (Function &llvm_function) { if (!m_resolve_vars) return true; @@ -1877,7 +2111,7 @@ return false; } - LLVMContext &context(llvm_module.getContext()); + LLVMContext &context(m_module->getContext()); const IntegerType *offset_type(Type::getInt32Ty(context)); if (!offset_type) @@ -1948,12 +2182,64 @@ return true; } +llvm::Constant * +IRForTarget::BuildRelocation(const llvm::Type *type, + uint64_t offset) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + + llvm::Constant *offset_int = ConstantInt::get(intptr_ty, offset); + llvm::Constant *reloc_getelementptr = ConstantExpr::getGetElementPtr(m_reloc_placeholder, &offset_int, 1); + llvm::Constant *reloc_getbitcast = ConstantExpr::getBitCast(reloc_getelementptr, type); + + return reloc_getbitcast; +} + +bool +IRForTarget::CompleteDataAllocation () +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (!m_data_allocator->GetStream().GetSize()) + return true; + + lldb::addr_t allocation = m_data_allocator->Allocate(); + + if (log) + { + if (allocation) + log->Printf("Allocated static data at 0x%llx", (unsigned long long)allocation); + else + log->Printf("Failed to allocate static data"); + } + + if (!allocation) + return false; + + const IntegerType *intptr_ty = Type::getIntNTy(m_module->getContext(), + (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); + + Constant *relocated_addr = ConstantInt::get(intptr_ty, (uint64_t)allocation); + Constant *relocated_bitcast = ConstantExpr::getIntToPtr(relocated_addr, llvm::Type::getInt8PtrTy(m_module->getContext())); + + m_reloc_placeholder->replaceAllUsesWith(relocated_bitcast); + + m_reloc_placeholder->eraseFromParent(); + + return true; +} + bool IRForTarget::runOnModule (Module &llvm_module) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - Function* function = llvm_module.getFunction(StringRef(m_func_name.c_str())); + m_module = &llvm_module; + + Function* function = m_module->getFunction(StringRef(m_func_name.c_str())); if (!function) { @@ -1961,20 +2247,40 @@ log->Printf("Couldn't find \"%s()\" in the module", m_func_name.c_str()); if (m_error_stream) - m_error_stream->Printf("Internal error [IRForTarget]: Couldn't find wrapper '%s' in the mdoule", m_func_name.c_str()); + m_error_stream->Printf("Internal error [IRForTarget]: Couldn't find wrapper '%s' in the module", m_func_name.c_str()); return false; } + + if (!FixFunctionLinkage (*function)) + { + if (log) + log->Printf("Couldn't fix the linkage for the function"); + + return false; + } + + const llvm::Type *intptr_ty = Type::getInt8Ty(m_module->getContext()); + + m_reloc_placeholder = new llvm::GlobalVariable((*m_module), + intptr_ty, + false /* isConstant */, + GlobalVariable::InternalLinkage, + Constant::getNullValue(intptr_ty), + "reloc_placeholder", + NULL /* InsertBefore */, + false /* ThreadLocal */, + 0 /* AddressSpace */); Function::iterator bbi; - m_has_side_effects = HasSideEffects(llvm_module, *function); + m_has_side_effects = HasSideEffects(*function); //////////////////////////////////////////////////////////// // Replace $__lldb_expr_result with a persistent variable // - if (!CreateResultVariable(llvm_module, *function)) + if (!CreateResultVariable(*function)) { if (log) log->Printf("CreateResultVariable() failed"); @@ -1987,11 +2293,23 @@ if (m_const_result) return true; + if (log) + { + std::string s; + raw_string_ostream oss(s); + + m_module->print(oss, NULL); + + oss.flush(); + + log->Printf("Module after creating the result variable: \n\"%s\"", s.c_str()); + } + /////////////////////////////////////////////////////////////////////////////// // Fix all Objective-C constant strings to use NSStringWithCString:encoding: // - if (!RewriteObjCConstStrings(llvm_module, *function)) + if (!RewriteObjCConstStrings(*function)) { if (log) log->Printf("RewriteObjCConstStrings() failed"); @@ -2009,7 +2327,7 @@ bbi != function->end(); ++bbi) { - if (!RemoveGuards(llvm_module, *bbi)) + if (!RemoveGuards(*bbi)) { if (log) log->Printf("RemoveGuards() failed"); @@ -2019,7 +2337,7 @@ return false; } - if (!RewritePersistentAllocs(llvm_module, *bbi)) + if (!RewritePersistentAllocs(*bbi)) { if (log) log->Printf("RewritePersistentAllocs() failed"); @@ -2029,7 +2347,7 @@ return false; } - if (!RewriteObjCSelectors(llvm_module, *bbi)) + if (!RewriteObjCSelectors(*bbi)) { if (log) log->Printf("RewriteObjCSelectors() failed"); @@ -2039,7 +2357,7 @@ return false; } - if (!ResolveCalls(llvm_module, *bbi)) + if (!ResolveCalls(*bbi)) { if (log) log->Printf("ResolveCalls() failed"); @@ -2048,13 +2366,21 @@ return false; } + + if (!ReplaceStaticLiterals(*bbi)) + { + if (log) + log->Printf("ReplaceStaticLiterals() failed"); + + return false; + } } /////////////////////////////// // Run function-level passes // - if (!ResolveExternals(llvm_module, *function)) + if (!ResolveExternals(*function)) { if (log) log->Printf("ResolveExternals() failed"); @@ -2064,7 +2390,7 @@ return false; } - if (!ReplaceVariables(llvm_module, *function)) + if (!ReplaceVariables(*function)) { if (log) log->Printf("ReplaceVariables() failed"); @@ -2074,12 +2400,28 @@ return false; } + if (!ReplaceStrings()) + { + if (log) + log->Printf("ReplaceStrings() failed"); + + return false; + } + + if (!CompleteDataAllocation()) + { + if (log) + log->Printf("CompleteDataAllocation() failed"); + + return false; + } + if (log) { std::string s; raw_string_ostream oss(s); - llvm_module.print(oss, NULL); + m_module->print(oss, NULL); oss.flush(); Added: lldb/trunk/source/Expression/ProcessDataAllocator.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ProcessDataAllocator.cpp?rev=131923&view=auto ============================================================================== --- lldb/trunk/source/Expression/ProcessDataAllocator.cpp (added) +++ lldb/trunk/source/Expression/ProcessDataAllocator.cpp Mon May 23 16:40:23 2011 @@ -0,0 +1,43 @@ +//===-- ProcessDataAllocator.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/DataExtractor.h" +#include "lldb/Expression/ProcessDataAllocator.h" + +using namespace lldb_private; + +void +ProcessDataAllocator::Dump(Stream &stream) +{ + size_t data_size = m_stream_string.GetSize(); + + if (!m_allocation) + return; + + lldb::DataBufferSP data(new DataBufferHeap(data_size, 0)); + + Error error; + if (m_process.ReadMemory (m_allocation, data->GetBytes(), data_size, error) != data_size) + return; + + DataExtractor extractor(data, m_process.GetByteOrder(), m_process.GetAddressByteSize()); + + extractor.Dump(&stream, // stream + 0, // offset + lldb::eFormatBytesWithASCII, // format + 1, // byte size of individual entries + data_size, // number of entries + 16, // entries per line + m_allocation, // address to print + 0, // bit size (bitfields only; 0 means ignore) + 0); // bit alignment (bitfields only; 0 means ignore) + + stream.PutChar('\n'); +} \ No newline at end of file From johnny.chen at apple.com Mon May 23 16:50:12 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 23 May 2011 21:50:12 -0000 Subject: [Lldb-commits] [lldb] r131924 - in /lldb/trunk/utils: git-svn/ git-svn/convert.py test/lldb-disasm.py Message-ID: <20110523215012.40DD72A6C12C@llvm.org> Author: johnny Date: Mon May 23 16:50:12 2011 New Revision: 131924 URL: http://llvm.org/viewvc/llvm-project?rev=131924&view=rev Log: Add a Python utility to help convert the Mail.app saved 'Raw Message Source' .eml file to a git-am friendly file. Added: lldb/trunk/utils/git-svn/ lldb/trunk/utils/git-svn/convert.py (with props) Modified: lldb/trunk/utils/test/lldb-disasm.py Added: lldb/trunk/utils/git-svn/convert.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/git-svn/convert.py?rev=131924&view=auto ============================================================================== --- lldb/trunk/utils/git-svn/convert.py (added) +++ lldb/trunk/utils/git-svn/convert.py Mon May 23 16:50:12 2011 @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +""" +Convert the raw message sources from git patch emails to git-am friendly files. + +Usage: + +1. Mail.app -> Save As -> api.eml (Raw Message Source) +2. .../convert.py api.eml +3. git am --signoff < api.eml +4. git commit -a +""" + +import os, re, sys +import StringIO + +def usage(problem_file=None): + if problem_file: + print "%s is not a file" % problem_file + print "Usage: convert.py raw-message-source [raw-message-source2 ...]" + sys.exit(0) + +def do_convert(file): + """Skip all preceding mail message headers until 'From: ' is encountered. + Then for each line ('From: ' header included), replace the dos style CRLF + end-of-line with unix style LF end-of-line. + """ + print "converting %s ..." % file + + with open(file, 'r') as f_in: + content = f_in.read() + + # The new content to be written back to the same file. + new_content = StringIO.StringIO() + + # Boolean flag controls whether to start printing lines. + from_header_seen = False + + # By default, splitlines() don't include line breaks. CRLF should be gone. + for line in content.splitlines(): + # Wait till we scan the 'From: ' header before start printing the lines. + if not from_header_seen: + if not line.startswith('From: '): + continue + else: + from_header_seen = True + + print >> new_content, line + + with open(file, 'w') as f_out: + f_out.write(new_content.getvalue()) + + print "done" + +def main(): + if len(sys.argv) == 1: + usage() + # Convert the raw message source one by one. + for file in sys.argv[1:]: + if not os.path.isfile(file): + usage(file) + do_convert(file) + +if __name__ == '__main__': + main() Propchange: lldb/trunk/utils/git-svn/convert.py ------------------------------------------------------------------------------ svn:executable = * Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=131924&r1=131923&r2=131924&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Mon May 23 16:50:12 2011 @@ -137,11 +137,11 @@ count = count + 1 print "returning symbol:", s.GetName() yield s.GetName() - #print "start address:", s.GetStartAddress() - #print "end address:", s.GetEndAddress() - #s.GetDescription(stream) - #print "symbol description:", stream.GetData() - #stream.Clear() + print "start address:", s.GetStartAddress() + print "end address:", s.GetEndAddress() + s.GetDescription(stream) + print "symbol description:", stream.GetData() + stream.Clear() # Disassembly time. for symbol in symbol_iter(num_symbols, symbols_to_disassemble, target): From johnny.chen at apple.com Mon May 23 16:56:09 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 23 May 2011 21:56:09 -0000 Subject: [Lldb-commits] [lldb] r131925 - /lldb/trunk/utils/git-svn/convert.py Message-ID: <20110523215609.2047F2A6C12C@llvm.org> Author: johnny Date: Mon May 23 16:56:08 2011 New Revision: 131925 URL: http://llvm.org/viewvc/llvm-project?rev=131925&view=rev Log: Fix usage comment. Modified: lldb/trunk/utils/git-svn/convert.py Modified: lldb/trunk/utils/git-svn/convert.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/git-svn/convert.py?rev=131925&r1=131924&r2=131925&view=diff ============================================================================== --- lldb/trunk/utils/git-svn/convert.py (original) +++ lldb/trunk/utils/git-svn/convert.py Mon May 23 16:56:08 2011 @@ -8,7 +8,7 @@ 1. Mail.app -> Save As -> api.eml (Raw Message Source) 2. .../convert.py api.eml 3. git am --signoff < api.eml -4. git commit -a +4. git svn dcommit """ import os, re, sys From gclayton at apple.com Mon May 23 18:14:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 23 May 2011 23:14:34 -0000 Subject: [Lldb-commits] [lldb] r131934 - /lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Message-ID: <20110523231434.D78CA2A6C12C@llvm.org> Author: gclayton Date: Mon May 23 18:14:34 2011 New Revision: 131934 URL: http://llvm.org/viewvc/llvm-project?rev=131934&view=rev Log: Don't resolve the path when we extract the path from the dyld info or we can end up with an invalid path if the path resolves to something different on the local machine. It is very important not to since remote debugging will mention paths that might exist on the current machine (like "/System/Library/Frameworks/CoreFoundation/CoreFoundation" which on the desktop systems is a symlink to "/System/Library/Frameworks/CoreFoundation/Versions/A/CoreFoundation"). We will let the platform plug-ins resolve the paths in a later stage. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp 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=131934&r1=131933&r2=131934&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon May 23 18:14:34 2011 @@ -607,10 +607,9 @@ char raw_path[PATH_MAX]; m_process->ReadCStringFromMemory (path_addr, raw_path, sizeof(raw_path)); - char raw_path2[PATH_MAX];// TODO: remove after assertion doesn't assert - m_process->ReadMemory (path_addr, raw_path2, sizeof(raw_path2), error);// TODO: remove after assertion doesn't assert - assert (strcmp (raw_path, raw_path2) == 0);// TODO: remove after assertion doesn't assert - m_dyld_image_infos[i].file_spec.SetFile(raw_path, true); + // don't resolve the path + const bool resolve_path = false; + m_dyld_image_infos[i].file_spec.SetFile(raw_path, resolve_path); } assert(i == m_dyld_all_image_infos.dylib_info_count); From johnny.chen at apple.com Mon May 23 18:29:23 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 23 May 2011 23:29:23 -0000 Subject: [Lldb-commits] [lldb] r131937 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110523232923.D47F82A6C12C@llvm.org> Author: johnny Date: Mon May 23 18:29:23 2011 New Revision: 131937 URL: http://llvm.org/viewvc/llvm-project?rev=131937&view=rev Log: Refactor InstructionLLVM::Dump() a little bit to reduce the entropy by introducing a new file static utility function AddSymbolicInfo() which is called from places within InstructionLLVM::Dump(). Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp 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=131937&r1=131936&r2=131937&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Mon May 23 18:29:23 2011 @@ -98,16 +98,40 @@ else s->Printf("%s ", str.c_str()); } +static void +AddSymbolicInfo(const ExecutionContext *exe_ctx, ExecutionContextScope *exe_scope, + StreamString &comment, uint64_t operand_value, const Address &inst_addr) +{ + Address so_addr; + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) + { + if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress(operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } + else + { + Module *module = inst_addr.GetModule(); + if (module) + { + if (module->ResolveFileAddress(operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } + } +} #include "llvm/ADT/StringRef.h" -static void -StripSpaces(llvm::StringRef &Str) +static inline void StripSpaces(llvm::StringRef &Str) { while (!Str.empty() && isspace(Str[0])) Str = Str.substr(1); while (!Str.empty() && isspace(Str.back())) Str = Str.substr(0, Str.size()-1); } +static inline void RStrip(llvm::StringRef &Str, char c) +{ + if (!Str.empty() && Str.back() == c) + Str = Str.substr(0, Str.size()-1); +} static void Align(Stream *s, const char *str, size_t opcodeColWidth, size_t operandColWidth) { @@ -290,21 +314,7 @@ comment.Printf("0x%llx ", operand_value); } - lldb_private::Address so_addr; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) - { - if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } - else - { - Module *module = GetAddress().GetModule(); - if (module) - { - if (module->ResolveFileAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } - } + AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); } // EDEvaluateOperand } // EDOperandIsMemory } // EDGetOperand @@ -331,19 +341,9 @@ operands.Clear(); comment.Clear(); if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { uint64_t operand_value = PC + atoi(++pos); + // Put the address value into the operands. operands.Printf("0x%llx ", operand_value); - - lldb_private::Address so_addr; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) { - if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } else { - Module *module = GetAddress().GetModule(); - if (module) { - if (module->ResolveFileAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } - } + AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); } } // Yet more workaround for "bl #..." and "blx #...". @@ -354,23 +354,13 @@ operands.Clear(); comment.Clear(); if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { uint64_t operand_value = PC + atoi(++pos); - // Put the address value into the comment + // Put the address value into the comment. comment.Printf("0x%llx ", operand_value); - llvm::StringRef string_ref(pos - 1); - llvm::StringRef operand_string_ref = string_ref.split('\n').first; - operands.PutCString(operand_string_ref.str().c_str()); - - lldb_private::Address so_addr; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) { - if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } else { - Module *module = GetAddress().GetModule(); - if (module) { - if (module->ResolveFileAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } - } + // And the original token string into the operands. + llvm::StringRef Str(pos - 1); + RStrip(Str, '\n'); + operands.PutCString(Str.str().c_str()); + AddSymbolicInfo(exe_ctx, exe_scope, comment, operand_value, GetAddress()); } } // END of workaround. From cdavis at mines.edu Mon May 23 20:54:03 2011 From: cdavis at mines.edu (Charles Davis) Date: Tue, 24 May 2011 01:54:03 -0000 Subject: [Lldb-commits] [lldb] r131949 - /lldb/trunk/lib/Makefile Message-ID: <20110524015403.C05282A6C12C@llvm.org> Author: cdavis Date: Mon May 23 20:54:03 2011 New Revision: 131949 URL: http://llvm.org/viewvc/llvm-project?rev=131949&view=rev Log: Link in the MCJIT. Fixes makefile build. Modified: lldb/trunk/lib/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131949&r1=131948&r2=131949&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Mon May 23 20:54:03 2011 @@ -65,7 +65,7 @@ include $(LLDB_LEVEL)/../../Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter codegen \ - instrumentation ipo selectiondag jit mc + instrumentation ipo selectiondag jit mc mcjit ifeq ($(HOST_OS),Darwin) USEDLIBS += lldbHostMacOSX.a \ From johnny.chen at apple.com Tue May 24 13:22:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 18:22:45 -0000 Subject: [Lldb-commits] [lldb] r131970 - in /lldb/trunk/test: array_types/ bitfields/ breakpoint_conditions/ breakpoint_ignore_count/ class_static/ class_types/ conditional_break/ cpp/dynamic-value/ expression_command/test/ foundation/ hello_world/ inferior-crashing/ macosx/universal/ objc-dynamic-value/ objc-stepping/ python_api/event/ python_api/frame/ python_api/function_symbol/ python_api/interpreter/ python_api/process/ python_api/symbol-context/ python_api/target/ python_api/thread/ source-manager/ Message-ID: <20110524182245.D26922A6C12C@llvm.org> Author: johnny Date: Tue May 24 13:22:45 2011 New Revision: 131970 URL: http://llvm.org/viewvc/llvm-project?rev=131970&view=rev Log: Now that we have added a post-processing step for adding truth value testing to those lldb objects which implement the IsValid() method, let's change the rest of the test suite to use the more compact truth value testing pattern (the Python way). Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/test/class_static/TestStaticVariables.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/class_types/TestClassTypesDisassembly.py lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/expression_command/test/TestExprs.py lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/foundation/TestSymbolTable.py lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py lldb/trunk/test/macosx/universal/TestUniversal.py lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py lldb/trunk/test/objc-stepping/TestObjCStepping.py lldb/trunk/test/python_api/event/TestEvents.py lldb/trunk/test/python_api/frame/TestFrames.py lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py lldb/trunk/test/python_api/process/TestProcessAPI.py lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py lldb/trunk/test/python_api/target/TestTargetAPI.py lldb/trunk/test/python_api/thread/TestThreadAPI.py lldb/trunk/test/source-manager/TestSourceManager.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Tue May 24 13:22:45 2011 @@ -95,10 +95,10 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.c", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Sanity check the print representation of breakpoint. bp = repr(breakpoint) @@ -113,7 +113,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Sanity check the print representation of process. proc = repr(self.process) Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Tue May 24 13:22:45 2011 @@ -89,13 +89,13 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.c", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Tue May 24 13:22:45 2011 @@ -104,12 +104,12 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') #print "breakpoint:", breakpoint - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -129,7 +129,7 @@ # Get the breakpoint location from breakpoint after we verified that, # indeed, it has one location. location = breakpoint.GetLocationAtIndex(0) - self.assertTrue(location.IsValid() and + self.assertTrue(location and location.IsEnabled(), VALID_BREAKPOINT_LOCATION) @@ -142,7 +142,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line1 and the break condition should hold. from lldbutil import get_stopped_thread Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original) +++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Tue May 24 13:22:45 2011 @@ -80,18 +80,18 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) # Get the breakpoint location from breakpoint after we verified that, # indeed, it has one location. location = breakpoint.GetLocationAtIndex(0) - self.assertTrue(location.IsValid() and + self.assertTrue(location and location.IsEnabled(), VALID_BREAKPOINT_LOCATION) @@ -104,7 +104,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # frame#2 should be on main.c:48. Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Tue May 24 13:22:45 2011 @@ -74,16 +74,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Tue May 24 13:22:45 2011 @@ -97,10 +97,10 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) filespec = target.GetExecutable() - self.assertTrue(filespec.IsValid(), VALID_FILESPEC) + self.assertTrue(filespec, VALID_FILESPEC) fsDir = filespec.GetDirectory() fsFile = filespec.GetFilename() @@ -111,7 +111,7 @@ bpfilespec = lldb.SBFileSpec("main.cpp", False) breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Verify the breakpoint just created. self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False, @@ -123,7 +123,7 @@ self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) #self.breakAfterLaunch(self.process, "C::C(int, int, int)") - if not error.Success() or not self.process.IsValid(): + if not error.Success() or not self.process: self.fail("SBTarget.Launch() failed") if self.process.GetState() != lldb.eStateStopped: Modified: lldb/trunk/test/class_types/TestClassTypesDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (original) +++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Tue May 24 13:22:45 2011 @@ -100,7 +100,7 @@ if self.TraceOn(): print print function - if function.IsValid(): + if function: # Get all instructions for this function and print them out. insts = function.GetInstructions(target) for inst in insts: Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Tue May 24 13:22:45 2011 @@ -46,16 +46,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByName("c", exe) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - self.assertTrue(error.Success() and self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(error.Success() and self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. self.assertTrue(self.process.GetState() == lldb.eStateStopped, Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Tue May 24 13:22:45 2011 @@ -41,12 +41,12 @@ # Get "this" as its static value - self.assertTrue (this_static.IsValid()) + self.assertTrue (this_static) this_static_loc = int (this_static.GetValue(), 16) # Get "this" as its dynamic value - self.assertTrue (this_dynamic.IsValid()) + self.assertTrue (this_dynamic) this_dynamic_typename = this_dynamic.GetTypeName() self.assertTrue (this_dynamic_typename.find('B') != -1) this_dynamic_loc = int (this_dynamic.GetValue(), 16) @@ -65,7 +65,7 @@ no_dynamic = lldb.eNoDynamicValues this_dynamic_m_b_value = this_dynamic.GetChildMemberWithName('m_b_value', use_dynamic) - self.assertTrue (this_dynamic_m_b_value.IsValid()) + self.assertTrue (this_dynamic_m_b_value) m_b_value = int (this_dynamic_m_b_value.GetValue(), 0) self.assertTrue (m_b_value == 10) @@ -73,17 +73,17 @@ # Make sure it is not in the static version this_static_m_b_value = this_static.GetChildMemberWithName('m_b_value', no_dynamic) - self.assertTrue (this_static_m_b_value.IsValid() == False) + self.assertFalse (this_static_m_b_value) # Okay, now let's make sure that we can get the dynamic type of a child element: contained_auto_ptr = this_dynamic.GetChildMemberWithName ('m_client_A', use_dynamic) - self.assertTrue (contained_auto_ptr.IsValid()) + self.assertTrue (contained_auto_ptr) contained_b = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', use_dynamic) - self.assertTrue (contained_b.IsValid()) + self.assertTrue (contained_b) contained_b_static = contained_auto_ptr.GetChildMemberWithName ('_M_ptr', no_dynamic) - self.assertTrue (contained_b_static.IsValid()) + self.assertTrue (contained_b_static) contained_b_addr = int (contained_b.GetValue(), 16) contained_b_static_addr = int (contained_b_static.GetValue(), 16) @@ -97,20 +97,20 @@ # Create a target from the debugger. target = self.dbg.CreateTarget (exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line) - self.assertTrue(do_something_bpt.IsValid(), + self.assertTrue(do_something_bpt, VALID_BREAKPOINT) first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line) - self.assertTrue(first_call_bpt.IsValid(), + self.assertTrue(first_call_bpt, VALID_BREAKPOINT) second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line) - self.assertTrue(second_call_bpt.IsValid(), + self.assertTrue(second_call_bpt, VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. @@ -132,11 +132,11 @@ no_dynamic = lldb.eNoDynamicValues myB = frame.FindVariable ('myB', no_dynamic); - self.assertTrue (myB.IsValid()) + self.assertTrue (myB) myB_loc = int (myB.GetLocation(), 16) otherB = frame.FindVariable('otherB', no_dynamic) - self.assertTrue (otherB.IsValid()) + self.assertTrue (otherB) otherB_loc = int (otherB.GetLocation(), 16) # Okay now run to doSomething: @@ -173,11 +173,11 @@ # Now make sure we also get it right for a reference as well: anotherA_static = frame.FindVariable ('anotherA', False) - self.assertTrue (anotherA_static.IsValid()) + self.assertTrue (anotherA_static) anotherA_static_addr = int (anotherA_static.GetValue(), 16) anotherA_dynamic = frame.FindVariable ('anotherA', True) - self.assertTrue (anotherA_dynamic.IsValid()) + self.assertTrue (anotherA_dynamic) anotherA_dynamic_addr = int (anotherA_dynamic.GetValue(), 16) anotherA_dynamic_typename = anotherA_dynamic.GetTypeName() self.assertTrue (anotherA_dynamic_typename.find('B') != -1) @@ -185,12 +185,12 @@ self.assertTrue(anotherA_dynamic_addr < anotherA_static_addr) anotherA_m_b_value_dynamic = anotherA_dynamic.GetChildMemberWithName('m_b_value', True) - self.assertTrue (anotherA_m_b_value_dynamic.IsValid()) + self.assertTrue (anotherA_m_b_value_dynamic) anotherA_m_b_val = int (anotherA_m_b_value_dynamic.GetValue(), 10) self.assertTrue (anotherA_m_b_val == 300) anotherA_m_b_value_static = anotherA_static.GetChildMemberWithName('m_b_value', True) - self.assertTrue (anotherA_m_b_value_static.IsValid() == False) + self.assertFalse (anotherA_m_b_value_static) # Okay, now continue again, and when we hit the second breakpoint in main @@ -200,7 +200,7 @@ frame = thread.GetFrameAtIndex(0) reallyA_value = frame.FindVariable ('reallyA', False) - self.assertTrue(reallyA_value.IsValid()) + self.assertTrue(reallyA_value) reallyA_loc = int (reallyA_value.GetLocation(), 16) # Finally continue to doSomething again, and make sure we get the right value for anotherA, @@ -212,7 +212,7 @@ frame = thread.GetFrameAtIndex(0) anotherA_value = frame.FindVariable ('anotherA', True) - self.assertTrue(anotherA_value.IsValid()) + self.assertTrue(anotherA_value) anotherA_loc = int (anotherA_value.GetValue(), 16) self.assertTrue (anotherA_loc == reallyA_loc) self.assertTrue (anotherA_value.GetTypeName().find ('B') == -1) Modified: lldb/trunk/test/expression_command/test/TestExprs.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/expression_command/test/TestExprs.py (original) +++ lldb/trunk/test/expression_command/test/TestExprs.py Tue May 24 13:22:45 2011 @@ -86,12 +86,12 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Create the breakpoint. filespec = lldb.SBFileSpec("main.cpp", False) breakpoint = target.BreakpointCreateByLocation(filespec, self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Verify the breakpoint just created. self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False, @@ -103,7 +103,7 @@ error = lldb.SBError() self.process = target.Launch(self.dbg.GetListener(), ['X', 'Y', 'Z'], None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - if not error.Success() or not self.process.IsValid(): + if not error.Success() or not self.process: self.fail("SBTarget.LaunchProcess() failed") if self.process.GetState() != lldb.eStateStopped: Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Tue May 24 13:22:45 2011 @@ -206,16 +206,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) break1 = target.BreakpointCreateByLocation(self.main_source, self.line) - self.assertTrue(break1.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break1, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. error = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) @@ -232,15 +232,15 @@ self.assertTrue (line_number == self.line, "Hit the first breakpoint.") my_var = cur_frame.FindVariable("my") - self.assertTrue(my_var.IsValid(), "Made a variable object for my") + self.assertTrue(my_var, "Made a variable object for my") str_var = cur_frame.FindVariable("str") - self.assertTrue(str_var.IsValid(), "Made a variable object for str") + self.assertTrue(str_var, "Made a variable object for str") # Now make sure that the my->str == str: my_str_var = my_var.GetChildMemberWithName("str") - self.assertTrue(my_str_var.IsValid(), "Found a str ivar in my") + self.assertTrue(my_str_var, "Found a str ivar in my") str_value = int(str_var.GetValue(cur_frame), 0) Modified: lldb/trunk/test/foundation/TestSymbolTable.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestSymbolTable.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestSymbolTable.py (original) +++ lldb/trunk/test/foundation/TestSymbolTable.py Tue May 24 13:22:45 2011 @@ -42,7 +42,7 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. process = target.LaunchSimple(None, None, os.getcwd()) @@ -55,13 +55,13 @@ filespec = lldb.SBFileSpec(exe, False) module = target.FindModule(filespec) - self.assertTrue(module.IsValid(), VALID_MODULE) + self.assertTrue(module, VALID_MODULE) # Create the set of known symbols. As we iterate through the symbol # table, remove the symbol from the set if it is a known symbol. expected_symbols = set(self.symbols_list) for symbol in module: - self.assertTrue(symbol.IsValid(), VALID_SYMBOL) + self.assertTrue(symbol, VALID_SYMBOL) #print "symbol:", symbol name = symbol.GetName() if name in expected_symbols: Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Tue May 24 13:22:45 2011 @@ -67,7 +67,7 @@ #self.runCmd("thread list") self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) thread = self.process.GetThreadAtIndex(0) if thread.GetStopReason() != lldb.eStopReasonBreakpoint: Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Tue May 24 13:22:45 2011 @@ -54,7 +54,7 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now launch the process, and do not stop at entry point. # Both argv and envp are null. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Tue May 24 13:22:45 2011 @@ -45,7 +45,7 @@ # Check whether we have a 64-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() - self.assertTrue(target.IsValid() and process.IsValid() and + self.assertTrue(target and process and self.invoke(process, 'GetAddressByteSize') == 8, "64-bit process launched") @@ -73,7 +73,7 @@ # Check whether we have a 32-bit process launched. target = self.dbg.GetSelectedTarget() process = target.GetProcess() - self.assertTrue(target.IsValid() and process.IsValid(), + self.assertTrue(target and process, "32-bit process launched") pointerSize = self.invoke(process, 'GetAddressByteSize') Modified: lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/objc-dynamic-value/TestObjCDynamicValue.py Tue May 24 13:22:45 2011 @@ -39,10 +39,10 @@ '// Break here to see if we can step into real method.') def examine_SourceDerived_ptr (self, object): - self.assertTrue (object.IsValid()) + self.assertTrue (object) self.assertTrue (object.GetTypeName().find ('SourceDerived') != -1) derivedValue = object.GetChildMemberWithName ('_derivedValue') - self.assertTrue (derivedValue.IsValid()) + self.assertTrue (derivedValue) self.assertTrue (int (derivedValue.GetValue(), 0) == 30) def do_get_dynamic_vals(self): @@ -52,17 +52,17 @@ # Create a target from the debugger. target = self.dbg.CreateTarget (exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Set up our breakpoints: handle_SourceBase_bkpt = target.BreakpointCreateByLocation(self.source_name, self.handle_SourceBase) - self.assertTrue(handle_SourceBase_bkpt.IsValid() and + self.assertTrue(handle_SourceBase_bkpt and handle_SourceBase_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) main_before_setProperty_bkpt = target.BreakpointCreateByLocation(self.source_name, self.main_before_setProperty_line) - self.assertTrue(main_before_setProperty_bkpt.IsValid() and + self.assertTrue(main_before_setProperty_bkpt and main_before_setProperty_bkpt.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -82,7 +82,7 @@ frame = thread.GetFrameAtIndex(0) myObserver = frame.FindVariable('myObserver', lldb.eDynamicCanRunTarget) - self.assertTrue (myObserver.IsValid()) + self.assertTrue (myObserver) myObserver_source = myObserver.GetChildMemberWithName ('_source', lldb.eDynamicCanRunTarget) self.examine_SourceDerived_ptr (myObserver_source) Modified: lldb/trunk/test/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-stepping/TestObjCStepping.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/test/objc-stepping/TestObjCStepping.py Tue May 24 13:22:45 2011 @@ -43,30 +43,30 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) break1 = target.BreakpointCreateByLocation(self.main_source, self.line1) - self.assertTrue(break1.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break1, VALID_BREAKPOINT) break2 = target.BreakpointCreateByLocation(self.main_source, self.line2) - self.assertTrue(break2.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break2, VALID_BREAKPOINT) break3 = target.BreakpointCreateByLocation(self.main_source, self.line3) - self.assertTrue(break3.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break3, VALID_BREAKPOINT) break4 = target.BreakpointCreateByLocation(self.main_source, self.line4) - self.assertTrue(break4.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break4, VALID_BREAKPOINT) break5 = target.BreakpointCreateByLocation(self.main_source, self.line5) - self.assertTrue(break5.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break5, VALID_BREAKPOINT) break_returnStruct_call_super = target.BreakpointCreateByLocation(self.main_source, self.source_returnsStruct_call_line) - self.assertTrue(break_returnStruct_call_super.IsValid(), VALID_BREAKPOINT) + self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. self.process = target.LaunchSimple (None, None, os.getcwd()) - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) @@ -81,9 +81,9 @@ self.assertTrue (line_number == self.line1, "Hit the first breakpoint.") mySource = thread.GetFrameAtIndex(0).FindVariable("mySource") - self.assertTrue(mySource.IsValid(), "Found mySource local variable.") + self.assertTrue(mySource, "Found mySource local variable.") mySource_isa = mySource.GetChildMemberWithName ("isa") - self.assertTrue(mySource_isa.IsValid(), "Found mySource->isa local variable.") + self.assertTrue(mySource_isa, "Found mySource->isa local variable.") mySource_isa.GetValue (thread.GetFrameAtIndex(0)) # Lets delete mySource so we can check that after stepping a child variable Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Tue May 24 13:22:45 2011 @@ -50,12 +50,12 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') #print "breakpoint:", breakpoint - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -67,15 +67,15 @@ self.process = target.Launch (listener, None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Get a handle on the process's broadcaster. broadcaster = self.process.GetBroadcaster() - self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster") + self.assertTrue(broadcaster, "Process with valid broadcaster") # Create an empty event object. event = lldb.SBEvent() - self.assertFalse(event.IsValid(), "Event should not be valid initially") + self.assertFalse(event, "Event should not be valid initially") # Create MyListeningThread to wait for any kind of event. import threading @@ -103,7 +103,7 @@ # Wait until the 'MyListeningThread' terminates. my_thread.join() - self.assertTrue(event.IsValid(), + self.assertTrue(event, "My listening thread successfully received an event") def do_add_listener_to_broadcaster(self): @@ -112,12 +112,12 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') #print "breakpoint:", breakpoint - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -130,11 +130,11 @@ # Get a handle on the process's broadcaster. broadcaster = self.process.GetBroadcaster() - self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster") + self.assertTrue(broadcaster, "Process with valid broadcaster") # Create an empty event object. event = lldb.SBEvent() - self.assertFalse(event.IsValid(), "Event should not be valid initially") + self.assertFalse(event, "Event should not be valid initially") # Create a listener object and register with the broadcaster. listener = lldb.SBListener("TestEvents.listener") Modified: lldb/trunk/test/python_api/frame/TestFrames.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/TestFrames.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/frame/TestFrames.py (original) +++ lldb/trunk/test/python_api/frame/TestFrames.py Tue May 24 13:22:45 2011 @@ -31,12 +31,12 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') #print "breakpoint:", breakpoint - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -87,10 +87,10 @@ # but they should be valid. Uses get_GPRs() from the lldbutil module. gpr_reg_set = lldbutil.get_GPRs(frame) pc_value = gpr_reg_set.GetChildMemberWithName("pc") - self.assertTrue (pc_value.IsValid(), "We should have a valid PC.") + self.assertTrue (pc_value, "We should have a valid PC.") self.assertTrue (int(pc_value.GetValue(frame), 0) == frame.GetPC(), "PC gotten as a value should equal frame's GetPC") sp_value = gpr_reg_set.GetChildMemberWithName("sp") - self.assertTrue (sp_value.IsValid(), "We should have a valid Stack Pointer.") + self.assertTrue (sp_value, "We should have a valid Stack Pointer.") self.assertTrue (int(sp_value.GetValue(frame), 0) == frame.GetSP(), "SP gotten as a value should equal frame's GetSP") print >> session, "---" Modified: lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestDisasmAPI.py Tue May 24 13:22:45 2011 @@ -38,17 +38,17 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) #print "breakpoint1:", breakpoint1 #print "breakpoint2:", breakpoint2 - self.assertTrue(breakpoint1.IsValid() and + self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) - self.assertTrue(breakpoint2.IsValid() and + self.assertTrue(breakpoint2 and breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -56,7 +56,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. self.assertTrue(self.process.GetState() == lldb.eStateStopped) @@ -72,7 +72,7 @@ # Now call SBTarget.ResolveSymbolContextForAddress() with address1. context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything) - self.assertTrue(context1.IsValid()) + self.assertTrue(context1) if self.TraceOn(): print "context1:", context1 @@ -88,7 +88,7 @@ # Verify that the symbol and the function has the same address range per function 'a'. symbol = context1.GetSymbol() function = frame0.GetFunction() - self.assertTrue(symbol.IsValid() and function.IsValid()) + self.assertTrue(symbol and function) disasm_output = lldbutil.disassemble(target, symbol) if self.TraceOn(): Modified: lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py (original) +++ lldb/trunk/test/python_api/function_symbol/TestSymbolAPI.py Tue May 24 13:22:45 2011 @@ -38,17 +38,17 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) #print "breakpoint1:", breakpoint1 #print "breakpoint2:", breakpoint2 - self.assertTrue(breakpoint1.IsValid() and + self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) - self.assertTrue(breakpoint2.IsValid() and + self.assertTrue(breakpoint2 and breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -56,7 +56,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. self.assertTrue(self.process.GetState() == lldb.eStateStopped) Modified: lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py (original) +++ lldb/trunk/test/python_api/interpreter/TestCommandInterpreterAPI.py Tue May 24 13:22:45 2011 @@ -35,11 +35,11 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Retrieve the associated command interpreter from our debugger. ci = self.dbg.GetCommandInterpreter() - self.assertTrue(ci.IsValid(), VALID_COMMAND_INTERPRETER) + self.assertTrue(ci, VALID_COMMAND_INTERPRETER) # Exercise some APIs.... @@ -61,7 +61,7 @@ # Assigning to self.process so it gets cleaned up during test tear down. self.process = ci.GetProcess() - self.assertTrue(self.process.IsValid()) + self.assertTrue(self.process) import lldbutil if self.process.GetState() != lldb.eStateStopped: 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=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/process/TestProcessAPI.py (original) +++ lldb/trunk/test/python_api/process/TestProcessAPI.py Tue May 24 13:22:45 2011 @@ -69,10 +69,10 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Launch the process, and do not stop at the entry point. error = lldb.SBError() @@ -111,10 +111,10 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Launch the process, and do not stop at the entry point. error = lldb.SBError() @@ -162,10 +162,10 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Launch the process, and do not stop at the entry point. error = lldb.SBError() @@ -251,7 +251,7 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. error = lldb.SBError() Modified: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py (original) +++ lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Tue May 24 13:22:45 2011 @@ -37,12 +37,12 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create a breakpoint on main.c by name 'c'. breakpoint = target.BreakpointCreateByName('c', 'a.out') #print "breakpoint:", breakpoint - self.assertTrue(breakpoint.IsValid() and + self.assertTrue(breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -50,7 +50,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line. from lldbutil import get_stopped_thread @@ -61,7 +61,7 @@ # Now get the SBSymbolContext from this frame. We want everything. :-) context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) - self.assertTrue(context.IsValid()) + self.assertTrue(context) # Get the description of this module. module = context.GetModule() @@ -74,11 +74,11 @@ substrs = [os.path.join(self.mydir, 'main.c')]) function = context.GetFunction() - self.assertTrue(function.IsValid()) + self.assertTrue(function) #print "function:", function block = context.GetBlock() - self.assertTrue(block.IsValid()) + self.assertTrue(block) #print "block:", block lineEntry = context.GetLineEntry() Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/target/TestTargetAPI.py (original) +++ lldb/trunk/test/python_api/target/TestTargetAPI.py Tue May 24 13:22:45 2011 @@ -64,7 +64,7 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) from lldbutil import get_description @@ -91,7 +91,7 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Add an extra twist of stopping the inferior in a breakpoint, and then continue till it's done. # We should still see the entire stdout redirected once the process is finished. @@ -131,17 +131,17 @@ # Create a target by the debugger. target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Now create the two breakpoints inside function 'a'. breakpoint1 = target.BreakpointCreateByLocation('main.c', self.line1) breakpoint2 = target.BreakpointCreateByLocation('main.c', self.line2) #print "breakpoint1:", breakpoint1 #print "breakpoint2:", breakpoint2 - self.assertTrue(breakpoint1.IsValid() and + self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT) - self.assertTrue(breakpoint2.IsValid() and + self.assertTrue(breakpoint2 and breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT) @@ -149,7 +149,7 @@ self.process = target.LaunchSimple(None, None, os.getcwd()) self.process = target.GetProcess() - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line1. self.assertTrue(self.process.GetState() == lldb.eStateStopped) @@ -181,14 +181,14 @@ context1 = target.ResolveSymbolContextForAddress(address1, lldb.eSymbolContextEverything) context2 = target.ResolveSymbolContextForAddress(address2, lldb.eSymbolContextEverything) - self.assertTrue(context1.IsValid() and context2.IsValid()) + self.assertTrue(context1 and context2) #print "context1:", context1 #print "context2:", context2 # Verify that the context point to the same function 'a'. symbol1 = context1.GetSymbol() symbol2 = context2.GetSymbol() - self.assertTrue(symbol1.IsValid() and symbol2.IsValid()) + self.assertTrue(symbol1 and symbol2) #print "symbol1:", symbol1 #print "symbol2:", symbol2 Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original) +++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Tue May 24 13:22:45 2011 @@ -109,10 +109,10 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. @@ -131,10 +131,10 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) #self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. @@ -156,10 +156,10 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByName('malloc') - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. @@ -189,16 +189,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. self.process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line2. self.assertTrue(self.process.GetState() == lldb.eStateStopped) @@ -230,16 +230,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation('main2.cpp', self.line2) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.runCmd("breakpoint list") # Launch the process, and do not stop at the entry point. self.process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + self.assertTrue(self.process, PROCESS_IS_VALID) # Frame #0 should be on self.line2. self.assertTrue(self.process.GetState() == lldb.eStateStopped) Modified: lldb/trunk/test/source-manager/TestSourceManager.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/source-manager/TestSourceManager.py?rev=131970&r1=131969&r2=131970&view=diff ============================================================================== --- lldb/trunk/test/source-manager/TestSourceManager.py (original) +++ lldb/trunk/test/source-manager/TestSourceManager.py Tue May 24 13:22:45 2011 @@ -40,7 +40,7 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) # Launch the process, and do not stop at the entry point. error = lldb.SBError() From jingham at apple.com Tue May 24 14:08:00 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 24 May 2011 19:08:00 -0000 Subject: [Lldb-commits] [lldb] r131984 - /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Message-ID: <20110524190800.9102A2A6C12C@llvm.org> Author: jingham Date: Tue May 24 14:08:00 2011 New Revision: 131984 URL: http://llvm.org/viewvc/llvm-project?rev=131984&view=rev Log: Fix a thinko in converting to ReadCStringFromMemory. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp 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=131984&r1=131983&r2=131984&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue May 24 14:08:00 2011 @@ -146,8 +146,9 @@ char buf[512]; size_t cstr_len = 0; - size_t curr_len = sizeof(buf); - while (curr_len == sizeof(buf)) + size_t full_buffer_len = sizeof (buf) - 1; + size_t curr_len = full_buffer_len; + while (curr_len == full_buffer_len) { curr_len = exe_ctx.process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); strm.Write (buf, curr_len); From johnny.chen at apple.com Tue May 24 15:36:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 20:36:40 -0000 Subject: [Lldb-commits] [lldb] r131998 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110524203640.949332A6C12C@llvm.org> Author: johnny Date: Tue May 24 15:36:40 2011 New Revision: 131998 URL: http://llvm.org/viewvc/llvm-project?rev=131998&view=rev Log: Add comment. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp 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=131998&r1=131997&r2=131998&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue May 24 15:36:40 2011 @@ -132,6 +132,8 @@ if (!Str.empty() && Str.back() == c) Str = Str.substr(0, Str.size()-1); } +// Aligns the raw disassembly (passed as 'str') with the rest of edis'ed disassembly output. +// This is called from non-raw mode when edis of the current m_inst fails for some reason. static void Align(Stream *s, const char *str, size_t opcodeColWidth, size_t operandColWidth) { From johnny.chen at apple.com Tue May 24 16:05:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 21:05:16 -0000 Subject: [Lldb-commits] [lldb] r132002 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110524210517.091692A6C12C@llvm.org> Author: johnny Date: Tue May 24 16:05:16 2011 New Revision: 132002 URL: http://llvm.org/viewvc/llvm-project?rev=132002&view=rev Log: Update comment. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132002&r1=132001&r2=132002&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue May 24 16:05:16 2011 @@ -3,7 +3,8 @@ # # This script modifies the lldb module (which was automatically generated via # running swig) to support iteration and/or equality operations for certain lldb -# objects, adds a global variable 'debugger_unique_id' and initializes it to 0. +# objects, implements truth value testing for certain lldb objects, and adds a +# global variable 'debugger_unique_id' which is initialized to 0. # # It also calls SBDebugger.Initialize() to initialize the lldb debugger # subsystem. From johnny.chen at apple.com Tue May 24 17:29:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 22:29:49 -0000 Subject: [Lldb-commits] [lldb] r132016 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110524222950.D6E5E2A6C12C@llvm.org> Author: johnny Date: Tue May 24 17:29:49 2011 New Revision: 132016 URL: http://llvm.org/viewvc/llvm-project?rev=132016&view=rev Log: Fix a potential bug resulting from the wrong assumption that SWIG puts out the __init__ method definition before other method definitions. Instead, do without it and process the class with IsValid() method definition in all possible states. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132016&r1=132015&r2=132016&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue May 24 17:29:49 2011 @@ -133,10 +133,9 @@ # method definition in order to insert the appropriate method(s) into the lldb # module. # -# Assuming that SWIG puts out the __init__ method definition before other method -# definitions, the FSM, while in NORMAL state, also checks the current input for -# IsValid() definition, and inserts a __nonzero__() method definition to -# implement truth value testing and the built-in operation bool(). +# The FSM, in all possible states, also checks the current input for IsValid() +# definition, and inserts a __nonzero__() method definition to implement truth +# value testing and the built-in operation bool(). state = NORMAL for line in content.splitlines(): if state == NORMAL: @@ -157,10 +156,6 @@ if cls in e: # Adding support for eq and ne for the matched SB class. state = (state | DEFINING_EQUALITY) - # Look for 'def IsValid(*args):', and once located, add implementation - # of truth value testing for objects by delegation. - elif isvalid_pattern.search(line): - print >> new_content, nonzero_def elif state > NORMAL: match = init_pattern.search(line) if match: @@ -182,6 +177,11 @@ # Next state will be NORMAL. state = NORMAL + # Look for 'def IsValid(*args):', and once located, add implementation + # of truth value testing for this object by delegation. + if isvalid_pattern.search(line): + print >> new_content, nonzero_def + # Pass the original line of content to new_content. print >> new_content, line From johnny.chen at apple.com Tue May 24 17:53:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 22:53:03 -0000 Subject: [Lldb-commits] [lldb] r132018 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110524225303.B0CA42A6C12C@llvm.org> Author: johnny Date: Tue May 24 17:53:03 2011 New Revision: 132018 URL: http://llvm.org/viewvc/llvm-project?rev=132018&view=rev Log: Comment change. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132018&r1=132017&r2=132018&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue May 24 17:53:03 2011 @@ -54,7 +54,7 @@ nonzero_def = " def __nonzero__(self): return self.IsValid()" # -# The dictionary defines a mapping from classname to (getsize, getelem) tuple. +# This dictionary defines a mapping from classname to (getsize, getelem) tuple. # d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), 'SBCompileUnit': ('GetNumLineEntries', 'GetLineEntryAtIndex'), From johnny.chen at apple.com Tue May 24 17:57:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 24 May 2011 22:57:42 -0000 Subject: [Lldb-commits] [lldb] r132019 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110524225742.D73512A6C12C@llvm.org> Author: johnny Date: Tue May 24 17:57:42 2011 New Revision: 132019 URL: http://llvm.org/viewvc/llvm-project?rev=132019&view=rev Log: Added comment. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132019&r1=132018&r2=132019&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue May 24 17:57:42 2011 @@ -71,6 +71,7 @@ 'SBType': ('GetNumberChildren', 'GetChildAtIndex'), 'SBValue': ('GetNumChildren', 'GetChildAtIndex'), + # SBTarget needs special processing, see below. 'SBTarget': {'module': ('GetNumModules', 'GetModuleAtIndex'), 'breakpoint': ('GetNumBreakpoints', 'GetBreakpointAtIndex') } From gclayton at apple.com Tue May 24 18:06:02 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 24 May 2011 23:06:02 -0000 Subject: [Lldb-commits] [lldb] r132021 - in /lldb/trunk: include/lldb/Target/ABI.h source/Expression/IRForTarget.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/Process/Utility/UnwindLLDB.cpp source/Plugins/Process/Utility/UnwindLLDB.h Message-ID: <20110524230602.AB9222A6C12C@llvm.org> Author: gclayton Date: Tue May 24 18:06:02 2011 New Revision: 132021 URL: http://llvm.org/viewvc/llvm-project?rev=132021&view=rev Log: ABI plug-ins must implement the following pure virtual functions: virtual bool ABI::StackUsesFrames () = 0; Should return true if your ABI uses frames when doing stack backtraces. This means a frame pointer is used that points to the previous stack frame in some way or another. virtual bool ABI::CallFrameAddressIsValid (lldb::addr_t cfa) = 0; Should take a look at a call frame address (CFA) which is just the stack pointer value upon entry to a function. ABIs usually impose alignment restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed. This function should return true if "cfa" is valid call frame address for the ABI, and false otherwise. This is used by the generic stack frame unwinding code to help determine when a stack ends. virtual bool ABI::CodeAddressIsValid (lldb::addr_t pc) = 0; Validates a possible PC value and returns true if an opcode can be at "pc". Some ABIs or architectures have fixed width instructions and must be aligned to a 2 or 4 byte boundary. "pc" can be an opcode or a callable address which means the load address might be decorated with extra bits (such as bit zero to indicate a thumb function call for ARM targets), so take this into account when returning true or false. The address should also be validated to ensure it is a valid address for the address size of the inferior process. 32 bit targets should make sure the address is less than UINT32_MAX. Modified UnwindLLDB to use the new ABI functions to help it properly terminate stacks. Modified the mach-o function that extracts dependent files to not resolve the path as the paths inside a binary might not match those on the current host system. Modified: lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Tue May 24 18:06:02 2011 @@ -58,6 +58,15 @@ virtual bool RegisterIsVolatile (const RegisterInfo *reg_info) = 0; + virtual bool + StackUsesFrames () = 0; + + virtual bool + CallFrameAddressIsValid (lldb::addr_t cfa) = 0; + + virtual bool + CodeAddressIsValid (lldb::addr_t pc) = 0; + static lldb::ABISP FindPlugin (const ArchSpec &arch); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue May 24 18:06:02 2011 @@ -1735,10 +1735,7 @@ ConstantIterator constant_iter; UserIterator user_iter; - - const Type *intptr_ty = Type::getIntNTy(m_module->getContext(), - (m_module->getPointerSize() == Module::Pointer64) ? 64 : 32); - + for (constant_iter = static_constants.begin(), user_iter = static_users.begin(); constant_iter != static_constants.end(); ++constant_iter, ++user_iter) Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h Tue May 24 18:06:02 2011 @@ -54,6 +54,31 @@ virtual bool RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); + virtual bool + StackUsesFrames () + { + return true; + } + + virtual bool + CallFrameAddressIsValid (lldb::addr_t cfa) + { + // Make sure the stack call frame addresses are are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + virtual bool + CodeAddressIsValid (lldb::addr_t pc) + { + // Just make sure the address is a valid 32 bit address. Bit zero + // might be set due to Thumb function calls, so don't enforce 2 byte + // alignment + return pc <= UINT32_MAX; + } //------------------------------------------------------------------ // Static Functions Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Tue May 24 18:06:02 2011 @@ -177,6 +177,30 @@ virtual bool RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); + virtual bool + StackUsesFrames () + { + return true; + } + + virtual bool + CallFrameAddressIsValid (lldb::addr_t cfa) + { + // Make sure the stack call frame addresses are are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + virtual bool + CodeAddressIsValid (lldb::addr_t pc) + { + // Just make sure the address is a valid 32 bit address. + return pc <= UINT32_MAX; + } + //------------------------------------------------------------------ // Static Functions Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Tue May 24 18:06:02 2011 @@ -196,6 +196,31 @@ virtual bool RegisterIsVolatile (const lldb_private::RegisterInfo *reg_info); + virtual bool + StackUsesFrames () + { + return true; + } + + virtual bool + CallFrameAddressIsValid (lldb::addr_t cfa) + { + // Make sure the stack call frame addresses are are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned + if (cfa == 0) + return false; // Zero is not a valid stack address + return true; + } + + virtual bool + CodeAddressIsValid (lldb::addr_t pc) + { + // We have a 64 bit address space, so anything is valid as opcodes + // aren't fixed width... + return true; + } + //------------------------------------------------------------------ // Static Functions //------------------------------------------------------------------ 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=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue May 24 18:06:02 2011 @@ -1503,6 +1503,7 @@ struct load_command load_cmd; uint32_t offset = MachHeaderSizeFromMagic(m_header.magic); uint32_t count = 0; + const bool resolve_path = false; // Don't resolve the dependend file paths since they may not reside on this system uint32_t i; for (i=0; i first_register_ctx_ap (new RegisterContextLLDB (m_thread, - RegisterContextLLDB::SharedPtr(), - first_cursor_sp->sctx, - 0)); - if (first_register_ctx_ap.get() == NULL) + RegisterContextLLDB::SharedPtr reg_ctx_sp (new RegisterContextLLDB (m_thread, + RegisterContextLLDB::SharedPtr(), + first_cursor_sp->sctx, + 0)); + if (reg_ctx_sp.get() == NULL) return false; - if (!first_register_ctx_ap->IsValid()) + if (!reg_ctx_sp->IsValid()) return false; - if (!first_register_ctx_ap->GetCFA (first_cursor_sp->cfa)) + if (!reg_ctx_sp->GetCFA (first_cursor_sp->cfa)) return false; - if (!first_register_ctx_ap->ReadPC (first_cursor_sp->start_pc)) + if (!reg_ctx_sp->ReadPC (first_cursor_sp->start_pc)) return false; // Everything checks out, so release the auto pointer value and let the // cursor own it in its shared pointer - first_cursor_sp->reg_ctx.reset(first_register_ctx_ap.release()); + first_cursor_sp->reg_ctx = reg_ctx_sp; m_frames.push_back (first_cursor_sp); return true; } // For adding a non-zero stack frame to m_frames. bool -UnwindLLDB::AddOneMoreFrame () +UnwindLLDB::AddOneMoreFrame (ABI *abi) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); CursorSP cursor_sp(new Cursor ()); @@ -101,14 +104,14 @@ return false; uint32_t cur_idx = m_frames.size (); - std::auto_ptr register_ctx_ap(new RegisterContextLLDB (m_thread, - m_frames[cur_idx - 1]->reg_ctx, - cursor_sp->sctx, - cur_idx)); - if (register_ctx_ap.get() == NULL) + RegisterContextLLDB::SharedPtr reg_ctx_sp(new RegisterContextLLDB (m_thread, + m_frames[cur_idx - 1]->reg_ctx, + cursor_sp->sctx, + cur_idx)); + if (reg_ctx_sp.get() == NULL) return false; - if (!register_ctx_ap->IsValid()) + if (!reg_ctx_sp->IsValid()) { if (log) { @@ -117,7 +120,7 @@ } return false; } - if (!register_ctx_ap->GetCFA (cursor_sp->cfa)) + if (!reg_ctx_sp->GetCFA (cursor_sp->cfa)) { if (log) { @@ -126,7 +129,7 @@ } return false; } - if (cursor_sp->cfa == (addr_t) -1 || cursor_sp->cfa == 1 || cursor_sp->cfa == 0) + if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa)) { if (log) { @@ -135,7 +138,7 @@ } return false; } - if (!register_ctx_ap->ReadPC (cursor_sp->start_pc)) + if (!reg_ctx_sp->ReadPC (cursor_sp->start_pc)) { if (log) { @@ -144,16 +147,28 @@ } return false; } + if (abi && !abi->CodeAddressIsValid (cursor_sp->start_pc)) + { + if (log) + { + log->Printf("%*sFrame %d did not get a valid PC, stopping stack walk", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); + } + return false; + } if (!m_frames.empty()) { - if ((m_frames.back()->start_pc == cursor_sp->start_pc) && - (m_frames.back()->cfa == cursor_sp->cfa)) + if (m_frames.back()->start_pc == cursor_sp->start_pc) { - // Infinite loop where the current cursor is the same as the previous one... - return false; + if (m_frames.back()->cfa == cursor_sp->cfa) + return false; // Infinite loop where the current cursor is the same as the previous one... + else if (abi->StackUsesFrames()) + { + if (reg_ctx_sp->GetFP() == 0) + return false; + } } } - RegisterContextLLDB::SharedPtr reg_ctx_sp(register_ctx_ap.release()); cursor_sp->reg_ctx = reg_ctx_sp; m_frames.push_back (cursor_sp); return true; @@ -168,7 +183,9 @@ return false; } - while (idx >= m_frames.size() && AddOneMoreFrame ()) + ABI *abi = m_thread.GetProcess().GetABI().get(); + + while (idx >= m_frames.size() && AddOneMoreFrame (abi)) ; if (idx < m_frames.size ()) @@ -197,7 +214,9 @@ return reg_ctx_sp; } - while (idx >= m_frames.size() && AddOneMoreFrame ()) + ABI *abi = m_thread.GetProcess().GetABI().get(); + + while (idx >= m_frames.size() && AddOneMoreFrame (abi)) ; if (idx < m_frames.size ()) Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=132021&r1=132020&r2=132021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Tue May 24 18:06:02 2011 @@ -63,7 +63,7 @@ typedef lldb::SharedPtr::Type CursorSP; std::vector m_frames; - bool AddOneMoreFrame (); + bool AddOneMoreFrame (ABI *abi); bool AddFirstFrame (); //------------------------------------------------------------------ From gclayton at apple.com Wed May 25 12:56:20 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 25 May 2011 17:56:20 -0000 Subject: [Lldb-commits] [lldb] r132066 - /lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Message-ID: <20110525175620.BCBD22A6C12C@llvm.org> Author: gclayton Date: Wed May 25 12:56:20 2011 New Revision: 132066 URL: http://llvm.org/viewvc/llvm-project?rev=132066&view=rev Log: Added some comments. Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=132066&r1=132065&r2=132066&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Wed May 25 12:56:20 2011 @@ -164,6 +164,8 @@ return false; // Infinite loop where the current cursor is the same as the previous one... else if (abi->StackUsesFrames()) { + // We might have a CFA that is not using the frame pointer and + // we want to validate that the frame pointer is valid. if (reg_ctx_sp->GetFP() == 0) return false; } From gclayton at apple.com Wed May 25 12:59:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 25 May 2011 17:59:01 -0000 Subject: [Lldb-commits] [lldb] r132067 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110525175901.4AB5C2A6C12C@llvm.org> Author: gclayton Date: Wed May 25 12:59:00 2011 New Revision: 132067 URL: http://llvm.org/viewvc/llvm-project?rev=132067&view=rev Log: Bumping Xcode project versions for lldb-55 and debugserver-139. 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=132067&r1=132066&r2=132067&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed May 25 12:59:00 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 55; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 55; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; - DYLIB_CURRENT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; + DYLIB_CURRENT_VERSION = 55; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 55; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 55; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 46; + DYLIB_CURRENT_VERSION = 55; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3773,7 +3773,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3805,7 +3805,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 46; + CURRENT_PROJECT_VERSION = 55; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132067&r1=132066&r2=132067&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed May 25 12:59:00 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 46 + 55 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=132067&r1=132066&r2=132067&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed May 25 12:59:00 2011 @@ -482,7 +482,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -503,7 +503,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -524,7 +524,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -542,7 +542,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -581,7 +581,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -619,7 +619,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 131; + CURRENT_PROJECT_VERSION = 139; 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 May 25 13:00:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 25 May 2011 18:00:39 -0000 Subject: [Lldb-commits] [lldb] r132068 - /lldb/tags/ Message-ID: <20110525180039.67EB32A6C12C@llvm.org> Author: gclayton Date: Wed May 25 13:00:39 2011 New Revision: 132068 URL: http://llvm.org/viewvc/llvm-project?rev=132068&view=rev Log: Making a tags directory. Added: lldb/tags/ From gclayton at apple.com Wed May 25 13:03:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 25 May 2011 18:03:47 -0000 Subject: [Lldb-commits] [lldb] r132069 - /lldb/tags/lldb-55/ Message-ID: <20110525180347.7D9E02A6C12C@llvm.org> Author: gclayton Date: Wed May 25 13:03:47 2011 New Revision: 132069 URL: http://llvm.org/viewvc/llvm-project?rev=132069&view=rev Log: Tagging lldb-55 Added: lldb/tags/lldb-55/ - copied from r132068, lldb/trunk/ From johnny.chen at apple.com Wed May 25 14:06:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 19:06:18 -0000 Subject: [Lldb-commits] [lldb] r132072 - in /lldb/trunk/test: lldbtest.py lldbutil.py Message-ID: <20110525190618.7DCC42A6C12C@llvm.org> Author: johnny Date: Wed May 25 14:06:18 2011 New Revision: 132072 URL: http://llvm.org/viewvc/llvm-project?rev=132072&view=rev Log: Convert these two modules to use the compact truth value testing as well. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=132072&r1=132071&r2=132072&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed May 25 14:06:18 2011 @@ -522,7 +522,7 @@ except AttributeError: self.dbg = lldb.SBDebugger.Create() - if not self.dbg.IsValid(): + if not self.dbg: raise Exception('Invalid debugger instance') # We want our debugger to be synchronous. @@ -715,7 +715,7 @@ # Terminate the current process being debugged, if any. if self.runStarted: self.runCmd("process kill", PROCESS_KILLED, check=False) - elif self.process and self.process.IsValid(): + elif self.process: rc = self.invoke(self.process, "Kill") self.assertTrue(rc.Success(), PROCESS_KILLED) del self.process Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=132072&r1=132071&r2=132072&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Wed May 25 14:06:18 2011 @@ -382,7 +382,7 @@ function = frame.GetFunction() load_addr = addrs[i].GetLoadAddress(target) - if not function.IsValid(): + if not function: file_addr = addrs[i].GetFileAddress() print >> output, " frame #{num}: {addr:#016x} {mod}`{symbol} + ????".format( num=i, addr=load_addr, mod=mods[i], symbol=symbols[i]) @@ -440,9 +440,9 @@ args.append("(%s)%s=%s" % (var.GetTypeName(), var.GetName(), var.GetValue(frame))) - if frame.GetFunction().IsValid(): + if frame.GetFunction(): name = frame.GetFunction().GetName() - elif frame.GetSymbol().IsValid(): + elif frame.GetSymbol(): name = frame.GetSymbol().GetName() else: name = "" From johnny.chen at apple.com Wed May 25 15:47:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 20:47:28 -0000 Subject: [Lldb-commits] [lldb] r132078 - /lldb/trunk/utils/test/lldb-disasm.py Message-ID: <20110525204728.2E9662A6C12C@llvm.org> Author: johnny Date: Wed May 25 15:47:27 2011 New Revision: 132078 URL: http://llvm.org/viewvc/llvm-project?rev=132078&view=rev Log: Use built-in truth value testing. Modified: lldb/trunk/utils/test/lldb-disasm.py Modified: lldb/trunk/utils/test/lldb-disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/lldb-disasm.py?rev=132078&r1=132077&r2=132078&view=diff ============================================================================== --- lldb/trunk/utils/test/lldb-disasm.py (original) +++ lldb/trunk/utils/test/lldb-disasm.py Wed May 25 15:47:27 2011 @@ -81,7 +81,7 @@ # Create the debugger instance now. dbg = lldb.SBDebugger.Create() - if not dbg.IsValid(): + if not dbg: raise Exception('Invalid debugger instance') # Register an exit callback. From johnny.chen at apple.com Wed May 25 15:48:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 20:48:29 -0000 Subject: [Lldb-commits] [lldb] r132079 - /lldb/trunk/examples/python/disasm.py Message-ID: <20110525204829.5601E2A6C12C@llvm.org> Author: johnny Date: Wed May 25 15:48:29 2011 New Revision: 132079 URL: http://llvm.org/viewvc/llvm-project?rev=132079&view=rev Log: Use built-in truth value testing. Modified: lldb/trunk/examples/python/disasm.py Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=132079&r1=132078&r2=132079&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed May 25 15:48:29 2011 @@ -29,7 +29,7 @@ target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT) -if target.IsValid(): +if target: # If the target is valid set a breakpoint at main main_bp = target.BreakpointCreateByName ("main", target.GetExecutable().GetFilename()); @@ -41,24 +41,24 @@ process = target.Launch (debugger.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) # Make sure the launch went ok - if process.IsValid(): + if process: # Print some simple process info state = process.GetState () print process if state == lldb.eStateStopped: # Get the first thread thread = process.GetThreadAtIndex (0) - if thread.IsValid(): + if thread: # Print some simple thread info print thread # Get the first frame frame = thread.GetFrameAtIndex (0) - if frame.IsValid(): + if frame: # Print some simple frame info print frame function = frame.GetFunction() # See if we have debug info (a function) - if function.IsValid(): + if function: # We do have a function, print some info for the function print function # Now get all instructions for this function and print them @@ -67,7 +67,7 @@ else: # See if we have a symbol in the symbol table for where we stopped symbol = frame.GetSymbol(); - if symbol.IsValid(): + if symbol: # We do have a symbol, print some info for the symbol print symbol # Now get all instructions for this symbol and print them From johnny.chen at apple.com Wed May 25 15:56:32 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 20:56:32 -0000 Subject: [Lldb-commits] [lldb] r132082 - /lldb/trunk/examples/python/disasm.py Message-ID: <20110525205632.E96EF2A6C12D@llvm.org> Author: johnny Date: Wed May 25 15:56:32 2011 New Revision: 132082 URL: http://llvm.org/viewvc/llvm-project?rev=132082&view=rev Log: Modified to use SBTarget.LaunchSimple() API. Modified: lldb/trunk/examples/python/disasm.py Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=132082&r1=132081&r2=132082&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed May 25 15:56:32 2011 @@ -37,8 +37,7 @@ # Launch the process. Since we specified synchronous mode, we won't return # from this function until we hit the breakpoint at main - error = lldb.SBError() - process = target.Launch (debugger.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error) + process = target.LaunchSimple (None, None, os.getcwd()) # Make sure the launch went ok if process: From johnny.chen at apple.com Wed May 25 17:01:17 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 22:01:17 -0000 Subject: [Lldb-commits] [lldb] r132088 - /lldb/trunk/examples/python/disasm.py Message-ID: <20110525220117.20DA22A6C12C@llvm.org> Author: johnny Date: Wed May 25 17:01:16 2011 New Revision: 132088 URL: http://llvm.org/viewvc/llvm-project?rev=132088&view=rev Log: Add a little twist to the disasm.py script so that it is possible to terminate the inferior process by entering 'Ctrl-D' or 'quit'. Modified: lldb/trunk/examples/python/disasm.py Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=132088&r1=132087&r2=132088&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed May 25 17:01:16 2011 @@ -11,7 +11,7 @@ import lldb import os import sys -import time +import signal def disassemble_instructions (insts): for i in insts: @@ -81,12 +81,17 @@ for child in value: print "Name: ", child.GetName(), " Value: ", child.GetValue(frame) - print "Hit the breakpoint at main, continue and wait for program to exit..." - # Now continue to the program exit - process.Continue() - # When we return from the above function we will hopefully be at the - # program exit. Print out some process info - print process + print "Hit the breakpoint at main, enter to continue and wait for program to exit or 'Ctrl-D'/'quit' to terminate the program" + next = sys.stdin.readline() + if not next or next.rstrip('\n') == 'quit': + print "Terminating the inferior process..." + process.Kill() + else: + # Now continue to the program exit + process.Continue() + # When we return from the above function we will hopefully be at the + # program exit. Print out some process info + print process elif state == lldb.eStateExited: print "Didn't hit the breakpoint at main, program has exited..." else: From johnny.chen at apple.com Wed May 25 17:29:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 25 May 2011 22:29:24 -0000 Subject: [Lldb-commits] [lldb] r132090 - /lldb/trunk/examples/python/disasm.py Message-ID: <20110525222924.13A4E2A6C12C@llvm.org> Author: johnny Date: Wed May 25 17:29:23 2011 New Revision: 132090 URL: http://llvm.org/viewvc/llvm-project?rev=132090&view=rev Log: Add a little spice to the script to allow us to specify a function name to break at and to disassemble. Usage: disasm.py [-n name] executable-image By default, it breaks at and disassembles the 'main' function. Modified: lldb/trunk/examples/python/disasm.py Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=132090&r1=132089&r2=132090&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed May 25 17:29:23 2011 @@ -17,6 +17,23 @@ for i in insts: print i +def usage(): + print "Usage: disasm.py [-n name] executable-image" + print " By default, it breaks at and disassembles the 'main' function." + sys.exit(0) + +if len(sys.argv) == 2: + fname = 'main' + exe = sys.argv[1] +elif len(sys.argv) == 4: + if sys.argv[1] != '-n': + usage() + else: + fname = sys.argv[2] + exe = sys.argv[3] +else: + usage() + # Create a new debugger instance debugger = lldb.SBDebugger.Create() @@ -25,13 +42,13 @@ debugger.SetAsync (False) # Create a target from a file and arch -print "Creating a target for '%s'" % sys.argv[1] +print "Creating a target for '%s'" % exe -target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT) +target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT) if target: # If the target is valid set a breakpoint at main - main_bp = target.BreakpointCreateByName ("main", target.GetExecutable().GetFilename()); + main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename()); print main_bp From gclayton at apple.com Thu May 26 11:54:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 26 May 2011 16:54:13 -0000 Subject: [Lldb-commits] [lldb] r132123 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110526165413.3AF592A6C12C@llvm.org> Author: gclayton Date: Thu May 26 11:54:13 2011 New Revision: 132123 URL: http://llvm.org/viewvc/llvm-project?rev=132123&view=rev Log: lldb-56 with codesign settings fixed in the Xcode projects. 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=132123&r1=132122&r2=132123&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu May 26 11:54:13 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 55; + DYLIB_CURRENT_VERSION = 56; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 55; + DYLIB_CURRENT_VERSION = 56; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 55; - DYLIB_CURRENT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; + DYLIB_CURRENT_VERSION = 56; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 55; + DYLIB_CURRENT_VERSION = 56; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 55; + DYLIB_CURRENT_VERSION = 56; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 55; + DYLIB_CURRENT_VERSION = 56; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3698,6 +3698,7 @@ 26DC6A121337FE6A00FF7998 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = YES; FRAMEWORK_SEARCH_PATHS = ( @@ -3717,6 +3718,7 @@ AppKit, ); PRODUCT_NAME = "lldb-platform"; + PROVISIONING_PROFILE = ""; 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 = Debug; @@ -3724,6 +3726,7 @@ 26DC6A131337FE6A00FF7998 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -3742,6 +3745,7 @@ AppKit, ); PRODUCT_NAME = "lldb-platform"; + PROVISIONING_PROFILE = ""; 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 = Release; @@ -3773,7 +3777,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3805,7 +3809,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 55; + CURRENT_PROJECT_VERSION = 56; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132123&r1=132122&r2=132123&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu May 26 11:54:13 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 55 + 56 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=132123&r1=132122&r2=132123&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu May 26 11:54:13 2011 @@ -359,7 +359,6 @@ 26CE05C7115C36870022F371 /* ShellScript */, 26CE0591115C31C20022F371 /* Sources */, 26CE0592115C31C20022F371 /* Frameworks */, - 26C688951378864600407EDF /* Codesign Hack */, ); buildRules = ( ); @@ -398,20 +397,6 @@ /* End PBXProject section */ /* Begin PBXShellScriptBuildPhase section */ - 26C688951378864600407EDF /* Codesign Hack */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Codesign Hack"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "codesign --force --keychain ~/Library/Keychains/login.keychain --sign lldb_codesign \"$CODESIGNING_FOLDER_PATH\""; - }; 26CE05C7115C36870022F371 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -580,6 +565,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 139; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -609,6 +595,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; + PROVISIONING_PROFILE = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -618,6 +605,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; + CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 139; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -647,6 +635,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; + PROVISIONING_PROFILE = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; From gclayton at apple.com Thu May 26 11:57:00 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 26 May 2011 16:57:00 -0000 Subject: [Lldb-commits] [lldb] r132124 - /lldb/tags/lldb-56/ Message-ID: <20110526165700.465122A6C12C@llvm.org> Author: gclayton Date: Thu May 26 11:57:00 2011 New Revision: 132124 URL: http://llvm.org/viewvc/llvm-project?rev=132124&view=rev Log: Tagging lldb-56 Added: lldb/tags/lldb-56/ - copied from r132123, lldb/trunk/ From jingham at apple.com Thu May 26 15:39:01 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 26 May 2011 20:39:01 -0000 Subject: [Lldb-commits] [lldb] r132141 - /lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Message-ID: <20110526203901.6B3532A6C12C@llvm.org> Author: jingham Date: Thu May 26 15:39:01 2011 New Revision: 132141 URL: http://llvm.org/viewvc/llvm-project?rev=132141&view=rev Log: regexp-break -> _regexp-break in command string. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=132141&r1=132140&r2=132141&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Thu May 26 15:39:01 2011 @@ -518,7 +518,7 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : CommandObjectMultiword (interpreter, "breakpoint", - "A set of commands for operating on breakpoints. Also see regexp-break.", + "A set of commands for operating on breakpoints. Also see _regexp-break.", "breakpoint []") { bool status; From johnny.chen at apple.com Thu May 26 16:43:19 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 26 May 2011 21:43:19 -0000 Subject: [Lldb-commits] [lldb] r132147 - /lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Message-ID: <20110526214319.95D192A6C12C@llvm.org> Author: johnny Date: Thu May 26 16:43:19 2011 New Revision: 132147 URL: http://llvm.org/viewvc/llvm-project?rev=132147&view=rev Log: Simplify test setup; there's no need to pass a customized dictionary here. Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=132147&r1=132146&r2=132147&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Thu May 26 16:43:19 2011 @@ -20,7 +20,7 @@ def test_frame_utils(self): """Test utility functions for the frame object.""" - self.buildDefault(dictionary={'C_SOURCES': 'main.c'}) + self.buildDefault() self.frame_utils() def frame_utils(self): From johnny.chen at apple.com Thu May 26 16:50:47 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 26 May 2011 21:50:47 -0000 Subject: [Lldb-commits] [lldb] r132150 - /lldb/trunk/test/python_api/thread/TestThreadAPI.py Message-ID: <20110526215048.03E462A6C12C@llvm.org> Author: johnny Date: Thu May 26 16:50:47 2011 New Revision: 132150 URL: http://llvm.org/viewvc/llvm-project?rev=132150&view=rev Log: Comment change. Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py Modified: lldb/trunk/test/python_api/thread/TestThreadAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/thread/TestThreadAPI.py?rev=132150&r1=132149&r2=132150&view=diff ============================================================================== --- lldb/trunk/test/python_api/thread/TestThreadAPI.py (original) +++ lldb/trunk/test/python_api/thread/TestThreadAPI.py Thu May 26 16:50:47 2011 @@ -98,7 +98,7 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break inside main(). + # Find the line number within main.cpp to break inside main(). self.line = line_number("main.cpp", "// Set break point at this line and check variable 'my_char'.") # Find the line numbers within main2.cpp for step_over_3_times() and step_out_of_malloc_into_function_b(). self.line2 = line_number("main2.cpp", "// thread step-out of malloc into function b.") From johnny.chen at apple.com Thu May 26 16:53:05 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 26 May 2011 21:53:05 -0000 Subject: [Lldb-commits] [lldb] r132152 - /lldb/trunk/test/lldbutil.py Message-ID: <20110526215305.9663B2A6C12C@llvm.org> Author: johnny Date: Thu May 26 16:53:05 2011 New Revision: 132152 URL: http://llvm.org/viewvc/llvm-project?rev=132152&view=rev Log: Add comment. Modified: lldb/trunk/test/lldbutil.py Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=132152&r1=132151&r2=132152&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu May 26 16:53:05 2011 @@ -210,7 +210,10 @@ # ================================================== def get_stopped_threads(process, reason): - """Returns the thread(s) with the specified stop reason in a list.""" + """Returns the thread(s) with the specified stop reason in a list. + + The list can be empty if no such thread exists. + """ threads = [] for t in process: if t.GetStopReason() == reason: From johnny.chen at apple.com Thu May 26 17:01:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 26 May 2011 22:01:50 -0000 Subject: [Lldb-commits] [lldb] r132160 - /lldb/trunk/test/process_launch/TestProcessLaunch.py Message-ID: <20110526220150.3C5C92A6C12C@llvm.org> Author: johnny Date: Thu May 26 17:01:50 2011 New Revision: 132160 URL: http://llvm.org/viewvc/llvm-project?rev=132160&view=rev Log: Remove extra '.' in the comment. Modified: lldb/trunk/test/process_launch/TestProcessLaunch.py Modified: lldb/trunk/test/process_launch/TestProcessLaunch.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/process_launch/TestProcessLaunch.py?rev=132160&r1=132159&r2=132160&view=diff ============================================================================== --- lldb/trunk/test/process_launch/TestProcessLaunch.py (original) +++ lldb/trunk/test/process_launch/TestProcessLaunch.py Thu May 26 17:01:50 2011 @@ -1,5 +1,5 @@ """ -Test lldb process launch flags.. +Test lldb process launch flags. """ import os, time From johnny.chen at apple.com Fri May 27 16:58:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 27 May 2011 21:58:22 -0000 Subject: [Lldb-commits] [lldb] r132221 - /lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py Message-ID: <20110527215822.3A5F32A6C12C@llvm.org> Author: johnny Date: Fri May 27 16:58:22 2011 New Revision: 132221 URL: http://llvm.org/viewvc/llvm-project?rev=132221&view=rev Log: Use the with statement to simplify the build script. Modified: lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py Modified: lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py?rev=132221&r1=132220&r2=132221&view=diff ============================================================================== --- lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py (original) +++ lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py Fri May 27 16:58:22 2011 @@ -20,52 +20,30 @@ # That's what this python script does. # - import os +include_python = '#include ' +include_python_ifdef = '''#if defined (__APPLE__) +#include +#else +#include +#endif +''' + input_dir_name = os.environ["SRCROOT"] full_input_name = input_dir_name + "/source/LLDBWrapPython.cpp" full_output_name = full_input_name + ".edited" -try: - f_in = open (full_input_name, 'r') -except IOError: - print "Error: Unable to open file for reading: " + full_input_name -else: - try: - f_out = open (full_output_name, 'w') - except IOError: - print "Error: Unable to open file for writing: " + full_output_name - else: - include_line_found = False +with open(full_input_name, 'r') as f_in: + with open(full_output_name, 'w') as f_out: + include_python_found = False + for line in f_in: + if not include_python_found: + if line.startswith(include_python): + # Write out the modified lines. + f_out.write(include_python_ifdef) + include_python_found = True + continue - try: - line = f_in.readline() - except IOError: - print "Error occurred while reading file." - else: - while line: - # - # - if not include_line_found: - if (line.find ("#include ") == 0): - f_out.write ("#if defined (__APPLE__)\n"); - f_out.write ("#include \n"); - f_out.write ("#else\n"); - f_out.write (line); - f_out.write ("#endif\n"); - include_line_found = True - else: - f_out.write (line) - else: - f_out.write (line) - try: - line = f_in.readline() - except IOError: - print "Error occurred while reading file." - - try: - f_in.close() - f_out.close() - except: - print "Error occurred while closing files" + # Otherwise, copy the line verbatim to the output file. + f_out.write(line) From johnny.chen at apple.com Fri May 27 18:36:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 27 May 2011 23:36:52 -0000 Subject: [Lldb-commits] [lldb] r132231 - /lldb/trunk/test/lldbtest.py Message-ID: <20110527233652.94F192A6C12C@llvm.org> Author: johnny Date: Fri May 27 18:36:52 2011 New Revision: 132231 URL: http://llvm.org/viewvc/llvm-project?rev=132231&view=rev Log: Add comment headers describing some method groups of our TestBase class. Remove an unnecessary __import__() function call. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=132231&r1=132230&r2=132231&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri May 27 18:36:52 2011 @@ -919,6 +919,10 @@ # End of while loop. + # ==================================================== + # Config. methods supported through a plugin interface + # (enables reading of the current test configuration) + # ==================================================== def getArchitecture(self): """Returns the architecture in effect the test suite is now running with.""" @@ -933,7 +937,6 @@ def getRunOptions(self): """Command line option for -A and -C to run this test again, called from within dumpSessionInfo().""" - module = __import__(sys.platform) arch = self.getArchitecture() comp = self.getCompiler() if not arch and not comp: @@ -942,6 +945,10 @@ return "%s %s" % ("-A "+arch if arch else "", "-C "+comp if comp else "") + # ================================================== + # Build methods supported through a plugin interface + # ================================================== + def buildDefault(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build the default binaries.""" module = __import__(sys.platform) @@ -960,6 +967,10 @@ if not module.buildDwarf(self, architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dwarf") + # ================================================= + # Misc. helper methods for debugging test execution + # ================================================= + def DebugSBValue(self, frame, val): """Debug print a SBValue object, if traceAlways is True.""" from lldbutil import value_type_to_str From johnny.chen at apple.com Fri May 27 18:42:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 27 May 2011 23:42:46 -0000 Subject: [Lldb-commits] [lldb] r132232 - in /lldb/trunk/test: lldbtest.py plugins/darwin.py Message-ID: <20110527234246.1BF6A2A6C12C@llvm.org> Author: johnny Date: Fri May 27 18:42:45 2011 New Revision: 132232 URL: http://llvm.org/viewvc/llvm-project?rev=132232&view=rev Log: Fix some comments. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/plugins/darwin.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=132232&r1=132231&r2=132232&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri May 27 18:42:45 2011 @@ -925,18 +925,18 @@ # ==================================================== def getArchitecture(self): - """Returns the architecture in effect the test suite is now running with.""" + """Returns the architecture in effect the test suite is running with.""" module = __import__(sys.platform) return module.getArchitecture() def getCompiler(self): - """Returns the compiler in effect the test suite is now running with.""" + """Returns the compiler in effect the test suite is running with.""" module = __import__(sys.platform) return module.getCompiler() def getRunOptions(self): """Command line option for -A and -C to run this test again, called from - within dumpSessionInfo().""" + self.dumpSessionInfo().""" arch = self.getArchitecture() comp = self.getCompiler() if not arch and not comp: Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=132232&r1=132231&r2=132232&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Fri May 27 18:42:45 2011 @@ -18,11 +18,11 @@ #print "Hello, darwin plugin!" def getArchitecture(): - """Returns the architecture in effect the test suite is now running with.""" + """Returns the architecture in effect the test suite is running with.""" return os.environ["ARCH"] if "ARCH" in os.environ else "" def getCompiler(): - """Returns the compiler in effect the test suite is now running with.""" + """Returns the compiler in effect the test suite is running with.""" return os.environ["CC"] if "CC" in os.environ else "" def getArchSpec(architecture): From gclayton at apple.com Sat May 28 19:45:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 00:45:15 -0000 Subject: [Lldb-commits] [lldb] r132270 - /lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Message-ID: <20110529004515.8834D2A6C12C@llvm.org> Author: gclayton Date: Sat May 28 19:45:15 2011 New Revision: 132270 URL: http://llvm.org/viewvc/llvm-project?rev=132270&view=rev Log: Fixed an issue that could cause LLDB to spin indefinitely. Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=132270&r1=132269&r2=132270&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Sat May 28 19:45:15 2011 @@ -245,6 +245,7 @@ status = eConnectionStatusError; break; // Break to close.... + case ENOENT: // no such file or directory case EBADF: // fildes is not a valid file or socket descriptor open for reading. case ENXIO: // An action is requested of a device that does not exist.. // A requested action cannot be performed by the device. From gclayton at apple.com Sat May 28 20:30:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 01:30:03 -0000 Subject: [Lldb-commits] [lldb] r132271 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110529013003.150B72A6C12C@llvm.org> Author: gclayton Date: Sat May 28 20:30:02 2011 New Revision: 132271 URL: http://llvm.org/viewvc/llvm-project?rev=132271&view=rev Log: lldb-57 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132271&r1=132270&r2=132271&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat May 28 20:30:02 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 56; + DYLIB_CURRENT_VERSION = 57; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 56; + DYLIB_CURRENT_VERSION = 57; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 56; - DYLIB_CURRENT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; + DYLIB_CURRENT_VERSION = 57; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 56; + DYLIB_CURRENT_VERSION = 57; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 56; + DYLIB_CURRENT_VERSION = 57; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 56; + DYLIB_CURRENT_VERSION = 57; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3777,7 +3777,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3809,7 +3809,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 56; + CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132271&r1=132270&r2=132271&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Sat May 28 20:30:02 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 56 + 57 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Sat May 28 20:31:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 01:31:32 -0000 Subject: [Lldb-commits] [lldb] r132272 - /lldb/tags/lldb-57/ Message-ID: <20110529013132.D000E2A6C12C@llvm.org> Author: gclayton Date: Sat May 28 20:31:32 2011 New Revision: 132272 URL: http://llvm.org/viewvc/llvm-project?rev=132272&view=rev Log: lldb-57 Added: lldb/tags/lldb-57/ - copied from r132271, lldb/trunk/ From gclayton at apple.com Sat May 28 20:50:51 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 01:50:51 -0000 Subject: [Lldb-commits] [lldb] r132273 - /lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj Message-ID: <20110529015051.920132A6C12C@llvm.org> Author: gclayton Date: Sat May 28 20:50:51 2011 New Revision: 132273 URL: http://llvm.org/viewvc/llvm-project?rev=132273&view=rev Log: Don't strip any debug symbols from the the liblldb-core.a. Modified: lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj Modified: lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj?rev=132273&r1=132272&r2=132273&view=diff ============================================================================== --- lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-57/lldb.xcodeproj/project.pbxproj Sat May 28 20:50:51 2011 @@ -3509,7 +3509,7 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_CURRENT_VERSION = 57; @@ -3549,7 +3549,7 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_CURRENT_VERSION = 57; From gclayton at apple.com Sat May 28 23:06:55 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 04:06:55 -0000 Subject: [Lldb-commits] [lldb] r132280 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Core/Debugger.h lldb.xcodeproj/project.pbxproj source/API/SBDebugger.cpp source/Core/Debugger.cpp tools/driver/Driver.cpp Message-ID: <20110529040655.DA74B2A6C12C@llvm.org> Author: gclayton Date: Sat May 28 23:06:55 2011 New Revision: 132280 URL: http://llvm.org/viewvc/llvm-project?rev=132280&view=rev Log: Don't have the debugger default to ignoring EOF. This is only what the driver (or anything running in a terminal) wants. Not what a UI (Xcode) would want where it creates a debugger per debug window. The current code had an infinite loop after a debug session ended. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Sat May 28 23:06:55 2011 @@ -205,6 +205,12 @@ void SetScriptLanguage (lldb::ScriptLanguage script_lang); + bool + GetCloseInputOnEOF () const; + + void + SetCloseInputOnEOF (bool b); + private: #ifndef SWIG Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Sat May 28 23:06:55 2011 @@ -415,6 +415,12 @@ static int TestDebuggerRefCount (); + bool + GetCloseInputOnEOF () const; + + void + SetCloseInputOnEOF (bool b); + protected: static void Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat May 28 23:06:55 2011 @@ -3509,7 +3509,7 @@ 2689FFD613353D7A00698AC0 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_CURRENT_VERSION = 57; @@ -3549,7 +3549,7 @@ 2689FFD713353D7A00698AC0 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 57; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_CURRENT_VERSION = 57; Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Sat May 28 23:06:55 2011 @@ -861,3 +861,17 @@ return sb_error; } +bool +SBDebugger::GetCloseInputOnEOF () const +{ + if (m_opaque_sp) + return m_opaque_sp->GetCloseInputOnEOF (); + return false; +} + +void +SBDebugger::SetCloseInputOnEOF (bool b) +{ + if (m_opaque_sp) + m_opaque_sp->SetCloseInputOnEOF (b); +} Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat May 28 23:06:55 2011 @@ -233,7 +233,6 @@ m_input_readers (), m_input_reader_data () { - m_input_comm.SetCloseOnEOF(false); m_command_interpreter_ap->Initialize (); // Always add our default platform to the platform list PlatformSP default_platform_sp (Platform::GetDefaultPlatform()); @@ -256,6 +255,18 @@ bool +Debugger::GetCloseInputOnEOF () const +{ + return m_input_comm.GetCloseOnEOF(); +} + +void +Debugger::SetCloseInputOnEOF (bool b) +{ + m_input_comm.SetCloseOnEOF(b); +} + +bool Debugger::GetAsyncExecution () { return !m_command_interpreter_ap->GetSynchronous(); Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=132280&r1=132279&r2=132280&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Sat May 28 23:06:55 2011 @@ -91,6 +91,9 @@ m_option_data (), m_waiting_for_command (false) { + // We want to be able to handle CTRL+D in the terminal to have it terminate + // certain input + m_debugger.SetCloseInputOnEOF (false); g_debugger_name = (char *) m_debugger.GetInstanceName(); if (g_debugger_name == NULL) g_debugger_name = (char *) ""; From gclayton at apple.com Sat May 28 23:10:48 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 04:10:48 -0000 Subject: [Lldb-commits] [lldb] r132281 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110529041048.BACB82A6C12C@llvm.org> Author: gclayton Date: Sat May 28 23:10:48 2011 New Revision: 132281 URL: http://llvm.org/viewvc/llvm-project?rev=132281&view=rev Log: lldb-58 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132281&r1=132280&r2=132281&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat May 28 23:10:48 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 57; + DYLIB_CURRENT_VERSION = 58; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 57; + DYLIB_CURRENT_VERSION = 58; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; - DYLIB_CURRENT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; + DYLIB_CURRENT_VERSION = 58; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 57; + DYLIB_CURRENT_VERSION = 58; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 57; + DYLIB_CURRENT_VERSION = 58; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 57; + DYLIB_CURRENT_VERSION = 58; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3777,7 +3777,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3809,7 +3809,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 57; + CURRENT_PROJECT_VERSION = 58; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132281&r1=132280&r2=132281&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Sat May 28 23:10:48 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 57 + 58 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Sat May 28 23:11:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 04:11:09 -0000 Subject: [Lldb-commits] [lldb] r132282 - /lldb/tags/lldb-58/ Message-ID: <20110529041110.0EC3A2A6C12C@llvm.org> Author: gclayton Date: Sat May 28 23:11:09 2011 New Revision: 132282 URL: http://llvm.org/viewvc/llvm-project?rev=132282&view=rev Log: lldb-58 Added: lldb/tags/lldb-58/ - copied from r132281, lldb/trunk/ From gclayton at apple.com Sun May 29 14:21:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 19:21:38 -0000 Subject: [Lldb-commits] [lldb] r132289 - /lldb/trunk/source/Core/UserSettingsController.cpp Message-ID: <20110529192138.1CDC02A6C12E@llvm.org> Author: gclayton Date: Sun May 29 14:21:37 2011 New Revision: 132289 URL: http://llvm.org/viewvc/llvm-project?rev=132289&view=rev Log: Make sure if an enumeration "settings" value has a valid default setting in its definition, that the first enumeration doesn't always get used as the default. Modified: lldb/trunk/source/Core/UserSettingsController.cpp Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=132289&r1=132288&r2=132289&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Sun May 29 14:21:37 2011 @@ -727,21 +727,23 @@ UserSettingsController::CreateDefaultInstanceSettings () { Error err; - const ConstString &default_name = InstanceSettings::GetDefaultName(); + const ConstString &default_instance_name = InstanceSettings::GetDefaultName(); for (int i = 0; i < m_settings.instance_settings.size(); ++i) { SettingEntry &entry = m_settings.instance_settings[i]; ConstString var_name (entry.var_name); - const char *value = entry.default_value; + const char *default_value = entry.default_value; - if (entry.var_type == eSetVarTypeEnum) - value = entry.enum_values[0].string_value; + // If there is no default value, then use the first enumeration value + // as the default value + if (default_value == NULL && entry.var_type == eSetVarTypeEnum) + default_value = entry.enum_values[0].string_value; - if (value != NULL) + if (default_value != NULL) m_default_settings->UpdateInstanceSettingsVariable (var_name, NULL, - value, - default_name, + default_value, + default_instance_name, entry, eVarSetOperationAssign, err, From gclayton at apple.com Sun May 29 18:07:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 29 May 2011 23:07:38 -0000 Subject: [Lldb-commits] [lldb] r132301 - in /lldb/trunk: include/lldb/Core/Debugger.h source/Core/Debugger.cpp Message-ID: <20110529230738.30F212A6C12C@llvm.org> Author: gclayton Date: Sun May 29 18:07:38 2011 New Revision: 132301 URL: http://llvm.org/viewvc/llvm-project?rev=132301&view=rev Log: Protect the input reader stack with a recursive mutex. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=132301&r1=132300&r2=132301&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Sun May 29 18:07:38 2011 @@ -451,6 +451,7 @@ SourceManager m_source_manager; std::auto_ptr m_command_interpreter_ap; + Mutex m_input_readers_mutex; std::stack m_input_readers; std::string m_input_reader_data; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=132301&r1=132300&r2=132301&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sun May 29 18:07:38 2011 @@ -230,6 +230,7 @@ m_listener ("lldb.Debugger"), m_source_manager (), m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), + m_input_readers_mutex (Mutex::eMutexTypeRecursive), m_input_readers (), m_input_reader_data () { @@ -356,6 +357,7 @@ { InputReaderSP reader_sp; + Mutex::Locker locker (m_input_readers_mutex); if (!m_input_readers.empty()) { // Clear any finished readers from the stack @@ -422,6 +424,7 @@ { m_input_reader_data.clear(); + Mutex::Locker locker (m_input_readers_mutex); // The bottom input reader should be the main debugger input reader. We do not want to close that one here. while (m_input_readers.size() > 1) { @@ -476,6 +479,7 @@ if (m_input_reader_data.empty()) return; + Mutex::Locker locker (m_input_readers_mutex); while (!m_input_readers.empty() && !m_input_reader_data.empty()) { // Get the input reader from the top of the stack @@ -515,6 +519,7 @@ if (top_reader_sp) top_reader_sp->Notify (eInputReaderDeactivate); + Mutex::Locker locker (m_input_readers_mutex); m_input_readers.push (reader_sp); reader_sp->Notify (eInputReaderActivate); ActivateInputReader (reader_sp); @@ -527,6 +532,7 @@ // The reader on the stop of the stack is done, so let the next // read on the stack referesh its prompt and if there is one... + Mutex::Locker locker (m_input_readers_mutex); if (!m_input_readers.empty()) { // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. @@ -557,6 +563,7 @@ Debugger::CheckIfTopInputReaderIsDone () { bool result = false; + Mutex::Locker locker (m_input_readers_mutex); if (!m_input_readers.empty()) { // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. From gclayton at apple.com Sun May 29 19:39:49 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 30 May 2011 00:39:49 -0000 Subject: [Lldb-commits] [lldb] r132303 - /lldb/trunk/source/Target/Target.cpp Message-ID: <20110530003949.162A82A6C12C@llvm.org> Author: gclayton Date: Sun May 29 19:39:48 2011 New Revision: 132303 URL: http://llvm.org/viewvc/llvm-project?rev=132303&view=rev Log: Disable dynamic types being on by default until kinks get worked out when they don't update correctly. Currently if a variable is unavailable due to a register not being available in a higher frame or due to the PC value not being a valid location list value, "" will get displayed as the variable type. I am not sure what other things will fail, so I am disabling it for now just by letting the default enumeration value default to it being disabled. Modified: lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=132303&r1=132302&r2=132303&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Sun May 29 19:39:48 2011 @@ -1717,9 +1717,9 @@ OptionEnumValueElement TargetInstanceSettings::g_dynamic_value_types[] = { -{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, -{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."}, -{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."}, +{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, +{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."}, +{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."}, { 0, NULL, NULL } }; @@ -1738,8 +1738,8 @@ // var-name var-type default enum init'd hidden help-text // ================= ================== =============== ======================= ====== ====== ========================================================================= { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, - { TSC_PREFER_DYNAMIC, eSetVarTypeEnum , "no-run-target", g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, - { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean ,"true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, - { TSC_SOURCE_MAP , eSetVarTypeArray ,NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, + { TSC_PREFER_DYNAMIC, eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, + { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, + { TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } }; From gclayton at apple.com Sun May 29 19:49:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 30 May 2011 00:49:24 -0000 Subject: [Lldb-commits] [lldb] r132304 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ lldb.xcodeproj/ resources/ source/Commands/ source/Core/ source/Expression/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ test/class_types/ Message-ID: <20110530004925.2AE2F2A6C12C@llvm.org> Author: gclayton Date: Sun May 29 19:49:24 2011 New Revision: 132304 URL: http://llvm.org/viewvc/llvm-project?rev=132304&view=rev Log: lldb-59. Modified: lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Expression/DWARFExpression.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/Variable.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/Error.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectDynamicValue.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/test/class_types/main.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Sun May 29 19:49:24 2011 @@ -124,8 +124,9 @@ /// @param[in] length /// The length in bytes of the subset of data. //------------------------------------------------------------------ - DataExtractor (const DataExtractor& data, uint32_t offset = 0, uint32_t length = UINT32_MAX); + DataExtractor (const DataExtractor& data, uint32_t offset, uint32_t length); + DataExtractor (const DataExtractor& rhs); //------------------------------------------------------------------ /// Assignment operator. /// @@ -1086,7 +1087,7 @@ /// The number of bytes that this object now contains. //------------------------------------------------------------------ uint32_t - SetData (const DataExtractor& data, uint32_t offset = 0, uint32_t length = UINT32_MAX); + SetData (const DataExtractor& data, uint32_t offset, uint32_t length); //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Sun May 29 19:49:24 2011 @@ -236,6 +236,9 @@ virtual bool IsPointerOrReferenceType (); + + virtual bool + IsPossibleCPlusPlusDynamicType (); virtual bool IsBaseClass () Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original) +++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Sun May 29 19:49:24 2011 @@ -304,6 +304,13 @@ void SetExpressionDeclMap (ClangExpressionDeclMap *decl_map); + bool + GetExpressionData (DataExtractor &data) const + { + data = m_data; + return data.GetByteSize() > 0; + } + protected: //------------------------------------------------------------------ /// Pretty-prints the location expression to a stream Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Sun May 29 19:49:24 2011 @@ -612,6 +612,11 @@ static bool IsPointerOrReferenceType (lldb::clang_type_t clang_type, lldb::clang_type_t *target_type = NULL); + + static bool + IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, + lldb::clang_type_t clang_type, + lldb::clang_type_t *target_type = NULL); static bool IsCStringType (lldb::clang_type_t clang_type, uint32_t &length); Modified: lldb/trunk/include/lldb/Symbol/Variable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Variable.h?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Variable.h (original) +++ lldb/trunk/include/lldb/Symbol/Variable.h Sun May 29 19:49:24 2011 @@ -120,6 +120,21 @@ bool IsInScope (StackFrame *frame); + bool + LocationIsValidForFrame (StackFrame *frame); + + bool + GetLocationIsConstantValueData () const + { + return m_loc_is_const_data; + } + + void + SetLocationIsConstantValueData (bool b) + { + m_loc_is_const_data = b; + } + protected: ConstString m_name; // The basename of the variable (no namespaces) Mangled m_mangled; // The mangled name of hte variable @@ -129,7 +144,8 @@ Declaration m_declaration; // Declaration location for this item. DWARFExpression m_location; // The location of this variable that can be fed to DWARFExpression::Evaluate() uint8_t m_external:1, // Visible outside the containing compile unit? - m_artificial:1; // Non-zero if the variable is not explicitly declared in source + m_artificial:1, // Non-zero if the variable is not explicitly declared in source + m_loc_is_const_data:1; // The m_location expression contains the constant variable value data, not a DWARF location private: Variable(const Variable& rhs); Variable& operator=(const Variable& rhs); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun May 29 19:49:24 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; - DYLIB_CURRENT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3777,7 +3777,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3809,7 +3809,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Sun May 29 19:49:24 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 58 + 59 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Sun May 29 19:49:24 2011 @@ -87,7 +87,7 @@ else { if (result) - use_dynamic = eLazyBoolYes; + use_dynamic = eLazyBoolYes; else use_dynamic = eLazyBoolNo; } Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Sun May 29 19:49:24 2011 @@ -127,6 +127,15 @@ } } +DataExtractor::DataExtractor (const DataExtractor& rhs) : + m_start (rhs.m_start), + m_end (rhs.m_end), + m_byte_order (rhs.m_byte_order), + m_addr_size (rhs.m_addr_size), + m_data_sp (rhs.m_data_sp) +{ +} + //---------------------------------------------------------------------- // Assignment operator //---------------------------------------------------------------------- @@ -135,11 +144,11 @@ { if (this != &rhs) { - m_start = rhs.m_start; - m_end = rhs.m_end; - m_byte_order= rhs.m_byte_order; + m_start = rhs.m_start; + m_end = rhs.m_end; + m_byte_order = rhs.m_byte_order; m_addr_size = rhs.m_addr_size; - m_data_sp = rhs.m_data_sp; + m_data_sp = rhs.m_data_sp; } return *this; } Modified: lldb/trunk/source/Core/Error.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Error.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Core/Error.cpp (original) +++ lldb/trunk/source/Core/Error.cpp Sun May 29 19:49:24 2011 @@ -302,7 +302,6 @@ if (Success()) SetErrorToGenericError(); m_string = err_str; - m_string.append("\n"); } else m_string.clear(); Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Sun May 29 19:49:24 2011 @@ -690,7 +690,12 @@ GetBitfieldBitOffset())) // Bitfield bit offset m_value_str.swap(sstr.GetString()); else + { + m_error.SetErrorStringWithFormat ("unsufficient data for value (only %u of %u bytes available)", + m_data.GetByteSize(), + GetByteSize()); m_value_str.clear(); + } } } break; @@ -953,7 +958,13 @@ bool ValueObject::IsPointerOrReferenceType () { - return ClangASTContext::IsPointerOrReferenceType(GetClangType()); + return ClangASTContext::IsPointerOrReferenceType (GetClangType()); +} + +bool +ValueObject::IsPossibleCPlusPlusDynamicType () +{ + return ClangASTContext::IsPossibleCPlusPlusDynamicType (GetClangAST (), GetClangType()); } ValueObjectSP @@ -1149,9 +1160,11 @@ bool flat_output ) { - if (valobj && valobj->UpdateValueIfNeeded ()) + if (valobj) { - if (use_dynamic != lldb::eNoDynamicValues) + bool update_success = valobj->UpdateValueIfNeeded (); + + if (update_success && use_dynamic != lldb::eNoDynamicValues) { ValueObject *dynamic_value = valobj->GetDynamicValue(use_dynamic).get(); if (dynamic_value) @@ -1196,7 +1209,7 @@ if (!scope_already_checked && !valobj->IsInScope()) { - err_cstr = "error: out of scope"; + err_cstr = "out of scope"; } } @@ -1210,7 +1223,7 @@ if (err_cstr) { - s.Printf (" error: %s\n", err_cstr); + s.Printf (" <%s>\n", err_cstr); } else { Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original) +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Sun May 29 19:49:24 2011 @@ -120,6 +120,9 @@ if (!m_parent->UpdateValueIfNeeded()) { + // The dynamic value failed to get an error, pass the error along + if (m_error.Success() && m_parent->GetError().Fail()) + m_error = m_parent->GetError(); return false; } Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Sun May 29 19:49:24 2011 @@ -88,7 +88,10 @@ size_t ValueObjectVariable::GetByteSize() { - return m_variable_sp->GetType()->GetByteSize(); + Type *type = m_variable_sp->GetType(); + if (type) + return type->GetByteSize(); + return 0; } lldb::ValueType @@ -107,96 +110,109 @@ Variable *variable = m_variable_sp.get(); DWARFExpression &expr = variable->LocationExpression(); - lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; - ExecutionContext exe_ctx (GetExecutionContextScope()); - if (exe_ctx.target) + if (variable->GetLocationIsConstantValueData()) { - m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); - m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + // expr doesn't contain DWARF bytes, it contains the constant variable + // value bytes themselves... + if (expr.GetExpressionData(m_data)) + m_value.SetContext(Value::eContextTypeVariable, variable); + else + m_error.SetErrorString ("empty constant data"); } - - if (expr.IsLocationList()) - { - SymbolContext sc; - variable->CalculateSymbolContext (&sc); - if (sc.function) - loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); - } - Value old_value(m_value); - if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error)) + else { - m_value.SetContext(Value::eContextTypeVariable, variable); - - Value::ValueType value_type = m_value.GetValueType(); + lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; + ExecutionContext exe_ctx (GetExecutionContextScope()); + + if (exe_ctx.target) + { + m_data.SetByteOrder(exe_ctx.target->GetArchitecture().GetByteOrder()); + m_data.SetAddressByteSize(exe_ctx.target->GetArchitecture().GetAddressByteSize()); + } - switch (value_type) + if (expr.IsLocationList()) + { + SymbolContext sc; + variable->CalculateSymbolContext (&sc); + if (sc.function) + loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); + } + Value old_value(m_value); + if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error)) { - default: - assert(!"Unhandled expression result value kind..."); - break; - - case Value::eValueTypeScalar: - // The variable value is in the Scalar value inside the m_value. - // We can point our m_data right to it. - m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0); - break; - - case Value::eValueTypeFileAddress: - case Value::eValueTypeLoadAddress: - case Value::eValueTypeHostAddress: - // The DWARF expression result was an address in the inferior - // process. If this variable is an aggregate type, we just need - // the address as the main value as all child variable objects - // will rely upon this location and add an offset and then read - // their own values as needed. If this variable is a simple - // type, we read all data for it into m_data. - // Make sure this type has a value before we try and read it + m_value.SetContext(Value::eContextTypeVariable, variable); - // If we have a file address, convert it to a load address if we can. - if (value_type == Value::eValueTypeFileAddress && exe_ctx.process) + Value::ValueType value_type = m_value.GetValueType(); + + switch (value_type) { - lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - if (file_addr != LLDB_INVALID_ADDRESS) + default: + assert(!"Unhandled expression result value kind..."); + break; + + case Value::eValueTypeScalar: + // The variable value is in the Scalar value inside the m_value. + // We can point our m_data right to it. + m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0); + break; + + case Value::eValueTypeFileAddress: + case Value::eValueTypeLoadAddress: + case Value::eValueTypeHostAddress: + // The DWARF expression result was an address in the inferior + // process. If this variable is an aggregate type, we just need + // the address as the main value as all child variable objects + // will rely upon this location and add an offset and then read + // their own values as needed. If this variable is a simple + // type, we read all data for it into m_data. + // Make sure this type has a value before we try and read it + + // If we have a file address, convert it to a load address if we can. + if (value_type == Value::eValueTypeFileAddress && exe_ctx.process) { - SymbolContext var_sc; - variable->CalculateSymbolContext(&var_sc); - if (var_sc.module_sp) + lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + if (file_addr != LLDB_INVALID_ADDRESS) { - ObjectFile *objfile = var_sc.module_sp->GetObjectFile(); - if (objfile) + SymbolContext var_sc; + variable->CalculateSymbolContext(&var_sc); + if (var_sc.module_sp) { - Address so_addr(file_addr, objfile->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target); - if (load_addr != LLDB_INVALID_ADDRESS) + ObjectFile *objfile = var_sc.module_sp->GetObjectFile(); + if (objfile) { - m_value.SetValueType(Value::eValueTypeLoadAddress); - m_value.GetScalar() = load_addr; + Address so_addr(file_addr, objfile->GetSectionList()); + lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target); + if (load_addr != LLDB_INVALID_ADDRESS) + { + m_value.SetValueType(Value::eValueTypeLoadAddress); + m_value.GetScalar() = load_addr; + } } } } } - } - if (ClangASTContext::IsAggregateType (GetClangType())) - { - // this value object represents an aggregate type whose - // children have values, but this object does not. So we - // say we are changed if our location has changed. - SetValueDidChange (value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); - } - else - { - // Copy the Value and set the context to use our Variable - // so it can extract read its value into m_data appropriately - Value value(m_value); - value.SetContext(Value::eContextTypeVariable, variable); - m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0); + if (ClangASTContext::IsAggregateType (GetClangType())) + { + // this value object represents an aggregate type whose + // children have values, but this object does not. So we + // say we are changed if our location has changed. + SetValueDidChange (value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar()); + } + else + { + // Copy the Value and set the context to use our Variable + // so it can extract read its value into m_data appropriately + Value value(m_value); + value.SetContext(Value::eContextTypeVariable, variable); + m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0); + } + break; } - break; - } - SetValueIsValid (m_error.Success()); + SetValueIsValid (m_error.Success()); + } } return m_error.Success(); } Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Sun May 29 19:49:24 2011 @@ -642,21 +642,25 @@ if (reg_value.GetScalarValue(value.GetScalar())) { value.SetValueType (Value::eValueTypeScalar); - value.SetContext (Value::eContextTypeRegisterInfo, const_cast(reg_info)); + value.SetContext (Value::eContextTypeRegisterInfo, + const_cast(reg_info)); if (error_ptr) error_ptr->Clear(); return true; } else { + // If we get this error, then we need to implement a value + // buffer in the dwarf expression evaluation function... if (error_ptr) - error_ptr->SetErrorStringWithFormat("Failed to read register %u.\n", native_reg); + error_ptr->SetErrorStringWithFormat ("register %s can't be converted to a scalar value", + reg_info->name); } } else { if (error_ptr) - error_ptr->SetErrorStringWithFormat("Failed to read register %u.\n", native_reg); + error_ptr->SetErrorStringWithFormat("register %s is not available", reg_info->name); } } } @@ -817,7 +821,7 @@ } } if (error_ptr) - error_ptr->SetErrorStringWithFormat("Out of scope."); + error_ptr->SetErrorString ("variable not available"); return false; } Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Sun May 29 19:49:24 2011 @@ -37,7 +37,7 @@ bool ItaniumABILanguageRuntime::CouldHaveDynamicValue (ValueObject &in_value) { - return in_value.IsPointerOrReferenceType(); + return in_value.IsPossibleCPlusPlusDynamicType(); } bool 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=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun May 29 19:49:24 2011 @@ -4040,6 +4040,7 @@ DWARFExpression location; bool is_external = false; bool is_artificial = false; + bool location_is_const_value_data = false; AccessType accessibility = eAccessNone; for (i=0; iSetLocationIsConstantValueData (location_is_const_value_data); } } // Cache var_sp even if NULL (the variable was just a specification or Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun May 29 19:49:24 2011 @@ -87,11 +87,14 @@ if (tag_decl->hasExternalLexicalStorage()) { - ExternalASTSource *external_ast_source = ast->getExternalSource(); - if (external_ast_source) + if (ast) { - external_ast_source->CompleteType(tag_decl); - return !tag_type->isIncompleteType(); + ExternalASTSource *external_ast_source = ast->getExternalSource(); + if (external_ast_source) + { + external_ast_source->CompleteType(tag_decl); + return !tag_type->isIncompleteType(); + } } } return false; @@ -113,11 +116,14 @@ bool is_forward_decl = class_interface_decl->isForwardDecl(); if (is_forward_decl && class_interface_decl->hasExternalLexicalStorage()) { - ExternalASTSource *external_ast_source = ast->getExternalSource(); - if (external_ast_source) + if (ast) { - external_ast_source->CompleteType (class_interface_decl); - is_forward_decl = class_interface_decl->isForwardDecl(); + ExternalASTSource *external_ast_source = ast->getExternalSource(); + if (external_ast_source) + { + external_ast_source->CompleteType (class_interface_decl); + is_forward_decl = class_interface_decl->isForwardDecl(); + } } return is_forward_decl == false; } @@ -3980,6 +3986,121 @@ } bool +ClangASTContext::IsPossibleCPlusPlusDynamicType (clang::ASTContext *ast, clang_type_t clang_type, clang_type_t *dynamic_pointee_type) +{ + QualType pointee_qual_type; + if (clang_type) + { + QualType qual_type (QualType::getFromOpaquePtr(clang_type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + bool success = false; + switch (type_class) + { + case clang::Type::Pointer: + pointee_qual_type = cast(qual_type)->getPointeeType(); + success = true; + break; + + case clang::Type::LValueReference: + case clang::Type::RValueReference: + pointee_qual_type = cast(qual_type)->getPointeeType(); + success = true; + break; + + case clang::Type::Typedef: + return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type); + + default: + break; + } + + if (success) + { + // Check to make sure what we are pointing too is a possible dynamic C++ type + // We currently accept any "void *" (in case we have a class that has been + // watered down to an opaque pointer) and virtual C++ classes. + const clang::Type::TypeClass pointee_type_class = pointee_qual_type->getTypeClass(); + switch (pointee_type_class) + { + case clang::Type::Builtin: + switch (cast(pointee_qual_type)->getKind()) + { + case clang::BuiltinType::UnknownAny: + case clang::BuiltinType::Void: + if (dynamic_pointee_type) + *dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr(); + return true; + + case clang::BuiltinType::NullPtr: + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar_U: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar_S: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: + case clang::BuiltinType::Dependent: + case clang::BuiltinType::Overload: + case clang::BuiltinType::ObjCId: + case clang::BuiltinType::ObjCClass: + case clang::BuiltinType::ObjCSel: + case clang::BuiltinType::BoundMember: + break; + } + break; + case clang::Type::Record: + { + CXXRecordDecl *cxx_record_decl = pointee_qual_type->getAsCXXRecordDecl(); + if (cxx_record_decl) + { + if (GetCompleteQualType (ast, pointee_qual_type)) + { + success = cxx_record_decl->isPolymorphic() || cxx_record_decl->isAbstract(); + } + else + { + // We failed to get the complete type, so we have to + // treat this as a void * which we might possibly be + // able to complete + success = true; + } + if (success) + { + if (dynamic_pointee_type) + *dynamic_pointee_type = pointee_qual_type.getAsOpaquePtr(); + return true; + } + } + } + break; + + default: + break; + } + } + } + if (dynamic_pointee_type) + *dynamic_pointee_type = NULL; + return false; +} + + +bool ClangASTContext::IsPointerOrReferenceType (clang_type_t clang_type, clang_type_t*target_type) { if (clang_type == NULL) Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Sun May 29 19:49:24 2011 @@ -156,40 +156,53 @@ sc->Clear(); } - bool -Variable::IsInScope (StackFrame *frame) +Variable::LocationIsValidForFrame (StackFrame *frame) { - switch (m_scope) + // Is the variable is described by a single location? + if (!m_location.IsLocationList()) { - case eValueTypeVariableGlobal: - case eValueTypeVariableStatic: - // Globals and statics are always in scope. + // Yes it is, the location is valid. return true; + } - case eValueTypeVariableArgument: - case eValueTypeVariableLocal: - // Check if the location has a location list that describes the value - // of the variable with address ranges and different locations for each - // address range? - if (m_location.IsLocationList()) + if (frame) + { + Target *target = &frame->GetThread().GetProcess().GetTarget(); + + Function *function = frame->GetSymbolContext(eSymbolContextFunction).function; + if (function) { - SymbolContext sc; - CalculateSymbolContext(&sc); - - // Currently we only support functions that have things with - // locations lists. If this expands, we will need to add support - assert (sc.function); - Target *target = &frame->GetThread().GetProcess().GetTarget(); - addr_t loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target); + addr_t loclist_base_load_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress (target); if (loclist_base_load_addr == LLDB_INVALID_ADDRESS) return false; // It is a location list. We just need to tell if the location // list contains the current address when converted to a load // address - return m_location.LocationListContainsAddress (loclist_base_load_addr, frame->GetFrameCodeAddress().GetLoadAddress (target)); + return m_location.LocationListContainsAddress (loclist_base_load_addr, + frame->GetFrameCodeAddress().GetLoadAddress (target)); } - else + } + return false; +} + +bool +Variable::IsInScope (StackFrame *frame) +{ + switch (m_scope) + { + case eValueTypeRegister: + case eValueTypeRegisterSet: + return frame != NULL; + + case eValueTypeConstResult: + return true; + + case eValueTypeVariableGlobal: + case eValueTypeVariableStatic: + case eValueTypeVariableArgument: + case eValueTypeVariableLocal: + if (frame) { // We don't have a location list, we just need to see if the block // that this variable was defined in is currently @@ -198,16 +211,19 @@ { SymbolContext variable_sc; CalculateSymbolContext (&variable_sc); + // Check for static or global variable defined at the compile unit + // level that wasn't defined in a block + if (variable_sc.block == NULL) + return true; + if (variable_sc.block == deepest_frame_block) return true; - return variable_sc.block->Contains (deepest_frame_block); } } break; default: - assert (!"Unhandled case"); break; } return false; Modified: lldb/trunk/test/class_types/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/main.cpp?rev=132304&r1=132303&r2=132304&view=diff ============================================================================== --- lldb/trunk/test/class_types/main.cpp (original) +++ lldb/trunk/test/class_types/main.cpp Sun May 29 19:49:24 2011 @@ -32,7 +32,7 @@ { } - //virtual + virtual ~A() { } @@ -62,7 +62,7 @@ { } - //virtual + virtual ~B() { } @@ -93,7 +93,7 @@ printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. } - //virtual + virtual ~C() { } @@ -119,6 +119,14 @@ A a(12); B b(22,33); C c(44,55,66); + A *c_as_a = &c; + B *c_as_b = &c; + void *a_as_void_ptr = &a; + void *b_as_void_ptr = &b; + void *c_as_void_ptr = &c; + const void *a_as_const_void_ptr = &a; + const void *b_as_const_void_ptr = &b; + const void *c_as_const_void_ptr = &c; Conversion conv(1); if (conv) return b.GetIntegerB() - a.GetInteger() + c.GetInteger(); From gclayton at apple.com Sun May 29 19:51:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 30 May 2011 00:51:34 -0000 Subject: [Lldb-commits] [lldb] r132305 - /lldb/tags/lldb-59/ Message-ID: <20110530005134.C364B2A6C12C@llvm.org> Author: gclayton Date: Sun May 29 19:51:34 2011 New Revision: 132305 URL: http://llvm.org/viewvc/llvm-project?rev=132305&view=rev Log: lldb-59. Added: lldb/tags/lldb-59/ - copied from r132303, lldb/trunk/ From gclayton at apple.com Sun May 29 19:53:42 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 30 May 2011 00:53:42 -0000 Subject: [Lldb-commits] [lldb] r132306 - in /lldb/tags/lldb-59: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110530005342.2A6F22A6C12C@llvm.org> Author: gclayton Date: Sun May 29 19:53:41 2011 New Revision: 132306 URL: http://llvm.org/viewvc/llvm-project?rev=132306&view=rev Log: This is the real lldb-59. I accidentally committed from the wrong repository on my machine, but this https://gclayton at llvm.org/svn/llvm-project/lldb/tags/lldb-59 directory contains the right stuff. Getting the Xcode project version up to date with this checkin. Modified: lldb/tags/lldb-59/lldb.xcodeproj/project.pbxproj lldb/tags/lldb-59/resources/LLDB-Info.plist Modified: lldb/tags/lldb-59/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-59/lldb.xcodeproj/project.pbxproj?rev=132306&r1=132305&r2=132306&view=diff ============================================================================== --- lldb/tags/lldb-59/lldb.xcodeproj/project.pbxproj (original) +++ lldb/tags/lldb-59/lldb.xcodeproj/project.pbxproj Sun May 29 19:53:41 2011 @@ -3374,10 +3374,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3423,11 +3423,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3471,8 +3471,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; - DYLIB_CURRENT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3510,9 +3510,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3550,9 +3550,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3620,7 +3620,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3651,11 +3651,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 58; + DYLIB_CURRENT_VERSION = 59; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3777,7 +3777,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3809,7 +3809,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 58; + CURRENT_PROJECT_VERSION = 59; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/tags/lldb-59/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/tags/lldb-59/resources/LLDB-Info.plist?rev=132306&r1=132305&r2=132306&view=diff ============================================================================== --- lldb/tags/lldb-59/resources/LLDB-Info.plist (original) +++ lldb/tags/lldb-59/resources/LLDB-Info.plist Sun May 29 19:53:41 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 58 + 59 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Sun May 29 20:18:46 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 30 May 2011 01:18:46 -0000 Subject: [Lldb-commits] [lldb] r132308 - /lldb/trunk/test/class_types/main.cpp Message-ID: <20110530011846.126BF2A6C12C@llvm.org> Author: gclayton Date: Sun May 29 20:18:45 2011 New Revision: 132308 URL: http://llvm.org/viewvc/llvm-project?rev=132308&view=rev Log: Revert previous changes. Modified: lldb/trunk/test/class_types/main.cpp Modified: lldb/trunk/test/class_types/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/main.cpp?rev=132308&r1=132307&r2=132308&view=diff ============================================================================== --- lldb/trunk/test/class_types/main.cpp (original) +++ lldb/trunk/test/class_types/main.cpp Sun May 29 20:18:45 2011 @@ -32,7 +32,7 @@ { } - virtual + //virtual ~A() { } @@ -62,7 +62,7 @@ { } - virtual + //virtual ~B() { } @@ -93,7 +93,7 @@ printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. } - virtual + //virtual ~C() { } @@ -119,14 +119,6 @@ A a(12); B b(22,33); C c(44,55,66); - A *c_as_a = &c; - B *c_as_b = &c; - void *a_as_void_ptr = &a; - void *b_as_void_ptr = &b; - void *c_as_void_ptr = &c; - const void *a_as_const_void_ptr = &a; - const void *b_as_const_void_ptr = &b; - const void *c_as_const_void_ptr = &c; Conversion conv(1); if (conv) return b.GetIntegerB() - a.GetInteger() + c.GetInteger();