From johnny.chen at apple.com Mon Oct 4 11:23:16 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 04 Oct 2010 16:23:16 -0000 Subject: [Lldb-commits] [lldb] r115512 - /lldb/trunk/test/dead-strip/TestDeadStrip.py Message-ID: <20101004162316.B3E072A6C12E@llvm.org> Author: johnny Date: Mon Oct 4 11:23:16 2010 New Revision: 115512 URL: http://llvm.org/viewvc/llvm-project?rev=115512&view=rev Log: The 'thread list' command no longer displays the file:lineno after the recent check-in. Remove file:lineno from the expected substrings. Modified: lldb/trunk/test/dead-strip/TestDeadStrip.py Modified: lldb/trunk/test/dead-strip/TestDeadStrip.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/TestDeadStrip.py?rev=115512&r1=115511&r2=115512&view=diff ============================================================================== --- lldb/trunk/test/dead-strip/TestDeadStrip.py (original) +++ lldb/trunk/test/dead-strip/TestDeadStrip.py Mon Oct 4 11:23:16 2010 @@ -44,7 +44,6 @@ # The stop reason of the thread should be breakpoint (breakpoint #1). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', - 'main.c:20', 'a.out`f1', 'stop reason = breakpoint']) @@ -57,7 +56,6 @@ # The stop reason of the thread should be breakpoint (breakpoint #3). self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', - 'main.c:40', 'a.out`f3', 'stop reason = breakpoint']) From johnny.chen at apple.com Mon Oct 4 11:38:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 04 Oct 2010 16:38:12 -0000 Subject: [Lldb-commits] [lldb] r115514 - /lldb/trunk/test/function_types/TestFunctionTypes.py Message-ID: <20101004163812.76EC02A6C12E@llvm.org> Author: johnny Date: Mon Oct 4 11:38:12 2010 New Revision: 115514 URL: http://llvm.org/viewvc/llvm-project?rev=115514&view=rev Log: Remove file:lineno from the expected substrings. Matching 'a.out`string_not_empty', i.e., ${module.file.basename}{`${function.name}, is sufficient for this test case. Modified: lldb/trunk/test/function_types/TestFunctionTypes.py Modified: lldb/trunk/test/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/function_types/TestFunctionTypes.py?rev=115514&r1=115513&r2=115514&view=diff ============================================================================== --- lldb/trunk/test/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/function_types/TestFunctionTypes.py Mon Oct 4 11:38:12 2010 @@ -51,7 +51,6 @@ # Check that we do indeed stop on the string_not_empty function. self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, substrs = ['a.out`string_not_empty', - 'main.c:12', 'stop reason = breakpoint']) From johnny.chen at apple.com Mon Oct 4 11:58:16 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 04 Oct 2010 16:58:16 -0000 Subject: [Lldb-commits] [lldb] r115517 - /lldb/trunk/test/load_unload/TestLoadUnload.py Message-ID: <20101004165816.A7C242A6C12E@llvm.org> Author: johnny Date: Mon Oct 4 11:58:16 2010 New Revision: 115517 URL: http://llvm.org/viewvc/llvm-project?rev=115517&view=rev Log: Remove file:lineno from the expected substrings. Matching 'a_function, i.e., the {function.name}, is sufficient for this test case. Plus added @expectedfailure decorator for a filed bug. Modified: lldb/trunk/test/load_unload/TestLoadUnload.py Modified: lldb/trunk/test/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=115517&r1=115516&r2=115517&view=diff ============================================================================== --- lldb/trunk/test/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/load_unload/TestLoadUnload.py Mon Oct 4 11:58:16 2010 @@ -11,6 +11,8 @@ mydir = "load_unload" + # rdar://problem/8508987 + @unittest2.expectedFailure def test_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" @@ -30,25 +32,23 @@ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', 'a_function', - 'a.c:14', 'stop reason = breakpoint']) # The breakpoint should have a hit count of 1. self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, substrs = [' resolved, hit count = 1']) -# # Issue the 'contnue' command. We should stop agaian at a_function. -# # The stop reason of the thread should be breakpoint and at a_function. -# self.runCmd("continue") -# self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, -# substrs = ['state is Stopped', -# 'a_function', -# 'a.c:14', -# 'stop reason = breakpoint']) -# -# # The breakpoint should have a hit count of 2. -# self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, -# substrs = [' resolved, hit count = 2']) + # Issue the 'contnue' command. We should stop agaian at a_function. + # The stop reason of the thread should be breakpoint and at a_function. + self.runCmd("continue") + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', + 'a_function', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 2. + self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 2']) if __name__ == '__main__': From gclayton at apple.com Mon Oct 4 12:04:23 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 17:04:23 -0000 Subject: [Lldb-commits] [lldb] r115519 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20101004170423.7A8AC2A6C12E@llvm.org> Author: gclayton Date: Mon Oct 4 12:04:23 2010 New Revision: 115519 URL: http://llvm.org/viewvc/llvm-project?rev=115519&view=rev Log: Added file and line back to the default thread format. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115519&r1=115518&r2=115519&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Oct 4 12:04:23 2010 @@ -1603,6 +1603,7 @@ #define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ "{, ${frame.pc}}"\ MODULE_WITH_FUNC\ + FILE_AND_LINE\ "{, stop reason = ${thread.stop-reason}}"\ "{, name = ${thread.name}}"\ "{, queue = ${thread.queue}}"\ From gclayton at apple.com Mon Oct 4 12:26:49 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 17:26:49 -0000 Subject: [Lldb-commits] [lldb] r115522 - /lldb/trunk/source/Core/Debugger.cpp Message-ID: <20101004172649.963392A6C12E@llvm.org> Author: gclayton Date: Mon Oct 4 12:26:49 2010 New Revision: 115522 URL: http://llvm.org/viewvc/llvm-project?rev=115522&view=rev Log: Fixed and issue where we weren't seeing inlined functions anymore. We also now show the correct pc-offset within the inlined function. Modified: lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115522&r1=115521&r2=115522&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Oct 4 12:26:49 2010 @@ -956,6 +956,20 @@ if (cstr) { s.PutCString(cstr); + + if (sc->block) + { + Block *inline_block = sc->block->GetContainingInlinedBlock (); + if (inline_block) + { + const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo(); + if (inline_info) + { + s.PutCString(" [inlined] "); + inline_info->GetName().Dump(&s); + } + } + } var_success = true; } } @@ -1083,7 +1097,20 @@ if (sc) { if (sc->function) + { func_addr = sc->function->GetAddressRange().GetBaseAddress(); + if (sc->block) + { + // Check to make sure we aren't in an inline + // function. If we are, use the inline block + // range that contains "format_addr" since + // blocks can be discontiguous. + Block *inline_block = sc->block->GetContainingInlinedBlock (); + AddressRange inline_range; + if (inline_block && inline_block->GetRangeContainingAddress (format_addr, inline_range)) + func_addr = inline_range.GetBaseAddress(); + } + } else if (sc->symbol && sc->symbol->GetAddressRangePtr()) func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress(); } From gclayton at apple.com Mon Oct 4 13:37:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 04 Oct 2010 18:37:53 -0000 Subject: [Lldb-commits] [lldb] r115535 - in /lldb/trunk: include/lldb/API/SBFrame.h source/API/SBFrame.cpp Message-ID: <20101004183753.164A22A6C12E@llvm.org> Author: gclayton Date: Mon Oct 4 13:37:52 2010 New Revision: 115535 URL: http://llvm.org/viewvc/llvm-project?rev=115535&view=rev Log: Added GetSymbol to the frame. Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=115535&r1=115534&r2=115535&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Oct 4 13:37:52 2010 @@ -57,6 +57,9 @@ lldb::SBFunction GetFunction () const; + lldb::SBSymbol + GetSymbol () const; + // Gets the deepest block that contains the frame PC lldb::SBBlock GetBlock () const; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115535&r1=115534&r2=115535&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Oct 4 13:37:52 2010 @@ -99,6 +99,13 @@ return sb_function; } +SBSymbol +SBFrame::GetSymbol () const +{ + SBSymbol sb_symbol(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); + return sb_symbol; +} + SBBlock SBFrame::GetBlock () const { From johnny.chen at apple.com Mon Oct 4 13:39:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 04 Oct 2010 18:39:14 -0000 Subject: [Lldb-commits] [lldb] r115536 - /lldb/trunk/test/stl/TestDisassemble.py Message-ID: <20101004183914.385F72A6C12E@llvm.org> Author: johnny Date: Mon Oct 4 13:39:14 2010 New Revision: 115536 URL: http://llvm.org/viewvc/llvm-project?rev=115536&view=rev Log: Initial version of a test case meant to disassemble each and every function from the stdc++ library module. Right now, it doesn't do any disassembly at all. It merely locates the stdc++ library. Also tests the SBProcess object description and verifies it is in a 'Stopped' state. Added: lldb/trunk/test/stl/TestDisassemble.py Added: lldb/trunk/test/stl/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassemble.py?rev=115536&view=auto ============================================================================== --- lldb/trunk/test/stl/TestDisassemble.py (added) +++ lldb/trunk/test/stl/TestDisassemble.py Mon Oct 4 13:39:14 2010 @@ -0,0 +1,56 @@ +""" +Test the lldb disassemble command. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + + at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") +class StdCXXDisassembleTestCase(TestBase): + + mydir = "stl" + + @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") + def test_stdcxx_disasm(self): + """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" + self.buildDefault() + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break on line 13 of main.cpp. + self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # Now let's get the target as well as the process objects. + target = self.dbg.GetSelectedTarget() + process = target.GetProcess() + + # The process should be in a 'Stopped' state. + self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, + substrs = ["a.out", + "state: Stopped"]) + + # Iterate through the available modules, looking for stdc++ library... + for i in range(target.GetNumModules()): + module = target.GetModuleAtIndex(i) + fs = module.GetFileSpec() + if (fs.GetFilename().startswith("libstdc++")): + lib_stdcxx = repr(fs) + break + + # At this point, lib_stdcxx is the full path to the stdc++ library and + # module is the corresponding SBModule. + + self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False, + substrs = ["libstdc++"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From jingham at apple.com Mon Oct 4 14:38:50 2010 From: jingham at apple.com (Jim Ingham) Date: Mon, 04 Oct 2010 19:38:50 -0000 Subject: [Lldb-commits] [lldb] r115543 - /lldb/trunk/include/lldb/API/SBSymbol.h Message-ID: <20101004193850.BC0BD2A6C12C@llvm.org> Author: jingham Date: Mon Oct 4 14:38:50 2010 New Revision: 115543 URL: http://llvm.org/viewvc/llvm-project?rev=115543&view=rev Log: Have to friend SBFrame or it can't make symbols for the frame. Modified: lldb/trunk/include/lldb/API/SBSymbol.h Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=115543&r1=115542&r2=115543&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Mon Oct 4 14:38:50 2010 @@ -44,6 +44,7 @@ GetDescription (lldb::SBStream &description); private: + friend class SBFrame; friend class SBSymbolContext; SBSymbol (lldb_private::Symbol *lldb_object_ptr); From jingham at apple.com Mon Oct 4 14:49:29 2010 From: jingham at apple.com (Jim Ingham) Date: Mon, 04 Oct 2010 19:49:29 -0000 Subject: [Lldb-commits] [lldb] r115546 - in /lldb/trunk: include/lldb/Core/InputReader.h include/lldb/Interpreter/CommandInterpreter.h source/Core/InputReader.cpp source/Interpreter/CommandInterpreter.cpp Message-ID: <20101004194929.4CAC92A6C12C@llvm.org> Author: jingham Date: Mon Oct 4 14:49:29 2010 New Revision: 115546 URL: http://llvm.org/viewvc/llvm-project?rev=115546&view=rev Log: Add a "Confirm" function to the CommandInterpreter so you can confirm potentially dangerous operations in a generic way. Modified: lldb/trunk/include/lldb/Core/InputReader.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/Core/InputReader.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/include/lldb/Core/InputReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReader.h?rev=115546&r1=115545&r2=115546&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/InputReader.h (original) +++ lldb/trunk/include/lldb/Core/InputReader.h Mon Oct 4 14:49:29 2010 @@ -15,6 +15,7 @@ #include "lldb/lldb-include.h" #include "lldb/lldb-enumerations.h" #include "lldb/Core/Debugger.h" +#include "lldb/Host/Predicate.h" namespace lldb_private { @@ -88,6 +89,11 @@ void RefreshPrompt(); + + // If you want to read from an input reader synchronously, then just initialize the + // reader and then call WaitOnReaderIsDone, which will return when the reader is popped. + void + WaitOnReaderIsDone (); protected: friend class Debugger; @@ -104,6 +110,7 @@ bool m_done; bool m_echo; bool m_active; + Predicate m_reader_done; private: DISALLOW_COPY_AND_ASSIGN (InputReader); Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=115546&r1=115545&r2=115546&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Mon Oct 4 14:49:29 2010 @@ -157,7 +157,16 @@ void SetPrompt (const char *); - + + bool Confirm (const char *message, bool default_answer); + + static size_t + GetConfirmationInputReaderCallback (void *baton, + InputReader &reader, + lldb::InputReaderAction action, + const char *bytes, + size_t bytes_len); + void LoadCommandDictionary (); Modified: lldb/trunk/source/Core/InputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=115546&r1=115545&r2=115546&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReader.cpp (original) +++ lldb/trunk/source/Core/InputReader.cpp Mon Oct 4 14:49:29 2010 @@ -23,7 +23,8 @@ m_granularity (eInputReaderGranularityInvalid), m_done (true), m_echo (true), - m_active (false) + m_active (false), + m_reader_done (false) { } @@ -315,6 +316,7 @@ case eInputReaderActivate: case eInputReaderReactivate: m_active = true; + m_reader_done.SetValue(false, eBroadcastAlways); break; case eInputReaderDeactivate: @@ -327,4 +329,12 @@ } if (m_callback) m_callback (m_callback_baton, *this, notification, NULL, 0); + if (notification == eInputReaderDone) + m_reader_done.SetValue(true, eBroadcastAlways); +} + +void +InputReader::WaitOnReaderIsDone () +{ + m_reader_done.WaitForValueEqualTo (true); } Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=115546&r1=115545&r2=115546&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Oct 4 14:49:29 2010 @@ -38,6 +38,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/InputReader.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" #include "lldb/Target/Process.h" @@ -778,6 +779,98 @@ m_debugger.SetPrompt (new_prompt); } +size_t +CommandInterpreter::GetConfirmationInputReaderCallback (void *baton, + InputReader &reader, + lldb::InputReaderAction action, + const char *bytes, + size_t bytes_len) +{ + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); + bool *response_ptr = (bool *) baton; + + switch (action) + { + case eInputReaderActivate: + if (out_fh) + { + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); + } + break; + + case eInputReaderDeactivate: + break; + + case eInputReaderReactivate: + if (out_fh && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); + break; + + case eInputReaderGotToken: + if (bytes_len == 0) + { + reader.SetIsDone(true); + } + else if (bytes[0] == 'y') + { + *response_ptr = true; + reader.SetIsDone(true); + } + else if (bytes[0] == 'n') + { + *response_ptr = false; + reader.SetIsDone(true); + } + else + { + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + { + ::fprintf (out_fh, "Please answer \"y\" or \"n\"\n"); + ::fprintf (out_fh, "%s", reader.GetPrompt()); + } + } + break; + + case eInputReaderDone: + break; + } + + return bytes_len; + +} + +bool +CommandInterpreter::Confirm (const char *message, bool default_answer) +{ + // The default interpretation just pushes a new input reader and lets it get the answer: + InputReaderSP reader_sp (new InputReader(GetDebugger())); + bool response = default_answer; + if (reader_sp) + { + std::string prompt(message); + prompt.append(": ["); + if (default_answer) + prompt.append ("Y/n] "); + else + prompt.append ("y/N] "); + + Error err (reader_sp->Initialize (CommandInterpreter::GetConfirmationInputReaderCallback, + &response, // baton + eInputReaderGranularityLine, // token size, to pass to callback function + NULL, // end token + prompt.c_str(), // prompt + true)); // echo input + if (err.Success()) + { + GetDebugger().PushInputReader (reader_sp); + } + reader_sp->WaitOnReaderIsDone(); + } + return response; +} + + void CommandInterpreter::CrossRegisterCommand (const char * dest_cmd, const char * object_type) { From sabre at nondot.org Mon Oct 4 16:24:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 04 Oct 2010 21:24:01 -0000 Subject: [Lldb-commits] [lldb] r115563 - in /lldb/trunk/source/Plugins/Process/Utility: ArchDefaultUnwindPlan-x86.cpp ArchVolatileRegs-x86.cpp Message-ID: <20101004212401.5E5AB2A6C12C@llvm.org> Author: lattner Date: Mon Oct 4 16:24:01 2010 New Revision: 115563 URL: http://llvm.org/viewvc/llvm-project?rev=115563&view=rev Log: Use the LLVM Macho.h header instead of relying on the system one, patch by Arvid Picciani! Modified: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp?rev=115563&r1=115562&r2=115563&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.cpp Mon Oct 4 16:24:01 2010 @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "ArchDefaultUnwindPlan-x86.h" - +#include "llvm/Support/MachO.h" #include "lldb/lldb-private.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" #include "lldb/Core/ArchSpec.h" @@ -21,11 +21,11 @@ lldb_private::UnwindPlan* ArchDefaultUnwindPlan_x86::GetArchDefaultUnwindPlan (Thread& thread, Address current_pc) { - if (m_cpu == CPU_TYPE_X86_64) + if (m_cpu == llvm::MachO::CPUTypeX86_64) { return &m_64bit_default; } - if (m_cpu == CPU_TYPE_I386) + if (m_cpu == llvm::MachO::CPUTypeI386) { return &m_32bit_default; } @@ -36,7 +36,7 @@ ArchDefaultUnwindPlan_x86::CreateInstance (const lldb_private::ArchSpec &arch) { uint32_t cpu = arch.GetCPUType (); - if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386) return NULL; return new ArchDefaultUnwindPlan_x86 (cpu); Modified: lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp?rev=115563&r1=115562&r2=115563&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/ArchVolatileRegs-x86.cpp Mon Oct 4 16:24:01 2010 @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "ArchVolatileRegs-x86.h" - +#include "llvm/Support/MachO.h" #include "lldb/lldb-private.h" #include "lldb/Utility/ArchVolatileRegs.h" #include "lldb/Core/ArchSpec.h" @@ -35,7 +35,7 @@ ArchVolatileRegs_x86::CreateInstance (const lldb_private::ArchSpec &arch) { uint32_t cpu = arch.GetCPUType (); - if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + if (cpu != llvm::MachO::CPUTypeX86_64 && cpu != llvm::MachO::CPUTypeI386) return NULL; return new ArchVolatileRegs_x86 (cpu); @@ -78,7 +78,7 @@ const char **names; int namecount; - if (m_cpu == CPU_TYPE_X86_64) + if (m_cpu == llvm::MachO::CPUTypeX86_64) { names = x86_64_regnames; namecount = sizeof (x86_64_regnames) / sizeof (char *); From ctice at apple.com Mon Oct 4 17:28:36 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 04 Oct 2010 22:28:36 -0000 Subject: [Lldb-commits] [lldb] r115570 - in /lldb/trunk: include/lldb/ include/lldb/Interpreter/ source/Commands/ source/Interpreter/ Message-ID: <20101004222836.E89AA2A6C12C@llvm.org> Author: ctice Date: Mon Oct 4 17:28:36 2010 New Revision: 115570 URL: http://llvm.org/viewvc/llvm-project?rev=115570&view=rev Log: Modify existing commands with arguments to use the new argument mechanism (for standardized argument names, argument help, etc.) Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectApropos.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectSyntax.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Mon Oct 4 17:28:36 2010 @@ -134,6 +134,9 @@ void GetFormattedCommandArguments (Stream &str); + bool + IsPairType (lldb::ArgumentRepetitionType arg_repeat_type); + enum { eFlagProcessMustBeLaunched = (1 << 0), Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Oct 4 17:28:36 2010 @@ -511,38 +511,42 @@ typedef enum CommandArgumentType { eArgTypeAddress = 0, + eArgTypeAliasName, + eArgTypeAliasOptions, eArgTypeArchitecture, eArgTypeBoolean, eArgTypeBreakpointID, eArgTypeBreakpointIDRange, eArgTypeByteSize, - eArgTypeChannel, + eArgTypeCommandName, eArgTypeCount, + eArgTypeEndAddress, eArgTypeExpression, eArgTypeExprFormat, eArgTypeFilename, eArgTypeFormat, - eArgTypeFrameNum, + eArgTypeFrameIndex, eArgTypeFullName, eArgTypeFunctionName, eArgTypeIndex, eArgTypeLineNum, + eArgTypeLogChannel, eArgTypeMethod, eArgTypeName, + eArgTypeNewPathPrefix, eArgTypeNumLines, eArgTypeNumberPerLine, eArgTypeOffset, + eArgTypeOldPathPrefix, eArgTypeOneLiner, - eArgTypeOther, eArgTypePath, - eArgTypePathPrefix, - eArgTypePathPrefixPair, eArgTypePid, eArgTypePlugin, eArgTypeProcessName, eArgTypeQueueName, eArgTypeRegisterName, eArgTypeRegularExpression, + eArgTypeRunArgs, eArgTypeRunMode, eArgTypeScriptLang, eArgTypeSearchWord, @@ -558,7 +562,6 @@ eArgTypeThreadID, eArgTypeThreadIndex, eArgTypeThreadName, - eArgTypeUUID, eArgTypeUnixSignalNumber, eArgTypeVarName, eArgTypeValue, @@ -569,10 +572,17 @@ typedef enum ArgumentRepetitionType { - eArgRepeatPlain, // Exactly one occurrence - eArgRepeatOptional, // At most one occurrence, but it's optional - eArgRepeatPlus, // One or more occurrences - eArgRepeatStar // Zero or more occurrences + eArgRepeatPlain, // Exactly one occurrence + eArgRepeatOptional, // At most one occurrence, but it's optional + eArgRepeatPlus, // One or more occurrences + eArgRepeatStar, // Zero or more occurrences + eArgRepeatRange, // Repetition of same argument, from 1 to n + eArgRepeatPairPlain, // A pair of arguments that must always go together ([arg-type arg-value]), occurs exactly once + eArgRepeatPairOptional, // A pair that occurs at most once (optional) + eArgRepeatPairPlus, // One or more occurrences of a pair + eArgRepeatPairStar, // Zero or more occurrences of a pair + eArgRepeatPairRange, // A pair that repeats from 1 to n + eArgRepeatPairRangeOptional, // A pair that repeats from 1 to n, but is optional } ArgumentRepetitionType; Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Mon Oct 4 17:28:36 2010 @@ -30,8 +30,20 @@ CommandObject (interpreter, "apropos", "Find a list of debugger commands related to a particular word/subject.", - "apropos ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData search_word_arg; + + // Define the first (and only) variant of this arg. + search_word_arg.arg_type = eArgTypeSearchWord; + search_word_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (search_word_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectApropos::~CommandObjectApropos() Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Mon Oct 4 17:28:36 2010 @@ -692,7 +692,7 @@ // Define the first (and only) variant of this arg. bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatStar; + bp_id_arg.arg_repetition = eArgRepeatOptional; // There is only one variant this argument could be; put it into the argument entry. arg.push_back (bp_id_arg); @@ -795,11 +795,11 @@ // Create the first variant for the first (and only) argument for this command. bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatStar; + bp_id_arg.arg_repetition = eArgRepeatOptional; // Create the second variant for the first (and only) argument for this command. bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatStar; + bp_id_range_arg.arg_repetition = eArgRepeatOptional; // The first (and only) argument for this command could be either a bp_id or a bp_id_range. // Push both variants into the entry for the first argument for this command. @@ -911,11 +911,11 @@ // Create the first variant for the first (and only) argument for this command. bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatStar; + bp_id_arg.arg_repetition = eArgRepeatOptional; // Create the second variant for the first (and only) argument for this command. bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatStar; + bp_id_range_arg.arg_repetition = eArgRepeatOptional; // The first (and only) argument for this command could be either a bp_id or a bp_id_range. // Push both variants into the entry for the first argument for this command. @@ -1025,11 +1025,11 @@ // Create the first variant for the first (and only) argument for this command. bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatStar; + bp_id_arg.arg_repetition = eArgRepeatOptional; // Create the second variant for the first (and only) argument for this command. bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatStar; + bp_id_range_arg.arg_repetition = eArgRepeatOptional; // The first (and only) argument for this command could be either a bp_id or a bp_id_range. // Push both variants into the entry for the first argument for this command. @@ -1265,11 +1265,11 @@ // Create the first variant for the first (and only) argument for this command. bp_id_arg.arg_type = eArgTypeBreakpointID; - bp_id_arg.arg_repetition = eArgRepeatPlus; + bp_id_arg.arg_repetition = eArgRepeatPlain; // Create the second variant for the first (and only) argument for this command. bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange; - bp_id_range_arg.arg_repetition = eArgRepeatPlus; + bp_id_range_arg.arg_repetition = eArgRepeatPlain; // The first (and only) argument for this command could be either a bp_id or a bp_id_range. // Push both variants into the entry for the first argument for this command. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Mon Oct 4 17:28:36 2010 @@ -129,7 +129,7 @@ CommandObject (interpreter, "add", "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.", - "breakpoint command add ") + NULL) { SetHelpLong ( "\nGeneral information about entering breakpoint commands \n\ @@ -236,6 +236,20 @@ You may enter any debugger command, exactly as you would at the \n\ debugger prompt. You may enter as many debugger commands as you like, \n\ but do NOT enter more than one command per line. \n" ); + + + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + + // Define the first (and only) variant of this arg. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (bp_id_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointCommandAdd::~CommandObjectBreakpointCommandAdd () @@ -463,8 +477,20 @@ CommandObject (interpreter, "remove", "Remove the set of commands from a breakpoint.", - "breakpoint command remove ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + + // Define the first (and only) variant of this arg. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (bp_id_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointCommandRemove::~CommandObjectBreakpointCommandRemove () @@ -549,8 +575,20 @@ CommandObject (interpreter, "list", "List the script or set of commands to be executed when the breakpoint is hit.", - "breakpoint command list ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData bp_id_arg; + + // Define the first (and only) variant of this arg. + bp_id_arg.arg_type = eArgTypeBreakpointID; + bp_id_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (bp_id_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectBreakpointCommandList::~CommandObjectBreakpointCommandList () Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Mon Oct 4 17:28:36 2010 @@ -110,9 +110,42 @@ CommandObject ( "call", "Call a function.", - "call [[ ] ... ] []", + //"call [[ ] ... ] []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentEntry arg3; + CommandArgumentData return_type_arg; + CommandArgumentData function_name_arg; + CommandArgumentData arg_type_arg; + CommandArgumentData arg_value_arg; + + // Define the first (and only) variant of this arg. + return_type_arg.arg_type = eArgTypeType; + return_type_arg.arg_repetition = eArgRepeatPlain; + + arg1.push_back (return_type_arg); + + function_name_arg.arg_type = eArgTypeFunctionName; + function_name_arg.arg_repetition = eArgTypePlain; + + arg2.push_back (function_name_arg); + + arg_type_arg.arg_type = eArgTypeArgType; + arg_type_arg.arg_repetition = eArgRepeatPairRangeOptional; + + arg_value_arg.arg_type = eArgTypeValue; + arg_value_arg.arg_repetition = eArgRepeatPairRangeOptional; + + arg3.push_back (arg_type_arg); + arg3.push_back (arg_value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); + m_arguments.push_back (arg3); } CommandObjectCall::~CommandObjectCall () Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Mon Oct 4 17:28:36 2010 @@ -35,8 +35,20 @@ CommandObject (interpreter, "commands source", "Read in debugger commands from the file and execute them.", - "command source ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectCommandsSource () @@ -139,7 +151,7 @@ CommandObject (interpreter, "commands alias", "Allow users to define their own debugger command abbreviations.", - "commands alias []") + NULL) { SetHelpLong( "'alias' allows the user to create a short-cut or abbreviation for long \n\ @@ -189,6 +201,38 @@ \n commands alias bl3 breakpoint set -f %1 -l 3 // Always sets a breakpoint on line \n\ // 3 of whatever file is indicated. \n"); + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentEntry arg3; + CommandArgumentData alias_arg; + CommandArgumentData cmd_arg; + CommandArgumentData options_arg; + + // Define the first (and only) variant of this arg. + alias_arg.arg_type = eArgTypeAliasName; + alias_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (alias_arg); + + // Define the first (and only) variant of this arg. + cmd_arg.arg_type = eArgTypeCommandName; + cmd_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (cmd_arg); + + // Define the first (and only) variant of this arg. + options_arg.arg_type = eArgTypeAliasOptions; + options_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg3.push_back (options_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); + m_arguments.push_back (arg3); } ~CommandObjectCommandsAlias () @@ -352,8 +396,20 @@ CommandObject (interpreter, "commands unalias", "Allow the user to remove/delete a user-defined command abbreviation.", - "unalias ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData alias_arg; + + // Define the first (and only) variant of this arg. + alias_arg.arg_type = eArgTypeAliasName; + alias_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (alias_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectCommandsUnalias() Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Mon Oct 4 17:28:36 2010 @@ -125,8 +125,8 @@ { LLDB_OPT_SET_ALL, false, "mixed", 'm', no_argument, NULL, 0, eArgTypeNone, "Enable mixed source and assembly display."}, { LLDB_OPT_SET_ALL, false, "raw", 'r', no_argument, NULL, 0, eArgTypeNone, "Print raw disassembly with no symbol information."}, -{ LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, eArgTypeAddress, "Address to start disassembling."}, -{ LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, eArgTypeAddress, "Address to start disassembling."}, +{ LLDB_OPT_SET_1, true, "start-address", 's', required_argument, NULL, 0, eArgTypeStartAddress, "Address at which to start disassembling."}, +{ LLDB_OPT_SET_1, false, "end-address", 'e', required_argument, NULL, 0, eArgTypeEndAddress, "Address at which to end disassembling."}, { LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."}, Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Oct 4 17:28:36 2010 @@ -106,7 +106,7 @@ CommandObject (interpreter, "expression", "Evaluate a C/ObjC/C++ expression in the current program context, using variables currently in scope.", - "expression [] "), + NULL), m_expr_line_count (0), m_expr_lines () { @@ -116,6 +116,19 @@ expr my_struct->a = my_array[3] \n\ expr -f bin -- (index * 8) + 5 \n\ expr char c[] = \"foo\"; c[0]\n"); + + CommandArgumentEntry arg; + CommandArgumentData expression_arg; + + // Define the first (and only) variant of this arg. + expression_arg.arg_type = eArgTypeExpression; + expression_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (expression_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectExpression::~CommandObjectExpression () Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Mon Oct 4 17:28:36 2010 @@ -89,8 +89,20 @@ CommandObject (interpreter, "file", "Set the file to be used as the main executable by the debugger.", - "file [] ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectFile::~CommandObjectFile () Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Oct 4 17:28:36 2010 @@ -98,9 +98,21 @@ CommandObject (interpreter, "frame select", "Select a frame by index from within the current thread and make it the current frame.", - "frame select ", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg; + CommandArgumentData index_arg; + + // Define the first (and only) variant of this arg. + index_arg.arg_type = eArgTypeFrameIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (index_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectFrameSelect () @@ -296,8 +308,20 @@ "argument, local, file static and file global variables." "Children of aggregate variables can be specified such as " "'var->child.x'.", - "frame variable [] [ [...]]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData var_name_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeVarName; + var_name_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (var_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Mon Oct 4 17:28:36 2010 @@ -31,6 +31,18 @@ "Show a list of all debugger commands, or give details about specific commands.", "help []") { + CommandArgumentEntry arg; + CommandArgumentData command_arg; + + // Define the first (and only) variant of this arg. + command_arg.arg_type = eArgTypeCommandName; + command_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (command_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectHelp::~CommandObjectHelp() Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Mon Oct 4 17:28:36 2010 @@ -482,6 +482,18 @@ const char *syntax) : CommandObject (interpreter, name, help, syntax) { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -525,6 +537,18 @@ const char *syntax) : CommandObject (interpreter, name, help, syntax) { + CommandArgumentEntry arg; + CommandArgumentData source_file_arg; + + // Define the first (and only) variant of this arg. + source_file_arg.arg_type = eArgTypeSourceFile; + source_file_arg.arg_repetition = eArgRepeatPlus; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (source_file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -566,7 +590,7 @@ CommandObjectImageDumpModuleList (interpreter, "image dump symtab", "Dump the symbol table from one or more executable images.", - "image dump symtab [ ...]") + NULL) { } @@ -674,7 +698,8 @@ CommandObjectImageDumpModuleList (interpreter, "image dump sections", "Dump the sections from one or more executable images.", - "image dump sections [ ...]") + //"image dump sections [ ...]") + NULL) { } @@ -781,7 +806,8 @@ CommandObjectImageDumpModuleList (interpreter, "image dump symfile", "Dump the debug symbol file for one or more executable images.", - "image dump symfile [ ...]") + //"image dump symfile [ ...]") + NULL) { } @@ -888,7 +914,7 @@ CommandObjectImageDumpSourceFileList (interpreter, "image dump line-table", "Dump the debug symbol file for one or more executable images.", - "image dump line-table [ ...]") + NULL) { } @@ -1326,8 +1352,20 @@ CommandObject (interpreter, "image lookup", "Look up information within executable and dependent shared library images.", - "image lookup [] [...]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Mon Oct 4 17:28:36 2010 @@ -62,8 +62,20 @@ CommandObject (interpreter, "log enable", "Enable logging for a single log channel.", - "log enable [] ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData channel_arg; + + // Define the first (and only) variant of this arg. + channel_arg.arg_type = eArgTypeLogChannel; + channel_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (channel_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -238,8 +250,20 @@ CommandObject (interpreter, "log disable", "Disable one or more log channels.", - "log disable [ ...]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData channel_arg; + + // Define the first (and only) variant of this arg. + channel_arg.arg_type = eArgTypeLogChannel; + channel_arg.arg_repetition = eArgRepeatPlus; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (channel_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -298,9 +322,21 @@ CommandObjectLogList(CommandInterpreter &interpreter) : CommandObject (interpreter, "log list", - "List the log categories for one or more log channels.", - "log list [ ...]") + "List the log categories for one or more log channels. If none specified, lists them all.", + NULL) { + CommandArgumentEntry arg; + CommandArgumentData channel_arg; + + // Define the first (and only) variant of this arg. + channel_arg.arg_type = eArgTypeLogChannel; + channel_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (channel_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Mon Oct 4 17:28:36 2010 @@ -180,9 +180,31 @@ CommandObject (interpreter, "memory read", "Read from the memory of the process being debugged.", - "memory read [] []", + NULL, eFlagProcessMustBeLaunched) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData start_addr_arg; + CommandArgumentData end_addr_arg; + + // Define the first (and only) variant of this arg. + start_addr_arg.arg_type = eArgTypeStartAddress; + start_addr_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (start_addr_arg); + + // Define the first (and only) variant of this arg. + end_addr_arg.arg_type = eArgTypeEndAddress; + end_addr_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (end_addr_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } virtual @@ -398,9 +420,32 @@ CommandObject (interpreter, "memory write", "Write to the memory of the process being debugged.", - "memory write [] [value1 value2 ...]", + //"memory write [] [value1 value2 ...]", + NULL, eFlagProcessMustBeLaunched) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData addr_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + addr_arg.arg_type = eArgTypeAddress; + addr_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (addr_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlus; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } virtual Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Oct 4 17:28:36 2010 @@ -105,8 +105,20 @@ CommandObject (interpreter, "process launch", "Launch the executable in the debugger.", - "process launch [] []") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData run_args_arg; + + // Define the first (and only) variant of this arg. + run_args_arg.arg_type = eArgTypeRunArgs; + run_args_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (run_args_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } @@ -797,8 +809,20 @@ CommandObject (interpreter, "process signal", "Send a UNIX signal to the current process being debugged.", - "process signal ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData signal_arg; + + // Define the first (and only) variant of this arg. + signal_arg.arg_type = eArgTypeUnixSignalNumber; + signal_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (signal_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectProcessSignal () Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Mon Oct 4 17:28:36 2010 @@ -34,10 +34,23 @@ CommandObjectRegisterRead (CommandInterpreter &interpreter) : CommandObject (interpreter, "register read", - "Dump the contents of one or more register values from the current frame.", - "register read [ [ [...]]]", + "Dump the contents of one or more register values from the current frame. If no register is specified, dumps them all.", + //"register read [ [ [...]]]", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg; + CommandArgumentData register_arg; + + // Define the first (and only) variant of this arg. + register_arg.arg_type = eArgTypeRegisterName; + register_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (register_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -143,9 +156,32 @@ CommandObject (interpreter, "register write", "Modify a single register value.", - "register write ", + //"register write ", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData register_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + register_arg.arg_type = eArgTypeRegisterName; + register_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (register_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } virtual Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Mon Oct 4 17:28:36 2010 @@ -65,9 +65,31 @@ CommandObject (interpreter, "settings set", "Set or change the value of a single debugger setting variable.", - "settings set [] "), + NULL), m_options () { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData var_name_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } CommandObjectSettingsSet::~CommandObjectSettingsSet() @@ -263,8 +285,20 @@ CommandObject (interpreter, "settings show", "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", - "settings show []") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentData var_name_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); } CommandObjectSettingsShow::~CommandObjectSettingsShow() @@ -374,8 +408,25 @@ CommandObject (interpreter, "settings list", "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", - "settings list [ | ]") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData var_name_arg; + CommandArgumentData prefix_name_arg; + + // Define the first variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatOptional; + + // Define the second variant of this arg. + prefix_name_arg.arg_type = eArgTypeSettingPrefix; + prefix_name_arg.arg_repetition = eArgRepeatOptional; + + arg.push_back (var_name_arg); + arg.push_back (prefix_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectSettingsList::~CommandObjectSettingsList() @@ -462,8 +513,36 @@ CommandObject (interpreter, "settings remove", "Remove the specified element from an internal debugger settings array or dictionary variable.", - "settings remove [|\"key\"]") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData var_name_arg; + CommandArgumentData index_arg; + CommandArgumentData key_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first variant of this arg. + index_arg.arg_type = eArgTypeSettingIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // Define the second variant of this arg. + key_arg.arg_type = eArgTypeSettingKey; + key_arg.arg_repetition = eArgRepeatPlain; + + // Push both variants into this arg + arg2.push_back (index_arg); + arg2.push_back (key_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } CommandObjectSettingsRemove::~CommandObjectSettingsRemove () @@ -560,8 +639,46 @@ CommandObject (interpreter, "settings replace", "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", - "settings replace [|\"\"] ") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentEntry arg3; + CommandArgumentData var_name_arg; + CommandArgumentData index_arg; + CommandArgumentData key_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first (variant of this arg. + index_arg.arg_type = eArgTypeSettingIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // Define the second (variant of this arg. + key_arg.arg_type = eArgTypeSettingKey; + key_arg.arg_repetition = eArgRepeatPlain; + + // Put both variants into this arg + arg2.push_back (index_arg); + arg2.push_back (key_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg3.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); + m_arguments.push_back (arg3); } CommandObjectSettingsReplace::~CommandObjectSettingsReplace () @@ -673,8 +790,40 @@ CommandObject (interpreter, "settings insert-before", "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", - "settings insert-before [] ") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentEntry arg3; + CommandArgumentData var_name_arg; + CommandArgumentData index_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first (variant of this arg. + index_arg.arg_type = eArgTypeSettingIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (index_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg3.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); + m_arguments.push_back (arg3); } CommandObjectSettingsInsertBefore::~CommandObjectSettingsInsertBefore () @@ -788,8 +937,40 @@ CommandObject (interpreter, "settings insert-after", "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", - "settings insert-after [] ") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentEntry arg3; + CommandArgumentData var_name_arg; + CommandArgumentData index_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first (variant of this arg. + index_arg.arg_type = eArgTypeSettingIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (index_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg3.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); + m_arguments.push_back (arg3); } CommandObjectSettingsInsertAfter::~CommandObjectSettingsInsertAfter () @@ -903,8 +1084,30 @@ CommandObject (interpreter, "settings append", "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", - "settings append ") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData var_name_arg; + CommandArgumentData value_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg1.push_back (var_name_arg); + + // Define the first (and only) variant of this arg. + value_arg.arg_type = eArgTypeValue; + value_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg2.push_back (value_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } CommandObjectSettingsAppend::~CommandObjectSettingsAppend () @@ -1005,8 +1208,20 @@ CommandObject (interpreter, "settings clear", "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", - "settings clear") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData var_name_arg; + + // Define the first (and only) variant of this arg. + var_name_arg.arg_type = eArgTypeSettingVariableName; + var_name_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (var_name_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectSettingsClear::~CommandObjectSettingsClear () Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Mon Oct 4 17:28:36 2010 @@ -231,8 +231,20 @@ CommandObject (interpreter, "source list", "Display source code (as specified) based on the current executable's debug info.", - "source list [] []") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData file_arg; + + // Define the first (and only) variant of this arg. + file_arg.arg_type = eArgTypeFilename; + file_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (file_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectSourceList () Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Mon Oct 4 17:28:36 2010 @@ -33,6 +33,18 @@ "Shows the correct syntax for a given debugger command.", "syntax ") { + CommandArgumentEntry arg; + CommandArgumentData command_arg; + + // Define the first (and only) variant of this arg. + command_arg.arg_type = eArgTypeCommandName; + command_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (command_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } CommandObjectSyntax::~CommandObjectSyntax() Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Oct 4 17:28:36 2010 @@ -38,8 +38,28 @@ CommandObject (interpreter, "target image-search-paths add", "Add new image search paths substitution pairs to the current target.", - "target image-search-paths add [ ] ...") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData old_prefix_arg; + CommandArgumentData new_prefix_arg; + + // Define the first variant of this arg pair. + old_prefix_arg.arg_type = eArgTypeOldPathPrefix; + old_prefix_arg.arg_repetition = eArgRepeatPairPlus; + + // Define the first variant of this arg pair. + new_prefix_arg.arg_type = eArgTypeNewPathPrefix; + new_prefix_arg.arg_repetition = eArgRepeatPairPlus; + + // There are two required arguments that must always occur together, i.e. an argument "pair". Because they + // must always occur together, they are treated as two variants of one argument rather than two independent + // arguments. Push them both into the first argument position for m_arguments... + + arg.push_back (old_prefix_arg); + arg.push_back (new_prefix_arg); + + m_arguments.push_back (arg); } ~CommandObjectTargetImageSearchPathsAdd () @@ -136,8 +156,39 @@ CommandObject (interpreter, "target image-search-paths insert", "Insert a new image search path substitution pair into the current target at the specified index.", - "target image-search-paths insert [ ] ...") + NULL) { + CommandArgumentEntry arg1; + CommandArgumentEntry arg2; + CommandArgumentData index_arg; + CommandArgumentData old_prefix_arg; + CommandArgumentData new_prefix_arg; + + // Define the first and only variant of this arg. + index_arg.arg_type = eArgTypeIndex; + index_arg.arg_repetition = eArgRepeatPlain; + + // Put the one and only variant into the first arg for m_arguments: + arg1.push_back (index_arg); + + // Define the first variant of this arg pair. + old_prefix_arg.arg_type = eArgTypeOldPathPrefix; + old_prefix_arg.arg_repetition = eArgRepeatPairPlus; + + // Define the first variant of this arg pair. + new_prefix_arg.arg_type = eArgTypeNewPathPrefix; + new_prefix_arg.arg_repetition = eArgRepeatPairPlus; + + // There are two required arguments that must always occur together, i.e. an argument "pair". Because they + // must always occur together, they are treated as two variants of one argument rather than two independent + // arguments. Push them both into the same argument position for m_arguments... + + arg2.push_back (old_prefix_arg); + arg2.push_back (new_prefix_arg); + + // Add arguments to m_arguments. + m_arguments.push_back (arg1); + m_arguments.push_back (arg2); } ~CommandObjectTargetImageSearchPathsInsert () @@ -260,8 +311,20 @@ CommandObject (interpreter, "target image-search-paths query", "Transform a path using the first applicable image search path.", - "target image-search-paths query ") + NULL) { + CommandArgumentEntry arg; + CommandArgumentData path_arg; + + // Define the first (and only) variant of this arg. + path_arg.arg_type = eArgTypePath; + path_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (path_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectTargetImageSearchPathsQuery () Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Oct 4 17:28:36 2010 @@ -322,10 +322,22 @@ CommandObject (interpreter, "thread backtrace", "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", - "thread backtrace [] ...", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options() { + CommandArgumentEntry arg; + CommandArgumentData thread_idx_arg; + + // Define the first (and only) variant of this arg. + thread_idx_arg.arg_type = eArgTypeThreadIndex; + thread_idx_arg.arg_repetition = eArgRepeatStar; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (thread_idx_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } ~CommandObjectThreadBacktrace() @@ -456,7 +468,7 @@ CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "How many frames to display (-1 for all)"}, -{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, eArgTypeFrameNum, "Frame in which to start the backtrace"}, +{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace"}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -562,6 +574,18 @@ m_step_scope (step_scope), m_options () { + CommandArgumentEntry arg; + CommandArgumentData thread_id_arg; + + // Define the first (and only) variant of this arg. + thread_id_arg.arg_type = eArgTypeThreadID; + thread_id_arg.arg_repetition = eArgRepeatOptional; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (thread_id_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } virtual @@ -779,9 +803,21 @@ CommandObject (interpreter, "thread continue", "Continue execution of one or more threads in an active process.", - "thread continue [ ...]", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg; + CommandArgumentData thread_idx_arg; + + // Define the first (and only) variant of this arg. + thread_idx_arg.arg_type = eArgTypeThreadIndex; + thread_idx_arg.arg_repetition = eArgRepeatPlus; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (thread_idx_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } @@ -1023,10 +1059,22 @@ CommandObject (interpreter, "thread until", "Run the current or specified thread until it reaches a given line number or leaves the current function.", - "thread until [] ", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), m_options () { + CommandArgumentEntry arg; + CommandArgumentData line_num_arg; + + // Define the first (and only) variant of this arg. + line_num_arg.arg_type = eArgTypeLineNum; + line_num_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (line_num_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } @@ -1203,7 +1251,7 @@ lldb::OptionDefinition CommandObjectThreadUntil::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, eArgTypeFrameNum, "Frame index for until operation - defaults to 0"}, +{ LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"}, { LLDB_OPT_SET_1, false, "thread", 't', required_argument, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"}, { LLDB_OPT_SET_1, false, "run-mode",'m', required_argument, g_duo_running_mode, 0, eArgTypeRunMode,"Determine how to run other threads while stepping this one"}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } @@ -1222,9 +1270,21 @@ CommandObject (interpreter, "thread select", "Select a thread as the currently active thread.", - "thread select ", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { + CommandArgumentEntry arg; + CommandArgumentData thread_idx_arg; + + // Define the first (and only) variant of this arg. + thread_idx_arg.arg_type = eArgTypeThreadIndex; + thread_idx_arg.arg_repetition = eArgRepeatPlain; + + // There is only one variant this argument could be; put it into the argument entry. + arg.push_back (thread_idx_arg); + + // Push the data for the first argument into the m_arguments vector. + m_arguments.push_back (arg); } @@ -1377,7 +1437,7 @@ interpreter, "thread step-in", "Source level single step in specified thread (current thread, if none specified).", - "thread step-in []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeInto, eStepScopeSource))); @@ -1386,7 +1446,7 @@ interpreter, "thread step-out", "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", - "thread step-out []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, eStepScopeSource))); @@ -1395,7 +1455,7 @@ interpreter, "thread step-over", "Source level single step in specified thread (current thread, if none specified), stepping over calls.", - "thread step-over []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOver, eStepScopeSource))); @@ -1404,7 +1464,7 @@ interpreter, "thread step-inst", "Single step one instruction in specified thread (current thread, if none specified).", - "thread step-inst []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTrace, eStepScopeInstruction))); @@ -1413,7 +1473,7 @@ interpreter, "thread step-inst-over", "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", - "thread step-inst-over []", + NULL, eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTraceOver, eStepScopeInstruction))); Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Oct 4 17:28:36 2010 @@ -166,7 +166,7 @@ break_regex_cmd_ap(new CommandObjectRegexCommand (*this, "regexp-break", "Set a breakpoint using a regular expression to specify the location.", - "regexp-break [:]\nregexp-break [
]\nregexp-break <...>", 2)); + "regexp-break [:]\nregexp-break [
]\nregexp-break <...>", 2)); if (break_regex_cmd_ap.get()) { if (break_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$", "breakpoint set --file '%1' --line %2") && Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=115570&r1=115569&r2=115570&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Mon Oct 4 17:28:36 2010 @@ -85,7 +85,7 @@ StreamString syntax_str; syntax_str.Printf ("%s", GetCommandName()); if (GetOptions() != NULL) - syntax_str.Printf (" "); + syntax_str.Printf (" "); if (m_arguments.size() > 0) { syntax_str.Printf (" "); @@ -511,6 +511,20 @@ return entry->arg_name; } +bool +CommandObject::IsPairType (lldb::ArgumentRepetitionType arg_repeat_type) +{ + if ((arg_repeat_type == eArgRepeatPairPlain) + || (arg_repeat_type == eArgRepeatPairOptional) + || (arg_repeat_type == eArgRepeatPairPlus) + || (arg_repeat_type == eArgRepeatPairStar) + || (arg_repeat_type == eArgRepeatPairRange) + || (arg_repeat_type == eArgRepeatPairRangeOptional)) + return true; + + return false; +} + void CommandObject::GetFormattedCommandArguments (Stream &str) { @@ -521,27 +535,60 @@ str.Printf (" "); CommandArgumentEntry arg_entry = m_arguments[i]; int num_alternatives = arg_entry.size(); - StreamString names; - for (int j = 0; j < num_alternatives; ++j) + + if ((num_alternatives == 2) + && IsPairType (arg_entry[0].arg_repetition)) { - if (j > 0) - names.Printf (" | "); - names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type)); + const char *first_name = GetArgumentName (arg_entry[0].arg_type); + const char *second_name = GetArgumentName (arg_entry[1].arg_type); + switch (arg_entry[0].arg_repetition) + { + case eArgRepeatPairPlain: + str.Printf ("<%s> <%s>", first_name, second_name); + break; + case eArgRepeatPairOptional: + str.Printf ("[<%s> <%s>]", first_name, second_name); + break; + case eArgRepeatPairPlus: + str.Printf ("<%s> <%s> [<%s> <%s> [...]]", first_name, second_name, first_name, second_name); + break; + case eArgRepeatPairStar: + str.Printf ("[<%s> <%s> [<%s> <%s> [...]]]", first_name, second_name, first_name, second_name); + break; + case eArgRepeatPairRange: + str.Printf ("<%s_1> <%s_1> ... <%s_n> <%s_n>", first_name, second_name, first_name, second_name); + break; + case eArgRepeatPairRangeOptional: + str.Printf ("[<%s_1> <%s_1> ... <%s_n> <%s_n>]", first_name, second_name, first_name, second_name); + break; + } } - switch (arg_entry[0].arg_repetition) + else { - case eArgRepeatPlain: - str.Printf ("<%s>", names.GetData()); - break; - case eArgRepeatPlus: - str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData()); - break; - case eArgRepeatStar: - str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); - break; - case eArgRepeatOptional: - str.Printf ("[<%s>]", names.GetData()); - break; + StreamString names; + for (int j = 0; j < num_alternatives; ++j) + { + if (j > 0) + names.Printf (" | "); + names.Printf ("%s", GetArgumentName (arg_entry[j].arg_type)); + } + switch (arg_entry[0].arg_repetition) + { + case eArgRepeatPlain: + str.Printf ("<%s>", names.GetData()); + break; + case eArgRepeatPlus: + str.Printf ("<%s> [<%s> [...]]", names.GetData(), names.GetData()); + break; + case eArgRepeatStar: + str.Printf ("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); + break; + case eArgRepeatOptional: + str.Printf ("[<%s>]", names.GetData()); + break; + case eArgRepeatRange: + str.Printf ("<%s_1> .. <%s_n>", names.GetData()); + } } } } @@ -573,66 +620,69 @@ static const char * BreakpointIDRangeHelpTextCallback () { - return "A 'breakpoint id range' is a manner of specifying multiple breakpoints. This can be done through several mechanisms. The easiest way is to just enter a space-separated list of breakpoint ids. To specify all the breakpoint locations under a major breakpoint, you can use the major breakpoint number followed by '.*', eg. '5.*' means all the locations under breakpoint 5. You can also indicate a range of breakpoints by using - . The start-bp-id and end-bp-id for a range can be any valid breakpoint ids. It is not legal, however, to specify a range using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7 is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; + return "A 'breakpoint id list' is a manner of specifying multiple breakpoints. This can be done through several mechanisms. The easiest way is to just enter a space-separated list of breakpoint ids. To specify all the breakpoint locations under a major breakpoint, you can use the major breakpoint number followed by '.*', eg. '5.*' means all the locations under breakpoint 5. You can also indicate a range of breakpoints by using - . The start-bp-id and end-bp-id for a range can be any valid breakpoint ids. It is not legal, however, to specify a range using specific locations that cross major breakpoint numbers. I.e. 3.2 - 3.7 is legal; 2 - 5 is legal; but 3.2 - 4.4 is not legal."; } CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = { - { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeArchitecture, "architecture", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "A valid address in the target program's execution space." }, + { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, NULL, "The name of an abbreviation (alias) for a debugger command." }, + { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" }, + { eArgTypeArchitecture, "arch", CommandCompletions::eNoCompletion, NULL, "The architecture name, e.g. i386 or x86_64." }, { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" }, - { eArgTypeBreakpointID, "breakpoint-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, - { eArgTypeBreakpointIDRange, "breakpoint-id-range", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL }, - { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeChannel, "channel", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, + { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL }, + { eArgTypeByteSize, "byte-size", CommandCompletions::eNoCompletion, NULL, "Number of bytes to use." }, + { eArgTypeCommandName, "cmd-name", CommandCompletions::eNoCompletion, NULL, "A debugger command (may be multiple words), without any options or arguments." }, { eArgTypeCount, "count", CommandCompletions::eNoCompletion, NULL, "An unsigned integer." }, - { eArgTypeExpression, "expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeEndAddress, "end-address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeExpression, "expr", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeExprFormat, "expression-format", CommandCompletions::eNoCompletion, NULL, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]" }, { eArgTypeFilename, "filename", CommandCompletions::eNoCompletion, NULL, "The name of a file (can include path)." }, { eArgTypeFormat, "format", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeFrameNum, "frame-num", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeFullName, "full-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeLineNum, "line-num", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFrameIndex, "frame-index", CommandCompletions::eNoCompletion, NULL, "Index into a thread's list of frames." }, + { eArgTypeFullName, "fullname", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeFunctionName, "function-name", CommandCompletions::eNoCompletion, NULL, "The name of a function." }, + { eArgTypeIndex, "index", CommandCompletions::eNoCompletion, NULL, "An index into a list." }, + { eArgTypeLineNum, "linenum", CommandCompletions::eNoCompletion, NULL, "Line number in a source file." }, + { eArgTypeLogChannel, "log-channel", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeMethod, "method", CommandCompletions::eNoCompletion, NULL, "A C++ method name." }, { eArgTypeName, "name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNewPathPrefix, "new-path-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNumLines, "num-lines", CommandCompletions::eNoCompletion, NULL, "The number of lines to use." }, + { eArgTypeNumberPerLine, "number-per-line", CommandCompletions::eNoCompletion, NULL, "The number of items per line to display." }, { eArgTypeOffset, "offset", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeOldPathPrefix, "old-path-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeOneLiner, "one-line-breakpoint-command", CommandCompletions::eNoCompletion, NULL, "A breakpoint command that is entered as a single line of text." }, - { eArgTypeOther, "other", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypePath, "path", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypePathPrefix, "path-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypePathPrefixPair, "path-prefix-pair", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypePid, "pid", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypePid, "pid", CommandCompletions::eNoCompletion, NULL, "The process ID number." }, { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, NULL, "The name of the process." }, + { eArgTypeQueueName, "queue-name", CommandCompletions::eNoCompletion, NULL, "The name of the thread queue." }, + { eArgTypeRegisterName, "register-name", CommandCompletions::eNoCompletion, NULL, "A register name." }, + { eArgTypeRegularExpression, "regular-expression", CommandCompletions::eNoCompletion, NULL, "A regular expression." }, + { eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, NULL, "Arguments to be passed to the target program when it starts executing." }, { eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, NULL, "The scripting language to be used for script-based commands. Currently only Python is valid." }, + { eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, NULL, "The word for which you wish to search for information about." }, + { eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, NULL, "An Objective-C selector name." }, + { eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, NULL, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." }, + { eArgTypeSettingKey, "setting-key", CommandCompletions::eNoCompletion, NULL, "A key into a settings variables that is a dictionary (try 'settings list' to see all the possible settings variables and their types)." }, + { eArgTypeSettingPrefix, "setting-prefix", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable up to a dot ('.'), e.g. 'target.process.'" }, + { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, + { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "The name of a shared library." }, + { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "The name of a source file.." }, { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeSymbol, "symbol", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeUUID, "UUID", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeUnixSignalNumber, "unix-signal-number", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeVarName, "var-name", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeSymbol, "symbol", CommandCompletions::eNoCompletion, NULL, "Any symbol name (function name, variable, argument, etc.)" }, + { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Thread ID number." }, + { eArgTypeThreadIndex, "thread-index", CommandCompletions::eNoCompletion, NULL, "Index into the process' list of threads." }, + { eArgTypeThreadName, "thread-name", CommandCompletions::eNoCompletion, NULL, "The thread's name." }, + { eArgTypeUnixSignalNumber, "unix-signal-number", CommandCompletions::eNoCompletion, NULL, "A valid Unix signal number." }, + { eArgTypeVarName, "variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a variable in your program." }, + { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "A value could be anything, depending on where and how it is used." }, { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, - { eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, + { eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "No help available for this." }, }; const CommandObject::ArgumentTableEntry* From jingham at apple.com Mon Oct 4 17:44:14 2010 From: jingham at apple.com (Jim Ingham) Date: Mon, 04 Oct 2010 22:44:14 -0000 Subject: [Lldb-commits] [lldb] r115572 - in /lldb/trunk: include/lldb/Core/Debugger.h source/Core/Debugger.cpp source/Interpreter/CommandInterpreter.cpp Message-ID: <20101004224414.84E132A6C12C@llvm.org> Author: jingham Date: Mon Oct 4 17:44:14 2010 New Revision: 115572 URL: http://llvm.org/viewvc/llvm-project?rev=115572&view=rev Log: Add an "auto-confirm" setting to the debugger so you can turn off the confirmations if you want to. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=115572&r1=115571&r2=115572&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon Oct 4 17:44:14 2010 @@ -153,6 +153,19 @@ m_use_external_editor = use_external_editor_p; return old_value; } + + bool + GetAutoConfirm () const + { + return m_auto_confirm_on; + } + + void + SetAutoConfirm (bool auto_confirm_on) + { + m_auto_confirm_on = auto_confirm_on; + } + protected: @@ -186,6 +199,9 @@ static const ConstString & UseExternalEditorVarName (); + + static const ConstString & + AutoConfirmName (); private: @@ -195,6 +211,7 @@ std::string m_thread_format; lldb::ScriptLanguage m_script_lang; bool m_use_external_editor; + bool m_auto_confirm_on; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=115572&r1=115571&r2=115572&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Oct 4 17:44:14 2010 @@ -1298,7 +1298,8 @@ m_frame_format (), m_thread_format (), m_script_lang (), - m_use_external_editor (false) + m_use_external_editor (false), + m_auto_confirm_on (false) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -1324,7 +1325,8 @@ m_frame_format (rhs.m_frame_format), m_thread_format (rhs.m_thread_format), m_script_lang (rhs.m_script_lang), - m_use_external_editor (rhs.m_use_external_editor) + m_use_external_editor (rhs.m_use_external_editor), + m_auto_confirm_on(rhs.m_auto_confirm_on) { const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); CopyInstanceSettings (pending_settings, false); @@ -1346,6 +1348,7 @@ m_thread_format = rhs.m_thread_format; m_script_lang = rhs.m_script_lang; m_use_external_editor = rhs.m_use_external_editor; + m_auto_confirm_on = rhs.m_auto_confirm_on; } return *this; @@ -1434,6 +1437,10 @@ { UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, err); } + else if (var_name == AutoConfirmName ()) + { + UserSettingsController::UpdateBooleanVariable (op, m_auto_confirm_on, value, err); + } } bool @@ -1472,6 +1479,13 @@ else value.AppendString ("false"); } + else if (var_name == AutoConfirmName()) + { + if (m_auto_confirm_on) + value.AppendString ("true"); + else + value.AppendString ("false"); + } else { if (err) @@ -1509,6 +1523,7 @@ m_term_width = new_debugger_settings->m_term_width; m_script_lang = new_debugger_settings->m_script_lang; m_use_external_editor = new_debugger_settings->m_use_external_editor; + m_auto_confirm_on = new_debugger_settings->m_auto_confirm_on; } @@ -1610,6 +1625,14 @@ return use_external_editor_var_name; } +const ConstString & +DebuggerInstanceSettings::AutoConfirmName () +{ + static ConstString use_external_editor_var_name ("auto-confirm"); + + return use_external_editor_var_name; +} + //-------------------------------------------------- // SettingsController Variable Tables //-------------------------------------------------- @@ -1646,11 +1669,12 @@ { // NAME Setting variable type Default Enum Init'd Hidden Help // ======================= ======================= ====================== ==== ====== ====== ====================== -{ "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, -{ "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, -{ "prompt", eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, { "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." }, +{ "prompt", eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." }, +{ "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, +{ "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, { "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, { "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." }, +{ "auto-confirm", eSetVarTypeBool, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, { NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } }; Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=115572&r1=115571&r2=115572&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Oct 4 17:44:14 2010 @@ -843,7 +843,10 @@ bool CommandInterpreter::Confirm (const char *message, bool default_answer) { - // The default interpretation just pushes a new input reader and lets it get the answer: + // Check AutoConfirm first: + if (m_debugger.GetAutoConfirm()) + return default_answer; + InputReaderSP reader_sp (new InputReader(GetDebugger())); bool response = default_answer; if (reader_sp) From johnny.chen at apple.com Mon Oct 4 18:03:34 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 04 Oct 2010 23:03:34 -0000 Subject: [Lldb-commits] [lldb] r115574 - in /lldb/trunk/test: foundation/TestDisassemble.py stl/TestDisassemble.py Message-ID: <20101004230334.A12262A6C12C@llvm.org> Author: johnny Date: Mon Oct 4 18:03:34 2010 New Revision: 115574 URL: http://llvm.org/viewvc/llvm-project?rev=115574&view=rev Log: Do 'disassemble -s start_addr -e end_addr' on stdc++ library function entries. Modified: lldb/trunk/test/foundation/TestDisassemble.py lldb/trunk/test/stl/TestDisassemble.py Modified: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115574&r1=115573&r2=115574&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (original) +++ lldb/trunk/test/foundation/TestDisassemble.py Mon Oct 4 18:03:34 2010 @@ -1,5 +1,5 @@ """ -Test the lldb disassemble command. +Test the lldb disassemble command on foundation framework. """ import os, time Modified: lldb/trunk/test/stl/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassemble.py?rev=115574&r1=115573&r2=115574&view=diff ============================================================================== --- lldb/trunk/test/stl/TestDisassemble.py (original) +++ lldb/trunk/test/stl/TestDisassemble.py Mon Oct 4 18:03:34 2010 @@ -1,5 +1,5 @@ """ -Test the lldb disassemble command. +Test the lldb disassemble command on lib stdc++. """ import os, time @@ -7,11 +7,12 @@ import lldb from lldbtest import * - at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") class StdCXXDisassembleTestCase(TestBase): mydir = "stl" + # rdar://problem/8504895 + # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") def test_stdcxx_disasm(self): """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" @@ -34,6 +35,15 @@ substrs = ["a.out", "state: Stopped"]) + # Disassemble the functions on the call stack. + self.runCmd("thread backtrace") + thread = process.GetThreadAtIndex(0) + depth = thread.GetNumFrames() + for i in range(depth - 1): + frame = thread.GetFrameAtIndex(i) + function = frame.GetFunction() + self.runCmd("disassemble -n '%s'" % function.GetName()) + # Iterate through the available modules, looking for stdc++ library... for i in range(target.GetNumModules()): module = target.GetModuleAtIndex(i) @@ -48,6 +58,40 @@ self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False, substrs = ["libstdc++"]) + self.runCmd("image dump symtab %s" % repr(fs)) + raw_output = self.res.GetOutput() + # Now, look for every 'Code' symbol and feed its load address into the + # command: 'disassemble -s load_address -e end_address', where the + # end_address is taken from the next consecutive 'Code' symbol entry's + # load address. + # + # The load address column comes after the file address column, with both + # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. + codeRE = re.compile(r""" + \ Code\ {9} # ' Code' followed by 9 SPCs, + 0x[0-9a-f]{16} # the file address column, and + \ # a SPC, and + (0x[0-9a-f]{16}) # the load address column, and + .* # the rest. + """, re.VERBOSE) + # Maintain a start address variable; if we arrive at a consecutive Code + # entry, then the load address of the that entry is fed as the end + # address to the 'disassemble -s SA -e LA' command. + SA = None + for line in raw_output.split(os.linesep): + match = codeRE.search(line) + if match: + LA = match.group(1) + print "line:", line + print "load address:", LA + print "SA:", SA + if SA and LA: + self.runCmd("disassemble -s %s -e %s" % (SA, LA)) + SA = LA + else: + # This entry is not a Code entry. Reset SA = None. + SA = None + if __name__ == '__main__': import atexit From gclayton at apple.com Mon Oct 4 19:00:42 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 05 Oct 2010 00:00:42 -0000 Subject: [Lldb-commits] [lldb] r115578 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Expression/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Expression/ Message-ID: <20101005000042.AA5E52A6C12C@llvm.org> Author: gclayton Date: Mon Oct 4 19:00:42 2010 New Revision: 115578 URL: http://llvm.org/viewvc/llvm-project?rev=115578&view=rev Log: Added a new ValueObject type that will be used to freeze dry expression results. The clang opaque type for the expression result will be added to the Target's ASTContext, and the bytes will be stored in a DataBuffer inside the new object. The class is named: ValueObjectConstResult Now after an expression is evaluated, we can get a ValueObjectSP back that contains a ValueObjectConstResult object. Relocated the value object dumping code into a static function within the ValueObject class instead of being in the CommandObjectFrame.cpp file which is what contained the code to dump variables ("frame variables"). Added: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/source/Core/ValueObjectConstResult.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangPersistentVariables.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Mon Oct 4 19:00:42 2010 @@ -64,6 +64,9 @@ lldb::SBBlock GetBlock () const; + lldb::SBValue + EvaluateExpression (const char *expr); + // Gets the lexical block that defines the stack frame. Another way to think // of this is it will return the block that contains all of the variables // for a stack frame. Inlined functions are represented as SBBlock objects Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Mon Oct 4 19:00:42 2010 @@ -99,7 +99,7 @@ /// @param[in] addr_size /// A new address byte size value. //------------------------------------------------------------------ - DataExtractor (lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint8_t addr_size); + DataExtractor (const lldb::DataBufferSP& data_sp, lldb::ByteOrder byte_order, uint8_t addr_size); //------------------------------------------------------------------ /// Construct with a subset of \a data. @@ -1068,7 +1068,7 @@ /// The number of bytes that this object now contains. //------------------------------------------------------------------ uint32_t - SetData (lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX); + SetData (const lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX); //------------------------------------------------------------------ /// Set the byte_order value. Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Oct 4 19:00:42 2010 @@ -188,6 +188,19 @@ bool SetDynamicValue (); + static void + DumpValueObject (Stream &s, + ExecutionContextScope *exe_scope, + ValueObject *valobj, + const char *root_valobj_name, + uint32_t ptr_depth, + uint32_t curr_depth, + uint32_t max_depth, + bool show_types, + bool show_location, + bool use_objc, + bool scope_already_checked); + protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these Added: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=115578&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (added) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Mon Oct 4 19:00:42 2010 @@ -0,0 +1,71 @@ +//===-- ValueObjectConstResult.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_ValueObjectChild_h_ +#define liblldb_ValueObjectChild_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/ValueObject.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +// A child of another ValueObject. +//---------------------------------------------------------------------- +class ValueObjectConstResult : public ValueObject +{ +public: + ValueObjectConstResult (clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + const lldb::DataBufferSP &result_data_sp, + lldb::ByteOrder byte_order, + uint8_t addr_size); + + + virtual ~ValueObjectConstResult(); + + virtual size_t + GetByteSize(); + + virtual clang::ASTContext * + GetClangAST (); + + virtual void * + GetClangType (); + + virtual lldb::ValueType + GetValueType() const; + + virtual uint32_t + CalculateNumChildren(); + + virtual ConstString + GetTypeName(); + + virtual void + UpdateValue (ExecutionContextScope *exe_scope); + + virtual bool + IsInScope (StackFrame *frame); + +protected: + clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from + ConstString m_type_name; + +private: + DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult); +}; + +} // namespace lldb_private + +#endif // liblldb_ValueObjectChild_h_ Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Mon Oct 4 19:00:42 2010 @@ -82,6 +82,9 @@ bool PointValueAtData(Value &value, ExecutionContext *exe_ctx); + lldb::ValueObjectSP + GetExpressionResult (ExecutionContext *exe_ctx); + //---------------------------------------------------------------------- /// The following values should stay valid for the life of the variable //---------------------------------------------------------------------- @@ -98,6 +101,15 @@ /// The following values should not live beyond parsing //---------------------------------------------------------------------- struct ParserVars { + + ParserVars() : + m_parser_type(), + m_named_decl (NULL), + m_llvm_value (NULL), + m_lldb_value (NULL) + { + } + TypeFromParser m_parser_type; ///< The type of the variable according to the parser const clang::NamedDecl *m_named_decl; ///< The Decl corresponding to this variable llvm::Value *m_llvm_value; ///< The IR value corresponding to this variable; usually a GlobalValue @@ -127,6 +139,13 @@ /// The following values are valid if the variable is used by JIT code //---------------------------------------------------------------------- struct JITVars { + JITVars () : + m_alignment (0), + m_size (0), + m_offset (0) + { + } + off_t m_alignment; ///< The required alignment of the variable, in bytes size_t m_size; ///< The space required for the variable, in bytes off_t m_offset; ///< The offset of the variable in the struct, in bytes @@ -151,24 +170,15 @@ m_jit_vars.reset(); } - //---------------------------------------------------------------------- - /// The following values are valid if the value contains its own data - //---------------------------------------------------------------------- - struct DataVars { - lldb_private::DataBufferHeap *m_data; ///< The heap area allocated to contain this variable's data. Responsibility for deleting this falls to whoever uses the variable last - }; - std::auto_ptr m_data_vars; + lldb::DataBufferSP m_data_sp; //---------------------------------------------------------------------- /// Make this variable usable for storing its data internally by /// allocating data-specific variables //---------------------------------------------------------------------- - void EnableDataVars() - { - if (!m_jit_vars.get()) - m_data_vars.reset(new struct DataVars); - } - + void + EnableDataVars(); + //---------------------------------------------------------------------- /// Deallocate data-specific variables //---------------------------------------------------------------------- @@ -180,40 +190,7 @@ size_t Size () { return (m_user_type.GetClangTypeBitWidth () + 7) / 8; - } - - //---------------------------------------------------------------------- - /// Pretty-print the variable, assuming it contains its own data - /// - /// @param[in] output_stream - /// The stream to pretty-print on. - /// - /// @param[in] exe_ctx - /// The execution context to use when resolving the contents of the - /// variable. - /// - /// @param[in] format - /// The format to print the variable in - /// - /// @param[in] show_types - /// If true, print the type of the variable - /// - /// @param[in] show_summary - /// If true, print a summary of the variable's type - /// - /// @param[in] verbose - /// If true, be verbose in printing the value of the variable - /// - /// @return - /// An Error describing the result of the operation. If Error::Success() - /// returns true, the pretty printing completed successfully. - //---------------------------------------------------------------------- - Error Print(Stream &output_stream, - ExecutionContext &exe_ctx, - lldb::Format format, - bool show_types, - bool show_summary, - bool verbose); + } }; //---------------------------------------------------------------------- Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Oct 4 19:00:42 2010 @@ -311,7 +311,8 @@ eValueTypeVariableArgument = 3, // function argument variables eValueTypeVariableLocal = 4, // function local variables eValueTypeRegister = 5, // stack frame register value - eValueTypeRegisterSet = 6 // A collection of stack frame register values + eValueTypeRegisterSet = 6, // A collection of stack frame register values + eValueTypeConstResult = 7, // function local variables } ValueType; //---------------------------------------------------------------------- Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Oct 4 19:00:42 2010 @@ -21,6 +21,8 @@ 261B5A5411C3F2AD00AABD0A /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; }; 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; + 26424E3D125986CB0016D82C /* ValueObjectConstResult.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26424E3C125986CB0016D82C /* ValueObjectConstResult.cpp */; }; + 26424E3F125986D30016D82C /* ValueObjectConstResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 26424E3E125986D30016D82C /* ValueObjectConstResult.h */; }; 264723A611FA076E00DE380C /* CleanUp.h in Headers */ = {isa = PBXBuildFile; fileRef = 264723A511FA076E00DE380C /* CleanUp.h */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; 2668020E115FD12C008E1FE4 /* lldb-defines.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -559,6 +561,8 @@ 263664921140A4930075843B /* Debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Debugger.cpp; path = source/Core/Debugger.cpp; sourceTree = ""; }; 263664941140A4C10075843B /* Debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Debugger.h; path = include/lldb/Core/Debugger.h; sourceTree = ""; }; 263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeSTLMap.h; path = include/lldb/Core/ThreadSafeSTLMap.h; sourceTree = ""; }; + 26424E3C125986CB0016D82C /* ValueObjectConstResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectConstResult.cpp; path = source/Core/ValueObjectConstResult.cpp; sourceTree = ""; }; + 26424E3E125986D30016D82C /* ValueObjectConstResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectConstResult.h; path = include/lldb/Core/ValueObjectConstResult.h; sourceTree = ""; }; 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectRegister.cpp; path = source/Core/ValueObjectRegister.cpp; sourceTree = ""; }; 2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectRegister.h; path = include/lldb/Core/ValueObjectRegister.h; sourceTree = ""; }; 264723A511FA076E00DE380C /* CleanUp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CleanUp.h; path = include/lldb/Utility/CleanUp.h; sourceTree = ""; }; @@ -1745,6 +1749,8 @@ 26BC7E9A10F1B85900F91463 /* ValueObject.cpp */, 26BC7D8310F1B77400F91463 /* ValueObjectChild.h */, 26BC7E9B10F1B85900F91463 /* ValueObjectChild.cpp */, + 26424E3E125986D30016D82C /* ValueObjectConstResult.h */, + 26424E3C125986CB0016D82C /* ValueObjectConstResult.cpp */, 26BC7D8410F1B77400F91463 /* ValueObjectList.h */, 26BC7E9C10F1B85900F91463 /* ValueObjectList.cpp */, 2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */, @@ -2377,6 +2383,7 @@ 4C139EA6124A8B03000BFF8D /* AppleObjCRuntimeV2.h in Headers */, 4C0A91D912511CB900CA6636 /* AppleObjCTrampolineHandler.h in Headers */, 4C0A91DB12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.h in Headers */, + 26424E3F125986D30016D82C /* ValueObjectConstResult.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2848,6 +2855,7 @@ 4C139EA5124A8B03000BFF8D /* AppleObjCRuntimeV2.cpp in Sources */, 4C0A91D812511CB900CA6636 /* AppleObjCTrampolineHandler.cpp in Sources */, 4C0A91DA12511CB900CA6636 /* AppleThreadPlanStepThroughObjCTrampoline.cpp in Sources */, + 26424E3D125986CB0016D82C /* ValueObjectConstResult.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Oct 4 19:00:42 2010 @@ -409,3 +409,13 @@ return true; } + +lldb::SBValue +SBFrame::EvaluateExpression (const char *expr) +{ + lldb::SBValue expr_result_value; + if (m_opaque_sp) + { + } + return expr_result_value; +} Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Oct 4 19:00:42 2010 @@ -206,8 +206,14 @@ } bool -CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream, - CommandReturnObject *result) +CommandObjectExpression::EvaluateExpression +( + const char *expr, + bool bare, + Stream &output_stream, + Stream &error_stream, + CommandReturnObject *result +) { if (!m_exe_ctx.process) { @@ -248,41 +254,31 @@ if (expr_result) { - StreamString ss; - - if (m_options.print_object) - { - Value result_value; - if (expr_result->PointValueAtData(result_value, &m_exe_ctx)) - { - bool obj_result; - ObjCLanguageRuntime *runtime = m_exe_ctx.process->GetObjCLanguageRuntime(); - obj_result = runtime->GetObjectDescription (ss, result_value, m_exe_ctx.GetBestExecutionContextScope()); - if (!obj_result) - { - error_stream.Printf ("Could not get object description: %s.\n", ss.GetData()); - return false; - } - // Sometimes the description doesn't have a newline on the end. For now, I'll just add one here, if - ss.Printf("\n"); - } + // TODO: seems weird to get a pointer to a result object back from + // a function. Do we own it? Feels like we do, but from looking at the + // code we don't. Might be best to make this a reference and state + // explicitly that we don't own it when we get a reference back from + // the execute? + lldb::ValueObjectSP valobj_sp (expr_result->GetExpressionResult (&m_exe_ctx)); + if (valobj_sp) + { + ValueObject::DumpValueObject (output_stream, + m_exe_ctx.GetBestExecutionContextScope(), + valobj_sp.get(), // Variable object to dump + expr_result->m_name.c_str(),// Root object name + 0, // Pointer depth to traverse (zero means stop at pointers) + 0, // Current depth, this is the top most, so zero... + UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... + m_options.show_types, // Show types when dumping? + false, // Show locations of variables, no since this is a host address which we don't care to see + m_options.print_object, // Print the objective C object? + true); // Scope is already checked. Const results are always in scope. + output_stream.EOL(); } else { - Error rc = expr_result->Print (ss, - m_exe_ctx, - m_options.format, - m_options.show_types, - m_options.show_summary, - m_options.debug); - - if (rc.Fail()) { - error_stream.Printf ("Couldn't print result : %s\n", rc.AsCString()); - return false; - } + error_stream.PutCString ("Couldn't extract expression result"); } - - output_stream.PutCString(ss.GetString().c_str()); if (result) result->SetStatus (eReturnStatusSuccessFinishResult); } Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Oct 4 19:00:42 2010 @@ -336,125 +336,6 @@ return &m_options; } - void - DumpValueObject (CommandReturnObject &result, - ExecutionContextScope *exe_scope, - ValueObject *valobj, - const char *root_valobj_name, - uint32_t ptr_depth, - uint32_t curr_depth, - uint32_t max_depth, - bool use_objc, - bool scope_already_checked) - { - if (valobj) - { - Stream &s = result.GetOutputStream(); - - //const char *loc_cstr = valobj->GetLocationAsCString(); - if (m_options.show_location) - { - s.Printf("%s: ", valobj->GetLocationAsCString(exe_scope)); - } - if (m_options.debug) - s.Printf ("%p ValueObject{%u} ", valobj, valobj->GetID()); - - s.Indent(); - - if (m_options.show_types) - s.Printf("(%s) ", valobj->GetTypeName().AsCString()); - - const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString(""); - s.Printf ("%s = ", name_cstr); - - if (!scope_already_checked && !valobj->IsInScope(exe_scope->CalculateStackFrame())) - { - s.PutCString("error: out of scope"); - return; - } - - const char *val_cstr = valobj->GetValueAsCString(exe_scope); - const char *err_cstr = valobj->GetError().AsCString(); - - if (err_cstr) - { - s.Printf ("error: %s", err_cstr); - } - else - { - const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope); - - const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType()); - - if (val_cstr) - s.PutCString(val_cstr); - - if (sum_cstr) - s.Printf(" %s", sum_cstr); - - if (use_objc) - { - const char *object_desc = valobj->GetObjectDescription(exe_scope); - if (object_desc) - s.Printf("\n%s\n", object_desc); - else - s.Printf ("No description available.\n"); - return; - } - - - if (curr_depth < max_depth) - { - if (is_aggregate) - s.PutChar('{'); - - bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType()); - - if (is_ptr_or_ref && ptr_depth == 0) - return; - - const uint32_t num_children = valobj->GetNumChildren(); - if (num_children) - { - s.IndentMore(); - for (uint32_t idx=0; idxGetChildAtIndex(idx, true)); - if (child_sp.get()) - { - s.EOL(); - DumpValueObject (result, - exe_scope, - child_sp.get(), - NULL, - is_ptr_or_ref ? ptr_depth - 1 : ptr_depth, - curr_depth + 1, - max_depth, - false, - true); - if (idx + 1 < num_children) - s.PutChar(','); - } - } - s.IndentLess(); - } - if (is_aggregate) - { - s.EOL(); - s.Indent("}"); - } - } - else - { - if (is_aggregate) - { - s.PutCString("{...}"); - } - } - - } - } - } virtual bool Execute @@ -517,16 +398,17 @@ s.PutCString (": "); } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - m_options.ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc, - false); - + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false); s.EOL(); } } @@ -683,15 +565,18 @@ s.PutCString (": "); } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc, - false); + + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false); s.EOL(); } @@ -762,16 +647,18 @@ var_sp->GetDeclaration ().DumpStopContext (&s, false); s.PutCString (": "); } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - m_options.ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc, - true); - + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false); + s.EOL(); } } Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Mon Oct 4 19:00:42 2010 @@ -93,7 +93,7 @@ // as long as any DataExtractor objects exist that have a reference to // this data. //---------------------------------------------------------------------- -DataExtractor::DataExtractor (DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) : +DataExtractor::DataExtractor (const DataBufferSP& data_sp, ByteOrder endian, uint8_t addr_size) : m_start (NULL), m_end (NULL), m_byte_order(endian), @@ -370,7 +370,7 @@ // settings will remain unchanged from their current settings. //---------------------------------------------------------------------- uint32_t -DataExtractor::SetData (DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length) +DataExtractor::SetData (const DataBufferSP& data_sp, uint32_t data_offset, uint32_t data_length) { m_start = m_end = NULL; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Oct 4 19:00:42 2010 @@ -851,3 +851,127 @@ return true; } + + +void +ValueObject::DumpValueObject +( + Stream &s, + ExecutionContextScope *exe_scope, + ValueObject *valobj, + const char *root_valobj_name, + uint32_t ptr_depth, + uint32_t curr_depth, + uint32_t max_depth, + bool show_types, + bool show_location, + bool use_objc, + bool scope_already_checked +) +{ + if (valobj) + { + //const char *loc_cstr = valobj->GetLocationAsCString(); + if (show_location) + { + s.Printf("%s: ", valobj->GetLocationAsCString(exe_scope)); + } + + s.Indent(); + + if (show_types) + s.Printf("(%s) ", valobj->GetTypeName().AsCString()); + + const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString(""); + s.Printf ("%s = ", name_cstr); + + if (!scope_already_checked && !valobj->IsInScope(exe_scope->CalculateStackFrame())) + { + s.PutCString("error: out of scope"); + return; + } + + const char *val_cstr = valobj->GetValueAsCString(exe_scope); + const char *err_cstr = valobj->GetError().AsCString(); + + if (err_cstr) + { + s.Printf ("error: %s", err_cstr); + } + else + { + const char *sum_cstr = valobj->GetSummaryAsCString(exe_scope); + + const bool is_aggregate = ClangASTContext::IsAggregateType (valobj->GetClangType()); + + if (val_cstr) + s.PutCString(val_cstr); + + if (sum_cstr) + s.Printf(" %s", sum_cstr); + + if (use_objc) + { + const char *object_desc = valobj->GetObjectDescription(exe_scope); + if (object_desc) + s.Printf("\n%s\n", object_desc); + else + s.Printf ("No description available.\n"); + return; + } + + + if (curr_depth < max_depth) + { + if (is_aggregate) + s.PutChar('{'); + + bool is_ptr_or_ref = ClangASTContext::IsPointerOrReferenceType (valobj->GetClangType()); + + if (is_ptr_or_ref && ptr_depth == 0) + return; + + const uint32_t num_children = valobj->GetNumChildren(); + if (num_children) + { + s.IndentMore(); + for (uint32_t idx=0; idxGetChildAtIndex(idx, true)); + if (child_sp.get()) + { + s.EOL(); + DumpValueObject (s, + exe_scope, + child_sp.get(), + NULL, + is_ptr_or_ref ? ptr_depth - 1 : ptr_depth, + curr_depth + 1, + max_depth, + show_types, + show_location, + false, + true); + if (idx + 1 < num_children) + s.PutChar(','); + } + } + s.IndentLess(); + } + if (is_aggregate) + { + s.EOL(); + s.Indent("}"); + } + } + else + { + if (is_aggregate) + { + s.PutCString("{...}"); + } + } + } + } +} + Added: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=115578&view=auto ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (added) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Mon Oct 4 19:00:42 2010 @@ -0,0 +1,109 @@ +//===-- ValueObjectConstResult.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/ValueObjectConstResult.h" + +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ValueObjectList.h" + +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/Variable.h" + +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + +ValueObjectConstResult::ValueObjectConstResult +( + clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + const lldb::DataBufferSP &data_sp, + lldb::ByteOrder data_byte_order, + uint8_t data_addr_size +) : + ValueObject (), + m_clang_ast (clang_ast), + m_type_name () +{ + m_data.SetByteOrder(data_byte_order); + m_data.SetAddressByteSize(data_addr_size); + m_data.SetData(data_sp); + m_value.GetScalar() = (uintptr_t)data_sp->GetBytes(); + m_value.SetValueType(Value::eValueTypeHostAddress); + m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type); + m_name = name; +} + +ValueObjectConstResult::~ValueObjectConstResult() +{ +} + +void * +ValueObjectConstResult::GetClangType() +{ + return m_value.GetClangType(); +} + +lldb::ValueType +ValueObjectConstResult::GetValueType() const +{ + return eValueTypeConstResult; +} + +size_t +ValueObjectConstResult::GetByteSize() +{ + // We stored all the data for this const object in our data + return m_data.GetByteSize(); +} + +uint32_t +ValueObjectConstResult::CalculateNumChildren() +{ + return ClangASTContext::GetNumChildren (GetClangType(), true); +} + +clang::ASTContext * +ValueObjectConstResult::GetClangAST () +{ + return m_clang_ast; +} + +ConstString +ValueObjectConstResult::GetTypeName() +{ + if (m_type_name.IsEmpty()) + m_type_name = ClangASTType::GetClangTypeName (GetClangType()); + return m_type_name; +} + +void +ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope) +{ + m_error.Clear(); + // Const value is always valid + SetValueIsValid (true); +} + + +bool +ValueObjectConstResult::IsInScope (StackFrame *frame) +{ + // A const result value is always in scope since it serializes all + // information needed to contain the constant value. + return true; +} Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Oct 4 19:00:42 2010 @@ -575,10 +575,10 @@ size_t pvar_size = pvar->Size(); - if (!pvar->m_data_vars.get()) + if (!pvar->m_data_sp.get()) return false; - uint8_t *pvar_data = pvar->m_data_vars->m_data->GetBytes(); + uint8_t *pvar_data = pvar->m_data_sp->GetBytes(); Error error; if (dematerialize) Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Oct 4 19:00:42 2010 @@ -18,154 +18,74 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Value.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" using namespace lldb_private; using namespace clang; -ClangExpressionVariable::ClangExpressionVariable() +ClangExpressionVariable::ClangExpressionVariable() : + m_name(), + m_user_type (TypeFromUser(NULL, NULL)), + m_store (NULL), + m_index (0), + m_parser_vars(), + m_jit_vars (), + m_data_sp () { - m_name = ""; - m_user_type = TypeFromUser(NULL, NULL); - m_parser_vars.reset(NULL); - m_jit_vars.reset(NULL); - m_data_vars.reset(NULL); } -void ClangExpressionVariable::DisableDataVars() +void +ClangExpressionVariable::DisableDataVars() { - if (m_data_vars.get() && m_data_vars->m_data) - delete m_data_vars->m_data; - m_data_vars.reset(); + m_data_sp.reset(); } -Error -ClangExpressionVariable::Print (Stream &output_stream, - ExecutionContext &exe_ctx, - lldb::Format format, - bool show_types, - bool show_summary, - bool verbose) -{ - Error err; - - Value val; - if (!PointValueAtData (val, NULL)) - { - err.SetErrorToGenericError(); - err.SetErrorStringWithFormat("Variable doesn't contain a value"); - return err; - } - - if (val.GetContextType () == Value::eContextTypeInvalid && - val.GetValueType () == Value::eValueTypeScalar && - format == lldb::eFormatDefault) - { - // The expression result is just a scalar with no special formatting - val.GetScalar ().GetValue (&output_stream, show_types); - output_stream.EOL (); - return err; - } - - clang::ASTContext *ast_context = m_user_type.GetASTContext(); - // The expression result is more complex and requires special handling - DataExtractor data; - Error expr_error = val.GetValueAsData (&exe_ctx, ast_context, data, 0); - - - // Set byte order and pointer size to TARGET byte order and pointer size! - - data.SetByteOrder(exe_ctx.process->GetByteOrder()); - data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize()); - - if (!expr_error.Success ()) - { - err.SetErrorToGenericError (); - err.SetErrorStringWithFormat ("Couldn't resolve variable value: %s", expr_error.AsCString ()); - return err; - } - - if (format == lldb::eFormatDefault) - format = val.GetValueDefaultFormat (); - - void *clang_type = val.GetClangType (); - - output_stream.Printf("%s = ", m_name.c_str()); - - if (clang_type) - { - if (show_types) - output_stream.Printf("(%s) ", ClangASTType::GetClangTypeName (clang_type).GetCString()); - - ClangASTType::DumpValue (ast_context, // The ASTContext that the clang type belongs to - clang_type, // The opaque clang type we want to dump that value of - &exe_ctx, // The execution context for memory and variable access - &output_stream, // Stream to dump to - format, // Format to use when dumping - data, // A buffer containing the bytes for the clang type - 0, // Byte offset within "data" where value is - data.GetByteSize (), // Size in bytes of the value we are dumping - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Show types? - show_summary, // Show summary? - verbose, // Debug logging output? - UINT32_MAX); // Depth to dump in case this is an aggregate type - } - else - { - data.Dump (&output_stream, // Stream to dump to - 0, // Byte offset within "data" - format, // Format to use when dumping - data.GetByteSize (), // Size in bytes of each item we are dumping - 1, // Number of items to dump - UINT32_MAX, // Number of items per line - LLDB_INVALID_ADDRESS, // Invalid address, don't show any offset/address context - 0, // Bitfield bit size - 0); // Bitfield bit offset - } - - output_stream.EOL(); - - return err; -} - -ClangExpressionVariable::ClangExpressionVariable(const ClangExpressionVariable &cev) : - m_name(cev.m_name), - m_user_type(cev.m_user_type), - m_store(cev.m_store), - m_index(cev.m_index) +ClangExpressionVariable::ClangExpressionVariable(const ClangExpressionVariable &rhs) : + m_name(rhs.m_name), + m_user_type(rhs.m_user_type), + m_store(rhs.m_store), + m_index(rhs.m_index) { - if (cev.m_parser_vars.get()) + if (rhs.m_parser_vars.get()) { + // TODO: Sean, can m_parser_vars be a shared pointer??? We are copy + // constructing it here. That is ok if we need to, but do we really + // need to? m_parser_vars.reset(new struct ParserVars); - *m_parser_vars.get() = *cev.m_parser_vars.get(); + *m_parser_vars.get() = *rhs.m_parser_vars.get(); } - if (cev.m_jit_vars.get()) + if (rhs.m_jit_vars.get()) { + // TODO: Sean, can m_jit_vars be a shared pointer??? We are copy + // constructing it here. That is ok if we need to, but do we really + // need to? m_jit_vars.reset(new struct JITVars); - *m_jit_vars.get() = *cev.m_jit_vars.get(); + *m_jit_vars.get() = *rhs.m_jit_vars.get(); } - if (cev.m_data_vars.get()) + if (rhs.m_data_sp) { - m_data_vars.reset(new struct DataVars); - *m_data_vars.get() = *cev.m_data_vars.get(); + // TODO: Sean, does m_data_sp need to be copy constructed? Or can it + // shared the data? + + m_data_sp.reset(new DataBufferHeap (rhs.m_data_sp->GetBytes(), + rhs.m_data_sp->GetByteSize())); } } bool ClangExpressionVariable::PointValueAtData(Value &value, ExecutionContext *exe_ctx) { - if (!m_data_vars.get() || !m_data_vars->m_data) + if (m_data_sp.get() == NULL) return false; value.SetContext(Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType()); value.SetValueType(Value::eValueTypeHostAddress); - value.GetScalar() = (uint64_t)m_data_vars->m_data->GetBytes(); + value.GetScalar() = (uintptr_t)m_data_sp->GetBytes(); clang::ASTContext *ast_context = m_user_type.GetASTContext(); if (exe_ctx) @@ -173,3 +93,46 @@ return true; } + +void +ClangExpressionVariable::EnableDataVars() +{ + if (!m_data_sp.get()) + m_data_sp.reset(new DataBufferHeap); +} + +lldb::ValueObjectSP +ClangExpressionVariable::GetExpressionResult (ExecutionContext *exe_ctx) +{ + lldb::ValueObjectSP result_sp; + if (m_data_sp) + { + Target * target = NULL; + Process *process = NULL; + if (exe_ctx) + { + target = exe_ctx->target; + process = exe_ctx->process; + } + + Value value; + if (PointValueAtData(value, exe_ctx)) + { + lldb::ByteOrder byte_order = lldb::eByteOrderHost; + uint32_t addr_byte_size = 4; + if (process) + { + byte_order = process->GetByteOrder(); + addr_byte_size = process->GetAddressByteSize(); + } + result_sp.reset (new ValueObjectConstResult (m_user_type.GetASTContext(), + m_user_type.GetOpaqueQualType(), + ConstString (m_name.c_str()), + m_data_sp,// TODO: sean can you get this to be valid? + byte_order, + addr_byte_size)); + } + } + return result_sp; +} + Modified: lldb/trunk/source/Expression/ClangPersistentVariables.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangPersistentVariables.cpp?rev=115578&r1=115577&r2=115578&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangPersistentVariables.cpp (original) +++ lldb/trunk/source/Expression/ClangPersistentVariables.cpp Mon Oct 4 19:00:42 2010 @@ -33,8 +33,8 @@ } bool -ClangPersistentVariables::CreatePersistentVariable(const char *name, - TypeFromUser user_type) +ClangPersistentVariables::CreatePersistentVariable(const char *name, + TypeFromUser user_type) { if (GetVariable(name)) return false; @@ -43,10 +43,11 @@ pvar.m_name = name; pvar.m_user_type = user_type; - - pvar.EnableDataVars(); - - pvar.m_data_vars->m_data = new DataBufferHeap(pvar.Size(), 0); + // TODO: Sean, why do we need to call this?, we can just make it below + // and we aren't checking the result or anything... Is this cruft left + // over from an old code re-org? + //pvar.EnableDataVars(); + pvar.m_data_sp.reset(new DataBufferHeap(pvar.Size(), 0)); return true; } \ No newline at end of file From johnny.chen at apple.com Mon Oct 4 19:08:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 05 Oct 2010 00:08:09 -0000 Subject: [Lldb-commits] [lldb] r115579 - in /lldb/trunk/test: README-TestSuite attic/ attic/dotest.pl attic/tester.py dotest.pl tester.py Message-ID: <20101005000809.1257C2A6C12C@llvm.org> Author: johnny Date: Mon Oct 4 19:08:08 2010 New Revision: 115579 URL: http://llvm.org/viewvc/llvm-project?rev=115579&view=rev Log: Move two files to the 'attic'. Added: lldb/trunk/test/attic/ lldb/trunk/test/attic/dotest.pl - copied unchanged from r115570, lldb/trunk/test/dotest.pl lldb/trunk/test/attic/tester.py - copied unchanged from r115570, lldb/trunk/test/tester.py Removed: lldb/trunk/test/dotest.pl lldb/trunk/test/tester.py Modified: lldb/trunk/test/README-TestSuite Modified: lldb/trunk/test/README-TestSuite URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/README-TestSuite?rev=115579&r1=115578&r2=115579&view=diff ============================================================================== --- lldb/trunk/test/README-TestSuite (original) +++ lldb/trunk/test/README-TestSuite Mon Oct 4 19:08:08 2010 @@ -89,3 +89,4 @@ different way of running the whole test suite. As lldb and the Python test suite become more reliable, we don't expect to be using 'dotest.pl' anymore. + Note: dotest.pl has been moved to the attic directory. Removed: lldb/trunk/test/dotest.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.pl?rev=115578&view=auto ============================================================================== --- lldb/trunk/test/dotest.pl (original) +++ lldb/trunk/test/dotest.pl (removed) @@ -1,44 +0,0 @@ -#!/usr/bin/perl -w - -# -# Use this script to visit each python test case under the specified directory -# and invoke unittest.main() on each test case. -# - -use strict; -use FindBin; -use File::Find; -use File::Basename; -use Cwd; -use Cwd 'abs_path'; - -scalar(@ARGV) == 1 or die "Usage: dotest.pl testdir"; - -my $scriptDir = $FindBin::Bin; -my $baseDir = abs_path("$scriptDir/.."); -my $pluginDir = "$baseDir/test/plugins"; -my $testDir = $ARGV[0]; - -my $dbgPath = "$baseDir/build/Debug/LLDB.framework/Resources/Python"; -my $relPath = "$baseDir/build/Release/LLDB.framework/Resources/Python"; -if (-d $dbgPath) { - $ENV{'PYTHONPATH'} = "$dbgPath:$scriptDir:$pluginDir"; -} elsif (-d $relPath) { - $ENV{'PYTHONPATH'} = "$relPath:$scriptDir:$pluginDir"; -} -#print("ENV{PYTHONPATH}=$ENV{'PYTHONPATH'}\n"); - -# Traverse the directory to find our python test cases. -find(\&handleFind, $testDir); - -sub handleFind { - my $foundFile = $File::Find::name; - my $dir = getcwd; - #print("foundFile: $foundFile\n"); - - # Test*.py is the naming pattern for our test cases. - if ($foundFile =~ /.*\/(Test.*\.py)$/) { - print("Running python $1 (cwd = $dir)...\n"); - system("python $1"); - } -} Removed: lldb/trunk/test/tester.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tester.py?rev=115578&view=auto ============================================================================== --- lldb/trunk/test/tester.py (original) +++ lldb/trunk/test/tester.py (removed) @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf8 -*- - -import math, os.path, re, sys, time, unittest - -def setupSysPath(): - testPath = sys.path[0] - rem = re.match("(^.*/)test$", testPath) - if not rem: - print "This script expects to reside in .../test." - sys.exit(-1) - lldbBasePath = rem.group(1) - lldbDebugPythonPath = "build/Debug/LLDB.framework/Resources/Python" - lldbReleasePythonPath = "build/Release/LLDB.framework/Resources/Python" - lldbPythonPath = None - if os.path.isfile(lldbDebugPythonPath + "/lldb.py"): - lldbPythonPath = lldbDebugPythonPath - if os.path.isfile(lldbReleasePythonPath + "/lldb.py"): - lldbPythonPath = lldbReleasePythonPath - if not lldbPythonPath: - print "This script requires lldb.py to be in either " + lldbDebugPythonPath, - print "or" + lldbReleasePythonPath - sys.exit(-1) - sys.path.append(lldbPythonPath) - -def prettyTime(t): - if t == 0.0: - return "0s" - if t < 0.000001: - return ("%.3f" % (t * 1000000000.0)) + "ns" - if t < 0.001: - return ("%.3f" % (t * 1000000.0)) + "??s" - if t < 1: - return ("%.3f" % (t * 1000.0)) + "ms" - return str(t) + "s" - -class ExecutionTimes: - @classmethod - def executionTimes(cls): - if cls.m_executionTimes == None: - cls.m_executionTimes = ExecutionTimes() - for i in range(100): - cls.m_executionTimes.start() - cls.m_executionTimes.end("null") - return cls.m_executionTimes - def __init__(self): - self.m_times = dict() - def start(self): - self.m_start = time.time() - def end(self, component): - e = time.time() - if component not in self.m_times: - self.m_times[component] = list() - self.m_times[component].append(e - self.m_start) - def dumpStats(self): - for key in self.m_times.keys(): - if len(self.m_times[key]): - sampleMin = float('inf') - sampleMax = float('-inf') - sampleSum = 0.0 - sampleCount = 0.0 - for time in self.m_times[key]: - if time > sampleMax: - sampleMax = time - if time < sampleMin: - sampleMin = time - sampleSum += time - sampleCount += 1.0 - sampleMean = sampleSum / sampleCount - sampleVariance = 0 - for time in self.m_times[key]: - sampleVariance += (time - sampleMean) ** 2 - sampleVariance /= sampleCount - sampleStandardDeviation = math.sqrt(sampleVariance) - print key + ": [" + prettyTime(sampleMin) + ", " + prettyTime(sampleMax) + "] ", - print "?? " + prettyTime(sampleMean) + ", ?? " + prettyTime(sampleStandardDeviation) - m_executionTimes = None - -setupSysPath() - -import lldb - -class LLDBTestCase(unittest.TestCase): - def setUp(self): - debugger = lldb.SBDebugger.Create() - debugger.SetAsync(True) - self.m_commandInterpreter = debugger.GetCommandInterpreter() - if not self.m_commandInterpreter: - print "Couldn't get the command interpreter" - sys.exit(-1) - def runCommand(self, command, component): - res = lldb.SBCommandReturnObject() - ExecutionTimes.executionTimes().start() - self.m_commandInterpreter.HandleCommand(command, res, False) - ExecutionTimes.executionTimes().end(component) - if res.Succeeded(): - return res.GetOutput() - else: - self.fail("Command " + command + " returned an error") - return None - -class SanityCheckTestCase(LLDBTestCase): - def runTest(self): - ret = self.runCommand("show arch", "show-arch") - #print ret - -suite = unittest.TestLoader().loadTestsFromTestCase(SanityCheckTestCase) -unittest.TextTestRunner(verbosity=2).run(suite) -ExecutionTimes.executionTimes().dumpStats() From gclayton at apple.com Mon Oct 4 19:31:29 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 05 Oct 2010 00:31:29 -0000 Subject: [Lldb-commits] [lldb] r115581 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h source/Commands/CommandObjectExpression.cpp source/Commands/CommandObjectExpression.h source/Expression/ClangUserExpression.cpp Message-ID: <20101005003129.6CD662A6C12C@llvm.org> Author: gclayton Date: Mon Oct 4 19:31:29 2010 New Revision: 115581 URL: http://llvm.org/viewvc/llvm-project?rev=115581&view=rev Log: Moved expression evaluation from CommandObjectExpression into ClangUserExpression::Evaluate () as a public static function so anyone can evaluate an expression. Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=115581&r1=115580&r2=115581&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Oct 4 19:31:29 2010 @@ -171,6 +171,12 @@ return true; } + + static Error + Evaluate (ExecutionContext &exe_ctx, + const char *expr_cstr, + lldb::ValueObjectSP &result_valobj_sp); + private: //------------------------------------------------------------------ /// Populate m_cplusplus and m_objetivec based on the environment. Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115581&r1=115580&r2=115581&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Oct 4 19:31:29 2010 @@ -193,9 +193,7 @@ case eInputReaderDone: { - bool bare = false; cmd_object_expr->EvaluateExpression (cmd_object_expr->m_expr_lines.c_str(), - bare, reader.GetDebugger().GetOutputStream(), reader.GetDebugger().GetErrorStream()); } @@ -209,7 +207,6 @@ CommandObjectExpression::EvaluateExpression ( const char *expr, - bool bare, Stream &output_stream, Stream &error_stream, CommandReturnObject *result @@ -236,54 +233,31 @@ m_exe_ctx.process->SetDynamicCheckers(dynamic_checkers); } - ClangUserExpression user_expression (expr); + lldb::ValueObjectSP result_valobj_sp; - if (!user_expression.Parse (error_stream, m_exe_ctx)) - { - error_stream.Printf ("Couldn't parse the expresssion\n"); - return false; - } + Error expr_error (ClangUserExpression::Evaluate (m_exe_ctx, expr, result_valobj_sp)); - ClangExpressionVariable *expr_result = NULL; - - if (!user_expression.Execute (error_stream, m_exe_ctx, expr_result)) - { - error_stream.Printf ("Couldn't execute the expresssion\n"); - return false; - } - - if (expr_result) + if (expr_error.Success()) { - // TODO: seems weird to get a pointer to a result object back from - // a function. Do we own it? Feels like we do, but from looking at the - // code we don't. Might be best to make this a reference and state - // explicitly that we don't own it when we get a reference back from - // the execute? - lldb::ValueObjectSP valobj_sp (expr_result->GetExpressionResult (&m_exe_ctx)); - if (valobj_sp) - { - ValueObject::DumpValueObject (output_stream, - m_exe_ctx.GetBestExecutionContextScope(), - valobj_sp.get(), // Variable object to dump - expr_result->m_name.c_str(),// Root object name - 0, // Pointer depth to traverse (zero means stop at pointers) - 0, // Current depth, this is the top most, so zero... - UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... - m_options.show_types, // Show types when dumping? - false, // Show locations of variables, no since this is a host address which we don't care to see - m_options.print_object, // Print the objective C object? - true); // Scope is already checked. Const results are always in scope. - output_stream.EOL(); - } - else - { - error_stream.PutCString ("Couldn't extract expression result"); - } + assert (result_valobj_sp.get() != NULL); + ValueObject::DumpValueObject (output_stream, + m_exe_ctx.GetBestExecutionContextScope(), + result_valobj_sp.get(), // Variable object to dump + result_valobj_sp->GetName().AsCString(),// Root object name + 0, // Pointer depth to traverse (zero means stop at pointers) + 0, // Current depth, this is the top most, so zero... + UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... + m_options.show_types, // Show types when dumping? + false, // Show locations of variables, no since this is a host address which we don't care to see + m_options.print_object, // Print the objective C object? + true); // Scope is already checked. Const results are always in scope. + output_stream.EOL(); if (result) result->SetStatus (eReturnStatusSuccessFinishResult); } else { + error_stream.PutCString(expr_error.AsCString()); if (result) result->SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -370,7 +344,7 @@ if (expr == NULL) expr = command; - if (EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream(), &result)) + if (EvaluateExpression (expr, result.GetOutputStream(), result.GetErrorStream(), &result)) return true; result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=115581&r1=115580&r2=115581&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Mon Oct 4 19:31:29 2010 @@ -87,7 +87,6 @@ bool EvaluateExpression (const char *expr, - bool bare, Stream &output_stream, Stream &error_stream, CommandReturnObject *result = NULL); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=115581&r1=115580&r2=115581&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Oct 4 19:31:29 2010 @@ -336,3 +336,55 @@ return *m_dwarf_opcodes.get(); } + + +Error +ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, lldb::ValueObjectSP &result_valobj_sp) +{ + Error error; + result_valobj_sp.reset(); + + ClangUserExpression user_expression (expr_cstr); + + StreamString error_stream; + + if (!user_expression.Parse (error_stream, exe_ctx)) + { + if (error_stream.GetString().empty()) + error.SetErrorString ("expression failed to parse, unknown error"); + else + error.SetErrorString (error_stream.GetString().c_str()); + } + else + { + ClangExpressionVariable *expr_result = NULL; + + error_stream.GetString().clear(); + + if (!user_expression.Execute (error_stream, exe_ctx, expr_result)) + { + if (error_stream.GetString().empty()) + error.SetErrorString ("expression failed to execute, unknown error"); + else + error.SetErrorString (error_stream.GetString().c_str()); + } + else + { + // TODO: seems weird to get a pointer to a result object back from + // a function. Do we own it? Feels like we do, but from looking at the + // code we don't. Might be best to make this a reference and state + // explicitly that we don't own it when we get a reference back from + // the execute? + if (expr_result) + { + result_valobj_sp = expr_result->GetExpressionResult (&exe_ctx); + } + else + { + error.SetErrorString ("NULL expression result"); + } + } + } + return error; + +} \ No newline at end of file From gclayton at apple.com Mon Oct 4 22:13:51 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 05 Oct 2010 03:13:51 -0000 Subject: [Lldb-commits] [lldb] r115589 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectConstResult.h include/lldb/Expression/ClangUserExpression.h include/lldb/lldb-forward.h source/API/SBFrame.cpp source/Commands/CommandObjectExpression.cpp source/Core/ValueObject.cpp source/Core/ValueObjectConstResult.cpp source/Expression/ClangUserExpression.cpp Message-ID: <20101005031352.05EE12A6C12C@llvm.org> Author: gclayton Date: Mon Oct 4 22:13:51 2010 New Revision: 115589 URL: http://llvm.org/viewvc/llvm-project?rev=115589&view=rev Log: Added the notion that a value object can be constant by adding: bool ValueObject::GetIsConstant() const; void ValueObject::SetIsConstant(); This will stop anything from being re-evaluated within the value object so that constant result value objects can maintain their frozen values without anything being updated or changed within the value object. Made it so the ValueObjectConstResult can be constructed with an lldb_private::Error object to allow for expression results to have errors. Since ValueObject objects contain error objects, I changed the expression evaluation in ClangUserExpression from static Error ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, lldb::ValueObjectSP &result_valobj_sp); to: static lldb::ValueObjectSP Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr); Even though expression parsing is borked right now (pending fixes coming from Sean Callanan), I filled in the implementation for: SBValue SBFrame::EvaluateExpression (const char *expr); Modified all expression code to deal with the above changes. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectConstResult.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Oct 4 22:13:51 2010 @@ -201,6 +201,18 @@ bool use_objc, bool scope_already_checked); + bool + GetIsConstant () const + { + return m_update_id == LLDB_INVALID_UID; + } + + void + SetIsConstant () + { + m_update_id = LLDB_INVALID_UID; + } + protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Mon Oct 4 22:13:51 2010 @@ -32,6 +32,9 @@ uint8_t addr_size); + // When an expression fails to evaluate, we return an error + ValueObjectConstResult (const Error& error); + virtual ~ValueObjectConstResult(); virtual size_t Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Oct 4 22:13:51 2010 @@ -172,10 +172,8 @@ } - static Error - Evaluate (ExecutionContext &exe_ctx, - const char *expr_cstr, - lldb::ValueObjectSP &result_valobj_sp); + static lldb::ValueObjectSP + Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr); private: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Oct 4 22:13:51 2010 @@ -43,6 +43,7 @@ class ClangASTContext; class ClangExpression; class ClangExpressionDeclMap; +class ClangExpressionVariable; class ClangExpressionVariableList; class ClangExpressionVariableStore; class CommandInterpreter; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Oct 4 22:13:51 2010 @@ -20,6 +20,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Expression/ClangUserExpression.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/VariableList.h" @@ -416,6 +417,9 @@ lldb::SBValue expr_result_value; if (m_opaque_sp) { + ExecutionContext exe_ctx; + m_opaque_sp->CalculateExecutionContext (exe_ctx); + *expr_result_value = ClangUserExpression::Evaluate (exe_ctx, expr); } return expr_result_value; } Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Oct 4 22:13:51 2010 @@ -233,13 +233,10 @@ m_exe_ctx.process->SetDynamicCheckers(dynamic_checkers); } - lldb::ValueObjectSP result_valobj_sp; - - Error expr_error (ClangUserExpression::Evaluate (m_exe_ctx, expr, result_valobj_sp)); - - if (expr_error.Success()) + lldb::ValueObjectSP result_valobj_sp (ClangUserExpression::Evaluate (m_exe_ctx, expr)); + assert (result_valobj_sp.get()); + if (result_valobj_sp->GetError().Success()) { - assert (result_valobj_sp.get() != NULL); ValueObject::DumpValueObject (output_stream, m_exe_ctx.GetBestExecutionContextScope(), result_valobj_sp.get(), // Variable object to dump @@ -257,9 +254,9 @@ } else { - error_stream.PutCString(expr_error.AsCString()); + error_stream.PutCString(result_valobj_sp->GetError().AsCString()); if (result) - result->SetStatus (eReturnStatusSuccessFinishNoResult); + result->SetStatus (eReturnStatusFailed); } return true; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Oct 4 22:13:51 2010 @@ -79,6 +79,11 @@ bool ValueObject::UpdateValueIfNeeded (ExecutionContextScope *exe_scope) { + // If this is a constant value, then our success is predicated on whether + // we have an error or not + if (GetIsConstant()) + return m_error.Success(); + if (exe_scope) { Process *process = exe_scope->CalculateProcess(); Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Mon Oct 4 22:13:51 2010 @@ -46,6 +46,16 @@ m_value.SetValueType(Value::eValueTypeHostAddress); m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type); m_name = name; + SetIsConstant (); +} + +ValueObjectConstResult::ValueObjectConstResult (const Error& error) : + ValueObject (), + m_clang_ast (NULL), + m_type_name () +{ + m_error = error; + SetIsConstant (); } ValueObjectConstResult::~ValueObjectConstResult() Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=115589&r1=115588&r2=115589&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Oct 4 22:13:51 2010 @@ -21,6 +21,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionParser.h" #include "lldb/Expression/ClangFunction.h" @@ -338,12 +339,11 @@ } -Error -ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, lldb::ValueObjectSP &result_valobj_sp) +lldb::ValueObjectSP +ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr) { Error error; - result_valobj_sp.reset(); - + lldb::ValueObjectSP result_valobj_sp; ClangUserExpression user_expression (expr_cstr); StreamString error_stream; @@ -385,6 +385,9 @@ } } } - return error; + if (result_valobj_sp.get() == NULL) + result_valobj_sp.reset (new ValueObjectConstResult (error)); + + return result_valobj_sp; } \ No newline at end of file From johnny.chen at apple.com Tue Oct 5 12:34:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 05 Oct 2010 17:34:07 -0000 Subject: [Lldb-commits] [lldb] r115636 - in /lldb/trunk/test: foundation/TestDisassemble.py foundation/TestDisassembly.py stl/TestDisassemble.py stl/TestDisassembly.py Message-ID: <20101005173407.3460E2A6C12C@llvm.org> Author: johnny Date: Tue Oct 5 12:34:07 2010 New Revision: 115636 URL: http://llvm.org/viewvc/llvm-project?rev=115636&view=rev Log: Filename renamings. Added: lldb/trunk/test/foundation/TestDisassembly.py - copied unchanged from r115574, lldb/trunk/test/foundation/TestDisassemble.py lldb/trunk/test/stl/TestDisassembly.py - copied unchanged from r115574, lldb/trunk/test/stl/TestDisassemble.py Removed: lldb/trunk/test/foundation/TestDisassemble.py lldb/trunk/test/stl/TestDisassemble.py Removed: lldb/trunk/test/foundation/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassemble.py?rev=115635&view=auto ============================================================================== --- lldb/trunk/test/foundation/TestDisassemble.py (original) +++ lldb/trunk/test/foundation/TestDisassemble.py (removed) @@ -1,129 +0,0 @@ -""" -Test the lldb disassemble command on foundation framework. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - - at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") -class FoundationDisassembleTestCase(TestBase): - - mydir = "foundation" - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - def test_foundation_disasm(self): - """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework.""" - self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - self.runCmd("run", RUN_SUCCEEDED) - - self.runCmd("image list") - raw_output = self.res.GetOutput() - # Grok the full path to the foundation framework. - for line in raw_output.split(os.linesep): - match = re.search(" (/.*/Foundation.framework/.*)$", line) - if match: - foundation_framework = match.group(1) - break - - self.assertTrue(match, "Foundation.framework path located") - self.runCmd("image dump symtab %s" % foundation_framework) - raw_output = self.res.GetOutput() - # Now, grab every 'Code' symbol and feed it into the command: - # 'disassemble -n func'. - # - # The symbol name is on the last column and trails the flag column which - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - .* # the wildcard chars, - 0x[0-9a-f]{8} # the flag column, and - \ (.+)$ # finally the function symbol. - """, re.VERBOSE) - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - func = match.group(1) - #print "line:", line - #print "func:", func - self.runCmd('disassemble -n "%s"' % func) - - - def test_simple_disasm_with_dsym(self): - """Test the lldb 'disassemble' command""" - self.buildDsym() - self.do_simple_disasm() - - def test_simple_disasm_with_dwarf(self): - """Test the lldb 'disassemble' command""" - self.buildDwarf() - self.do_simple_disasm() - - def do_simple_disasm(self): - """Do a bunch of simple disassemble commands.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Stop at +[NSString stringWithFormat:]. - self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") - - # Stop at -[MyString initWithNSString:]. - self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") - - # Stop at the "description" selector. - self.expect("breakpoint set -S description", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 3: name = 'description', locations = 1") - - # Stop at -[NSAutoreleasePool release]. - self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1") - - self.runCmd("run", RUN_SUCCEEDED) - - # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by -[MyString description]. - self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by -[NSAutoreleasePool release]. - self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Removed: lldb/trunk/test/stl/TestDisassemble.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassemble.py?rev=115635&view=auto ============================================================================== --- lldb/trunk/test/stl/TestDisassemble.py (original) +++ lldb/trunk/test/stl/TestDisassemble.py (removed) @@ -1,100 +0,0 @@ -""" -Test the lldb disassemble command on lib stdc++. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class StdCXXDisassembleTestCase(TestBase): - - mydir = "stl" - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - def test_stdcxx_disasm(self): - """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" - self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on line 13 of main.cpp. - self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1") - - self.runCmd("run", RUN_SUCCEEDED) - - # Now let's get the target as well as the process objects. - target = self.dbg.GetSelectedTarget() - process = target.GetProcess() - - # The process should be in a 'Stopped' state. - self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, - substrs = ["a.out", - "state: Stopped"]) - - # Disassemble the functions on the call stack. - self.runCmd("thread backtrace") - thread = process.GetThreadAtIndex(0) - depth = thread.GetNumFrames() - for i in range(depth - 1): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - self.runCmd("disassemble -n '%s'" % function.GetName()) - - # Iterate through the available modules, looking for stdc++ library... - for i in range(target.GetNumModules()): - module = target.GetModuleAtIndex(i) - fs = module.GetFileSpec() - if (fs.GetFilename().startswith("libstdc++")): - lib_stdcxx = repr(fs) - break - - # At this point, lib_stdcxx is the full path to the stdc++ library and - # module is the corresponding SBModule. - - self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False, - substrs = ["libstdc++"]) - - self.runCmd("image dump symtab %s" % repr(fs)) - raw_output = self.res.GetOutput() - # Now, look for every 'Code' symbol and feed its load address into the - # command: 'disassemble -s load_address -e end_address', where the - # end_address is taken from the next consecutive 'Code' symbol entry's - # load address. - # - # The load address column comes after the file address column, with both - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - 0x[0-9a-f]{16} # the file address column, and - \ # a SPC, and - (0x[0-9a-f]{16}) # the load address column, and - .* # the rest. - """, re.VERBOSE) - # Maintain a start address variable; if we arrive at a consecutive Code - # entry, then the load address of the that entry is fed as the end - # address to the 'disassemble -s SA -e LA' command. - SA = None - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - LA = match.group(1) - print "line:", line - print "load address:", LA - print "SA:", SA - if SA and LA: - self.runCmd("disassemble -s %s -e %s" % (SA, LA)) - SA = LA - else: - # This entry is not a Code entry. Reset SA = None. - SA = None - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() From johnny.chen at apple.com Tue Oct 5 14:27:32 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 05 Oct 2010 19:27:32 -0000 Subject: [Lldb-commits] [lldb] r115652 - in /lldb/trunk/test: foundation/TestDisassembly.py foundation/TestFoundationDisassembly.py lldbtest.py stl/TestDisassembly.py stl/TestStdCXXDisassembly.py Message-ID: <20101005192732.BA3602A6C12C@llvm.org> Author: johnny Date: Tue Oct 5 14:27:32 2010 New Revision: 115652 URL: http://llvm.org/viewvc/llvm-project?rev=115652&view=rev Log: Make the test module with unique name instead of just the generic name TestDisassembly. Add a utility function to lldbtest.py to get the native pointer size of the host os. Added: lldb/trunk/test/foundation/TestFoundationDisassembly.py - copied unchanged from r115636, lldb/trunk/test/foundation/TestDisassembly.py lldb/trunk/test/stl/TestStdCXXDisassembly.py - copied unchanged from r115636, lldb/trunk/test/stl/TestDisassembly.py Removed: lldb/trunk/test/foundation/TestDisassembly.py lldb/trunk/test/stl/TestDisassembly.py Modified: lldb/trunk/test/lldbtest.py Removed: lldb/trunk/test/foundation/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestDisassembly.py?rev=115651&view=auto ============================================================================== --- lldb/trunk/test/foundation/TestDisassembly.py (original) +++ lldb/trunk/test/foundation/TestDisassembly.py (removed) @@ -1,129 +0,0 @@ -""" -Test the lldb disassemble command on foundation framework. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - - at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") -class FoundationDisassembleTestCase(TestBase): - - mydir = "foundation" - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - def test_foundation_disasm(self): - """Do 'disassemble -n func' on each and every 'Code' symbol entry from the Foundation.framework.""" - self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - self.runCmd("run", RUN_SUCCEEDED) - - self.runCmd("image list") - raw_output = self.res.GetOutput() - # Grok the full path to the foundation framework. - for line in raw_output.split(os.linesep): - match = re.search(" (/.*/Foundation.framework/.*)$", line) - if match: - foundation_framework = match.group(1) - break - - self.assertTrue(match, "Foundation.framework path located") - self.runCmd("image dump symtab %s" % foundation_framework) - raw_output = self.res.GetOutput() - # Now, grab every 'Code' symbol and feed it into the command: - # 'disassemble -n func'. - # - # The symbol name is on the last column and trails the flag column which - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - .* # the wildcard chars, - 0x[0-9a-f]{8} # the flag column, and - \ (.+)$ # finally the function symbol. - """, re.VERBOSE) - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - func = match.group(1) - #print "line:", line - #print "func:", func - self.runCmd('disassemble -n "%s"' % func) - - - def test_simple_disasm_with_dsym(self): - """Test the lldb 'disassemble' command""" - self.buildDsym() - self.do_simple_disasm() - - def test_simple_disasm_with_dwarf(self): - """Test the lldb 'disassemble' command""" - self.buildDwarf() - self.do_simple_disasm() - - def do_simple_disasm(self): - """Do a bunch of simple disassemble commands.""" - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Stop at +[NSString stringWithFormat:]. - self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") - - # Stop at -[MyString initWithNSString:]. - self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") - - # Stop at the "description" selector. - self.expect("breakpoint set -S description", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 3: name = 'description', locations = 1") - - # Stop at -[NSAutoreleasePool release]. - self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1") - - self.runCmd("run", RUN_SUCCEEDED) - - # First stop is +[NSString stringWithFormat:]. - self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", - substrs = ["Foundation`+[NSString stringWithFormat:]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by a.out`-[MyString initWithNSString:]. - self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", - substrs = ["a.out`-[MyString initWithNSString:]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by -[MyString description]. - self.expect("thread backtrace", "Stop at -[MyString description]", - substrs = ["a.out`-[MyString description]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - self.runCmd("process continue") - - # Followed by -[NSAutoreleasePool release]. - self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", - substrs = ["Foundation`-[NSAutoreleasePool release]"]) - - # Do the disassemble for the currently stopped function. - self.runCmd("disassemble") - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115652&r1=115651&r2=115652&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Oct 5 14:27:32 2010 @@ -126,6 +126,8 @@ RUN_COMPLETED = "Process exited successfully" +BACKTRACE_DISPLAYED_CORRECTLY = "Backtrace displayed correctly" + BREAKPOINT_CREATED = "Breakpoint created successfully" BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully" @@ -260,6 +262,12 @@ raise CalledProcessError(retcode, cmd) return output +def pointer_size(): + """Return the pointer size of the host system.""" + import ctypes + a_pointer = ctypes.c_void_p(0xffff) + return 8 * ctypes.sizeof(a_pointer) + class TestBase(unittest2.TestCase): """This LLDB abstract base class is meant to be subclassed.""" Removed: lldb/trunk/test/stl/TestDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestDisassembly.py?rev=115651&view=auto ============================================================================== --- lldb/trunk/test/stl/TestDisassembly.py (original) +++ lldb/trunk/test/stl/TestDisassembly.py (removed) @@ -1,100 +0,0 @@ -""" -Test the lldb disassemble command on lib stdc++. -""" - -import os, time -import unittest2 -import lldb -from lldbtest import * - -class StdCXXDisassembleTestCase(TestBase): - - mydir = "stl" - - # rdar://problem/8504895 - # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]" - @unittest2.skipIf(TestBase.skipLongRunningTest(), "Skip this long running test") - def test_stdcxx_disasm(self): - """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib.""" - self.buildDefault() - exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - - # Break on line 13 of main.cpp. - self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1") - - self.runCmd("run", RUN_SUCCEEDED) - - # Now let's get the target as well as the process objects. - target = self.dbg.GetSelectedTarget() - process = target.GetProcess() - - # The process should be in a 'Stopped' state. - self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, - substrs = ["a.out", - "state: Stopped"]) - - # Disassemble the functions on the call stack. - self.runCmd("thread backtrace") - thread = process.GetThreadAtIndex(0) - depth = thread.GetNumFrames() - for i in range(depth - 1): - frame = thread.GetFrameAtIndex(i) - function = frame.GetFunction() - self.runCmd("disassemble -n '%s'" % function.GetName()) - - # Iterate through the available modules, looking for stdc++ library... - for i in range(target.GetNumModules()): - module = target.GetModuleAtIndex(i) - fs = module.GetFileSpec() - if (fs.GetFilename().startswith("libstdc++")): - lib_stdcxx = repr(fs) - break - - # At this point, lib_stdcxx is the full path to the stdc++ library and - # module is the corresponding SBModule. - - self.expect(fs.GetFilename(), "Libraray StdC++ is located", exe=False, - substrs = ["libstdc++"]) - - self.runCmd("image dump symtab %s" % repr(fs)) - raw_output = self.res.GetOutput() - # Now, look for every 'Code' symbol and feed its load address into the - # command: 'disassemble -s load_address -e end_address', where the - # end_address is taken from the next consecutive 'Code' symbol entry's - # load address. - # - # The load address column comes after the file address column, with both - # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits. - codeRE = re.compile(r""" - \ Code\ {9} # ' Code' followed by 9 SPCs, - 0x[0-9a-f]{16} # the file address column, and - \ # a SPC, and - (0x[0-9a-f]{16}) # the load address column, and - .* # the rest. - """, re.VERBOSE) - # Maintain a start address variable; if we arrive at a consecutive Code - # entry, then the load address of the that entry is fed as the end - # address to the 'disassemble -s SA -e LA' command. - SA = None - for line in raw_output.split(os.linesep): - match = codeRE.search(line) - if match: - LA = match.group(1) - print "line:", line - print "load address:", LA - print "SA:", SA - if SA and LA: - self.runCmd("disassemble -s %s -e %s" % (SA, LA)) - SA = LA - else: - # This entry is not a Code entry. Reset SA = None. - SA = None - - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() From johnny.chen at apple.com Tue Oct 5 14:34:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 05 Oct 2010 19:34:07 -0000 Subject: [Lldb-commits] [lldb] r115653 - /lldb/trunk/test/class_types/TestClassTypesDisassembly.py Message-ID: <20101005193407.242F72A6C12C@llvm.org> Author: johnny Date: Tue Oct 5 14:34:06 2010 New Revision: 115653 URL: http://llvm.org/viewvc/llvm-project?rev=115653&view=rev Log: Add a test class to call lldb 'disassemble -n function' command on each call frame when stopped on C's ctor. This is not a long running test so it shall always be exercised. Added: lldb/trunk/test/class_types/TestClassTypesDisassembly.py Added: lldb/trunk/test/class_types/TestClassTypesDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=115653&view=auto ============================================================================== --- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (added) +++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Tue Oct 5 14:34:06 2010 @@ -0,0 +1,96 @@ +""" +Test the lldb disassemble command on each call frame when stopped on C's ctor. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class IterateFrameAndDisassembleTestCase(TestBase): + + mydir = "class_types" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.buildDsym() + self.disassemble_call_stack() + + def test_with_dwarf_and_run_command(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.buildDwarf() + self.disassemble_call_stack() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_python_api(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.buildDsym() + self.disassemble_call_stack_api() + + def test_with_dwarf_and_python_api(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.buildDwarf() + self.disassemble_call_stack_api() + + def breakOnCtor(self): + """Setup/run the program so it stops on C's constructor.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break on the ctor function of class C. + self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = 93, locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', + 'stop reason = breakpoint']) + + # We should be stopped on the ctor function of class C. + self.expect("thread backtrace", BACKTRACE_DISPLAYED_CORRECTLY, + substrs = ['C::C']) + + def disassemble_call_stack(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.breakOnCtor() + + raw_output = self.res.GetOutput() + frameRE = re.compile(r""" + ^\s\sframe # heading for the frame info, + .* # wildcard, and + 0x[0-9a-f]{16} # the frame pc, and + \sa.out`(.+) # module`function, and + \s\+\s # the rest ' + ....' + """, re.VERBOSE) + for line in raw_output.split(os.linesep): + match = frameRE.search(line) + if match: + function = match.group(1) + #print "line:", line + #print "function:", function + self.runCmd("disassemble -n '%s'" % function) + + def disassemble_call_stack_api(self): + """Disassemble each call frame when stopped on C's constructor.""" + self.breakOnCtor() + + # Now use the Python API to get at each function on the call stack and + # disassemble it. + target = self.dbg.GetSelectedTarget() + process = target.GetProcess() + thread = process.GetThreadAtIndex(0) + depth = thread.GetNumFrames() + for i in range(depth - 1): + frame = thread.GetFrameAtIndex(i) + function = frame.GetFunction() + self.runCmd("disassemble -n '%s'" % function.GetName()) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From scallanan at apple.com Tue Oct 5 15:18:49 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 05 Oct 2010 20:18:49 -0000 Subject: [Lldb-commits] [lldb] r115658 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20101005201849.100F02A6C12C@llvm.org> Author: spyffe Date: Tue Oct 5 15:18:48 2010 New Revision: 115658 URL: http://llvm.org/viewvc/llvm-project?rev=115658&view=rev Log: Added support for (de)materializing values in registers, so that expressions can use them. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=115658&r1=115657&r2=115658&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Oct 5 15:18:48 2010 @@ -32,6 +32,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" @@ -612,7 +613,7 @@ { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - if (!exe_ctx.frame) + if (!exe_ctx.frame || !exe_ctx.process) return false; Variable *var = FindVariableInScope(*exe_ctx.frame, name, &type); @@ -635,54 +636,216 @@ err.SetErrorStringWithFormat("Couldn't get value for %s", name); return false; } + + // The size of the type contained in addr - if (location_value->GetValueType() == Value::eValueTypeLoadAddress) + size_t addr_bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()); + size_t addr_byte_size = addr_bit_size % 8 ? ((addr_bit_size + 8) / 8) : (addr_bit_size / 8); + + Value::ValueType value_type = location_value->GetValueType(); + + switch (value_type) { - lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - - size_t bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()); - size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); - - DataBufferHeap data; - data.SetByteSize(byte_size); - - lldb::addr_t src_addr; - lldb::addr_t dest_addr; - - if (dematerialize) + default: { - src_addr = addr; - dest_addr = value_addr; - } - else - { - src_addr = value_addr; - dest_addr = addr; + StreamString ss; + + location_value->Dump(&ss); + + err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); + return false; } - - Error error; - if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), byte_size, error) != byte_size) + break; + case Value::eValueTypeLoadAddress: { - err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); - return false; + lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); + + DataBufferHeap data; + data.SetByteSize(addr_byte_size); + + lldb::addr_t src_addr; + lldb::addr_t dest_addr; + + if (dematerialize) + { + src_addr = addr; + dest_addr = value_addr; + } + else + { + src_addr = value_addr; + dest_addr = addr; + } + + Error error; + if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), addr_byte_size, error) != addr_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", name, error.AsCString()); + return false; + } + + if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), addr_byte_size, error) != addr_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", name, error.AsCString()); + return false; + } + + if (log) + log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); } - - if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), byte_size, error) != byte_size) + break; + case Value::eValueTypeScalar: { - err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); - return false; + if (location_value->GetContextType() != Value::eContextTypeDCRegisterInfo) + { + StreamString ss; + + location_value->Dump(&ss); + + err.SetErrorStringWithFormat("%s is a scalar of unhandled type: %s", name, ss.GetString().c_str()); + return false; + } + + lldb::RegisterInfo *register_info = location_value->GetRegisterInfo(); + + if (!register_info) + { + err.SetErrorStringWithFormat("Couldn't get the register information for %s", name); + return false; + } + + RegisterContext *register_context = exe_ctx.GetRegisterContext(); + + if (!register_context) + { + err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", name, register_info->name); + return false; + } + + uint32_t register_number = register_info->kinds[lldb::eRegisterKindLLDB]; + uint32_t register_byte_size = register_info->byte_size; + + if (dematerialize) + { + // Moving from addr into a register + // + // Case 1: addr_byte_size and register_byte_size are the same + // + // |AABBCCDD| Address contents + // |AABBCCDD| Register contents + // + // Case 2: addr_byte_size is bigger than register_byte_size + // + // Error! (The register should always be big enough to hold the data) + // + // Case 3: register_byte_size is bigger than addr_byte_size + // + // |AABB| Address contents + // |AABB0000| Register contents [on little-endian hardware] + // |0000AABB| Register contents [on big-endian hardware] + + if (addr_byte_size > register_byte_size) + { + err.SetErrorStringWithFormat("%s is too big to store in %s", name, register_info->name); + return false; + } + + uint32_t register_offset; + + switch (exe_ctx.process->GetByteOrder()) + { + default: + err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name); + return false; + case lldb::eByteOrderLittle: + register_offset = 0; + break; + case lldb::eByteOrderBig: + register_offset = register_byte_size - addr_byte_size; + break; + } + + DataBufferHeap register_data (register_byte_size, 0); + + Error error; + if (exe_ctx.process->ReadMemory (addr, register_data.GetBytes() + register_offset, addr_byte_size, error) != addr_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", name, error.AsCString()); + return false; + } + + DataExtractor register_extractor (register_data.GetBytes(), register_byte_size, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); + + if (!register_context->WriteRegisterBytes(register_number, register_extractor, 0)) + { + err.SetErrorStringWithFormat("Couldn't read %s from %s", name, register_info->name); + return false; + } + } + else + { + // Moving from a register into addr + // + // Case 1: addr_byte_size and register_byte_size are the same + // + // |AABBCCDD| Register contents + // |AABBCCDD| Address contents + // + // Case 2: addr_byte_size is bigger than register_byte_size + // + // Error! (The register should always be big enough to hold the data) + // + // Case 3: register_byte_size is bigger than addr_byte_size + // + // |AABBCCDD| Register contents + // |AABB| Address contents on little-endian hardware + // |CCDD| Address contents on big-endian hardware + + if (addr_byte_size > register_byte_size) + { + err.SetErrorStringWithFormat("%s is too big to store in %s", name, register_info->name); + return false; + } + + uint32_t register_offset; + + switch (exe_ctx.process->GetByteOrder()) + { + default: + err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name); + return false; + case lldb::eByteOrderLittle: + register_offset = 0; + break; + case lldb::eByteOrderBig: + register_offset = register_byte_size - addr_byte_size; + break; + } + + DataExtractor register_extractor; + + if (!register_context->ReadRegisterBytes(register_number, register_extractor)) + { + err.SetErrorStringWithFormat("Couldn't read %s from %s", name, register_info->name); + return false; + } + + const void *register_data = register_extractor.GetData(®ister_offset, addr_byte_size); + + if (!register_data) + { + err.SetErrorStringWithFormat("Read but couldn't extract data for %s from %s", name, register_info->name); + return false; + } + + Error error; + if (exe_ctx.process->WriteMemory (addr, register_data, addr_byte_size, error) != addr_byte_size) + { + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", error.AsCString()); + return false; + } + } } - - if (log) - log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); - } - else - { - StreamString ss; - - location_value->Dump(&ss); - - err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); } return true; From scallanan at apple.com Tue Oct 5 17:26:43 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 05 Oct 2010 22:26:43 -0000 Subject: [Lldb-commits] [lldb] r115698 - in /lldb/trunk: include/lldb/Expression/IRForTarget.h source/Expression/IRForTarget.cpp Message-ID: <20101005222643.837932A6C12D@llvm.org> Author: spyffe Date: Tue Oct 5 17:26:43 2010 New Revision: 115698 URL: http://llvm.org/viewvc/llvm-project?rev=115698&view=rev Log: Added handling for external variables in function arguments to the expression parser. This means that structs can be returned from the "expr" command. Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=115698&r1=115697&r2=115698&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Tue Oct 5 17:26:43 2010 @@ -220,6 +220,21 @@ bool Store); //------------------------------------------------------------------ + /// Handle all the arguments to a function call + /// + /// @param[in] M + /// The module currently being processed. + /// + /// @param[in] C + /// The call instruction. + /// + /// @return + /// True on success; false otherwise + //------------------------------------------------------------------ + bool MaybeHandleCallArguments(llvm::Module &M, + llvm::CallInst *C); + + //------------------------------------------------------------------ /// Handle a single external function call /// /// @param[in] M Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=115698&r1=115697&r2=115698&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Oct 5 17:26:43 2010 @@ -629,6 +629,21 @@ } bool +IRForTarget::MaybeHandleCallArguments(Module &M, + CallInst *C) +{ + // lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + for (unsigned op_index = 0, num_ops = C->getNumArgOperands(); + op_index < num_ops; + ++op_index) + if (!MaybeHandleVariable(M, C->getArgOperand(op_index), true)) // conservatively believe that this is a store + return false; + + return true; +} + +bool IRForTarget::MaybeHandleCall(Module &M, CallInst *C) { @@ -772,8 +787,13 @@ } if (CallInst *call = dyn_cast(&inst)) + { + if (!MaybeHandleCallArguments(M, call)) + return false; + if (!MaybeHandleCall(M, call)) return false; + } } return true; From johnny.chen at apple.com Tue Oct 5 18:15:41 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 05 Oct 2010 23:15:41 -0000 Subject: [Lldb-commits] [lldb] r115712 - in /lldb/trunk/test/class_types: TestClassTypes.py TestClassTypesDisassembly.py Message-ID: <20101005231542.05D222A6C12C@llvm.org> Author: johnny Date: Tue Oct 5 18:15:41 2010 New Revision: 115712 URL: http://llvm.org/viewvc/llvm-project?rev=115712&view=rev Log: Modified to accomodate gcc, llvm-gcc, and clang as compilers. Add a comment for 'breakpoint set -M C' not working correctly for clang. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/class_types/TestClassTypesDisassembly.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115712&r1=115711&r2=115712&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Tue Oct 5 18:15:41 2010 @@ -52,7 +52,7 @@ # Break on the ctor function of class C. self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 93, locations = 1") + startstr = "Breakpoint created: 1: file ='main.cpp', line = 93") self.runCmd("run", RUN_SUCCEEDED) @@ -67,7 +67,8 @@ # We should be stopped on the ctor function of class C. self.expect("frame variable this", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['C *const) this = ']) + substrs = ['C *', + ' this = ']) def breakpoint_creation_by_filespec_python(self): """Use Python APIs to create a breakpoint by (filespec, line).""" @@ -106,6 +107,9 @@ exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + # rdar://problem/8516141 + # Is this a case of clang (116.1) generating bad debug info? + # # Break on the ctor function of class C. self.expect("breakpoint set -M C", BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: name = 'C', locations = 1") Modified: lldb/trunk/test/class_types/TestClassTypesDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypesDisassembly.py?rev=115712&r1=115711&r2=115712&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypesDisassembly.py (original) +++ lldb/trunk/test/class_types/TestClassTypesDisassembly.py Tue Oct 5 18:15:41 2010 @@ -40,7 +40,7 @@ # Break on the ctor function of class C. self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 93, locations = 1") + startstr = "Breakpoint created: 1: file ='main.cpp', line = 93") self.runCmd("run", RUN_SUCCEEDED) From scallanan at apple.com Tue Oct 5 19:10:07 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 06 Oct 2010 00:10:07 -0000 Subject: [Lldb-commits] [lldb] r115721 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20101006001007.ED0C92A6C12C@llvm.org> Author: spyffe Date: Tue Oct 5 19:10:07 2010 New Revision: 115721 URL: http://llvm.org/viewvc/llvm-project?rev=115721&view=rev Log: Updated the expression parser to ignore non-external functions it finds in libraries unless it cannot find an external function with the desired name. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=115721&r1=115720&r2=115721&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Oct 5 19:10:07 2010 @@ -945,8 +945,9 @@ m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); - bool found_generic = false; bool found_specific = false; + Symbol *generic_symbol = NULL; + Symbol *non_extern_symbol = NULL; for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); index < num_indices; @@ -954,7 +955,7 @@ { SymbolContext sym_ctx; sym_ctxs.GetContextAtIndex(index, sym_ctx); - + if (sym_ctx.function) { // TODO only do this if it's a C function; C++ functions may be @@ -963,16 +964,23 @@ AddOneFunction(context, sym_ctx.function, NULL); found_specific = true; } - else if(sym_ctx.symbol) + else if (sym_ctx.symbol) { - if (!found_generic && !found_specific) - { - AddOneFunction(context, NULL, sym_ctx.symbol); - found_generic = true; - } + if (sym_ctx.symbol->IsExternal()) + generic_symbol = sym_ctx.symbol; + else + non_extern_symbol = sym_ctx.symbol; } } + if (!found_specific) + { + if (generic_symbol) + AddOneFunction(context, NULL, generic_symbol); + else if (non_extern_symbol) + AddOneFunction(context, NULL, non_extern_symbol); + } + Variable *var = FindVariableInScope(*m_exe_ctx->frame, name); if (var) From gclayton at apple.com Tue Oct 5 20:26:32 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 01:26:32 -0000 Subject: [Lldb-commits] [lldb] r115729 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20101006012632.D48632A6C12C@llvm.org> Author: gclayton Date: Tue Oct 5 20:26:32 2010 New Revision: 115729 URL: http://llvm.org/viewvc/llvm-project?rev=115729&view=rev Log: Fixed an issue with the mach-o file parser when parsing indirect symbol stubs where the symbol index was set to INDIRECT_SYMBOL_ABS and was causing an assertion to fire when we loaded older Mac OS X binaries. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=115729&r1=115728&r2=115729&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Oct 5 20:26:32 2010 @@ -277,8 +277,10 @@ struct section_64 sect64; ::bzero (§64, sizeof(sect64)); // Push a section into our mach sections for the section at - // index zero (NListSectionNoSection) - m_mach_sections.push_back(sect64); + // index zero (NListSectionNoSection) if we don't have any + // mach sections yet... + if (m_mach_sections.empty()) + m_mach_sections.push_back(sect64); uint32_t segment_sect_idx; const lldb::user_id_t first_segment_sectID = sectID + 1; @@ -1254,6 +1256,8 @@ if (indirect_symbol_index_data.ValidOffsetForDataOfSize(symbol_stub_offset, 4)) { const uint32_t stub_sym_id = indirect_symbol_index_data.GetU32 (&symbol_stub_offset); + if (stub_sym_id & (IndirectSymbolAbsolute | IndirectSymbolLocal)) + continue; NListIndexToSymbolIndexMap::const_iterator index_pos = m_nlist_idx_to_sym_idx.find (stub_sym_id); Symbol *stub_symbol = NULL; From gclayton at apple.com Tue Oct 5 22:09:11 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 03:09:11 -0000 Subject: [Lldb-commits] [lldb] r115733 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Commands/CommandObjectExpression.cpp source/Core/ValueObject.cpp Message-ID: <20101006030911.C74302A6C12C@llvm.org> Author: gclayton Date: Tue Oct 5 22:09:11 2010 New Revision: 115733 URL: http://llvm.org/viewvc/llvm-project?rev=115733&view=rev Log: Restored the ability to set the format for expressions after changing the expression results over to ValueObjectSP objects. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=115733&r1=115732&r2=115733&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Oct 5 22:09:11 2010 @@ -213,6 +213,18 @@ m_update_id = LLDB_INVALID_UID; } + lldb::Format + GetFormat () const + { + return m_format; + } + + void + SetFormat (lldb::Format format) + { + m_format = format; + } + protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these @@ -236,6 +248,7 @@ std::vector m_children; std::map m_synthetic_children; lldb::ValueObjectSP m_dynamic_value_sp; + lldb::Format m_format; bool m_value_is_valid:1, m_value_did_change:1, m_children_count_valid:1, Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=115733&r1=115732&r2=115733&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Oct 5 22:09:11 2010 @@ -237,6 +237,9 @@ assert (result_valobj_sp.get()); if (result_valobj_sp->GetError().Success()) { + if (m_options.format != eFormatDefault) + result_valobj_sp->SetFormat (m_options.format); + ValueObject::DumpValueObject (output_stream, m_exe_ctx.GetBestExecutionContextScope(), result_valobj_sp.get(), // Variable object to dump Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=115733&r1=115732&r2=115733&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Oct 5 22:09:11 2010 @@ -56,6 +56,8 @@ m_object_desc_str (), m_children (), m_synthetic_children (), + m_dynamic_value_sp (), + m_format (eFormatDefault), m_value_is_valid (false), m_value_did_change (false), m_children_count_valid (false), @@ -584,16 +586,18 @@ if (clang_type) { StreamString sstr; - lldb::Format format = ClangASTType::GetFormat(clang_type); - if (ClangASTType::DumpTypeValue(GetClangAST(), // The clang AST - clang_type, // The clang type to display - &sstr, - format, // Format to display this type with - m_data, // Data to extract from - 0, // Byte offset into "m_data" - GetByteSize(), // Byte size of item in "m_data" - GetBitfieldBitSize(), // Bitfield bit size - GetBitfieldBitOffset())) // Bitfield bit offset + if (m_format == eFormatDefault) + m_format = ClangASTType::GetFormat(clang_type); + + if (ClangASTType::DumpTypeValue (GetClangAST(), // The clang AST + clang_type, // The clang type to display + &sstr, + m_format, // Format to display this type with + m_data, // Data to extract from + 0, // Byte offset into "m_data" + GetByteSize(), // Byte size of item in "m_data" + GetBitfieldBitSize(), // Bitfield bit size + GetBitfieldBitOffset())) // Bitfield bit offset m_value_str.swap(sstr.GetString()); else m_value_str.clear(); From gclayton at apple.com Tue Oct 5 22:09:58 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 03:09:58 -0000 Subject: [Lldb-commits] [lldb] r115734 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ scripts/ scripts/Python/ source/API/ source/Core/ source/Expression/ source/Plugins/Disassembler/llvm/ Message-ID: <20101006030959.07DE02A6C12C@llvm.org> Author: gclayton Date: Tue Oct 5 22:09:58 2010 New Revision: 115734 URL: http://llvm.org/viewvc/llvm-project?rev=115734&view=rev Log: Added the ability to get the disassembly instructions from the function and symbol. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/API/SBInstructionList.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/scripts/Python/python-extensions.swig lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/API/SBInstructionList.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBSymbol.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Tue Oct 5 22:09:58 2010 @@ -51,6 +51,7 @@ friend class SBFrame; friend class SBLineEntry; + friend class SBInstruction; friend class SBModule; friend class SBSymbolContext; friend class SBThread; Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Tue Oct 5 22:09:58 2010 @@ -11,6 +11,7 @@ #define LLDB_SBFunction_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBInstructionList.h" namespace lldb { @@ -31,6 +32,9 @@ const char * GetMangledName () const; + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + #ifndef SWIG bool operator == (const lldb::SBFunction &rhs) const; Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Tue Oct 5 22:09:58 2010 @@ -17,43 +17,45 @@ // There's a lot to be fixed here, but need to wait for underlying insn implementation // to be revised & settle down first. -//class lldb_private::Disassembler::Instruction; - namespace lldb { class SBInstruction { public: - //SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn); - SBInstruction (); ~SBInstruction (); - //bool - //IsValid(); + bool + IsValid(); - //size_t - //GetByteSize (); + SBAddress + GetAddress(); - //void - //SetByteSize (size_t byte_size); + size_t + GetByteSize (); - //bool - //DoesBranch (); + bool + DoesBranch (); void Print (FILE *out); - //bool - //GetDescription (lldb::SBStream &description); + bool + GetDescription (lldb::SBStream &description); -private: +protected: + friend class SBInstructionList; - //lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp; + SBInstruction (const lldb::InstructionSP &inst_sp); + void + SetOpaque (const lldb::InstructionSP &inst_sp); + +private: + lldb::InstructionSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBInstructionList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstructionList.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstructionList.h (original) +++ lldb/trunk/include/lldb/API/SBInstructionList.h Tue Oct 5 22:09:58 2010 @@ -36,17 +36,21 @@ void AppendInstruction (lldb::SBInstruction inst); - void Print (FILE *out); -private: + bool + GetDescription (lldb::SBStream &description); - // If we have an instruction list, it will need to be backed by an - // lldb_private class that contains the list, we can't inherit from - // std::vector here... - //std::vector m_insn_list; +protected: + friend class SBFunction; + friend class SBSymbol; + + void + SetDisassembler (const lldb::DisassemblerSP &opaque_sp); +private: + lldb::DisassemblerSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Tue Oct 5 22:09:58 2010 @@ -161,6 +161,7 @@ friend class SBBreakpointLocation; friend class SBCommandInterpreter; friend class SBDebugger; + friend class SBFunction; friend class SBTarget; friend class SBThread; friend class SBValue; Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Tue Oct 5 22:09:58 2010 @@ -63,6 +63,8 @@ friend class SBEvent; friend class SBFrame; friend class SBFunction; + friend class SBInstruction; + friend class SBInstructionList; friend class SBModule; friend class SBSymbol; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Tue Oct 5 22:09:58 2010 @@ -11,6 +11,8 @@ #define LLDB_SBSymbol_h_ #include "lldb/API/SBDefines.h" +#include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBTarget.h" namespace lldb { @@ -32,6 +34,9 @@ const char * GetMangledName () const; + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + #ifndef SWIG bool operator == (const lldb::SBSymbol &rhs) const; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Oct 5 22:09:58 2010 @@ -148,7 +148,9 @@ protected: friend class SBAddress; friend class SBDebugger; + friend class SBFunction; friend class SBProcess; + friend class SBSymbol; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Tue Oct 5 22:09:58 2010 @@ -17,79 +17,95 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/Core/Address.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { -class ExecutionContext; - -class Disassembler : - public PluginInterface +class Instruction { public: - class Instruction + Instruction (const Address &addr); + + virtual + ~Instruction(); + + const Address & + GetAddress () const { - public: - typedef lldb::SharedPtr::Type shared_ptr; + return m_addr; + } - Instruction(); + void + SetAddress (const Address &addr) + { + m_addr = addr; + } - virtual - ~Instruction(); + virtual size_t + GetByteSize() const = 0; - virtual size_t - GetByteSize() const = 0; - - virtual void - Dump (Stream *s, - Address *address, - const DataExtractor *bytes, - uint32_t bytes_offset, - const ExecutionContext &exe_ctx, - bool raw) = 0; - - virtual bool - DoesBranch () const = 0; - - virtual size_t - Extract (const DataExtractor& data, uint32_t data_offset) = 0; - }; + + virtual void + Dump (Stream *s, + bool show_address, + const DataExtractor *bytes, + uint32_t bytes_offset, + const ExecutionContext *exe_ctx, + bool raw) = 0; + + virtual bool + DoesBranch () const = 0; + virtual size_t + Extract (const DataExtractor& data, uint32_t data_offset) = 0; - class InstructionList - { - public: - InstructionList(); - ~InstructionList(); +protected: + Address m_addr; // The section offset address of this instruction +}; - size_t - GetSize() const; - Instruction * - GetInstructionAtIndex (uint32_t idx); +class InstructionList +{ +public: + InstructionList(); + ~InstructionList(); - const Instruction * - GetInstructionAtIndex (uint32_t idx) const; + size_t + GetSize() const; + + lldb::InstructionSP + GetInstructionAtIndex (uint32_t idx) const; void Clear(); void - AppendInstruction (Instruction::shared_ptr &inst_sp); + Append (lldb::InstructionSP &inst_sp); - private: - typedef std::vector collection; - typedef collection::iterator iterator; - typedef collection::const_iterator const_iterator; +private: + typedef std::vector collection; + typedef collection::iterator iterator; + typedef collection::const_iterator const_iterator; - collection m_instructions; - }; + collection m_instructions; +}; + +class Disassembler : + public PluginInterface +{ +public: static Disassembler* FindPlugin (const ArchSpec &arch); + static lldb::DisassemblerSP + DisassembleRange (const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const AddressRange &disasm_range); + static bool Disassemble (Debugger &debugger, const ArchSpec &arch, @@ -140,7 +156,8 @@ DataExtractor& data); virtual size_t - DecodeInstructions (const DataExtractor& data, + DecodeInstructions (const Address &base_addr, + const DataExtractor& data, uint32_t data_offset, uint32_t num_instructions) = 0; Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Oct 5 22:09:58 2010 @@ -34,12 +34,14 @@ typedef SharedPtr::Type CompUnitSP; typedef SharedPtr::Type DataBufferSP; typedef SharedPtr::Type DebuggerSP; + typedef SharedPtr::Type DisassemblerSP; typedef SharedPtr::Type DynamicLoaderSP; typedef SharedPtr::Type EventSP; typedef SharedPtr::Type FunctionSP; typedef SharedPtr::Type InlineFunctionInfoSP; typedef SharedPtr::Type InputReaderSP; typedef SharedPtr::Type InstanceSettingsSP; + typedef SharedPtr::Type InstructionSP; typedef SharedPtr::Type LanguageRuntimeSP; typedef SharedPtr::Type LineTableSP; typedef SharedPtr::Type ListenerSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Tue Oct 5 22:09:58 2010 @@ -78,6 +78,7 @@ class InlineFunctionInfo; class InputReader; class InstanceSettings; +class Instruction; class LanguageRuntime; class LineTable; class Listener; Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Tue Oct 5 22:09:58 2010 @@ -44,6 +44,8 @@ " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\ " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ " ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ +" ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\ +" ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\ " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ " ${SRC_ROOT}/include/lldb/API/SBListener.h"\ " ${SRC_ROOT}/include/lldb/API/SBModule.h"\ Modified: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (original) +++ lldb/trunk/scripts/Python/python-extensions.swig Tue Oct 5 22:09:58 2010 @@ -76,6 +76,20 @@ return PyString_FromString (description.GetData()); } } +%extend lldb::SBInstruction { + PyObject *lldb::SBInstruction::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} +%extend lldb::SBInstructionList { + PyObject *lldb::SBInstructionList::__repr__ (){ + lldb::SBStream description; + $self->GetDescription (description); + return PyString_FromString (description.GetData()); + } +} %extend lldb::SBLineEntry { PyObject *lldb::SBLineEntry::__repr__ (){ lldb::SBStream description; Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Tue Oct 5 22:09:58 2010 @@ -85,6 +85,8 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" @@ -149,6 +151,8 @@ %include "lldb/API/SBFileSpec.h" %include "lldb/API/SBFrame.h" %include "lldb/API/SBFunction.h" +%include "lldb/API/SBInstruction.h" +%include "lldb/API/SBInstructionList.h" %include "lldb/API/SBLineEntry.h" %include "lldb/API/SBListener.h" %include "lldb/API/SBModule.h" Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Tue Oct 5 22:09:58 2010 @@ -10,10 +10,15 @@ #include "lldb/API/SBFunction.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Module.h" +#include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Target.h" using namespace lldb; - +using namespace lldb_private; SBFunction::SBFunction () : m_opaque_ptr (NULL) @@ -77,3 +82,28 @@ return true; } + +SBInstructionList +SBFunction::GetInstructions (SBTarget target) +{ + SBInstructionList sb_instructions; + if (m_opaque_ptr) + { + ExecutionContext exe_ctx; + if (target.IsValid()) + { + target->CalculateExecutionContext (exe_ctx); + exe_ctx.process = target->GetProcessSP().get(); + } + Module *module = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule(); + if (module) + { + sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture(), + exe_ctx, + m_opaque_ptr->GetAddressRange())); + } + } + return sb_instructions; +} + + Modified: lldb/trunk/source/API/SBInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstruction.cpp (original) +++ lldb/trunk/source/API/SBInstruction.cpp Tue Oct 5 22:09:58 2010 @@ -9,58 +9,78 @@ #include "lldb/API/SBInstruction.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBStream.h" + #include "lldb/Core/Disassembler.h" +#include "lldb/Core/StreamFile.h" using namespace lldb; using namespace lldb_private; -//SBInstruction::SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn) : -// m_opaque_sp (lldb_insn); -//{ -//} - SBInstruction::SBInstruction () { } +SBInstruction::SBInstruction (const lldb::InstructionSP& inst_sp) : + m_opaque_sp (inst_sp) +{ +} + SBInstruction::~SBInstruction () { } -//bool -//SBInstruction::IsValid() -//{ -// return (m_opaque_sp.get() != NULL); -//} - -//size_t -//SBInstruction::GetByteSize () -//{ -// if (IsValid()) -// { -// return m_opaque_sp->GetByteSize(); -// } -// return 0; -//} - -//void -//SBInstruction::SetByteSize (size_T byte_size) -//{ -// if (IsValid ()) -// { -// m_opaque_sp->SetByteSize (byte_size); -// } -//} - -//bool -//SBInstruction::DoesBranch () -//{ -// if (IsValid ()) -// { -// return m_opaque_sp->DoesBranch (); -// } -// return false; -//} +bool +SBInstruction::IsValid() +{ + return (m_opaque_sp.get() != NULL); +} + +SBAddress +SBInstruction::GetAddress() +{ + SBAddress sb_addr; + if (m_opaque_sp && m_opaque_sp->GetAddress().IsValid()) + sb_addr.SetAddress(&m_opaque_sp->GetAddress()); + return sb_addr; +} + +size_t +SBInstruction::GetByteSize () +{ + if (m_opaque_sp) + return m_opaque_sp->GetByteSize(); + return 0; +} + +bool +SBInstruction::DoesBranch () +{ + if (m_opaque_sp) + return m_opaque_sp->DoesBranch (); + return false; +} + +void +SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp) +{ + m_opaque_sp = inst_sp; +} + +bool +SBInstruction::GetDescription (lldb::SBStream &s) +{ + if (m_opaque_sp) + { + // Use the "ref()" instead of the "get()" accessor in case the SBStream + // didn't have a stream already created, one will get created... + m_opaque_sp->Dump (&s.ref(), true, NULL, 0, NULL, false); + return true; + } + return false; +} void SBInstruction::Print (FILE *out) @@ -68,7 +88,9 @@ if (out == NULL) return; - //StreamFile out_strem (out); - - //m_opaque_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); + if (m_opaque_sp) + { + StreamFile out_stream (out); + m_opaque_sp->Dump (&out_stream, true, NULL, 0, NULL, false); + } } Modified: lldb/trunk/source/API/SBInstructionList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstructionList.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstructionList.cpp (original) +++ lldb/trunk/source/API/SBInstructionList.cpp Tue Oct 5 22:09:58 2010 @@ -9,11 +9,16 @@ #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBInstruction.h" +#include "lldb/API/SBStream.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Stream.h" using namespace lldb; +using namespace lldb_private; -SBInstructionList::SBInstructionList () +SBInstructionList::SBInstructionList () : + m_opaque_sp() { } @@ -24,6 +29,8 @@ size_t SBInstructionList::GetSize () { + if (m_opaque_sp) + return m_opaque_sp->GetInstructionList().GetSize(); return 0; } @@ -31,12 +38,15 @@ SBInstructionList::GetInstructionAtIndex (uint32_t idx) { SBInstruction inst; + if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize()) + inst.SetOpaque (m_opaque_sp->GetInstructionList().GetInstructionAtIndex (idx)); return inst; } void SBInstructionList::Clear () { + m_opaque_sp.reset(); } void @@ -45,9 +55,42 @@ } void +SBInstructionList::SetDisassembler (const lldb::DisassemblerSP &opaque_sp) +{ + m_opaque_sp = opaque_sp; +} + +void SBInstructionList::Print (FILE *out) { if (out == NULL) return; } + +bool +SBInstructionList::GetDescription (lldb::SBStream &description) +{ + if (m_opaque_sp) + { + size_t num_instructions = GetSize (); + if (num_instructions) + { + // Call the ref() to make sure a stream is created if one deesn't + // exist already inside description... + Stream &sref = description.ref(); + for (size_t i=0; iGetInstructionList().GetInstructionAtIndex (i).get(); + if (inst == NULL) + break; + inst->Dump (&sref, true, NULL, 0, NULL, false); + sref.EOL(); + } + return true; + } + } + return false; +} + + Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Tue Oct 5 22:09:58 2010 @@ -474,11 +474,17 @@ { char path[PATH_MAX]; GetTarget().GetExecutable().GetPath (path, sizeof(path)); - description.Printf ("Process {pid: %d, executable %s\n", (int) GetProcessID(), path); - description.Printf (" instance name: %s, state: %s, thread cnt: %d}", - m_opaque_sp->GetInstanceName().AsCString(), + Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModule ().get(); + const char *exe_name = NULL; + if (exe_module) + exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); + + description.Printf ("Process {pid: %d, state: %s, threads: %d%s%s}", + m_opaque_sp->GetID(), SBDebugger::StateAsCString (GetState()), - GetNumThreads()); + GetNumThreads(), + exe_name ? ", executable: " : "", + exe_name ? exe_name : ""); } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Tue Oct 5 22:09:58 2010 @@ -9,10 +9,14 @@ #include "lldb/API/SBSymbol.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Disassembler.h" +#include "lldb/Core/Module.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Target.h" using namespace lldb; - +using namespace lldb_private; SBSymbol::SBSymbol () : m_opaque_ptr (NULL) @@ -78,3 +82,30 @@ return true; } + + + +SBInstructionList +SBSymbol::GetInstructions (SBTarget target) +{ + SBInstructionList sb_instructions; + if (m_opaque_ptr) + { + ExecutionContext exe_ctx; + if (target.IsValid()) + target->CalculateExecutionContext (exe_ctx); + const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr(); + if (symbol_range) + { + Module *module = symbol_range->GetBaseAddress().GetModule(); + if (module) + { + sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture (), + exe_ctx, + *symbol_range)); + } + } + } + return sb_instructions; +} + Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Tue Oct 5 22:09:58 2010 @@ -418,11 +418,7 @@ SBThread::GetDescription (SBStream &description) { if (m_opaque_sp) - { - m_opaque_sp->DumpUsingSettingsFormat (description.ref(), LLDB_INVALID_INDEX32); - description.Printf (" %d frames, (instance name: %s)", GetNumFrames(), - m_opaque_sp->GetInstanceName().AsCString()); - } + m_opaque_sp->DumpUsingSettingsFormat (description.ref(), 0); else description.Printf ("No value"); Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Tue Oct 5 22:09:58 2010 @@ -135,6 +135,32 @@ return false; } + +lldb::DisassemblerSP +Disassembler::DisassembleRange +( + const ArchSpec &arch, + const ExecutionContext &exe_ctx, + const AddressRange &range +) +{ + lldb::DisassemblerSP disasm_sp; + if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid()) + { + disasm_sp.reset (Disassembler::FindPlugin(arch)); + + if (disasm_sp) + { + DataExtractor data; + size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, data); + if (bytes_disassembled == 0) + disasm_sp.reset(); + } + } + return disasm_sp; +} + + bool Disassembler::Disassemble ( @@ -149,9 +175,9 @@ { if (disasm_range.GetByteSize()) { - Disassembler *disassembler = Disassembler::FindPlugin(arch); + std::auto_ptr disasm_ap (Disassembler::FindPlugin(arch)); - if (disassembler) + if (disasm_ap.get()) { AddressRange range(disasm_range); @@ -175,7 +201,7 @@ } DataExtractor data; - size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, range, data); + size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, range, data); if (bytes_disassembled == 0) { return false; @@ -183,7 +209,7 @@ else { // We got some things disassembled... - size_t num_instructions = disassembler->GetInstructionList().GetSize(); + size_t num_instructions = disasm_ap->GetInstructionList().GetSize(); uint32_t offset = 0; SymbolContext sc; SymbolContext prev_sc; @@ -201,7 +227,7 @@ for (size_t i=0; iGetInstructionList().GetInstructionAtIndex (i); + Instruction *inst = disasm_ap->GetInstructionList().GetInstructionAtIndex (i).get(); if (inst) { addr_t file_addr = addr.GetFileAddress(); @@ -270,7 +296,7 @@ strm.IndentMore (); strm.Indent(); size_t inst_byte_size = inst->GetByteSize(); - inst->Dump(&strm, &addr, show_bytes ? &data : NULL, offset, exe_ctx, show_bytes); + inst->Dump(&strm, true, show_bytes ? &data : NULL, offset, &exe_ctx, show_bytes); strm.EOL(); offset += inst_byte_size; @@ -330,55 +356,49 @@ return Disassemble(debugger, arch, exe_ctx, range, num_mixed_context_lines, show_bytes, strm); } -Disassembler::Instruction::Instruction() +Instruction::Instruction(const Address &addr) : + m_addr (addr) { } -Disassembler::Instruction::~Instruction() +Instruction::~Instruction() { } -Disassembler::InstructionList::InstructionList() : +InstructionList::InstructionList() : m_instructions() { } -Disassembler::InstructionList::~InstructionList() +InstructionList::~InstructionList() { } size_t -Disassembler::InstructionList::GetSize() const +InstructionList::GetSize() const { return m_instructions.size(); } -Disassembler::Instruction * -Disassembler::InstructionList::GetInstructionAtIndex (uint32_t idx) +InstructionSP +InstructionList::GetInstructionAtIndex (uint32_t idx) const { + InstructionSP inst_sp; if (idx < m_instructions.size()) - return m_instructions[idx].get(); - return NULL; -} - -const Disassembler::Instruction * -Disassembler::InstructionList::GetInstructionAtIndex (uint32_t idx) const -{ - if (idx < m_instructions.size()) - return m_instructions[idx].get(); - return NULL; + inst_sp = m_instructions[idx]; + return inst_sp; } void -Disassembler::InstructionList::Clear() +InstructionList::Clear() { m_instructions.clear(); } void -Disassembler::InstructionList::AppendInstruction (Instruction::shared_ptr &inst_sp) +InstructionList::Append (lldb::InstructionSP &inst_sp) { if (inst_sp) m_instructions.push_back(inst_sp); @@ -394,7 +414,6 @@ ) { Target *target = exe_ctx->target; - const addr_t byte_size = range.GetByteSize(); if (target == NULL || byte_size == 0 || !range.GetBaseAddress().IsValid()) return 0; @@ -421,7 +440,7 @@ data.SetByteOrder(target->GetArchitecture().GetDefaultEndian()); data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize()); } - return DecodeInstructions (data, 0, UINT32_MAX); + return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX); } return 0; @@ -445,13 +464,13 @@ { } -Disassembler::InstructionList & +InstructionList & Disassembler::GetInstructionList () { return m_instruction_list; } -const Disassembler::InstructionList & +const InstructionList & Disassembler::GetInstructionList () const { return m_instruction_list; Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Tue Oct 5 22:09:58 2010 @@ -668,9 +668,9 @@ DataExtractor::TypeUInt8); } - disassembler->DecodeInstructions(extractor, 0, UINT32_MAX); + disassembler->DecodeInstructions (Address (NULL, func_remote_addr), extractor, 0, UINT32_MAX); - Disassembler::InstructionList &instruction_list = disassembler->GetInstructionList(); + InstructionList &instruction_list = disassembler->GetInstructionList(); uint32_t bytes_offset = 0; @@ -678,13 +678,12 @@ instruction_index < num_instructions; ++instruction_index) { - Disassembler::Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index); - Address addr(NULL, func_remote_addr + bytes_offset); + Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index).get(); instruction->Dump (&stream, - &addr, + true, &extractor, bytes_offset, - exe_ctx, + &exe_ctx, true); stream.PutChar('\n'); bytes_offset += instruction->GetByteSize(); 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=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue Oct 5 22:09:58 2010 @@ -75,13 +75,13 @@ return -1; } -DisassemblerLLVM::Instruction::Instruction(EDDisassemblerRef disassembler) : - Disassembler::Instruction (), +DisassemblerLLVM::InstructionLLVM::InstructionLLVM (EDDisassemblerRef disassembler, const Address &addr) : + Instruction (addr), m_disassembler (disassembler) { } -DisassemblerLLVM::Instruction::~Instruction() +DisassemblerLLVM::InstructionLLVM::~InstructionLLVM() { } @@ -97,28 +97,31 @@ } void -DisassemblerLLVM::Instruction::Dump +DisassemblerLLVM::InstructionLLVM::Dump ( Stream *s, - lldb_private::Address *inst_addr_ptr, + bool show_address, const DataExtractor *bytes, uint32_t bytes_offset, - const lldb_private::ExecutionContext& exe_ctx, + const lldb_private::ExecutionContext* exe_ctx, bool raw ) { const size_t opcodeColumnWidth = 7; const size_t operandColumnWidth = 25; - ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = NULL; + if (exe_ctx) + exe_scope = exe_ctx->GetBestExecutionContextScope(); + // If we have an address, print it out - if (inst_addr_ptr) + if (GetAddress().IsValid()) { - if (inst_addr_ptr->Dump (s, - exe_scope, - Address::DumpStyleLoadAddress, - Address::DumpStyleModuleWithFileAddress, - 0)) + if (GetAddress().Dump (s, + exe_scope, + Address::DumpStyleLoadAddress, + Address::DumpStyleModuleWithFileAddress, + 0)) s->PutCString(": "); } @@ -139,16 +142,15 @@ int currentOpIndex = -1; - //lldb_private::Process *process = exe_ctx.process; std::auto_ptr rra; if (!raw) { addr_t base_addr = LLDB_INVALID_ADDRESS; - if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) - base_addr = inst_addr_ptr->GetLoadAddress (exe_ctx.target); + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) + base_addr = GetAddress().GetLoadAddress (exe_ctx->target); if (base_addr == LLDB_INVALID_ADDRESS) - base_addr = inst_addr_ptr->GetFileAddress (); + base_addr = GetAddress().GetFileAddress (); rra.reset(new RegisterReaderArg(base_addr + EDInstByteSize(m_inst), m_disassembler)); } @@ -246,14 +248,14 @@ } lldb_private::Address so_addr; - if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) { - if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) + if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); } - else if (inst_addr_ptr) + else { - Module *module = inst_addr_ptr->GetModule(); + Module *module = GetAddress().GetModule(); if (module) { if (module->ResolveFileAddress (operand_value, so_addr)) @@ -318,19 +320,19 @@ } bool -DisassemblerLLVM::Instruction::DoesBranch() const +DisassemblerLLVM::InstructionLLVM::DoesBranch() const { return EDInstIsBranch(m_inst); } size_t -DisassemblerLLVM::Instruction::GetByteSize() const +DisassemblerLLVM::InstructionLLVM::GetByteSize() const { return EDInstByteSize(m_inst); } size_t -DisassemblerLLVM::Instruction::Extract(const DataExtractor &data, uint32_t data_offset) +DisassemblerLLVM::InstructionLLVM::Extract(const DataExtractor &data, uint32_t data_offset) { if (EDCreateInsts(&m_inst, 1, m_disassembler, DataExtractorByteReader, data_offset, (void*)(&data))) return EDInstByteSize(m_inst); @@ -391,6 +393,7 @@ size_t DisassemblerLLVM::DecodeInstructions ( + const Address &base_addr, const DataExtractor& data, uint32_t data_offset, uint32_t num_instructions @@ -402,14 +405,16 @@ while (data.ValidOffset(data_offset) && num_instructions) { - Instruction::shared_ptr inst_sp (new Instruction(m_disassembler)); + Address inst_addr (base_addr); + inst_addr.Slide(data_offset); + InstructionSP inst_sp (new InstructionLLVM(m_disassembler, inst_addr)); - size_t inst_byte_size = inst_sp->Extract(data, data_offset); + size_t inst_byte_size = inst_sp->Extract (data, data_offset); if (inst_byte_size == 0) break; - m_instruction_list.AppendInstruction(inst_sp); + m_instruction_list.Append (inst_sp); total_inst_byte_size += inst_byte_size; data_offset += inst_byte_size; Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=115734&r1=115733&r2=115734&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Tue Oct 5 22:09:58 2010 @@ -19,20 +19,20 @@ class DisassemblerLLVM : public lldb_private::Disassembler { public: - class Instruction : public lldb_private::Disassembler::Instruction + class InstructionLLVM : public lldb_private::Instruction { public: - Instruction(EDDisassemblerRef disassembler); + InstructionLLVM(EDDisassemblerRef disassembler, const lldb_private::Address &addr); virtual - ~Instruction(); + ~InstructionLLVM(); void Dump (lldb_private::Stream *s, - lldb_private::Address *instr_addr_ptr, + bool show_address, const lldb_private::DataExtractor *bytes, uint32_t bytes_offset, - const lldb_private::ExecutionContext& exe_ctx, + const lldb_private::ExecutionContext* exe_ctx, bool raw); bool @@ -75,7 +75,8 @@ ~DisassemblerLLVM(); size_t - DecodeInstructions (const lldb_private::DataExtractor& data, + DecodeInstructions (const lldb_private::Address &base_addr, + const lldb_private::DataExtractor& data, uint32_t data_offset, uint32_t num_instructions); From gclayton at apple.com Tue Oct 5 22:53:16 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 03:53:16 -0000 Subject: [Lldb-commits] [lldb] r115738 - in /lldb/trunk: examples/python/ examples/python/disasm.py include/lldb/API/SBTarget.h source/API/SBProcess.cpp source/API/SBTarget.cpp source/API/SBThread.cpp Message-ID: <20101006035316.F0CE02A6C12C@llvm.org> Author: gclayton Date: Tue Oct 5 22:53:16 2010 New Revision: 115738 URL: http://llvm.org/viewvc/llvm-project?rev=115738&view=rev Log: Added the first of hopefully many python example scripts that show how to use the python API that is exposed through SWIG to do some cool stuff. Also fixed synchronous debugging so that all process control APIs exposed through the python API will now wait for the process to stop if you set the async mode to false (see disasm.py). Added: lldb/trunk/examples/python/ lldb/trunk/examples/python/disasm.py (with props) Modified: lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp Added: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=115738&view=auto ============================================================================== --- lldb/trunk/examples/python/disasm.py (added) +++ lldb/trunk/examples/python/disasm.py Tue Oct 5 22:53:16 2010 @@ -0,0 +1,79 @@ +#!/usr/bin/python + +#---------------------------------------------------------------------- +# Be sure to add the python path that points to the LLDB shared library. +# On MacOSX csh, tcsh: +# setenv PYTHONPATH /Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +# On MacOSX sh, bash: +# export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python +#---------------------------------------------------------------------- + +import lldb +import os +import sys +import time + +def disassemble_instructions (insts): + for i in range(0, insts.GetSize()): + print insts.GetInstructionAtIndex(i) + +# Initialize LLDB so we can use it +lldb.SBDebugger.Initialize() + +# Create a new debugger instance +debugger = lldb.SBDebugger.Create() + +# When we step or continue, don't return from the function until the process +# stops. We do this by setting the async mode to false. +debugger.SetAsync (False) + +# Create a target from a file and arch +target = debugger.CreateTargetWithFileAndArch (sys.argv[1], "x86_64") + +if target.IsValid(): + # If the target is valid set a breakpoint at main + main_bp = target.BreakpointCreateByName ("main", "a.out"); + + # Launch the process. Since we specified synchronous mode, we won't return + # from this function until we hit the breakpoint at main + process = target.LaunchProcess (sys.argv[2:], [''], "dev/stdout", 0, False) + + # Make sure the launch went ok + if process.IsValid(): + # Print some simple process info + print "process:", process, "\n" + # Get the first thread + thread = process.GetThreadAtIndex (0) + if thread.IsValid(): + # Print some simple thread info + print "thread: ", thread + # Get the first frame + frame = thread.GetFrameAtIndex (0) + if frame.IsValid(): + # Print some simple frame info + print "frame: ", frame + function = frame.GetFunction() + # See if we have debug info (a function) + if function.IsValid(): + # We do have a function, print some info for the function + print "function: ", function, "\n" + # Now get all instructions for this function and print them + insts = function.GetInstructions(target) + disassemble_instructions (insts) + else: + # See if we have a symbol in the symbol table for where we stopped + symbol = frame.GetSymbol(); + if symbol.IsValid(): + # We do have a symbol, print some info for the symbol + print "symbol: ", symbol, "\n" + # Now get all instructions for this symbol and print them + insts = symbol.GetInstructions(target) + disassemble_instructions (insts) + # 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:", process, "\n" + + +lldb.SBDebugger.Terminate() Propchange: lldb/trunk/examples/python/disasm.py ------------------------------------------------------------------------------ svn:executable = * Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115738&r1=115737&r2=115738&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Oct 5 22:53:16 2010 @@ -53,9 +53,6 @@ GetProcess (); lldb::SBProcess - CreateProcess (); - - lldb::SBProcess LaunchProcess (char const **argv, char const **envp, const char *tty, Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=115738&r1=115737&r2=115738&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Tue Oct 5 22:53:16 2010 @@ -15,6 +15,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" @@ -287,7 +288,15 @@ { SBError sb_error; if (IsValid()) - sb_error.SetError(m_opaque_sp->Resume()); + { + Error error (m_opaque_sp->Resume()); + if (error.Success()) + { + if (m_opaque_sp->GetTarget().GetDebugger().GetAsyncExecution () == false) + m_opaque_sp->WaitForProcessToStop (NULL); + } + sb_error.SetError(error); + } else sb_error.SetErrorString ("SBProcess is invalid"); Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115738&r1=115737&r2=115738&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Oct 5 22:53:16 2010 @@ -106,17 +106,6 @@ } SBProcess -SBTarget::CreateProcess () -{ - SBProcess sb_process; - - if (m_opaque_sp) - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - - return sb_process; -} - -SBProcess SBTarget::LaunchProcess ( char const **argv, @@ -126,23 +115,39 @@ bool stop_at_entry ) { - SBProcess process(GetProcess ()); - if (!process.IsValid()) - process = CreateProcess(); - if (process.IsValid()) + SBProcess sb_process; + if (m_opaque_sp) { - Error error (process->Launch (argv, envp, launch_flags, tty, tty, tty)); - if (error.Success()) + // When launching, we always want to create a new process + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + + if (sb_process.IsValid()) { - if (!stop_at_entry) + Error error (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty)); + if (error.Success()) { - StateType state = process->WaitForProcessToStop (NULL); + // We we are stopping at the entry point, we can return now! + if (stop_at_entry) + return sb_process; + + // Make sure we are stopped at the entry + StateType state = sb_process->WaitForProcessToStop (NULL); if (state == eStateStopped) - process->Resume(); + { + // resume the process to skip the entry point + error = sb_process->Resume(); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) + sb_process->WaitForProcessToStop (NULL); + } + } } } } - return process; + return sb_process; } SBFileSpec @@ -401,9 +406,9 @@ // Make sure the process object is alive if we have one (it might be // created but we might not be launched yet). - Process *process = m_opaque_sp->GetProcessSP().get(); - if (process && !process->IsAlive()) - process = NULL; + Process *sb_process = m_opaque_sp->GetProcessSP().get(); + if (sb_process && !sb_process->IsAlive()) + sb_process = NULL; // If we are given a module, then "start_addr" is a file address in // that module. @@ -430,8 +435,8 @@ ExecutionContext exe_ctx; - if (process) - process->CalculateExecutionContext(exe_ctx); + if (sb_process) + sb_process->CalculateExecutionContext(exe_ctx); else m_opaque_sp->CalculateExecutionContext(exe_ctx); @@ -479,12 +484,12 @@ // Make sure the process object is alive if we have one (it might be // created but we might not be launched yet). - Process *process = m_opaque_sp->GetProcessSP().get(); - if (process && !process->IsAlive()) - process = NULL; + Process *sb_process = m_opaque_sp->GetProcessSP().get(); + if (sb_process && !sb_process->IsAlive()) + sb_process = NULL; - if (process) - process->CalculateExecutionContext(exe_ctx); + if (sb_process) + sb_process->CalculateExecutionContext(exe_ctx); else m_opaque_sp->CalculateExecutionContext(exe_ctx); Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=115738&r1=115737&r2=115738&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Tue Oct 5 22:53:16 2010 @@ -233,25 +233,32 @@ { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, - eStepTypeOver, - sc.line_entry.range, - sc, - stop_other_threads, - false); + eStepTypeOver, + sc.line_entry.range, + sc, + stop_other_threads, + false); } else { m_opaque_sp->QueueThreadPlanForStepSingleInstruction (true, - abort_other_plans, - stop_other_threads); + abort_other_plans, + stop_other_threads); } } Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); - process.Resume(); + Error error (process.Resume()); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (process.GetTarget().GetDebugger().GetAsyncExecution () == false) + process.WaitForProcessToStop (NULL); + } } } @@ -269,24 +276,30 @@ bool avoid_code_without_debug_info = true; SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, - eStepTypeInto, - sc.line_entry.range, - sc, - stop_other_threads, - avoid_code_without_debug_info); + eStepTypeInto, + sc.line_entry.range, + sc, + stop_other_threads, + avoid_code_without_debug_info); } else { m_opaque_sp->QueueThreadPlanForStepSingleInstruction (false, - abort_other_plans, - stop_other_threads); + abort_other_plans, + stop_other_threads); } Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); - process.Resume(); - + Error error (process.Resume()); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (process.GetTarget().GetDebugger().GetAsyncExecution () == false) + process.WaitForProcessToStop (NULL); + } } } @@ -302,7 +315,14 @@ Process &process = m_opaque_sp->GetProcess(); process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); - process.Resume(); + Error error (process.Resume()); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (process.GetTarget().GetDebugger().GetAsyncExecution () == false) + process.WaitForProcessToStop (NULL); + } } } @@ -314,7 +334,14 @@ m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); Process &process = m_opaque_sp->GetProcess(); process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); - process.Resume(); + Error error (process.Resume()); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (process.GetTarget().GetDebugger().GetAsyncExecution () == false) + process.WaitForProcessToStop (NULL); + } } } @@ -331,7 +358,14 @@ m_opaque_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads); Process &process = m_opaque_sp->GetProcess(); process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); - process.Resume(); + Error error (process.Resume()); + if (error.Success()) + { + // If we are doing synchronous mode, then wait for the + // process to stop yet again! + if (process.GetTarget().GetDebugger().GetAsyncExecution () == false) + process.WaitForProcessToStop (NULL); + } } } From gclayton at apple.com Wed Oct 6 12:33:31 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 17:33:31 -0000 Subject: [Lldb-commits] [lldb] r115801 - /lldb/trunk/examples/python/disasm.py Message-ID: <20101006173331.1457F2A6C12C@llvm.org> Author: gclayton Date: Wed Oct 6 12:33:30 2010 New Revision: 115801 URL: http://llvm.org/viewvc/llvm-project?rev=115801&view=rev Log: Fixed a few issues with the example script. 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=115801&r1=115800&r2=115801&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed Oct 6 12:33:30 2010 @@ -32,11 +32,11 @@ if target.IsValid(): # If the target is valid set a breakpoint at main - main_bp = target.BreakpointCreateByName ("main", "a.out"); + main_bp = target.BreakpointCreateByName ("main", sys.argv[1]); # Launch the process. Since we specified synchronous mode, we won't return # from this function until we hit the breakpoint at main - process = target.LaunchProcess (sys.argv[2:], [''], "dev/stdout", 0, False) + process = target.LaunchProcess (sys.argv[2:], [''], "/dev/stdout", 0, False) # Make sure the launch went ok if process.IsValid(): From johnny.chen at apple.com Wed Oct 6 13:16:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 18:16:19 -0000 Subject: [Lldb-commits] [lldb] r115804 - /lldb/trunk/test/array_types/TestArrayTypes.py Message-ID: <20101006181619.E33422A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 13:16:19 2010 New Revision: 115804 URL: http://llvm.org/viewvc/llvm-project?rev=115804&view=rev Log: Modification of the expected substrings for the print representations of SBProcess and SBThread. Modified: lldb/trunk/test/array_types/TestArrayTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=115804&r1=115803&r2=115804&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Oct 6 13:16:19 2010 @@ -103,8 +103,8 @@ # Sanity check the print representation of process. proc = repr(self.process) self.expect(proc, msg="Process looks good", exe=False, - patterns = ["executable.+array_types.a\.out", - "instance name:.+state: Stopped"]) + substrs = ["state: Stopped", + "executable: a.out"]) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) @@ -116,8 +116,7 @@ self.expect(thr, "Thread looks good with stop reason = breakpoint", exe=False, substrs = ["thread #%d: tid = 0x%4.4x" % (thread.GetIndexID(), thread.GetThreadID()), "stop reason = breakpoint", - "queue = %s" % thread.GetQueueName() if thread.GetQueueName() else "", - "%d frames" % thread.GetNumFrames()]) + "queue = %s" % thread.GetQueueName() if thread.GetQueueName() else ""]) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) From gclayton at apple.com Wed Oct 6 13:44:26 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 18:44:26 -0000 Subject: [Lldb-commits] [lldb] r115815 - in /lldb/trunk: include/lldb/API/SBTarget.h source/API/SBTarget.cpp Message-ID: <20101006184426.6A62D2A6C12C@llvm.org> Author: gclayton Date: Wed Oct 6 13:44:26 2010 New Revision: 115815 URL: http://llvm.org/viewvc/llvm-project?rev=115815&view=rev Log: Leaving in deprecated functions until we can get a clean build with the new APIs in place before removing the deprecated functions. Modified: lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115815&r1=115814&r2=115815&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct 6 13:44:26 2010 @@ -50,6 +50,9 @@ IsValid() const; lldb::SBProcess + CreateProcess (); // DEPRECATED + + lldb::SBProcess GetProcess (); lldb::SBProcess Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115815&r1=115814&r2=115815&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 6 13:44:26 2010 @@ -105,6 +105,20 @@ return debugger; } + +// DEPRECATED +SBProcess +SBTarget::CreateProcess () +{ + SBProcess sb_process; + + if (m_opaque_sp) + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + + return sb_process; +} + + SBProcess SBTarget::LaunchProcess ( @@ -118,8 +132,17 @@ SBProcess sb_process; if (m_opaque_sp) { - // When launching, we always want to create a new process - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + // DEPRECATED, this will change when CreateProcess is removed... + if (m_opaque_sp->GetProcessSP()) + { + sb_process.SetProcess(m_opaque_sp->GetProcessSP()); + } + else + { + // When launching, we always want to create a new process When + // SBTarget::CreateProcess is removed, this will always happen. + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } if (sb_process.IsValid()) { From johnny.chen at apple.com Wed Oct 6 14:32:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 19:32:50 -0000 Subject: [Lldb-commits] [lldb] r115818 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20101006193250.868E02A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 14:32:50 2010 New Revision: 115818 URL: http://llvm.org/viewvc/llvm-project?rev=115818&view=rev Log: Modification of the expected pattern for 'expr this->m_c_int' output. Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115818&r1=115817&r2=115818&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Oct 6 14:32:50 2010 @@ -137,7 +137,7 @@ # # Verify that expr this->m_c_int behaves correctly. self.expect("expr this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(int) 66']) + patterns = ['\(int\) \$[0-9]+ = 66']) if __name__ == '__main__': From johnny.chen at apple.com Wed Oct 6 14:38:08 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 19:38:08 -0000 Subject: [Lldb-commits] [lldb] r115819 - /lldb/trunk/test/persistent_variables/TestPersistentVariables.py Message-ID: <20101006193808.591712A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 14:38:08 2010 New Revision: 115819 URL: http://llvm.org/viewvc/llvm-project?rev=115819&view=rev Log: Modification of the expected start strings for simple 'expr' output involving persistent variables. Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=115819&r1=115818&r2=115819&view=diff ============================================================================== --- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Wed Oct 6 14:38:08 2010 @@ -22,20 +22,20 @@ self.runCmd("run", RUN_SUCCEEDED) self.expect("expr int $i = 5; $i + 1", - startstr = "$0 = (int) 6") - # $0 = (int) 6 + startstr = "(int) $0 = 6") + # (int) $0 = 6 self.expect("expr $i + 3", - startstr = "$1 = (int) 8") - # $1 = (int) 8 + startstr = "(int) $1 = 8") + # (int) $1 = 8 self.expect("expr $1 + $0", - startstr = "$2 = (int) 14") - # $2 = (int) 14 + startstr = "(int) $2 = 14") + # (int) $2 = 14 self.expect("expr $2", - startstr = "$3 = (int) 14") - # $3 = (int) 14 + startstr = "(int) $3 = 14") + # (int) $3 = 14 if __name__ == '__main__': From johnny.chen at apple.com Wed Oct 6 14:42:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 19:42:37 -0000 Subject: [Lldb-commits] [lldb] r115820 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101006194237.9673E2A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 14:42:37 2010 New Revision: 115820 URL: http://llvm.org/viewvc/llvm-project?rev=115820&view=rev Log: Change the expected term-width output string to be a substring instead of a startstring for the test case test_set_term_width() after the recent changes. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=115820&r1=115819&r2=115820&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Wed Oct 6 14:42:37 2010 @@ -45,7 +45,7 @@ # The overall display should also reflect the new setting. self.expect("settings show", - startstr = "term-width (int) = '70'") + substrs = "term-width (int) = '70'") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): From johnny.chen at apple.com Wed Oct 6 15:00:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 20:00:48 -0000 Subject: [Lldb-commits] [lldb] r115821 - /lldb/trunk/test/types/AbstractBase.py Message-ID: <20101006200048.D31712A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 15:00:48 2010 New Revision: 115821 URL: http://llvm.org/viewvc/llvm-project?rev=115821&view=rev Log: Change the regular expression used to grok the data type associated the output of expression parser in light of the recent check ins. Example: runCmd: expr a output: (double) $0 = 1100.12 Modified: lldb/trunk/test/types/AbstractBase.py Modified: lldb/trunk/test/types/AbstractBase.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/AbstractBase.py?rev=115821&r1=115820&r2=115821&view=diff ============================================================================== --- lldb/trunk/test/types/AbstractBase.py (original) +++ lldb/trunk/test/types/AbstractBase.py Wed Oct 6 15:00:48 2010 @@ -138,10 +138,10 @@ # # Example: # runCmd: expr a - # output: $0 = (double) 1100.12 + # output: (double) $0 = 1100.12 # try: - dt = re.match("^\$[0-9]+ = \((.*)\)", output).group(1) + dt = re.match("^\((.*)\) \$[0-9]+ = ", output).group(1) except: self.fail(self.DATA_TYPE_GROKKED) From johnny.chen at apple.com Wed Oct 6 15:03:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 20:03:28 -0000 Subject: [Lldb-commits] [lldb] r115822 - /lldb/trunk/test/array_types/TestArrayTypes.py Message-ID: <20101006200328.5710C2A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 15:03:28 2010 New Revision: 115822 URL: http://llvm.org/viewvc/llvm-project?rev=115822&view=rev Log: Use the SBTarget process launch API for api testings. Modified: lldb/trunk/test/array_types/TestArrayTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=115822&r1=115821&r2=115822&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Oct 6 15:03:28 2010 @@ -42,6 +42,13 @@ self.runCmd("run", RUN_SUCCEEDED) + # The test suite sometimes shows that the process has exited without stopping. + # + # CC=clang ./dotest.py -v -t array_types + # ... + # Process 76604 exited with status = 0 (0x00000000) + self.runCmd("process status") + # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', @@ -93,9 +100,8 @@ self.expect(bp, msg="Breakpoint is not resolved as yet", exe=False, matching=False, substrs = ["resolved = 1"]) - self.runCmd("run", RUN_SUCCEEDED, setCookie=False) - # This does not work, and results in the process stopped at dyld_start? - #process = target.LaunchProcess([''], [''], os.ctermid(), False) + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) From johnny.chen at apple.com Wed Oct 6 15:13:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 20:13:28 -0000 Subject: [Lldb-commits] [lldb] r115826 - /lldb/trunk/test/hello_world/TestHelloWorld.py Message-ID: <20101006201328.DF34D2A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 15:13:28 2010 New Revision: 115826 URL: http://llvm.org/viewvc/llvm-project?rev=115826&view=rev Log: Remove the @expectedFailure decorator since the SBTarget.LaunchProcess() race condition has been fixed. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=115826&r1=115825&r2=115826&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Oct 6 15:13:28 2010 @@ -18,7 +18,6 @@ self.buildDsym() self.hello_world_python(useLaunchAPI = False) - @unittest2.expectedFailure def test_with_dwarf_and_process_launch_api(self): """Create target, breakpoint, launch a process, and then kill it. @@ -53,9 +52,11 @@ if useLaunchAPI: process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + # The following isn't needed anymore, rdar://8364687 is fixed. + # # Apply some dances after LaunchProcess() in order to break at "main". # It only works sometimes. - self.breakAfterLaunch(process, "main") + #self.breakAfterLaunch(process, "main") else: # On the other hand, the following line of code are more reliable. self.runCmd("run", setCookie=False) From johnny.chen at apple.com Wed Oct 6 15:40:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 06 Oct 2010 20:40:56 -0000 Subject: [Lldb-commits] [lldb] r115832 - /lldb/trunk/test/dotest.py Message-ID: <20101006204056.8C4B42A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 15:40:56 2010 New Revision: 115832 URL: http://llvm.org/viewvc/llvm-project?rev=115832&view=rev Log: Enhance the test driver with a '-f filterspec' option to specify the testclass.testmethod to be run and with a '-g' option which instructs the test driver to only admit the module which satisfy the filterspec condition to the test suite. Example: # This only runs the test case under the array_types directory which has class # name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'. /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types ---------------------------------------------------------------------- Collected 1 test test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.353s OK # And this runs the test cases under the array_types and the hello_world directories. # If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command' # attribute, only the test case specified by the filterspec for the module will be run. # If the module does not have the said attribute, e.g., the module under hello_world, # the whole module is still admitted to the test suite. /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world ---------------------------------------------------------------------- Collected 3 tests test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... ok test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase) Create target, breakpoint, launch a process, and then kill it. ... ok test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase) Create target, breakpoint, launch a process, and then kill it. ... ok ---------------------------------------------------------------------- Ran 3 tests in 4.964s OK Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115832&r1=115831&r2=115832&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Oct 6 15:40:56 2010 @@ -54,6 +54,12 @@ # Delay startup in order for the debugger to attach. delay = False +# The filter (testcase.testmethod) used to admit tests into our test suite. +filterspec = None + +# If '-g' is specified, the filterspec must be consulted for each test module, default to False. +fs4all = False + # Ignore the build search path relative to this script to locate the lldb.py module. ignore = False @@ -81,6 +87,12 @@ -c : read a config file specified after this option (see also lldb-trunk/example/test/usage-config) -d : delay startup for 10 seconds (in order for the debugger to attach) +-f : specify a filter to admit tests into the test suite + e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api' +-g : if specified, only the modules with the corect filter will be run + it has no effect if no '-f' option is present + '-f filterspec -g' can be used with '-p filename-regexp' to select only + the testfile.testclass.testmethod to run -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module -l : don't skip long running test @@ -117,6 +129,8 @@ global configFile global delay + global filterspec + global fs4all global ignore global skipLongRunningTest global regexp @@ -148,6 +162,16 @@ elif sys.argv[index].startswith('-d'): delay = True index += 1 + elif sys.argv[index].startswith('-f'): + # Increment by 1 to fetch the filter spec. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + filterspec = sys.argv[index] + index += 1 + elif sys.argv[index].startswith('-g'): + fs4all = True + index += 1 elif sys.argv[index].startswith('-i'): ignore = True index += 1 @@ -267,6 +291,8 @@ global suite global regexp + global filterspec + global fs4all for name in names: if os.path.isdir(os.path.join(dir, name)): @@ -287,7 +313,35 @@ if not sys.path.count(dir): sys.path.append(dir) base = os.path.splitext(name)[0] - suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base)) + + # Thoroughly check the filterspec against the base module and admit + # the (base, filterspec) combination only when it makes sense. + if filterspec: + # Optimistically set the flag to True. + filtered = True + module = __import__(base) + parts = filterspec.split('.') + obj = module + for part in parts: + try: + parent, obj = obj, getattr(obj, part) + except AttributeError: + # The filterspec has failed. + filtered = False + break + # Forgo this module if the (base, filterspec) combo is invalid + # and the '-g' option is present. + if fs4all and not filtered: + continue + + if filterspec and filtered: + suite.addTests( + unittest2.defaultTestLoader.loadTestsFromName(filterspec, module)) + else: + # A simple case of just the module name. Also the failover case + # from the filterspec branch when the (base, filterspec) combo + # doesn't make sense. + suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base)) def lldbLoggings(): From gclayton at apple.com Wed Oct 6 17:10:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 06 Oct 2010 22:10:18 -0000 Subject: [Lldb-commits] [lldb] r115854 - in /lldb/trunk: include/lldb/API/SBError.h include/lldb/API/SBProcess.h include/lldb/API/SBTarget.h include/lldb/API/SBValue.h source/API/SBTarget.cpp source/API/SBValue.cpp Message-ID: <20101006221018.3AE4A2A6C12C@llvm.org> Author: gclayton Date: Wed Oct 6 17:10:17 2010 New Revision: 115854 URL: http://llvm.org/viewvc/llvm-project?rev=115854&view=rev Log: Expose the error contained within an SBValue. Move anything that creates a new process into SBTarget. Marked some functions as deprecated. I will remove them after our new API changes make it through a build cycle. Modified: lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Wed Oct 6 17:10:17 2010 @@ -75,6 +75,8 @@ friend class SBHostOS; friend class SBInputReader; friend class SBProcess; + friend class SBTarget; + friend class SBValue; #ifndef SWIG Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Wed Oct 6 17:10:17 2010 @@ -112,9 +112,11 @@ lldb::pid_t AttachByPID (lldb::pid_t pid); // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t) + // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (lldb::pid_t pid, SBError& error)" SBError Attach (lldb::pid_t pid); + // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (const char *name, bool wait_for_launch, SBError& error)" SBError AttachByName (const char *name, bool wait_for_launch); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct 6 17:10:17 2010 @@ -55,6 +55,8 @@ lldb::SBProcess GetProcess (); + // DEPRECATED in favor of the function below that contains an SBError as the + // last parameter. lldb::SBProcess LaunchProcess (char const **argv, char const **envp, @@ -62,6 +64,23 @@ uint32_t launch_flags, // See lldb::LaunchFlags bool stop_at_entry); + lldb::SBProcess + LaunchProcess (char const **argv, + char const **envp, + const char *tty, + uint32_t launch_flags, // See lldb::LaunchFlags + bool stop_at_entry, + SBError& error); + + lldb::SBProcess + AttachToProcess (lldb::pid_t pid, // The process ID to attach to + SBError& error); // An error explaining what went wrong if attach fails + + lldb::SBProcess + AttachToProcess (const char *name, // basename of process to attach to + bool wait_for, // if true wait for a new instance of "name" to be launched + SBError& error); // An error explaining what went wrong if attach fails + lldb::SBFileSpec GetExecutable (); Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Wed Oct 6 17:10:17 2010 @@ -25,6 +25,9 @@ bool IsValid() const; + + SBError + GetError(); const char * GetName(); Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 6 17:10:17 2010 @@ -129,6 +129,22 @@ bool stop_at_entry ) { + SBError sb_error; + return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); +} + + +SBProcess +SBTarget::LaunchProcess +( + char const **argv, + char const **envp, + const char *tty, + uint32_t launch_flags, + bool stop_at_entry, + SBError &error +) +{ SBProcess sb_process; if (m_opaque_sp) { @@ -146,7 +162,7 @@ if (sb_process.IsValid()) { - Error error (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty)); + error.SetError (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty)); if (error.Success()) { // We we are stopping at the entry point, we can return now! @@ -158,7 +174,7 @@ if (state == eStateStopped) { // resume the process to skip the entry point - error = sb_process->Resume(); + error.SetError (sb_process->Resume()); if (error.Success()) { // If we are doing synchronous mode, then wait for the @@ -169,8 +185,96 @@ } } } + else + { + error.SetErrorString ("unable to create lldb_private::Process"); + } + } + else + { + error.SetErrorString ("SBTarget is invalid"); + } + return sb_process; +} + + +lldb::SBProcess +SBTarget::AttachToProcess +( + lldb::pid_t pid,// The process ID to attach to + SBError& error // An error explaining what went wrong if attach fails +) +{ + SBProcess sb_process; + if (m_opaque_sp) + { + // DEPRECATED, this will change when CreateProcess is removed... + if (m_opaque_sp->GetProcessSP()) + { + sb_process.SetProcess(m_opaque_sp->GetProcessSP()); + } + else + { + // When launching, we always want to create a new process When + // SBTarget::CreateProcess is removed, this will always happen. + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } + + if (sb_process.IsValid()) + { + error.SetError (sb_process->Attach (pid)); + } + else + { + error.SetErrorString ("unable to create lldb_private::Process"); + } + } + else + { + error.SetErrorString ("SBTarget is invalid"); } return sb_process; + +} + +lldb::SBProcess +SBTarget::AttachToProcess +( + const char *name, // basename of process to attach to + bool wait_for, // if true wait for a new instance of "name" to be launched + SBError& error // An error explaining what went wrong if attach fails +) +{ + SBProcess sb_process; + if (m_opaque_sp) + { + // DEPRECATED, this will change when CreateProcess is removed... + if (m_opaque_sp->GetProcessSP()) + { + sb_process.SetProcess(m_opaque_sp->GetProcessSP()); + } + else + { + // When launching, we always want to create a new process When + // SBTarget::CreateProcess is removed, this will always happen. + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); + } + + if (sb_process.IsValid()) + { + error.SetError (sb_process->Attach (name, wait_for)); + } + else + { + error.SetErrorString ("unable to create lldb_private::Process"); + } + } + else + { + error.SetErrorString ("SBTarget is invalid"); + } + return sb_process; + } SBFileSpec Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=115854&r1=115853&r2=115854&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Wed Oct 6 17:10:17 2010 @@ -53,6 +53,17 @@ return (m_opaque_sp.get() != NULL); } +SBError +SBValue::GetError() +{ + SBError sb_error; + + if (m_opaque_sp.get()) + sb_error.SetError(m_opaque_sp->GetError()); + + return sb_error; +} + const char * SBValue::GetName() { From johnny.chen at apple.com Wed Oct 6 21:04:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 02:04:14 -0000 Subject: [Lldb-commits] [lldb] r115899 - in /lldb/trunk: include/lldb/API/SBTarget.h scripts/lldb.swig source/API/SBTarget.cpp test/class_types/TestClassTypes.py test/dotest.py test/lldbtest.py Message-ID: <20101007020414.962892A6C12C@llvm.org> Author: johnny Date: Wed Oct 6 21:04:14 2010 New Revision: 115899 URL: http://llvm.org/viewvc/llvm-project?rev=115899&view=rev Log: o SBtarget.cpp/.h: Temporarily commenting out the deprecated LaunchProcess() method. SWIG is not able to handle the overloaded functions. o dotest.py/lldbtest.py: Add an '-w' option to insert some wait time between consecutive test cases. o TestClassTypes.py: Make the breakpoint_creation_by_filespec_python() test method more robust and more descriptive by printing out a more insightful assert message. o lldb.swig: Coaches swig to treat StateType as an int type, instead of a C++ class. Modified: lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBTarget.cpp lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct 6 21:04:14 2010 @@ -57,12 +57,12 @@ // DEPRECATED in favor of the function below that contains an SBError as the // last parameter. - lldb::SBProcess - LaunchProcess (char const **argv, - char const **envp, - const char *tty, - uint32_t launch_flags, // See lldb::LaunchFlags - bool stop_at_entry); +// lldb::SBProcess +// LaunchProcess (char const **argv, +// char const **envp, +// const char *tty, +// uint32_t launch_flags, // See lldb::LaunchFlags +// bool stop_at_entry); lldb::SBProcess LaunchProcess (char const **argv, Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Oct 6 21:04:14 2010 @@ -134,6 +134,7 @@ typedef lldb::SBStringList SBStringList; typedef lldb::RegisterKind RegisterKind; const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ; +typedef int StateType; typedef int StopReason; Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 6 21:04:14 2010 @@ -119,19 +119,19 @@ } -SBProcess -SBTarget::LaunchProcess -( - char const **argv, - char const **envp, - const char *tty, - uint32_t launch_flags, - bool stop_at_entry -) -{ - SBError sb_error; - return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); -} +// SBProcess +// SBTarget::LaunchProcess +// ( +// char const **argv, +// char const **envp, +// const char *tty, +// uint32_t launch_flags, +// bool stop_at_entry +// ) +// { +// SBError sb_error; +// return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); +// } SBProcess Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Oct 6 21:04:14 2010 @@ -3,6 +3,7 @@ import os, time import unittest2 import lldb +import lldbutil from lldbtest import * class ClassTypesTestCase(TestBase): @@ -56,6 +57,13 @@ self.runCmd("run", RUN_SUCCEEDED) + # The test suite sometimes shows that the process has exited without stopping. + # + # CC=clang ./dotest.py -v -t class_types + # ... + # Process 76604 exited with status = 0 (0x00000000) + self.runCmd("process status") + # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, substrs = ['state is Stopped', @@ -92,15 +100,43 @@ self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Verify the breakpoint just created. - self.expect("breakpoint list", BREAKPOINT_CREATED, - substrs = ['main.cpp:93']) + self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False, + substrs = ['main.cpp', + '93']) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False, rc) + #self.breakAfterLaunch(self.process, "C::C(int, int, int)") + + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + if self.process.GetState() != StateTypeEnum("Stopped"): + self.fail("Process should be in the 'Stopped' state, " + "instead the actual state is: '%s'" % + StateTypeString(self.process.GetState())) - self.runCmd("run", RUN_SUCCEEDED) + # The stop reason of the thread should be breakpoint. + thread = self.process.GetThreadAtIndex(0) - self.runCmd("thread backtrace") + self.expect(StopReasonString(thread.GetStopReason()), + STOPPED_DUE_TO_BREAKPOINT, exe=False, + startstr = "Breakpoint") + + # The filename of frame #0 should be 'main.cpp' and the line number + # should be 93. + self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0], + lldbutil.GetLineNumbers(thread)[0]), + "Break correctly at main.cpp:93", exe=False, + startstr = "main.cpp:") + ### clang compiled code reported main.cpp:94? + ### startstr = "main.cpp:93") # We should be stopped on the breakpoint with a hit count of 1. - self.assertTrue(breakpoint.GetHitCount() == 1) + self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) + + self.process.Continue() def class_types_expr_parser(self): """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Oct 6 21:04:14 2010 @@ -99,6 +99,7 @@ -p : specify a regexp filename pattern for inclusion in the test suite -t : trace lldb command execution and result -v : do verbose mode of unittest framework +-w : insert some wait time (currently 0.5 sec) between consecutive test cases and: args : specify a list of directory names to search for python Test*.py scripts @@ -191,6 +192,9 @@ elif sys.argv[index].startswith('-v'): verbose = 2 index += 1 + elif sys.argv[index].startswith('-w'): + os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] = 'YES' + index += 1 else: print "Unknown option: ", sys.argv[index] usage() Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115899&r1=115898&r2=115899&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Oct 6 21:04:14 2010 @@ -167,6 +167,64 @@ # # Returns the enum from the input string. # +def StateTypeEnum(string): + if string == "Invalid": + return 0 + elif string == "Unloaded": + return 1 + elif string == "Attaching": + return 2 + elif string == "Launching": + return 3 + elif string == "Stopped": + return 4 + elif string == "Running": + return 5 + elif string == "Stepping": + return 6 + elif string == "Crashed": + return 7 + elif string == "Detached": + return 8 + elif string == "Exited": + return 9 + elif string == "Suspended": + return 10 + else: + raise Exception("Unknown stateType string") + +# +# Returns the stateType string given an enum. +# +def StateTypeString(enum): + if enum == 0: + return "Invalid" + elif enum == 1: + return "Unloaded" + elif enum == 2: + return "Attaching" + elif enum == 3: + return "Launching" + elif enum == 4: + return "Stopped" + elif enum == 5: + return "Running" + elif enum == 6: + return "Stepping" + elif enum == 7: + return "Crashed" + elif enum == 8: + return "Detached" + elif enum == 9: + return "Exited" + elif enum == 10: + return "Suspended" + else: + raise Exception("Unknown stopReason enum") + +# +# Returns the enum from the input string. +# def StopReasonEnum(string): if string == "Invalid": return 0 @@ -354,6 +412,10 @@ #import traceback #traceback.print_stack() + if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and + os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): + time.sleep(0.5) + if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) @@ -401,8 +463,9 @@ if self.runStarted: self.runCmd("process kill", PROCESS_KILLED, check=False) elif self.process and self.process.IsValid(): - rc = self.process.Kill() + rc = self.invoke(self.process, "Kill") self.assertTrue(rc.Success(), PROCESS_KILLED) + del self.process del self.dbg From gclayton at apple.com Wed Oct 6 23:19:01 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 07 Oct 2010 04:19:01 -0000 Subject: [Lldb-commits] [lldb] r115902 - in /lldb/trunk: examples/python/ include/lldb/ include/lldb/API/ scripts/ scripts/Python/ source/API/ source/Commands/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20101007041901.CAF642A6C12C@llvm.org> Author: gclayton Date: Wed Oct 6 23:19:01 2010 New Revision: 115902 URL: http://llvm.org/viewvc/llvm-project?rev=115902&view=rev Log: Cleaned up the SWIG stuff so all includes happen as they should, no pulling tricks to get types to resolve. I did this by correctly including the correct files: stdint.h and all lldb-*.h files first before including the API files. This allowed me to remove all of the hacks that were in the lldb.swig file and it also allows all of the #defines in lldb-defines.h and enumerations in lldb-enumerations.h to appear in the lldb.py module. This will make the python script code a lot more readable. Cleaned up the "process launch" command to not execute a "process continue" command, it now just does what it should have with the internal API calls instead of executing another command line command. Made the lldb_private::Process set the state to launching and attaching if WillLaunch/WillAttach return no error respectively. Modified: lldb/trunk/examples/python/disasm.py lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/lldb-defines.h lldb/trunk/scripts/Python/build-swig-Python.sh lldb/trunk/scripts/Python/python-extensions.swig lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/examples/python/disasm.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Wed Oct 6 23:19:01 2010 @@ -28,52 +28,65 @@ debugger.SetAsync (False) # Create a target from a file and arch -target = debugger.CreateTargetWithFileAndArch (sys.argv[1], "x86_64") +print "Creating a target for '%s'" % sys.argv[1] + +target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT) if target.IsValid(): # If the target is valid set a breakpoint at main main_bp = target.BreakpointCreateByName ("main", sys.argv[1]); - + + print main_bp + # Launch the process. Since we specified synchronous mode, we won't return # from this function until we hit the breakpoint at main - process = target.LaunchProcess (sys.argv[2:], [''], "/dev/stdout", 0, False) + process = target.LaunchProcess ([''], [''], "/dev/stdout", 0, False) # Make sure the launch went ok if process.IsValid(): # Print some simple process info - print "process:", process, "\n" - # Get the first thread - thread = process.GetThreadAtIndex (0) - if thread.IsValid(): - # Print some simple thread info - print "thread: ", thread - # Get the first frame - frame = thread.GetFrameAtIndex (0) - if frame.IsValid(): - # Print some simple frame info - print "frame: ", frame - function = frame.GetFunction() - # See if we have debug info (a function) - if function.IsValid(): - # We do have a function, print some info for the function - print "function: ", function, "\n" - # Now get all instructions for this function and print them - insts = function.GetInstructions(target) - disassemble_instructions (insts) - else: - # See if we have a symbol in the symbol table for where we stopped - symbol = frame.GetSymbol(); - if symbol.IsValid(): - # We do have a symbol, print some info for the symbol - print "symbol: ", symbol, "\n" - # Now get all instructions for this symbol and print them - insts = symbol.GetInstructions(target) + state = process.GetState () + print process + if state == lldb.eStateStopped: + # Get the first thread + thread = process.GetThreadAtIndex (0) + if thread.IsValid(): + # Print some simple thread info + print thread + # Get the first frame + frame = thread.GetFrameAtIndex (0) + if frame.IsValid(): + # Print some simple frame info + print frame + function = frame.GetFunction() + # See if we have debug info (a function) + if function.IsValid(): + # We do have a function, print some info for the function + print function + # Now get all instructions for this function and print them + insts = function.GetInstructions(target) disassemble_instructions (insts) - # 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:", process, "\n" + else: + # See if we have a symbol in the symbol table for where we stopped + symbol = frame.GetSymbol(); + if symbol.IsValid(): + # We do have a symbol, print some info for the symbol + print symbol + # Now get all instructions for this symbol and print them + insts = symbol.GetInstructions(target) + disassemble_instructions (insts) + 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 + elif state == lldb.eStateExited: + print "Didn't hit the breakpoint at main, program has exited..." + else: + print "Unexpected process state: %s, killing process..." % debugger.StateAsCString (state) + process.Kill() + lldb.SBDebugger.Terminate() Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Wed Oct 6 23:19:01 2010 @@ -105,7 +105,7 @@ GetNumLocations() const; bool - GetDescription (const char *description_level, lldb::SBStream &description); + GetDescription (lldb::SBStream &description); static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Wed Oct 6 23:19:01 2010 @@ -72,7 +72,7 @@ const char *last_char, int match_start_point, int max_return_elements, - SBStringList &matches); + lldb::SBStringList &matches); protected: Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct 6 23:19:01 2010 @@ -57,29 +57,29 @@ // DEPRECATED in favor of the function below that contains an SBError as the // last parameter. -// lldb::SBProcess -// LaunchProcess (char const **argv, -// char const **envp, -// const char *tty, -// uint32_t launch_flags, // See lldb::LaunchFlags -// bool stop_at_entry); - lldb::SBProcess LaunchProcess (char const **argv, char const **envp, const char *tty, - uint32_t launch_flags, // See lldb::LaunchFlags - bool stop_at_entry, - SBError& error); + uint32_t launch_flags, // See LaunchFlags + bool stop_at_entry); lldb::SBProcess - AttachToProcess (lldb::pid_t pid, // The process ID to attach to - SBError& error); // An error explaining what went wrong if attach fails + Launch (char const **argv, + char const **envp, + const char *tty, + uint32_t launch_flags, // See LaunchFlags + bool stop_at_entry, + lldb::SBError& error); + + lldb::SBProcess + AttachToProcessWithID (lldb::pid_t pid, // The process ID to attach to + lldb::SBError& error); // An error explaining what went wrong if attach fails lldb::SBProcess - AttachToProcess (const char *name, // basename of process to attach to - bool wait_for, // if true wait for a new instance of "name" to be launched - SBError& error); // An error explaining what went wrong if attach fails + AttachToProcessWithName (const char *name, // basename of process to attach to + bool wait_for, // if true wait for a new instance of "name" to be launched + lldb::SBError& error); // An error explaining what went wrong if attach fails lldb::SBFileSpec GetExecutable (); Modified: lldb/trunk/include/lldb/lldb-defines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-defines.h (original) +++ lldb/trunk/include/lldb/lldb-defines.h Wed Oct 6 23:19:01 2010 @@ -23,12 +23,12 @@ //---------------------------------------------------------------------- // lldb defines //---------------------------------------------------------------------- -#define LLDB_GENERIC_ERROR ((uint32_t)UINT32_MAX) +#define LLDB_GENERIC_ERROR UINT32_MAX //---------------------------------------------------------------------- // Breakpoints //---------------------------------------------------------------------- -#define LLDB_INVALID_BREAK_ID ((lldb::break_id_t)0) +#define LLDB_INVALID_BREAK_ID 0 #define LLDB_DEFAULT_BREAK_SIZE 0 #define LLDB_BREAK_ID_IS_VALID(bid) ((bid) != (LLDB_INVALID_BREAK_ID)) #define LLDB_BREAK_ID_IS_INTERNAL(bid) ((bid) < 0) @@ -36,7 +36,7 @@ //---------------------------------------------------------------------- // Watchpoints //---------------------------------------------------------------------- -#define LLDB_INVALID_WATCH_ID ((lldb::user_id_t)0) +#define LLDB_INVALID_WATCH_ID 0 #define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID)) #define LLDB_WATCH_TYPE_READ (1u << 0) #define LLDB_WATCH_TYPE_WRITE (1u << 1) @@ -53,14 +53,14 @@ //---------------------------------------------------------------------- /// Invalid value definitions //---------------------------------------------------------------------- -#define LLDB_INVALID_ADDRESS (~((lldb::addr_t)0)) -#define LLDB_INVALID_INDEX32 ((uint32_t)UINT32_MAX) -#define LLDB_INVALID_REGNUM ((uint32_t)UINT32_MAX) -#define LLDB_INVALID_UID ((lldb::user_id_t)UINT32_MAX) -#define LLDB_INVALID_PROCESS_ID ((lldb::pid_t)0) -#define LLDB_INVALID_THREAD_ID ((lldb::tid_t)0) -#define LLDB_INVALID_FRAME_ID ((uint32_t) UINT32_MAX) -#define LLDB_INVALID_SIGNAL_NUMBER ((int32_t) INT32_MAX) +#define LLDB_INVALID_ADDRESS UINT64_MAX +#define LLDB_INVALID_INDEX32 UINT32_MAX +#define LLDB_INVALID_REGNUM UINT32_MAX +#define LLDB_INVALID_UID UINT32_MAX +#define LLDB_INVALID_PROCESS_ID 0 +#define LLDB_INVALID_THREAD_ID 0 +#define LLDB_INVALID_FRAME_ID UINT32_MAX +#define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX //---------------------------------------------------------------------- /// CPU Type defintions Modified: lldb/trunk/scripts/Python/build-swig-Python.sh URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/scripts/Python/build-swig-Python.sh (original) +++ lldb/trunk/scripts/Python/build-swig-Python.sh Wed Oct 6 23:19:01 2010 @@ -29,7 +29,7 @@ fi -HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-types.h"\ +HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-include.h"\ " ${SRC_ROOT}/include/lldb/API/SBAddress.h"\ " ${SRC_ROOT}/include/lldb/API/SBBlock.h"\ " ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\ @@ -37,6 +37,7 @@ " ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\ " ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\ " ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\ +" ${SRC_ROOT}/include/lldb/API/SBCommunication.h"\ " ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\ " ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\ " ${SRC_ROOT}/include/lldb/API/SBError.h"\ @@ -44,6 +45,8 @@ " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\ " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\ " ${SRC_ROOT}/include/lldb/API/SBFunction.h"\ +" ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\ +" ${SRC_ROOT}/include/lldb/API/SBInputReader.h"\ " ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\ " ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\ " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\ @@ -55,6 +58,7 @@ " ${SRC_ROOT}/include/lldb/API/SBStringList.h"\ " ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\ " ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\ +" ${SRC_ROOT}/include/lldb/API/SBSymbolContextList.h"\ " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\ " ${SRC_ROOT}/include/lldb/API/SBThread.h"\ " ${SRC_ROOT}/include/lldb/API/SBType.h"\ @@ -143,7 +147,7 @@ # Build the SWIG C++ wrapper file for Python. -swig -c++ -shadow -python -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" +swig -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}" # Append global variable to lldb Python module. Modified: lldb/trunk/scripts/Python/python-extensions.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-extensions.swig (original) +++ lldb/trunk/scripts/Python/python-extensions.swig Wed Oct 6 23:19:01 2010 @@ -16,7 +16,7 @@ %extend lldb::SBBreakpoint { PyObject *lldb::SBBreakpoint::__repr__ (){ lldb::SBStream description; - $self->GetDescription ("full", description); + $self->GetDescription (description); return PyString_FromString (description.GetData()); } } Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Oct 6 23:19:01 2010 @@ -13,17 +13,6 @@ %module lldb -%typemap(in) lldb::ReturnStatus { - $1 = (int) $input; -} - -%typemap(freearg) lldb::ReturnStatus { -} - -%typemap(out) lldb::ReturnStatus { - $result = SWIG_From_unsigned_SS_int(static_cast< unsigned int >($1)); -} - /* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */ %typemap(in) char ** { @@ -70,7 +59,7 @@ /* The liblldb header files to be included. */ %{ -#include "lldb/lldb-types.h" +#include "lldb/lldb-include.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" @@ -78,6 +67,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBCommunication.h" #include "lldb/API/SBCompileUnit.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" @@ -85,6 +75,8 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFrame.h" #include "lldb/API/SBFunction.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/API/SBInputReader.h" #include "lldb/API/SBInstruction.h" #include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLineEntry.h" @@ -96,6 +88,7 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBSymbolContextList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" #include "lldb/API/SBType.h" @@ -109,35 +102,15 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include "lldb/lldb-forward-rtti.h" -using namespace lldb_private; %} /* Various liblldb typedefs that SWIG needs to know about. */ - -%{ -typedef unsigned int uint32_t; -typedef int int32_t; -typedef uint32_t tid_t; -typedef uint64_t addr_t; -typedef int32_t break_id_t; -typedef lldb::SBStringList SBStringList; -typedef lldb::RegisterKind RegisterKind; -const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ; -%} - -typedef unsigned int uint32_t; -typedef int int32_t; -typedef uint32_t tid_t; -typedef uint64_t addr_t; -typedef int32_t break_id_t; -typedef lldb::SBStringList SBStringList; -typedef lldb::RegisterKind RegisterKind; -const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ; -typedef int StateType; -typedef int StopReason; - - +%include +%include "lldb/lldb-defines.h" +%include "lldb/lldb-enumerations.h" +%include "lldb/lldb-forward.h" +%include "lldb/lldb-forward-rtti.h" +%include "lldb/lldb-types.h" %include "lldb/API/SBAddress.h" %include "lldb/API/SBBlock.h" %include "lldb/API/SBBreakpoint.h" @@ -145,6 +118,7 @@ %include "lldb/API/SBBroadcaster.h" %include "lldb/API/SBCommandInterpreter.h" %include "lldb/API/SBCommandReturnObject.h" +%include "lldb/API/SBCommunication.h" %include "lldb/API/SBCompileUnit.h" %include "lldb/API/SBDebugger.h" %include "lldb/API/SBError.h" @@ -152,6 +126,8 @@ %include "lldb/API/SBFileSpec.h" %include "lldb/API/SBFrame.h" %include "lldb/API/SBFunction.h" +%include "lldb/API/SBHostOS.h" +%include "lldb/API/SBInputReader.h" %include "lldb/API/SBInstruction.h" %include "lldb/API/SBInstructionList.h" %include "lldb/API/SBLineEntry.h" @@ -163,12 +139,12 @@ %include "lldb/API/SBStringList.h" %include "lldb/API/SBSymbol.h" %include "lldb/API/SBSymbolContext.h" +%include "lldb/API/SBSymbolContextList.h" %include "lldb/API/SBTarget.h" %include "lldb/API/SBThread.h" %include "lldb/API/SBType.h" %include "lldb/API/SBValue.h" %include "lldb/API/SBValueList.h" -%include "lldb/lldb-types.h" %include "./Python/python-extensions.swig" @@ -177,21 +153,24 @@ bool -ScriptInterpreterPython::BreakpointCallbackFunction (void *baton, - StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id) +lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction +( + void *baton, + lldb_private::StoppointCallbackContext *context, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id +) { bool ret_value = true; - BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; + lldb_private::BreakpointOptions::CommandData *bp_option_data = (lldb_private::BreakpointOptions::CommandData *) baton; const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); if (python_function_name != NULL && python_function_name[0] != '\0') { - Thread *thread = context->exe_ctx.thread; - Target *target = context->exe_ctx.target; + lldb_private::Thread *thread = context->exe_ctx.thread; + lldb_private::Target *target = context->exe_ctx.target; const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Oct 6 23:19:01 2010 @@ -323,28 +323,19 @@ } bool -SBBreakpoint::GetDescription (const char *description_level, SBStream &description) +SBBreakpoint::GetDescription (SBStream &s) { if (m_opaque_sp) { - DescriptionLevel level; - if (strcmp (description_level, "brief") == 0) - level = eDescriptionLevelBrief; - else if (strcmp (description_level, "full") == 0) - level = eDescriptionLevelFull; - else if (strcmp (description_level, "verbose") == 0) - level = eDescriptionLevelVerbose; - else - level = eDescriptionLevelBrief; - - description.ref(); - m_opaque_sp->GetDescription (description.get(), level); - description.get()->EOL(); + s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); + m_opaque_sp->GetResolverDescription (s.get()); + m_opaque_sp->GetFilterDescription (s.get()); + const size_t num_locations = m_opaque_sp->GetNumLocations (); + s.Printf(", locations = %zu", num_locations); + return true; } - else - description.Printf ("No value"); - - return true; + s.Printf ("No value"); + return false; } bool Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Wed Oct 6 23:19:01 2010 @@ -402,8 +402,7 @@ { if (m_opaque_sp) { - description.ref(); - m_opaque_sp->DumpUsingSettingsFormat (description.get()); + description.Printf("SBFrame: idx = %u", m_opaque_sp->GetFrameIndex()); } else description.Printf ("No value"); Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Wed Oct 6 23:19:01 2010 @@ -14,6 +14,7 @@ #include "lldb/Core/Module.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" @@ -70,17 +71,20 @@ } bool -SBFunction::GetDescription (SBStream &description) +SBFunction::GetDescription (SBStream &s) { if (m_opaque_ptr) { - description.ref(); - m_opaque_ptr->Dump (description.get(), false); + s.Printf ("SBFunction: id = 0x%8.8x, name = %s", + m_opaque_ptr->GetID(), + m_opaque_ptr->GetName().AsCString()); + Type *func_type = m_opaque_ptr->GetType(); + if (func_type) + s.Printf(", type = %s", func_type->GetName().AsCString()); + return true; } - else - description.Printf ("No value"); - - return true; + s.Printf ("No value"); + return false; } SBInstructionList Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Oct 6 23:19:01 2010 @@ -488,11 +488,11 @@ if (exe_module) exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); - description.Printf ("Process {pid: %d, state: %s, threads: %d%s%s}", + description.Printf ("SBProcess: pid = %d, state = %s, threads = %d%s%s", m_opaque_sp->GetID(), SBDebugger::StateAsCString (GetState()), GetNumThreads(), - exe_name ? ", executable: " : "", + exe_name ? ", executable = " : "", exe_name ? exe_name : ""); } else Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Oct 6 23:19:01 2010 @@ -119,21 +119,6 @@ } -// SBProcess -// SBTarget::LaunchProcess -// ( -// char const **argv, -// char const **envp, -// const char *tty, -// uint32_t launch_flags, -// bool stop_at_entry -// ) -// { -// SBError sb_error; -// return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error); -// } - - SBProcess SBTarget::LaunchProcess ( @@ -141,6 +126,20 @@ char const **envp, const char *tty, uint32_t launch_flags, + bool stop_at_entry +) +{ + SBError sb_error; + return Launch (argv, envp, tty, launch_flags, stop_at_entry, sb_error); +} + +SBProcess +SBTarget::Launch +( + char const **argv, + char const **envp, + const char *tty, + uint32_t launch_flags, bool stop_at_entry, SBError &error ) @@ -165,14 +164,14 @@ error.SetError (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty)); if (error.Success()) { - // We we are stopping at the entry point, we can return now! - if (stop_at_entry) - return sb_process; - // Make sure we are stopped at the entry StateType state = sb_process->WaitForProcessToStop (NULL); if (state == eStateStopped) { + // We we are stopping at the entry point, we can return now! + if (stop_at_entry) + return sb_process; + // resume the process to skip the entry point error.SetError (sb_process->Resume()); if (error.Success()) @@ -199,7 +198,7 @@ lldb::SBProcess -SBTarget::AttachToProcess +SBTarget::AttachToProcessWithID ( lldb::pid_t pid,// The process ID to attach to SBError& error // An error explaining what went wrong if attach fails @@ -238,7 +237,7 @@ } lldb::SBProcess -SBTarget::AttachToProcess +SBTarget::AttachToProcessWithName ( const char *name, // basename of process to attach to bool wait_for, // if true wait for a new instance of "name" to be launched Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Wed Oct 6 23:19:01 2010 @@ -452,7 +452,10 @@ SBThread::GetDescription (SBStream &description) { if (m_opaque_sp) - m_opaque_sp->DumpUsingSettingsFormat (description.ref(), 0); + { + StreamString strm; + description.Printf("SBThread: tid = 0x%4.4x", m_opaque_sp->GetID()); + } else description.Printf ("No value"); Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Oct 6 23:19:01 2010 @@ -133,13 +133,9 @@ } bool - Execute (Args& launch_args, - CommandReturnObject &result) + Execute (Args& launch_args, CommandReturnObject &result) { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - bool synchronous_execution = m_interpreter.GetSynchronous (); - // bool launched = false; - // bool stopped_after_launch = false; if (target == NULL) { @@ -235,22 +231,29 @@ if (error.Success()) { result.AppendMessageWithFormat ("Launching '%s' (%s)\n", filename, archname); - result.SetStatus (eReturnStatusSuccessContinuingNoResult); + result.SetDidChangeProcessState (true); if (m_options.stop_at_entry == false) { + result.SetStatus (eReturnStatusSuccessContinuingNoResult); StateType state = process->WaitForProcessToStop (NULL); if (state == eStateStopped) { - // Call continue_command. - CommandReturnObject continue_result; - m_interpreter.HandleCommand("process continue", false, continue_result); - } - - if (synchronous_execution) - { - result.SetDidChangeProcessState (true); - result.SetStatus (eReturnStatusSuccessFinishNoResult); + error = process->Resume(); + if (error.Success()) + { + bool synchronous_execution = m_interpreter.GetSynchronous (); + if (synchronous_execution) + { + state = process->WaitForProcessToStop (NULL); + result.SetDidChangeProcessState (true); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.SetStatus (eReturnStatusSuccessContinuingNoResult); + } + } } } } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Wed Oct 6 23:19:01 2010 @@ -360,7 +360,6 @@ Log *log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_PROCESS); if (attach_pid != LLDB_INVALID_PROCESS_ID) { - SetPrivateState (eStateAttaching); SetID(attach_pid); // Let ourselves know we are going to be using SBS if the correct flag bit is set... #if defined (__arm__) @@ -1642,8 +1641,6 @@ if (launch_type == eLaunchPosixSpawn) { - - //SetState (eStateAttaching); errno = 0; if (::ptrace (PT_ATTACHEXC, pid, 0, 0) == 0) launch_err.Clear(); @@ -1967,7 +1964,6 @@ // m_args.push_back(arg); Task().StartExceptionThread(); StartSTDIOThread(); - SetState (eStateAttaching); int err = ptrace (PT_ATTACHEXC, m_pid, 0, 0); if (err == 0) { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct 6 23:19:01 2010 @@ -652,7 +652,6 @@ if (attach_pid != LLDB_INVALID_PROCESS_ID) { - SetPrivateState (eStateAttaching); char host_port[128]; snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ()); error = StartDebugserverProcess (host_port, // debugserver_url @@ -753,8 +752,6 @@ //Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS); if (process_name && process_name[0]) { - - SetPrivateState (eStateAttaching); char host_port[128]; ArchSpec arch_spec = GetTarget().GetArchitecture(); snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ()); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=115902&r1=115901&r2=115902&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Oct 6 23:19:01 2010 @@ -198,9 +198,14 @@ { EventSP event_sp; uint32_t i; - StateType state = eStateUnloaded; + StateType state = GetState(); while (state != eStateInvalid) { + // If we are exited or detached, we won't ever get back to any + // other valid state... + if (state == eStateDetached || state == eStateExited) + return state; + state = WaitForStateChangedEvents (timeout, event_sp); for (i=0; i Author: johnny Date: Thu Oct 7 10:41:55 2010 New Revision: 115916 URL: http://llvm.org/viewvc/llvm-project?rev=115916&view=rev Log: Fix logic error of the option processing loop. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=115916&r1=115915&r2=115916&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Oct 7 10:41:55 2010 @@ -143,7 +143,7 @@ # Process possible trace and/or verbose flag, among other things. index = 1 - for i in range(1, len(sys.argv)): + while index < len(sys.argv): if not sys.argv[index].startswith('-'): # End of option processing. break From johnny.chen at apple.com Thu Oct 7 11:06:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 16:06:12 -0000 Subject: [Lldb-commits] [lldb] r115917 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20101007160612.A4DE62A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 11:06:12 2010 New Revision: 115917 URL: http://llvm.org/viewvc/llvm-project?rev=115917&view=rev Log: Use the updated process launch API. Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115917&r1=115916&r2=115917&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Thu Oct 7 11:06:12 2010 @@ -106,7 +106,7 @@ # Now launch the process, and do not stop at entry point. rc = lldb.SBError() - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False, rc) + self.process = target.Launch([''], [''], os.ctermid(), 0, False, rc) #self.breakAfterLaunch(self.process, "C::C(int, int, int)") if not rc.Success() or not self.process.IsValid(): From johnny.chen at apple.com Thu Oct 7 11:23:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 16:23:37 -0000 Subject: [Lldb-commits] [lldb] r115918 - /lldb/trunk/test/array_types/TestArrayTypes.py Message-ID: <20101007162337.EB8D22A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 11:23:37 2010 New Revision: 115918 URL: http://llvm.org/viewvc/llvm-project?rev=115918&view=rev Log: Updated expected match strings because the print representations of SBProcess, SBThread, SBBreakpoint, and SBFrame have changed. Modified: lldb/trunk/test/array_types/TestArrayTypes.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=115918&r1=115917&r2=115918&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Thu Oct 7 11:23:37 2010 @@ -109,8 +109,8 @@ # Sanity check the print representation of process. proc = repr(self.process) self.expect(proc, msg="Process looks good", exe=False, - substrs = ["state: Stopped", - "executable: a.out"]) + substrs = ["state = Stopped", + "executable = a.out"]) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) @@ -120,9 +120,7 @@ # Sanity check the print representation of thread. thr = repr(thread) self.expect(thr, "Thread looks good with stop reason = breakpoint", exe=False, - substrs = ["thread #%d: tid = 0x%4.4x" % (thread.GetIndexID(), thread.GetThreadID()), - "stop reason = breakpoint", - "queue = %s" % thread.GetQueueName() if thread.GetQueueName() else ""]) + substrs = ["tid = 0x%4.4x" % thread.GetThreadID()]) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) @@ -132,15 +130,15 @@ self.expect(bp, "Breakpoint looks good and is resolved", exe=False, substrs = ["file ='main.c'", "line = 42", - "locations = 1", - "resolved = 1"]) + "locations = 1"]) # Sanity check the print representation of frame. frame = thread.GetFrameAtIndex(0) frm = repr(frame) - self.expect(frm, "Thread looks good with correct frame function", exe=False, - substrs = ["frame #%d" % frame.GetFrameID(), - "a.out`%s" % frame.GetFunction().GetName()]) + self.expect(frm, + "Frame looks good with correct index %d" % frame.GetFrameID(), + exe=False, + substrs = ["idx = %d" % frame.GetFrameID()]) # Lookup the "strings" string array variable and sanity check its print # representation. From johnny.chen at apple.com Thu Oct 7 11:51:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 16:51:56 -0000 Subject: [Lldb-commits] [lldb] r115922 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py class_types/TestClassTypes.py hello_world/TestHelloWorld.py lldbtest.py Message-ID: <20101007165156.41C622A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 11:51:56 2010 New Revision: 115922 URL: http://llvm.org/viewvc/llvm-project?rev=115922&view=rev Log: Clean up the StateType and StopReason enums now that they reside in the lldb module. Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/hello_world/TestHelloWorld.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=115922&r1=115921&r2=115922&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Thu Oct 7 11:51:56 2010 @@ -114,7 +114,7 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # Sanity check the print representation of thread. Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=115922&r1=115921&r2=115922&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Thu Oct 7 11:51:56 2010 @@ -93,7 +93,7 @@ # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115922&r1=115921&r2=115922&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Thu Oct 7 11:51:56 2010 @@ -112,7 +112,7 @@ if not rc.Success() or not self.process.IsValid(): self.fail("SBTarget.LaunchProcess() failed") - if self.process.GetState() != StateTypeEnum("Stopped"): + if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'Stopped' state, " "instead the actual state is: '%s'" % StateTypeString(self.process.GetState())) @@ -120,9 +120,8 @@ # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) - self.expect(StopReasonString(thread.GetStopReason()), - STOPPED_DUE_TO_BREAKPOINT, exe=False, - startstr = "Breakpoint") + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, + STOPPED_DUE_TO_BREAKPOINT) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=115922&r1=115921&r2=115922&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Thu Oct 7 11:51:56 2010 @@ -69,7 +69,7 @@ self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == StopReasonEnum("Breakpoint"), + self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT) # The breakpoint should have a hit count of 1. Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115922&r1=115921&r2=115922&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Oct 7 11:51:56 2010 @@ -165,105 +165,53 @@ return "'%s' compares successfully" % str # -# Returns the enum from the input string. -# -def StateTypeEnum(string): - if string == "Invalid": - return 0 - elif string == "Unloaded": - return 1 - elif string == "Attaching": - return 2 - elif string == "Launching": - return 3 - elif string == "Stopped": - return 4 - elif string == "Running": - return 5 - elif string == "Stepping": - return 6 - elif string == "Crashed": - return 7 - elif string == "Detached": - return 8 - elif string == "Exited": - return 9 - elif string == "Suspended": - return 10 - else: - raise Exception("Unknown stateType string") - -# # Returns the stateType string given an enum. # def StateTypeString(enum): - if enum == 0: + if enum == lldb.eStateInvalid: return "Invalid" - elif enum == 1: + elif enum == lldb.eStateUnloaded: return "Unloaded" - elif enum == 2: + elif enum == lldb.eStateAttaching: return "Attaching" - elif enum == 3: + elif enum == lldb.eStateLaunching: return "Launching" - elif enum == 4: + elif enum == lldb.eStateStopped: return "Stopped" - elif enum == 5: + elif enum == lldb.eStateRunning: return "Running" - elif enum == 6: + elif enum == lldb.eStateStepping: return "Stepping" - elif enum == 7: + elif enum == lldb.eStateCrashed: return "Crashed" - elif enum == 8: + elif enum == lldb.eStateDetached: return "Detached" - elif enum == 9: + elif enum == lldb.eStateExited: return "Exited" - elif enum == 10: + elif enum == lldb.eStateSuspended: return "Suspended" else: raise Exception("Unknown stopReason enum") # -# Returns the enum from the input string. -# -def StopReasonEnum(string): - if string == "Invalid": - return 0 - elif string == "None": - return 1 - elif string == "Trace": - return 2 - elif string == "Breakpoint": - return 3 - elif string == "Watchpoint": - return 4 - elif string == "Signal": - return 5 - elif string == "Exception": - return 6 - elif string == "PlanComplete": - return 7 - else: - raise Exception("Unknown stopReason string") - -# # Returns the stopReason string given an enum. # def StopReasonString(enum): - if enum == 0: + if enum == lldb.eStopReasonInvalid: return "Invalid" - elif enum == 1: + elif enum == lldb.eStopReasonNone: return "None" - elif enum == 2: + elif enum == lldb.eStopReasonTrace: return "Trace" - elif enum == 3: + elif enum == lldb.eStopReasonBreakpoint: return "Breakpoint" - elif enum == 4: + elif enum == lldb.eStopReasonWatchpoint: return "Watchpoint" - elif enum == 5: + elif enum == lldb.eStopReasonSignal: return "Signal" - elif enum == 6: + elif enum == lldb.eStopReasonException: return "Exception" - elif enum == 7: + elif enum == lldb.eStopReasonPlanComplete: return "PlanComplete" else: raise Exception("Unknown stopReason enum") From gclayton at apple.com Thu Oct 7 12:14:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 07 Oct 2010 17:14:24 -0000 Subject: [Lldb-commits] [lldb] r115926 - in /lldb/trunk: scripts/lldb.swig source/Interpreter/ScriptInterpreterPython.cpp tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101007171424.857D72A6C12E@llvm.org> Author: gclayton Date: Thu Oct 7 12:14:24 2010 New Revision: 115926 URL: http://llvm.org/viewvc/llvm-project?rev=115926&view=rev Log: More SWIG cleanup. Moved the breakpoint callback function back to the ScriptInterpreterPython class and made a simple callback function that ScriptInterpreterPython::BreakpointCallbackFunction() now calls so we don't include any internal API stuff into the cpp file that is generated by SWIG. Fixed a few build warnings in debugserver. Modified: lldb/trunk/scripts/lldb.swig lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115926&r1=115925&r2=115926&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Thu Oct 7 12:14:24 2010 @@ -94,14 +94,6 @@ #include "lldb/API/SBType.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBValueList.h" -#include "lldb/Interpreter/ScriptInterpreterPython.h" -#include "lldb/Breakpoint/Breakpoint.h" -#include "lldb/Breakpoint/BreakpointLocation.h" -#include "lldb/Breakpoint/StoppointCallbackContext.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Target/StackFrame.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" %} /* Various liblldb typedefs that SWIG needs to know about. */ @@ -151,96 +143,74 @@ %wrapper %{ +// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) +// and is used when a script command is attached to a breakpoint for execution. -bool -lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction +SWIGEXPORT bool +LLDBSWIGPythonBreakpointCallbackFunction ( - void *baton, - lldb_private::StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id + const char *python_function_name, + lldb::SBFrame& sb_frame, + lldb::SBBreakpointLocation& sb_bp_loc ) { - bool ret_value = true; + bool stop_at_breakpoint = true; + PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); + PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); - lldb_private::BreakpointOptions::CommandData *bp_option_data = (lldb_private::BreakpointOptions::CommandData *) baton; - const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); + if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL) + return stop_at_breakpoint; + + PyObject *pmodule, *pdict, *pfunc; + PyObject *pargs, *pvalue; - if (python_function_name != NULL - && python_function_name[0] != '\0') + pmodule = PyImport_AddModule ("__main__"); + if (pmodule != NULL) { - lldb_private::Thread *thread = context->exe_ctx.thread; - lldb_private::Target *target = context->exe_ctx.target; - const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); - lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); - const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); - - lldb::SBFrame sb_frame (stop_frame_sp); - lldb::SBBreakpointLocation sb_bp_loc (bp_loc_sp); - - if (!sb_bp_loc.IsValid() || !sb_frame.IsValid()) - return ret_value; - - - PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0); - PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0); - - if (Frame_PyObj == NULL - || Bp_Loc_PyObj == NULL) - return ret_value; - - PyObject *pmodule, *pdict, *pfunc; - PyObject *pargs, *pvalue; - - pmodule = PyImport_AddModule ("__main__"); - if (pmodule != NULL) + pdict = PyModule_GetDict (pmodule); + if (pdict != NULL) { - pdict = PyModule_GetDict (pmodule); - if (pdict != NULL) + pfunc = PyObject_GetAttrString (pmodule, python_function_name); + if (pfunc && PyCallable_Check (pfunc)) { - pfunc = PyObject_GetAttrString (pmodule, python_function_name); - if (pfunc && PyCallable_Check (pfunc)) + pargs = PyTuple_New (2); + if (pargs == NULL) { - pargs = PyTuple_New (2); - if (pargs == NULL) - { - if (PyErr_Occurred()) - PyErr_Clear(); - return ret_value; - } - - PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj - PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj - pvalue = PyObject_CallObject (pfunc, pargs); - Py_DECREF (pargs); - - if (pvalue != NULL) - { - Py_DECREF (pvalue); - } - else if (PyErr_Occurred ()) - { + if (PyErr_Occurred()) PyErr_Clear(); - } - Py_DECREF (pfunc); + return stop_at_breakpoint; + } + + PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj + PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj + pvalue = PyObject_CallObject (pfunc, pargs); + Py_DECREF (pargs); + + if (pvalue != NULL) + { + Py_DECREF (pvalue); } - else if (PyErr_Occurred()) + else if (PyErr_Occurred ()) { PyErr_Clear(); } + Py_DECREF (pfunc); } else if (PyErr_Occurred()) { PyErr_Clear(); } } - else if (PyErr_Occurred ()) + else if (PyErr_Occurred()) { - PyErr_Clear (); + PyErr_Clear(); } } - - return ret_value; + else if (PyErr_Occurred ()) + { + PyErr_Clear (); + } + return stop_at_breakpoint; } %} Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=115926&r1=115925&r2=115926&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Oct 7 12:14:24 2010 @@ -22,6 +22,8 @@ #include +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBBreakpointLocation.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" @@ -36,11 +38,20 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Core/Debugger.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Thread.h" // This function is in the C++ output file generated by SWIG after it is // run on all of the headers in "lldb/API/SB*.h" extern "C" void init_lldb (void); +extern "C" bool +LLDBSWIGPythonBreakpointCallbackFunction +( + const char *python_function_name, + lldb::SBFrame& sb_frame, + lldb::SBBreakpointLocation& sb_bp_loc +); + using namespace lldb; using namespace lldb_private; @@ -282,7 +293,7 @@ ( void *baton, InputReader &reader, - lldb::InputReaderAction notification, + InputReaderAction notification, const char *bytes, size_t bytes_len ) @@ -565,7 +576,7 @@ ( void *baton, InputReader &reader, - lldb::InputReaderAction notification, + InputReaderAction notification, const char *bytes, size_t bytes_len ) @@ -764,3 +775,34 @@ return true; } +bool +ScriptInterpreterPython::BreakpointCallbackFunction +( + void *baton, + StoppointCallbackContext *context, + user_id_t break_id, + user_id_t break_loc_id +) +{ + BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton; + const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0); + + if (python_function_name != NULL + && python_function_name[0] != '\0') + { + Thread *thread = context->exe_ctx.thread; + Target *target = context->exe_ctx.target; + const StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame); + BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id); + const BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id); + + SBFrame sb_frame (stop_frame_sp); + SBBreakpointLocation sb_bp_loc (bp_loc_sp); + + if (sb_bp_loc.IsValid() || sb_frame.IsValid()) + return LLDBSWIGPythonBreakpointCallbackFunction (python_function_name, sb_frame, sb_bp_loc); + } + // We currently always true so we stop in case anything goes wrong when + // trying to call the script function + return true; +} 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=115926&r1=115925&r2=115926&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Oct 7 12:14:24 2010 @@ -457,7 +457,6 @@ ); COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 113; - FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -477,7 +476,6 @@ ); CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; - FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIPFLAGS = "-x"; @@ -498,7 +496,6 @@ ); CURRENT_PROJECT_VERSION = 113; DEAD_CODE_STRIPPING = YES; - FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIPFLAGS = "-x"; @@ -512,7 +509,6 @@ 262419A21198A93E00067686 /* BuildAndIntegration */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 113; @@ -553,7 +549,6 @@ 26CE0596115C31C30022F371 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; @@ -595,7 +590,6 @@ 26CE0597115C31C30022F371 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; From scallanan at apple.com Thu Oct 7 13:17:31 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 07 Oct 2010 18:17:31 -0000 Subject: [Lldb-commits] [lldb] r115942 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101007181731.4031A2A6C12F@llvm.org> Author: spyffe Date: Thu Oct 7 13:17:31 2010 New Revision: 115942 URL: http://llvm.org/viewvc/llvm-project?rev=115942&view=rev Log: Changed the timeout for expressions from 10 milliseconds to 10 seconds, which was the original intent. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=115942&r1=115941&r2=115942&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Oct 7 13:17:31 2010 @@ -281,7 +281,7 @@ struct_address, true, true, - 10000, + 10000000, error_stream, (m_needs_object_ptr ? &object_ptr : NULL)); From johnny.chen at apple.com Thu Oct 7 13:49:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 18:49:04 -0000 Subject: [Lldb-commits] [lldb] r115955 - /lldb/trunk/test/conditional_break/TestConditionalBreak.py Message-ID: <20101007184904.855322A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 13:49:04 2010 New Revision: 115955 URL: http://llvm.org/viewvc/llvm-project?rev=115955&view=rev Log: Minor cleanup with added comment. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=115955&r1=115954&r2=115955&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Thu Oct 7 13:49:04 2010 @@ -50,14 +50,15 @@ substrs = ['state is Stopped', 'stop reason = breakpoint']) # Suppose we are only interested in the call scenario where c()'s - # immediate caller is a() and we want to find out the value passed - # from a(). - for j in range(3): + # immediate caller is a() and we want to find out the value passed from + # a(). + # + # The 10 in range(10) is just an arbitrary number, which means we would + # like to try for at most 10 times. + for j in range(10): target = self.dbg.GetSelectedTarget() process = target.GetProcess() thread = process.GetThreadAtIndex(0) - import lldbutil - #lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) From johnny.chen at apple.com Thu Oct 7 13:52:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 18:52:48 -0000 Subject: [Lldb-commits] [lldb] r115960 - /lldb/trunk/test/lldbutil.py Message-ID: <20101007185248.9A6472A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 13:52:48 2010 New Revision: 115960 URL: http://llvm.org/viewvc/llvm-project?rev=115960&view=rev Log: Add a keyword argument string_buffer (with a default value of False) to the PrintStackTrace(thread) function. If string_buffer is True, PrintStackTrace() will return the content of the stack trace as a string, instead. 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=115960&r1=115959&r2=115960&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Oct 7 13:52:48 2010 @@ -3,6 +3,8 @@ """ import lldb +import sys +import StringIO def GetFunctionNames(thread): """ @@ -54,8 +56,9 @@ return map(GetStackFrame, range(thread.GetNumFrames())) -def PrintStackTrace(thread): +def PrintStackTrace(thread, string_buffer = False): """Prints a simple stack trace of this thread.""" + depth = thread.GetNumFrames() mods = GetModuleNames(thread) @@ -63,11 +66,16 @@ files = GetFilenames(thread) lines = GetLineNumbers(thread) - print "Stack trace for thread id={0:#x} name={1} queue={2}:".format( + output = StringIO.StringIO() if string_buffer else sys.stdout + + print >> output, "Stack trace for thread id={0:#x} name={1} queue={2}:".format( thread.GetThreadID(), thread.GetName(), thread.GetQueueName()) for i in range(depth - 1): - print " frame #{num}: {mod}`{func} at {file}:{line}".format( + print >> output, " frame #{num}: {mod}`{func} at {file}:{line}".format( num=i, mod=mods[i], func=funcs[i], file=files[i], line=lines[i]) - print " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1]) + print >> output, " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1]) + + if string_buffer: + return output.getvalue() From johnny.chen at apple.com Thu Oct 7 16:38:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 21:38:28 -0000 Subject: [Lldb-commits] [lldb] r115983 - in /lldb/trunk/test: lldbutil.py threads/Makefile threads/TestPrintStackTraces.py threads/main.cpp Message-ID: <20101007213828.966492A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 16:38:28 2010 New Revision: 115983 URL: http://llvm.org/viewvc/llvm-project?rev=115983&view=rev Log: Add a test case which uses the SBProcess and SBThread APIs to iterate through the threads and print their stack traces when stopped on a breakpoint. Add a PrintStackTraces(process) utility function into the lldbutil.py module. Added: lldb/trunk/test/threads/TestPrintStackTraces.py Modified: lldb/trunk/test/lldbutil.py lldb/trunk/test/threads/Makefile lldb/trunk/test/threads/main.cpp Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=115983&r1=115982&r2=115983&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Oct 7 16:38:28 2010 @@ -1,5 +1,5 @@ """ -LLDB modules which contains miscellaneous utilities. +This LLDB module contains miscellaneous utilities. """ import lldb @@ -16,6 +16,26 @@ return map(GetFuncName, range(thread.GetNumFrames())) +def GetSymbolNames(thread): + """ + Returns a sequence of symbols for this thread. + """ + def GetSymbol(i): + return thread.GetFrameAtIndex(i).GetSymbol().GetName() + + return map(GetSymbol, range(thread.GetNumFrames())) + + +def GetPCAddresses(thread): + """ + Returns a sequence of pc addresses for this thread. + """ + def GetPCAddress(i): + return thread.GetFrameAtIndex(i).GetPCAddress() + + return map(GetPCAddress, range(thread.GetNumFrames())) + + def GetFilenames(thread): """ Returns a sequence of file names from the stack frames of this thread. @@ -59,23 +79,47 @@ def PrintStackTrace(thread, string_buffer = False): """Prints a simple stack trace of this thread.""" + output = StringIO.StringIO() if string_buffer else sys.stdout + target = thread.GetProcess().GetTarget() + depth = thread.GetNumFrames() mods = GetModuleNames(thread) funcs = GetFunctionNames(thread) + symbols = GetSymbolNames(thread) files = GetFilenames(thread) lines = GetLineNumbers(thread) - - output = StringIO.StringIO() if string_buffer else sys.stdout + addrs = GetPCAddresses(thread) print >> output, "Stack trace for thread id={0:#x} name={1} queue={2}:".format( thread.GetThreadID(), thread.GetName(), thread.GetQueueName()) - for i in range(depth - 1): - print >> output, " frame #{num}: {mod}`{func} at {file}:{line}".format( - num=i, mod=mods[i], func=funcs[i], file=files[i], line=lines[i]) + for i in range(depth): + frame = thread.GetFrameAtIndex(i) + function = frame.GetFunction() + + load_addr = addrs[i].GetLoadAddress(target) + if not function.IsValid(): + 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]) + else: + print >> output, " frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line}".format( + num=i, addr=load_addr, mod=mods[i], func=funcs[i], file=files[i], line=lines[i]) + + if string_buffer: + return output.getvalue() + + +def PrintStackTraces(process, string_buffer = False): + """Prints the stack traces of all the threads.""" + + output = StringIO.StringIO() if string_buffer else sys.stdout + + print >> output, "Stack traces for " + repr(process) - print >> output, " frame #{num}: {mod}`start".format(num=depth-1, mod=mods[depth-1]) + for i in range(process.GetNumThreads()): + print >> output, PrintStackTrace(process.GetThreadAtIndex(i), string_buffer=True) if string_buffer: return output.getvalue() Modified: lldb/trunk/test/threads/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/Makefile?rev=115983&r1=115982&r2=115983&view=diff ============================================================================== --- lldb/trunk/test/threads/Makefile (original) +++ lldb/trunk/test/threads/Makefile Thu Oct 7 16:38:28 2010 @@ -1,125 +1,6 @@ -#---------------------------------------------------------------------- -# Fill in the source files to build -#---------------------------------------------------------------------- -C_SOURCES := -CXX_SOURCES :=main.cpp -OBJC_SOURCES := -OBJCXX_SOURCES := - -# Uncomment line below for debugging shell commands -# SHELL = /bin/sh -x - -#---------------------------------------------------------------------- -# Change any build/tool options needed -#---------------------------------------------------------------------- -DS := /usr/bin/dsymutil -DSFLAGS = -CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 -CPLUSPLUSFLAGS +=$(CFLAGS) -CPPFLAGS +=$(CFLAGS) -LD = gcc -LDFLAGS = $(CFLAGS) -OBJECTS = -EXE=a.out -DSYM=$(EXE).dSYM - -#---------------------------------------------------------------------- -# Check if we have any C source files -#---------------------------------------------------------------------- -ifneq "$(strip $(C_SOURCES))" "" - OBJECTS +=$(strip $(C_SOURCES:.c=.o)) -endif - -#---------------------------------------------------------------------- -# Check if we have any C++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(CXX_SOURCES))" "" - OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) - LD = g++ -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJC_SOURCES))" "" - OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) - LDFLAGS +=-lobjc -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJCXX_SOURCES))" "" - OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) - LD = g++ - ifeq $(findstring lobjc,$(LDFLAGS)) "" - LDFLAGS +=-lobjc - endif -endif - - -#---------------------------------------------------------------------- -# Make the dSYM file from the executable -#---------------------------------------------------------------------- -$(DSYM) : $(EXE) - $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)" - -#---------------------------------------------------------------------- -# Compile the executable from all the objects (default rule) with no -# dsym file. -#---------------------------------------------------------------------- -$(EXE) : $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" - - -#---------------------------------------------------------------------- -# Automatic variables based on items already entered. Below we create -# an objects lists from the list of sources by replacing all entries -# that end with .c with .o, and we also create a list of prerequisite -# files by replacing all .c files with .d. -#---------------------------------------------------------------------- -PREREQS := $(OBJECTS:.o=.d) - -#---------------------------------------------------------------------- -# Rule for Generating Prerequisites Automatically using .d files and -# the compiler -MM option. The -M option will list all system headers, -# and the -MM option will list all non-system dependencies. -#---------------------------------------------------------------------- -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.cpp - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.m - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.mm - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -#---------------------------------------------------------------------- -# Include all of the makefiles for each source file so we don't have -# to manually track all of the prerequisites for each source file. -#---------------------------------------------------------------------- -sinclude $(PREREQS) - -.PHONY: clean -dsym: $(DSYM) -all: $(EXE) $(DSYM) -clean: - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) - +LEVEL = ../make +CXX_SOURCES := main.cpp +MAKE_DSYM :=NO +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/threads/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/TestPrintStackTraces.py?rev=115983&view=auto ============================================================================== --- lldb/trunk/test/threads/TestPrintStackTraces.py (added) +++ lldb/trunk/test/threads/TestPrintStackTraces.py Thu Oct 7 16:38:28 2010 @@ -0,0 +1,50 @@ +""" +Test SBprocess and SBThread APIs with printing of the stack traces. +""" + +import os, time +import re +import unittest2 +import lldb +from lldbtest import * + +class ThreadsStackTracesTestCase(TestBase): + + mydir = "threads" + + def test_stack_traces(self): + """Test SBprocess and SBThread APIs with printing of the stack traces.""" + self.buildDefault() + self.break_and_print_stacktraces() + + def break_and_print_stacktraces(self): + """Break at main.cpp:68 and do a threads dump""" + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + breakpoint = target.BreakpointCreateByLocation("main.cpp", 68) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.Launch([''], [''], os.ctermid(), 0, False, rc) + + if not rc.Success() or not self.process.IsValid(): + self.fail("SBTarget.LaunchProcess() failed") + + if self.process.GetState() != lldb.eStateStopped: + self.fail("Process should be in the 'Stopped' state, " + "instead the actual state is: '%s'" % + StateTypeString(self.process.GetState())) + + import lldbutil + lldbutil.PrintStackTraces(self.process) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Modified: lldb/trunk/test/threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/main.cpp?rev=115983&r1=115982&r2=115983&view=diff ============================================================================== --- lldb/trunk/test/threads/main.cpp (original) +++ lldb/trunk/test/threads/main.cpp Thu Oct 7 16:38:28 2010 @@ -65,6 +65,7 @@ long usec = ::random() % 3000000; printf ("%s (thread = %u) doing a usleep (%li)...\n", __FUNCTION__, thread_index, usec); ::usleep (usec); + printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); } printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); @@ -126,4 +127,4 @@ err = ::pthread_join (g_thread_3, &thread_result); return 0; -} \ No newline at end of file +} From gclayton at apple.com Thu Oct 7 17:06:19 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 07 Oct 2010 22:06:19 -0000 Subject: [Lldb-commits] [lldb] r115992 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Message-ID: <20101007220619.3708E2A6C12E@llvm.org> Author: gclayton Date: Thu Oct 7 17:06:19 2010 New Revision: 115992 URL: http://llvm.org/viewvc/llvm-project?rev=115992&view=rev Log: Make sure to lock down the sequence mutex and select the thread we want when read or write all registers. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 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=115992&r1=115991&r2=115992&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Thu Oct 7 17:06:19 2010 @@ -373,15 +373,23 @@ { GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); StringExtractorGDBRemote response; - if (gdb_comm.SendPacketAndWaitForResponse("g", response, 1, false)) + + Mutex::Locker locker; + if (gdb_comm.GetSequenceMutex (locker)) { - if (response.IsErrorPacket()) - return false; - - response.GetStringRef().insert(0, 1, 'G'); - data_sp.reset (new DataBufferHeap(response.GetStringRef().c_str(), - response.GetStringRef().size())); - return true; + if (GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + { + if (gdb_comm.SendPacketAndWaitForResponse("g", response, 1, false)) + { + if (response.IsErrorPacket()) + return false; + + response.GetStringRef().insert(0, 1, 'G'); + data_sp.reset (new DataBufferHeap(response.GetStringRef().c_str(), + response.GetStringRef().size())); + return true; + } + } } return false; } @@ -391,14 +399,21 @@ { GDBRemoteCommunication &gdb_comm = GetGDBProcess().GetGDBRemote(); StringExtractorGDBRemote response; - if (gdb_comm.SendPacketAndWaitForResponse((const char *)data_sp->GetBytes(), - data_sp->GetByteSize(), - response, - 1, - false)) + Mutex::Locker locker; + if (gdb_comm.GetSequenceMutex (locker)) { - if (response.IsOKPacket()) - return true; + if (GetGDBProcess().SetCurrentGDBRemoteThread(m_thread.GetID())) + { + if (gdb_comm.SendPacketAndWaitForResponse((const char *)data_sp->GetBytes(), + data_sp->GetByteSize(), + response, + 1, + false)) + { + if (response.IsOKPacket()) + return true; + } + } } return false; } From johnny.chen at apple.com Thu Oct 7 17:15:59 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 07 Oct 2010 22:15:59 -0000 Subject: [Lldb-commits] [lldb] r115995 - in /lldb/trunk/test: class_types/TestClassTypes.py lldbtest.py lldbutil.py threads/TestPrintStackTraces.py Message-ID: <20101007221559.1B3CE2A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 17:15:58 2010 New Revision: 115995 URL: http://llvm.org/viewvc/llvm-project?rev=115995&view=rev Log: Move the enum to string utility functions from lldbtest.py to lldbuti.py and update the affected API clients. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/lldbtest.py lldb/trunk/test/lldbutil.py lldb/trunk/test/threads/TestPrintStackTraces.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=115995&r1=115994&r2=115995&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Thu Oct 7 17:15:58 2010 @@ -115,7 +115,7 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'Stopped' state, " "instead the actual state is: '%s'" % - StateTypeString(self.process.GetState())) + lldbutil.StateTypeString(self.process.GetState())) # The stop reason of the thread should be breakpoint. thread = self.process.GetThreadAtIndex(0) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=115995&r1=115994&r2=115995&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Oct 7 17:15:58 2010 @@ -165,58 +165,6 @@ return "'%s' compares successfully" % str # -# Returns the stateType string given an enum. -# -def StateTypeString(enum): - if enum == lldb.eStateInvalid: - return "Invalid" - elif enum == lldb.eStateUnloaded: - return "Unloaded" - elif enum == lldb.eStateAttaching: - return "Attaching" - elif enum == lldb.eStateLaunching: - return "Launching" - elif enum == lldb.eStateStopped: - return "Stopped" - elif enum == lldb.eStateRunning: - return "Running" - elif enum == lldb.eStateStepping: - return "Stepping" - elif enum == lldb.eStateCrashed: - return "Crashed" - elif enum == lldb.eStateDetached: - return "Detached" - elif enum == lldb.eStateExited: - return "Exited" - elif enum == lldb.eStateSuspended: - return "Suspended" - else: - raise Exception("Unknown stopReason enum") - -# -# Returns the stopReason string given an enum. -# -def StopReasonString(enum): - if enum == lldb.eStopReasonInvalid: - return "Invalid" - elif enum == lldb.eStopReasonNone: - return "None" - elif enum == lldb.eStopReasonTrace: - return "Trace" - elif enum == lldb.eStopReasonBreakpoint: - return "Breakpoint" - elif enum == lldb.eStopReasonWatchpoint: - return "Watchpoint" - elif enum == lldb.eStopReasonSignal: - return "Signal" - elif enum == lldb.eStopReasonException: - return "Exception" - elif enum == lldb.eStopReasonPlanComplete: - return "PlanComplete" - else: - raise Exception("Unknown stopReason enum") - -# # Returns an env variable array from the os.environ map object. # def EnvArray(): Modified: lldb/trunk/test/lldbutil.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=115995&r1=115994&r2=115995&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Thu Oct 7 17:15:58 2010 @@ -6,6 +6,67 @@ import sys import StringIO +######################################################## +# # +# Convert some enum value to its string's counterpart. # +# # +######################################################## + +def StateTypeString(enum): + """Returns the stateType string given an enum.""" + if enum == lldb.eStateInvalid: + return "Invalid" + elif enum == lldb.eStateUnloaded: + return "Unloaded" + elif enum == lldb.eStateAttaching: + return "Attaching" + elif enum == lldb.eStateLaunching: + return "Launching" + elif enum == lldb.eStateStopped: + return "Stopped" + elif enum == lldb.eStateRunning: + return "Running" + elif enum == lldb.eStateStepping: + return "Stepping" + elif enum == lldb.eStateCrashed: + return "Crashed" + elif enum == lldb.eStateDetached: + return "Detached" + elif enum == lldb.eStateExited: + return "Exited" + elif enum == lldb.eStateSuspended: + return "Suspended" + else: + raise Exception("Unknown stopReason enum") + +def StopReasonString(enum): + """Returns the stopReason string given an enum.""" + if enum == lldb.eStopReasonInvalid: + return "Invalid" + elif enum == lldb.eStopReasonNone: + return "None" + elif enum == lldb.eStopReasonTrace: + return "Trace" + elif enum == lldb.eStopReasonBreakpoint: + return "Breakpoint" + elif enum == lldb.eStopReasonWatchpoint: + return "Watchpoint" + elif enum == lldb.eStopReasonSignal: + return "Signal" + elif enum == lldb.eStopReasonException: + return "Exception" + elif enum == lldb.eStopReasonPlanComplete: + return "PlanComplete" + else: + raise Exception("Unknown stopReason enum") + + +####################################################### +# # +# Utility functions related to Threads and Processes. # +# # +####################################################### + def GetFunctionNames(thread): """ Returns a sequence of function names from the stack frames of this thread. Modified: lldb/trunk/test/threads/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/TestPrintStackTraces.py?rev=115995&r1=115994&r2=115995&view=diff ============================================================================== --- lldb/trunk/test/threads/TestPrintStackTraces.py (original) +++ lldb/trunk/test/threads/TestPrintStackTraces.py Thu Oct 7 17:15:58 2010 @@ -37,7 +37,7 @@ if self.process.GetState() != lldb.eStateStopped: self.fail("Process should be in the 'Stopped' state, " "instead the actual state is: '%s'" % - StateTypeString(self.process.GetState())) + lldbutil.StateTypeString(self.process.GetState())) import lldbutil lldbutil.PrintStackTraces(self.process) From scallanan at apple.com Thu Oct 7 17:51:14 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 07 Oct 2010 22:51:14 -0000 Subject: [Lldb-commits] [lldb] r115999 - /lldb/trunk/source/API/SBTarget.cpp Message-ID: <20101007225114.B465C2A6C12E@llvm.org> Author: spyffe Date: Thu Oct 7 17:51:14 2010 New Revision: 115999 URL: http://llvm.org/viewvc/llvm-project?rev=115999&view=rev Log: Fixed a launching issue. Modified: lldb/trunk/source/API/SBTarget.cpp Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115999&r1=115998&r2=115999&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Thu Oct 7 17:51:14 2010 @@ -164,14 +164,14 @@ error.SetError (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty)); if (error.Success()) { + // We we are stopping at the entry point, we can return now! + if (stop_at_entry) + return sb_process; + // Make sure we are stopped at the entry StateType state = sb_process->WaitForProcessToStop (NULL); if (state == eStateStopped) { - // We we are stopping at the entry point, we can return now! - if (stop_at_entry) - return sb_process; - // resume the process to skip the entry point error.SetError (sb_process->Resume()); if (error.Success()) From gclayton at apple.com Thu Oct 7 19:21:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 08 Oct 2010 00:21:05 -0000 Subject: [Lldb-commits] [lldb] r116017 - in /lldb/trunk: include/lldb/lldb-private.h source/Commands/CommandObjectImage.cpp source/Core/Address.cpp source/Core/Module.cpp source/Core/Section.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp source/Target/Target.cpp source/lldb.cpp Message-ID: <20101008002105.5DA082A6C12E@llvm.org> Author: gclayton Date: Thu Oct 7 19:21:05 2010 New Revision: 116017 URL: http://llvm.org/viewvc/llvm-project?rev=116017&view=rev Log: Hooked up ability to look up data symbols so they show up in disassembly if the address comes from a data section. Fixed an issue that could occur when looking up a symbol that has a zero byte size where no match would be returned even if there was an exact symbol match. Cleaned up the section dump output and added the section type into the output. Modified: lldb/trunk/include/lldb/lldb-private.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Symbol/Symtab.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/lldb.cpp Modified: lldb/trunk/include/lldb/lldb-private.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private.h (original) +++ lldb/trunk/include/lldb/lldb-private.h Thu Oct 7 19:21:05 2010 @@ -67,6 +67,9 @@ const char * GetVoteAsCString (lldb::Vote vote); +const char * +GetSectionTypeAsCString (lldb::SectionType sect_type); + } // namespace lldb_private Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Oct 7 19:21:05 2010 @@ -180,7 +180,14 @@ { SectionList *section_list = objfile->GetSectionList(); if (section_list) + { + strm.PutCString ("Sections for '"); + strm << module->GetFileSpec(); + strm.Printf ("' (%s):\n", module->GetArchitecture().AsCString()); + strm.IndentMore(); section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true); + strm.IndentLess(); + } } } } Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Thu Oct 7 19:21:05 2010 @@ -466,6 +466,34 @@ SectionType sect_type = section->GetType(); switch (sect_type) { + case eSectionTypeData: + if (module) + { + ObjectFile *objfile = module->GetObjectFile(); + if (objfile) + { + Symtab *symtab = objfile->GetSymtab(); + if (symtab) + { + const addr_t file_Addr = GetFileAddress(); + Symbol *symbol = symtab->FindSymbolContainingFileAddress (file_Addr); + if (symbol) + { + const char *symbol_name = symbol->GetName().AsCString(); + if (symbol_name) + { + s->PutCString(symbol_name); + addr_t delta = file_Addr - symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(); + if (delta) + s->Printf(" + %llu", delta); + showed_info = true; + } + } + } + } + } + break; + case eSectionTypeDataCString: // Read the C string from memory and display it showed_info = true; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Thu Oct 7 19:21:05 2010 @@ -372,7 +372,7 @@ Module::Dump(Stream *s) { Mutex::Locker locker (m_mutex); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); s->Printf("Module %s/%s%s%s%s\n", m_file.GetDirectory().AsCString(), Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Thu Oct 7 19:21:05 2010 @@ -222,11 +222,11 @@ void -Section::Dump(Stream *s, Target *target) const +Section::Dump (Stream *s, Target *target) const { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); +// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - s->Printf("0x%8.8x ", GetID()); + s->Printf("0x%8.8x %-14s ", GetID(), GetSectionTypeAsCString (m_type)); bool resolved = true; addr_t addr = LLDB_INVALID_ADDRESS; @@ -672,16 +672,16 @@ { if (show_header && !m_sections.empty()) { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); +// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); +// s->Indent(); +// s->PutCString( "SectionList\n"); +// s->IndentMore(); +// s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); - s->PutCString( "SectionList\n"); - s->IndentMore(); - s->Printf("%*s", 2*(sizeof(void *) + 2), ""); + s->Printf("SectID Type %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File"); +// s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); - s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File"); - s->Printf("%*s", 2*(sizeof(void *) + 2), ""); - s->Indent(); - s->PutCString("---------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); + s->PutCString("---------- -------------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); } 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=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Oct 7 19:21:05 2010 @@ -394,10 +394,11 @@ static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges"); static ConstString g_sect_name_dwarf_debug_str ("__debug_str"); static ConstString g_sect_name_eh_frame ("__eh_frame"); + static ConstString g_sect_name_DATA ("__DATA"); + static ConstString g_sect_name_TEXT ("__TEXT"); SectionType sect_type = eSectionTypeOther; - if (section_name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev; else if (section_name == g_sect_name_dwarf_debug_aranges) @@ -442,7 +443,14 @@ switch (mach_sect_type) { // TODO: categorize sections by other flags for regular sections - case SectionTypeRegular: sect_type = eSectionTypeOther; break; + case SectionTypeRegular: + if (segment_sp->GetName() == g_sect_name_TEXT) + sect_type = eSectionTypeCode; + else if (segment_sp->GetName() == g_sect_name_DATA) + sect_type = eSectionTypeData; + else + sect_type = eSectionTypeOther; + break; case SectionTypeZeroFill: sect_type = eSectionTypeZeroFill; break; case SectionTypeCStringLiterals: sect_type = eSectionTypeDataCString; break; // section with only literal C strings case SectionType4ByteLiterals: sect_type = eSectionTypeData4; break; // section with only 4 byte literals Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Thu Oct 7 19:21:05 2010 @@ -65,7 +65,7 @@ Symtab::Dump(Stream *s, Target *target) const { const_iterator pos; - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); +// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); const FileSpec &file_spec = m_objfile->GetFileSpec(); const char * object_name = NULL; @@ -705,7 +705,24 @@ if (info.match_symbol) { - if (info.match_offset < CalculateSymbolSize(info.match_symbol)) + if (info.match_offset == 0) + { + // We found an exact match! + return info.match_symbol; + } + + const size_t symbol_byte_size = CalculateSymbolSize(info.match_symbol); + + if (symbol_byte_size == 0) + { + // We weren't able to find the size of the symbol so lets just go + // with that match we found in our search... + return info.match_symbol; + } + + // We were able to figure out a symbol size so lets make sure our + // offset puts "file_addr" in the symbol's address range. + if (info.match_offset < symbol_byte_size) return info.match_symbol; } return NULL; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Oct 7 19:21:05 2010 @@ -66,7 +66,7 @@ void Target::Dump (Stream *s) { - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); +// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); s->PutCString("Target\n"); s->IndentMore(); Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=116017&r1=116016&r2=116017&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Thu Oct 7 19:21:05 2010 @@ -156,3 +156,42 @@ return "invalid"; } + +const char * +lldb_private::GetSectionTypeAsCString (lldb::SectionType sect_type) +{ + switch (sect_type) + { + case eSectionTypeInvalid: return "invalid"; + case eSectionTypeCode: return "code"; + case eSectionTypeContainer: return "container"; + case eSectionTypeData: return "data"; + case eSectionTypeDataCString: return "data-cstr"; + case eSectionTypeDataCStringPointers: return "data-cstr-ptr"; + case eSectionTypeDataSymbolAddress: return "data-symbol-addr"; + case eSectionTypeData4: return "data-4-byte"; + case eSectionTypeData8: return "data-8-byte"; + case eSectionTypeData16: return "data-16-byte"; + case eSectionTypeDataPointers: return "data-ptrs"; + case eSectionTypeDebug: return "debug"; + case eSectionTypeZeroFill: return "zero-fill"; + case eSectionTypeDataObjCMessageRefs: return "objc-message-refs"; + case eSectionTypeDataObjCCFStrings: return "objc-cfstrings"; + case eSectionTypeDWARFDebugAbbrev: return "dwarf-abbrev"; + case eSectionTypeDWARFDebugAranges: return "dwarf-aranges"; + case eSectionTypeDWARFDebugFrame: return "dwarf-frame"; + case eSectionTypeDWARFDebugInfo: return "dwarf-info"; + case eSectionTypeDWARFDebugLine: return "dwarf-line"; + case eSectionTypeDWARFDebugLoc: return "dwarf-loc"; + case eSectionTypeDWARFDebugMacInfo: return "dwarf-macinfo"; + case eSectionTypeDWARFDebugPubNames: return "dwarf-pubnames"; + case eSectionTypeDWARFDebugPubTypes: return "dwarf-pubtypes"; + case eSectionTypeDWARFDebugRanges: return "dwarf-ranges"; + case eSectionTypeDWARFDebugStr: return "dwarf-str"; + case eSectionTypeEHFrame: return "eh-frame"; + case eSectionTypeOther: return "regular"; + } + return "unknown"; + +} + From gclayton at apple.com Thu Oct 7 19:23:58 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 08 Oct 2010 00:23:58 -0000 Subject: [Lldb-commits] [lldb] r116019 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101008002358.125212A6C12E@llvm.org> Author: gclayton Date: Thu Oct 7 19:23:57 2010 New Revision: 116019 URL: http://llvm.org/viewvc/llvm-project?rev=116019&view=rev Log: Bumped versions to lldb-26 and debugserver-114 for a build. 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=116019&r1=116018&r2=116019&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Oct 7 19:23:57 2010 @@ -2941,9 +2941,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 25; + DYLIB_CURRENT_VERSION = 26; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2994,11 +2994,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 25; + DYLIB_CURRENT_VERSION = 26; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3069,7 +3069,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3105,11 +3105,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 25; + DYLIB_CURRENT_VERSION = 26; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3159,7 +3159,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3199,7 +3199,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; 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=116019&r1=116018&r2=116019&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu Oct 7 19:23:57 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 25 + 26 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=116019&r1=116018&r2=116019&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Oct 7 19:23:57 2010 @@ -456,7 +456,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -474,7 +474,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -511,7 +511,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -552,7 +552,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -593,7 +593,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 113; + CURRENT_PROJECT_VERSION = 114; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Thu Oct 7 19:47:31 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 00:47:31 -0000 Subject: [Lldb-commits] [lldb] r116023 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101008004731.182952A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 19:47:30 2010 New Revision: 116023 URL: http://llvm.org/viewvc/llvm-project?rev=116023&view=rev Log: The expected term-width output string should be put within a list, not as a list of characters. Also uncomment the cleanup of "stdout.txt" file as part of the class cleanup routine even though test_set_output_path() is failing right now. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116023&r1=116022&r2=116023&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Thu Oct 7 19:47:30 2010 @@ -13,8 +13,8 @@ @classmethod def classCleanup(cls): - system(["/bin/sh", "-c", "rm output.txt"]) - #system(["/bin/sh", "-c", "rm stdout.txt"]) + system(["/bin/sh", "-c", "rm -f output.txt"]) + system(["/bin/sh", "-c", "rm -f stdout.txt"]) def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" @@ -45,7 +45,7 @@ # The overall display should also reflect the new setting. self.expect("settings show", - substrs = "term-width (int) = '70'") + substrs = ["term-width (int) = '70'"]) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): From johnny.chen at apple.com Thu Oct 7 19:50:36 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 00:50:36 -0000 Subject: [Lldb-commits] [lldb] r116025 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20101008005036.DD1FF2A6C12E@llvm.org> Author: johnny Date: Thu Oct 7 19:50:36 2010 New Revision: 116025 URL: http://llvm.org/viewvc/llvm-project?rev=116025&view=rev Log: Pass '-f' option to rm command so that it won't report an error if the file to be removed does not exist for any reason. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=116025&r1=116024&r2=116025&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Thu Oct 7 19:50:36 2010 @@ -13,7 +13,7 @@ @classmethod def classCleanup(cls): - system(["/bin/sh", "-c", "rm output.txt"]) + system(["/bin/sh", "-c", "rm -f output.txt"]) @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): From scallanan at apple.com Thu Oct 7 20:58:41 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 08 Oct 2010 01:58:41 -0000 Subject: [Lldb-commits] [lldb] r116028 - in /lldb/trunk/source: Expression/ClangExpressionDeclMap.cpp Expression/ClangExpressionParser.cpp Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Message-ID: <20101008015841.A733C2A6C12E@llvm.org> Author: spyffe Date: Thu Oct 7 20:58:41 2010 New Revision: 116028 URL: http://llvm.org/viewvc/llvm-project?rev=116028&view=rev Log: Added extra logging, and made sure that the argument struct for expressions is deallocated when the ClangExpressionDeclMap is taken down. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=116028&r1=116027&r2=116028&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Oct 7 20:58:41 2010 @@ -74,6 +74,12 @@ pvar.DisableParserVars(); } + if (m_materialized_location) + { + m_exe_ctx->process->DeallocateMemory(m_materialized_location); + m_materialized_location = 0; + } + if (m_sym_ctx) delete m_sym_ctx; } @@ -495,6 +501,9 @@ m_materialized_location = 0; } + if (log) + log->PutCString("Allocating memory for materialized argument struct"); + lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, lldb::ePermissionsReadable | lldb::ePermissionsWritable, err); Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=116028&r1=116027&r2=116028&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Oct 7 20:58:41 2010 @@ -449,6 +449,8 @@ if (m_expr.NeedsValidation()) { + /* + Disabled temporarily - TODO Centralize and re-enable this inside Process to avoid race conditions IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str()); if (!ir_dynamic_checks.runOnModule(*module)) @@ -457,6 +459,7 @@ err.SetErrorString("Couldn't add dynamic checks to the expression"); return err; } + */ } } Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=116028&r1=116027&r2=116028&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Thu Oct 7 20:58:41 2010 @@ -12,6 +12,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Error.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Value.h" @@ -60,6 +61,17 @@ lldb::addr_t arg, lldb::addr_t *this_arg) const { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + if (log) + log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n functionAddress = 0x%llx\n returnAddress = 0x%llx\n arg = 0x%llx\n this_arg = %p(0x%llx)\n)", + (void*)&thread, + (uint64_t)sp, + (uint64_t)functionAddress, + (uint64_t)returnAddress, + (void*)arg, + this_arg ? (uint64_t)*this_arg : (uint64_t)0); + RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) return false; @@ -78,21 +90,39 @@ if (this_arg) { + if (log) + log->PutCString("The trivial call has a this pointer"); + uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; + if (log) + log->Printf("About to write 'this' (0x%llx) into RDI", (uint64_t)*this_arg); + if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg)) return false; + if (log) + log->Printf("About to write the argument (0x%llx) into RSI", (uint64_t)arg); + if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, arg)) return false; } else { + if (log) + log->PutCString("The trivial call does not have a this pointer"); + + if (log) + log->Printf("About to write the argument (0x%llx) into RDI", (uint64_t)arg); + if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, arg)) return false; } // First, align the SP + + if (log) + log->Printf("16-byte aligning SP: 0x%llx to 0x%llx", (uint64_t)sp, (uint64_t)(sp & ~0xfull)); sp &= ~(0xfull); // 16-byte alignment @@ -101,11 +131,18 @@ sp -= 8; uint64_t returnAddressU64 = returnAddress; Error error; + + if (log) + log->Printf("Pushing the return address onto the stack: new SP 0x%llx, return address 0x%llx", (uint64_t)sp, (uint64_t)returnAddressU64); + if (thread.GetProcess().WriteMemory (sp, &returnAddressU64, sizeof(returnAddressU64), error) != sizeof(returnAddressU64)) return false; // %rsp is set to the actual stack value. + if (log) + log->Printf("Writing SP (0x%llx) down", (uint64_t)sp); + if (!reg_ctx->WriteRegisterFromUnsigned(rspID, sp)) return false; @@ -117,6 +154,9 @@ #endif // %rip is set to the address of the called function. + + if (log) + log->Printf("Writing new IP (0x%llx) down", (uint64_t)functionAddress); if (!reg_ctx->WriteRegisterFromUnsigned(ripID, functionAddress)) return false; From gclayton at apple.com Thu Oct 7 23:20:14 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 08 Oct 2010 04:20:14 -0000 Subject: [Lldb-commits] [lldb] r116049 - in /lldb/trunk: include/lldb/Symbol/Symtab.h include/lldb/lldb-enumerations.h source/Commands/CommandObjectImage.cpp source/Commands/CommandObjectThread.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Symbol/Symtab.cpp Message-ID: <20101008042015.0D4AE2A6C12E@llvm.org> Author: gclayton Date: Thu Oct 7 23:20:14 2010 New Revision: 116049 URL: http://llvm.org/viewvc/llvm-project?rev=116049&view=rev Log: Added mutex protection to the Symtab class. Added a new SortOrder enumeration and hooked it up to the "image dump symtab" command so we can dump symbol tables in the original order, sorted by address, or sorted by name. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Thu Oct 7 23:20:14 2010 @@ -15,6 +15,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/UniqueCStringMap.h" +#include "lldb/Host/Mutex.h" #include "lldb/Symbol/Symbol.h" namespace lldb_private { @@ -41,9 +42,13 @@ Symbol * Resize (uint32_t count); uint32_t AddSymbol(const Symbol& symbol); size_t GetNumSymbols() const; - void Dump(Stream *s, Target *target) const; + void Dump(Stream *s, Target *target, lldb::SortOrder sort_type); void Dump(Stream *s, Target *target, std::vector& indexes) const; uint32_t GetIndexForSymbol (const Symbol *symbol) const; + Mutex & GetMutex () + { + return m_mutex; + } Symbol * FindSymbolByID (lldb::user_id_t uid) const; Symbol * SymbolAtIndex (uint32_t idx); const Symbol * SymbolAtIndex (uint32_t idx) const; @@ -84,7 +89,9 @@ collection m_symbols; std::vector m_addr_indexes; UniqueCStringMap m_name_to_index; - + mutable Mutex m_mutex; // Provide thread safety for this symbol table + bool m_addr_indexes_computed:1, + m_name_indexes_computed:1; private: bool Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Oct 7 23:20:14 2010 @@ -558,6 +558,7 @@ eArgTypeSettingVariableName, eArgTypeShlibName, eArgTypeSourceFile, + eArgTypeSortOrder, eArgTypeStartAddress, eArgTypeSymbol, eArgTypeThreadID, @@ -573,19 +574,25 @@ typedef enum ArgumentRepetitionType { - eArgRepeatPlain, // Exactly one occurrence - eArgRepeatOptional, // At most one occurrence, but it's optional - eArgRepeatPlus, // One or more occurrences - eArgRepeatStar, // Zero or more occurrences - eArgRepeatRange, // Repetition of same argument, from 1 to n - eArgRepeatPairPlain, // A pair of arguments that must always go together ([arg-type arg-value]), occurs exactly once - eArgRepeatPairOptional, // A pair that occurs at most once (optional) - eArgRepeatPairPlus, // One or more occurrences of a pair - eArgRepeatPairStar, // Zero or more occurrences of a pair - eArgRepeatPairRange, // A pair that repeats from 1 to n - eArgRepeatPairRangeOptional, // A pair that repeats from 1 to n, but is optional + eArgRepeatPlain, // Exactly one occurrence + eArgRepeatOptional, // At most one occurrence, but it's optional + eArgRepeatPlus, // One or more occurrences + eArgRepeatStar, // Zero or more occurrences + eArgRepeatRange, // Repetition of same argument, from 1 to n + eArgRepeatPairPlain, // A pair of arguments that must always go together ([arg-type arg-value]), occurs exactly once + eArgRepeatPairOptional, // A pair that occurs at most once (optional) + eArgRepeatPairPlus, // One or more occurrences of a pair + eArgRepeatPairStar, // Zero or more occurrences of a pair + eArgRepeatPairRange, // A pair that repeats from 1 to n + eArgRepeatPairRangeOptional // A pair that repeats from 1 to n, but is optional } ArgumentRepetitionType; +typedef enum SortOrder +{ + eSortOrderNone, + eSortOrderByAddress, + eSortOrderByName, +} SortOrder; } // namespace lldb Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Oct 7 23:20:14 2010 @@ -156,7 +156,7 @@ static void -DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module) +DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module, lldb::SortOrder sort_order) { if (module) { @@ -165,7 +165,7 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target); + symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, sort_order); } } } @@ -634,8 +634,13 @@ result.GetOutputStream().Printf("Dumping symbol table for %u modules.\n", num_modules); for (uint32_t image_idx = 0; image_idx 0) + { + result.GetOutputStream().EOL(); + result.GetOutputStream().EOL(); + } num_dumped++; - DumpModuleSymtab (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx), m_options.m_sort_order); } } else @@ -672,8 +677,13 @@ Module *image_module = matching_modules.GetModulePointerAtIndex(i); if (image_module) { + if (num_dumped > 0) + { + result.GetOutputStream().EOL(); + result.GetOutputStream().EOL(); + } num_dumped++; - DumpModuleSymtab (m_interpreter, result.GetOutputStream(), image_module); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), image_module, m_options.m_sort_order); } } } @@ -692,9 +702,100 @@ } return result.Succeeded(); } + + virtual Options * + GetOptions () + { + return &m_options; + } + + class CommandOptions : public Options + { + public: + + CommandOptions () : + Options(), + m_sort_order (eSortOrderNone) + { + } + + virtual + ~CommandOptions () + { + } + + virtual Error + SetOptionValue (int option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 's': + { + bool found_one = false; + m_sort_order = (lldb::SortOrder) Args::StringToOptionEnum (option_arg, + g_option_table[option_idx].enum_values, + eSortOrderNone, + &found_one); + if (!found_one) + error.SetErrorStringWithFormat("Invalid enumeration value '%s' for option '%c'.\n", + option_arg, + short_option); + } + break; + default: + error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); + break; + + } + return error; + } + + void + ResetOptionValues () + { + Options::ResetOptionValues(); + m_sort_order = eSortOrderNone; + } + + const lldb::OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + static lldb::OptionDefinition g_option_table[]; + + SortOrder m_sort_order; + }; + +protected: + + CommandOptions m_options; +}; + +lldb::OptionEnumValueElement +g_sort_option_enumeration[4] = +{ + { eSortOrderNone, "none", "No sorting, use the original symbol table order."}, + { eSortOrderByAddress, "address", "Sort output by symbol address."}, + { eSortOrderByName, "name", "Sort output by symbol name."}, + { 0, NULL, NULL } }; + +lldb::OptionDefinition +CommandObjectImageDumpSymtab::CommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_1, false, "sort", 's', required_argument, g_sort_option_enumeration, 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + + //---------------------------------------------------------------------- // Image section dumping command //---------------------------------------------------------------------- @@ -1380,8 +1481,7 @@ { } - virtual - Options * + virtual Options * GetOptions () { return &m_options; Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Thu Oct 7 23:20:14 2010 @@ -506,7 +506,7 @@ switch (short_option) { - case 'a': + case 'a': { bool success; m_avoid_no_debug = Args::StringToBoolean (option_arg, true, &success); @@ -514,7 +514,8 @@ error.SetErrorStringWithFormat("Invalid boolean value for option '%c'.\n", short_option); } break; - case 'm': + + case 'm': { bool found_one = false; OptionEnumValueElement *enum_values = g_option_table[option_idx].enum_values; @@ -523,15 +524,17 @@ error.SetErrorStringWithFormat("Invalid enumeration value for option '%c'.\n", short_option); } break; - case 'r': + + case 'r': { m_avoid_regexp.clear(); m_avoid_regexp.assign(option_arg); } break; - default: - error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); - break; + + default: + error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); + break; } return error; Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Oct 7 23:20:14 2010 @@ -647,6 +647,8 @@ Symtab *symbol_table = new Symtab(this); m_symtab_ap.reset(symbol_table); + Mutex::Locker locker (symbol_table->GetMutex ()); + if (!(ParseSectionHeaders() && GetSectionHeaderStringTable())) return symbol_table; @@ -658,7 +660,7 @@ { const ELFSectionHeader &symtab_section = *I; user_id_t section_id = SectionIndex(I); - ParseSymbolTable(symbol_table, symtab_section, section_id); + ParseSymbolTable (symbol_table, symtab_section, section_id); } } @@ -685,7 +687,7 @@ section_list->Dump(s, NULL, true); Symtab *symtab = GetSymtab(); if (symtab) - symtab->Dump(s, NULL); + symtab->Dump(s, NULL, lldb::eSortOrderNone); s->EOL(); DumpDependentModules(s); s->EOL(); 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=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Oct 7 23:20:14 2010 @@ -206,6 +206,7 @@ if (m_symtab_ap.get() == NULL) { m_symtab_ap.reset(new Symtab(this)); + Mutex::Locker locker (m_symtab_ap->GetMutex()); ParseSymtab (true); } return m_symtab_ap.get(); @@ -1348,7 +1349,7 @@ m_sections_ap->Dump(s, NULL, true); if (m_symtab_ap.get()) - m_symtab_ap->Dump(s, NULL); + m_symtab_ap->Dump(s, NULL, eSortOrderNone); } Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=116049&r1=116048&r2=116049&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Thu Oct 7 23:20:14 2010 @@ -21,10 +21,13 @@ Symtab::Symtab(ObjectFile *objfile) : - m_objfile(objfile), - m_symbols(), - m_addr_indexes(), - m_name_to_index() + m_objfile (objfile), + m_symbols (), + m_addr_indexes (), + m_name_to_index (), + m_mutex (Mutex::eMutexTypeRecursive), + m_addr_indexes_computed (false), + m_name_indexes_computed (false) { } @@ -35,12 +38,16 @@ void Symtab::Reserve(uint32_t count) { + // Clients should grab the mutex from this symbol table and lock it manually + // when calling this function to avoid performance issues. m_symbols.reserve (count); } Symbol * Symtab::Resize(uint32_t count) { + // Clients should grab the mutex from this symbol table and lock it manually + // when calling this function to avoid performance issues. m_symbols.resize (count); return &m_symbols[0]; } @@ -48,23 +55,29 @@ uint32_t Symtab::AddSymbol(const Symbol& symbol) { + // Clients should grab the mutex from this symbol table and lock it manually + // when calling this function to avoid performance issues. uint32_t symbol_idx = m_symbols.size(); m_name_to_index.Clear(); m_addr_indexes.clear(); m_symbols.push_back(symbol); + m_addr_indexes_computed = false; + m_name_indexes_computed = false; return symbol_idx; } size_t Symtab::GetNumSymbols() const { + Mutex::Locker locker (m_mutex); return m_symbols.size(); } void -Symtab::Dump(Stream *s, Target *target) const +Symtab::Dump (Stream *s, Target *target, lldb::SortOrder sort_order) { - const_iterator pos; + Mutex::Locker locker (m_mutex); + // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); const FileSpec &file_spec = m_objfile->GetFileSpec(); @@ -73,7 +86,7 @@ object_name = m_objfile->GetModule()->GetObjectName().GetCString(); if (file_spec) - s->Printf("Symtab, file = %s/%s%s%s%s, num_symbols = %u:\n", + s->Printf("Symtab, file = %s/%s%s%s%s, num_symbols = %u", file_spec.GetDirectory().AsCString(), file_spec.GetFilename().AsCString(), object_name ? "(" : "", @@ -81,28 +94,79 @@ object_name ? ")" : "", m_symbols.size()); else - s->Printf("Symtab, num_symbols = %u:\n", m_symbols.size()); - s->IndentMore(); + s->Printf("Symtab, num_symbols = %u", m_symbols.size()); if (!m_symbols.empty()) { - const_iterator begin = m_symbols.begin(); - const_iterator end = m_symbols.end(); - DumpSymbolHeader (s); - for (pos = m_symbols.begin(); pos != end; ++pos) + switch (sort_order) { - s->Indent(); - pos->Dump(s, target, std::distance(begin, pos)); + case eSortOrderNone: + { + s->PutCString (":\n"); + DumpSymbolHeader (s); + const_iterator begin = m_symbols.begin(); + const_iterator end = m_symbols.end(); + for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) + { + s->Indent(); + pos->Dump(s, target, std::distance(begin, pos)); + } + } + break; + + case eSortOrderByName: + { + // Although we maintain a lookup by exact name map, the table + // isn't sorted by name. So we must make the ordered symbol list + // up ourselves. + s->PutCString (" (sorted by name):\n"); + DumpSymbolHeader (s); + typedef std::multimap CStringToSymbol; + CStringToSymbol name_map; + for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); pos != end; ++pos) + { + const char *name = pos->GetMangled().GetName(Mangled::ePreferDemangled).AsCString(); + if (name && name[0]) + name_map.insert (std::make_pair(name, &(*pos))); + } + + for (CStringToSymbol::const_iterator pos = name_map.begin(), end = name_map.end(); pos != end; ++pos) + { + s->Indent(); + pos->second->Dump (s, target, pos->second - &m_symbols[0]); + } + } + break; + + case eSortOrderByAddress: + s->PutCString (" (sorted by address):\n"); + DumpSymbolHeader (s); + if (!m_addr_indexes_computed) + InitAddressIndexes(); + const size_t num_symbols = GetNumSymbols(); + std::vector::const_iterator pos; + std::vector::const_iterator end = m_addr_indexes.end(); + for (pos = m_addr_indexes.begin(); pos != end; ++pos) + { + uint32_t idx = *pos; + if (idx < num_symbols) + { + s->Indent(); + m_symbols[idx].Dump(s, target, idx); + } + } + break; } } - s->IndentLess (); } void Symtab::Dump(Stream *s, Target *target, std::vector& indexes) const { + Mutex::Locker locker (m_mutex); + const size_t num_symbols = GetNumSymbols(); - s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); + //s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); s->Printf("Symtab %u symbol indexes (%u symbols total):\n", indexes.size(), m_symbols.size()); s->IndentMore(); @@ -152,6 +216,8 @@ Symbol * Symtab::FindSymbolByID (lldb::user_id_t symbol_uid) const { + Mutex::Locker locker (m_mutex); + Symbol *symbol = (Symbol*)::bsearch (&symbol_uid, &m_symbols[0], m_symbols.size(), @@ -164,6 +230,8 @@ Symbol * Symtab::SymbolAtIndex(uint32_t idx) { + // Clients should grab the mutex from this symbol table and lock it manually + // when calling this function to avoid performance issues. if (idx < m_symbols.size()) return &m_symbols[idx]; return NULL; @@ -173,6 +241,8 @@ const Symbol * Symtab::SymbolAtIndex(uint32_t idx) const { + // Clients should grab the mutex from this symbol table and lock it manually + // when calling this function to avoid performance issues. if (idx < m_symbols.size()) return &m_symbols[idx]; return NULL; @@ -184,42 +254,70 @@ void Symtab::InitNameIndexes() { - Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); - // Create the name index vector to be able to quickly search by name - const size_t count = m_symbols.size(); - assert(m_objfile != NULL); - assert(m_objfile->GetModule() != NULL); - m_name_to_index.Reserve (count); - - UniqueCStringMap::Entry entry; - - for (entry.value = 0; entry.value < count; ++entry.value) - { - const Symbol *symbol = &m_symbols[entry.value]; - - // Don't let trampolines get into the lookup by name map - // If we ever need the trampoline symbols to be searchable by name - // we can remove this and then possibly add a new bool to any of the - // Symtab functions that lookup symbols by name to indicate if they - // want trampolines. - if (symbol->IsTrampoline()) - continue; - - const Mangled &mangled = symbol->GetMangled(); - entry.cstring = mangled.GetMangledName().GetCString(); - if (entry.cstring && entry.cstring[0]) - m_name_to_index.Append (entry); - - entry.cstring = mangled.GetDemangledName().GetCString(); - if (entry.cstring && entry.cstring[0]) - m_name_to_index.Append (entry); + // Protected function, no need to lock mutex... + if (!m_name_indexes_computed) + { + m_name_indexes_computed = true; + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); + // Create the name index vector to be able to quickly search by name + const size_t count = m_symbols.size(); + assert(m_objfile != NULL); + assert(m_objfile->GetModule() != NULL); + +#if 1 + m_name_to_index.Reserve (count); +#else + // TODO: benchmark this to see if we save any memory. Otherwise we + // will always keep the memory reserved in the vector unless we pull + // some STL swap magic and then recopy... + uint32_t actual_count = 0; + for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); + pos != end; + ++pos) + { + const Mangled &mangled = pos->GetMangled(); + if (mangled.GetMangledName()) + ++actual_count; + + if (mangled.GetDemangledName()) + ++actual_count; + } + + m_name_to_index.Reserve (actual_count); +#endif + + UniqueCStringMap::Entry entry; + + for (entry.value = 0; entry.value < count; ++entry.value) + { + const Symbol *symbol = &m_symbols[entry.value]; + + // Don't let trampolines get into the lookup by name map + // If we ever need the trampoline symbols to be searchable by name + // we can remove this and then possibly add a new bool to any of the + // Symtab functions that lookup symbols by name to indicate if they + // want trampolines. + if (symbol->IsTrampoline()) + continue; + + const Mangled &mangled = symbol->GetMangled(); + entry.cstring = mangled.GetMangledName().GetCString(); + if (entry.cstring && entry.cstring[0]) + m_name_to_index.Append (entry); + + entry.cstring = mangled.GetDemangledName().GetCString(); + if (entry.cstring && entry.cstring[0]) + m_name_to_index.Append (entry); + } + m_name_to_index.Sort(); } - m_name_to_index.Sort(); } uint32_t Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { + Mutex::Locker locker (m_mutex); + uint32_t prev_size = indexes.size(); const uint32_t count = std::min (m_symbols.size(), end_index); @@ -236,6 +334,8 @@ uint32_t Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes, uint32_t start_idx, uint32_t end_index) const { + Mutex::Locker locker (m_mutex); + uint32_t prev_size = indexes.size(); const uint32_t count = std::min (m_symbols.size(), end_index); @@ -303,6 +403,8 @@ void Symtab::SortSymbolIndexesByValue (std::vector& indexes, bool remove_duplicates) const { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__,__PRETTY_FUNCTION__); // No need to sort if we have zero or one items... if (indexes.size() <= 1) @@ -322,15 +424,18 @@ uint32_t Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (symbol_name) { const size_t old_size = indexes.size(); - if (m_name_to_index.IsEmpty()) + if (!m_name_indexes_computed) InitNameIndexes(); const char *symbol_cstr = symbol_name.GetCString(); const UniqueCStringMap::Entry *entry_ptr; + for (entry_ptr = m_name_to_index.FindFirstValueForName (symbol_cstr); entry_ptr!= NULL; entry_ptr = m_name_to_index.FindNextValueForName (symbol_cstr, entry_ptr)) @@ -345,11 +450,13 @@ uint32_t Symtab::AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); if (symbol_name) { const size_t old_size = indexes.size(); - if (m_name_to_index.IsEmpty()) + if (!m_name_indexes_computed) InitNameIndexes(); const char *symbol_cstr = symbol_name.GetCString(); @@ -369,6 +476,8 @@ uint32_t Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + if (AppendSymbolIndexesWithName(symbol_name, indexes) > 0) { std::vector::iterator pos = indexes.begin(); @@ -386,6 +495,8 @@ uint32_t Symtab::AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + if (AppendSymbolIndexesWithName(symbol_name, symbol_debug_type, symbol_visibility, indexes) > 0) { std::vector::iterator pos = indexes.begin(); @@ -404,6 +515,8 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + uint32_t prev_size = indexes.size(); uint32_t sym_end = m_symbols.size(); @@ -426,6 +539,8 @@ uint32_t Symtab::AppendSymbolIndexesMatchingRegExAndType (const RegularExpression ®exp, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& indexes) { + Mutex::Locker locker (m_mutex); + uint32_t prev_size = indexes.size(); uint32_t sym_end = m_symbols.size(); @@ -451,6 +566,8 @@ Symbol * Symtab::FindSymbolWithType (SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t& start_idx) { + Mutex::Locker locker (m_mutex); + const size_t count = m_symbols.size(); for (uint32_t idx = start_idx; idx < count; ++idx) { @@ -469,10 +586,12 @@ size_t Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, std::vector& symbol_indexes) { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); // Initialize all of the lookup by name indexes before converting NAME // to a uniqued string NAME_STR below. - if (m_name_to_index.IsEmpty()) + if (!m_name_indexes_computed) InitNameIndexes(); if (name) @@ -487,10 +606,12 @@ size_t Symtab::FindAllSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); // Initialize all of the lookup by name indexes before converting NAME // to a uniqued string NAME_STR below. - if (m_name_to_index.IsEmpty()) + if (!m_name_indexes_computed) InitNameIndexes(); if (name) @@ -505,6 +626,8 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType (const RegularExpression ®ex, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& symbol_indexes) { + Mutex::Locker locker (m_mutex); + AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type, symbol_visibility, symbol_indexes); return symbol_indexes.size(); } @@ -512,8 +635,10 @@ Symbol * Symtab::FindFirstSymbolWithNameAndType (const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility) { + Mutex::Locker locker (m_mutex); + Timer scoped_timer (__PRETTY_FUNCTION__, "%s", __PRETTY_FUNCTION__); - if (m_name_to_index.IsEmpty()) + if (!m_name_indexes_computed) InitNameIndexes(); if (name) @@ -614,19 +739,36 @@ void Symtab::InitAddressIndexes() { - if (m_addr_indexes.empty()) + // Protected function, no need to lock mutex... + if (!m_addr_indexes_computed && !m_symbols.empty()) { + m_addr_indexes_computed = true; +#if 0 + // The old was to add only code, trampoline or data symbols... AppendSymbolIndexesWithType (eSymbolTypeCode, m_addr_indexes); AppendSymbolIndexesWithType (eSymbolTypeTrampoline, m_addr_indexes); AppendSymbolIndexesWithType (eSymbolTypeData, m_addr_indexes); - SortSymbolIndexesByValue(m_addr_indexes, true); - m_addr_indexes.push_back(UINT32_MAX); // Terminator for bsearch since we might need to look at the next symbol +#else + // The new way adds all symbols with valid addresses that are section + // offset. + const_iterator begin = m_symbols.begin(); + const_iterator end = m_symbols.end(); + for (const_iterator pos = m_symbols.begin(); pos != end; ++pos) + { + if (pos->GetAddressRangePtr()) + m_addr_indexes.push_back (std::distance(begin, pos)); + } +#endif + SortSymbolIndexesByValue (m_addr_indexes, false); + m_addr_indexes.push_back (UINT32_MAX); // Terminator for bsearch since we might need to look at the next symbol } } size_t Symtab::CalculateSymbolSize (Symbol *symbol) { + Mutex::Locker locker (m_mutex); + if (m_symbols.empty()) return 0; @@ -647,7 +789,7 @@ // it and the next address based symbol if (symbol->GetAddressRangePtr()) { - if (m_addr_indexes.empty()) + if (!m_addr_indexes_computed) InitAddressIndexes(); const size_t num_addr_indexes = m_addr_indexes.size(); SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress(this, symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(), &m_addr_indexes.front(), num_addr_indexes); @@ -684,7 +826,9 @@ Symbol * Symtab::FindSymbolWithFileAddress (addr_t file_addr) { - if (m_addr_indexes.empty()) + Mutex::Locker locker (m_mutex); + + if (!m_addr_indexes_computed) InitAddressIndexes(); SymbolSearchInfo info = { this, file_addr, NULL, NULL, 0 }; @@ -699,6 +843,8 @@ Symbol * Symtab::FindSymbolContainingFileAddress (addr_t file_addr, const uint32_t* indexes, uint32_t num_indexes) { + Mutex::Locker locker (m_mutex); + SymbolSearchInfo info = { this, file_addr, NULL, NULL, 0 }; bsearch(&info, indexes, num_indexes, sizeof(uint32_t), (comparison_function)SymbolWithClosestFileAddress); @@ -731,7 +877,9 @@ Symbol * Symtab::FindSymbolContainingFileAddress (addr_t file_addr) { - if (m_addr_indexes.empty()) + Mutex::Locker locker (m_mutex); + + if (!m_addr_indexes_computed) InitAddressIndexes(); return FindSymbolContainingFileAddress (file_addr, &m_addr_indexes[0], m_addr_indexes.size()); From johnny.chen at apple.com Fri Oct 8 11:36:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 16:36:27 -0000 Subject: [Lldb-commits] [lldb] r116058 - /lldb/trunk/source/Interpreter/CommandObject.cpp Message-ID: <20101008163628.1A0F12A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 11:36:25 2010 New Revision: 116058 URL: http://llvm.org/viewvc/llvm-project?rev=116058&view=rev Log: Fixed a crasher when doing 'help image dump symtab'. Supply the entry to the global arguments table. Modified: lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=116058&r1=116057&r2=116058&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Oct 8 11:36:25 2010 @@ -673,6 +673,7 @@ { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "The name of a shared library." }, { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "The name of a source file.." }, + { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, NULL, "The sort order when dumping the symbol table." }, { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeSymbol, "symbol", CommandCompletions::eNoCompletion, NULL, "Any symbol name (function name, variable, argument, etc.)" }, { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Thread ID number." }, From johnny.chen at apple.com Fri Oct 8 12:21:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 17:21:27 -0000 Subject: [Lldb-commits] [lldb] r116062 - in /lldb/trunk: source/Commands/CommandObjectHelp.cpp test/help/TestHelp.py test/lldbtest.py test/stl/TestStdCXXDisassembly.py Message-ID: <20101008172127.9BECC2A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 12:21:27 2010 New Revision: 116062 URL: http://llvm.org/viewvc/llvm-project?rev=116062&view=rev Log: o TestStdCXXDisassembly.py: Update the expected match string. o lldbtest.py: Indicate when a command fails, even if there is nothing in the error stream. o TestHelp.py: Add a regression test case for 'help image dump symtab'. o CommandObjectHelp.cpp: Some of the logic branches with successful help command results were not tagged with a Success Status. They are fixed now. This is important for Python interaction. Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/test/help/TestHelp.py lldb/trunk/test/lldbtest.py lldb/trunk/test/stl/TestStdCXXDisassembly.py Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=116062&r1=116061&r2=116062&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Fri Oct 8 12:21:27 2010 @@ -121,6 +121,8 @@ if ((long_help != NULL) && (strlen (long_help) > 0)) output_strm.Printf ("\n%s", long_help); + // Mark this help command with a success status. + result.SetStatus (eReturnStatusSuccessFinishNoResult); } else if (sub_cmd_obj->IsMultiwordObject()) { @@ -149,6 +151,8 @@ else m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); + // Mark this help command with a success status. + result.SetStatus (eReturnStatusSuccessFinishNoResult); } } } Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=116062&r1=116061&r2=116062&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Fri Oct 8 12:21:27 2010 @@ -1,5 +1,5 @@ """ -Test lldb help command. +Test some lldb help commands. See also CommandInterpreter::OutputFormattedHelpText(). """ @@ -24,6 +24,12 @@ self.expect("help", startstr = 'The following is a list of built-in, permanent debugger commands') + def test_help_image_dump_symtab_should_not_crash(self): + """Command 'help image dump symtab' should not crash lldb.""" + self.expect("help image dump symtab", + substrs = ['image dump symtab', + 'sort-order']) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=116062&r1=116061&r2=116062&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Oct 8 12:21:27 2010 @@ -392,6 +392,7 @@ if self.res.Succeeded(): print >> sys.stderr, "output:", self.res.GetOutput() else: + print >> sys.stderr, "runCmd failed!" print >> sys.stderr, self.res.GetError() if running: Modified: lldb/trunk/test/stl/TestStdCXXDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestStdCXXDisassembly.py?rev=116062&r1=116061&r2=116062&view=diff ============================================================================== --- lldb/trunk/test/stl/TestStdCXXDisassembly.py (original) +++ lldb/trunk/test/stl/TestStdCXXDisassembly.py Fri Oct 8 12:21:27 2010 @@ -33,7 +33,7 @@ # The process should be in a 'Stopped' state. self.expect(repr(process), STOPPED_DUE_TO_BREAKPOINT, exe=False, substrs = ["a.out", - "state: Stopped"]) + "Stopped"]) # Disassemble the functions on the call stack. self.runCmd("thread backtrace") From johnny.chen at apple.com Fri Oct 8 15:01:03 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 20:01:03 -0000 Subject: [Lldb-commits] [lldb] r116096 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101008200103.6ABED2A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 15:01:03 2010 New Revision: 116096 URL: http://llvm.org/viewvc/llvm-project?rev=116096&view=rev Log: Convert two instances of assertTrue() and string matching usages to self.expect() which is more descriptive. And wrap the file open operation inside a with block so that close() is automatically called upon exiting the block. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116096&r1=116095&r2=116096&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Fri Oct 8 15:01:03 2010 @@ -72,10 +72,11 @@ # Read the output file produced by running the program. output = open('output.txt', 'r').read() - self.assertTrue(output.startswith("argv[1] matches") and - output.find("argv[2] matches") > 0 and - output.find("argv[3] matches") > 0 and - output.find("Environment variable 'MY_ENV_VAR' successfully passed.") > 0) + self.expect(output, exe=False, + substrs = ["argv[1] matches", + "argv[2] matches", + "argv[3] matches", + "Environment variable 'MY_ENV_VAR' successfully passed."]) @unittest2.expectedFailure # rdar://problem/8435794 @@ -95,10 +96,11 @@ self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - output = open('stdout.txt', 'r').read() + with open('stdout.txt', 'r') as f: + output = f.read() - self.assertTrue( - output.startswith("This message should go to standard out.")) + self.expect(output, exe=False, + startstr = "This message should go to standard out.") if __name__ == '__main__': From johnny.chen at apple.com Fri Oct 8 17:01:53 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 22:01:53 -0000 Subject: [Lldb-commits] [lldb] r116114 - /lldb/trunk/source/Interpreter/CommandObject.cpp Message-ID: <20101008220153.1B3CF2A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 17:01:52 2010 New Revision: 116114 URL: http://llvm.org/viewvc/llvm-project?rev=116114&view=rev Log: Emit a diagnostic message instead of crashing when an argument entry is missing. Modified: lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=116114&r1=116113&r2=116114&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Oct 8 17:01:52 2010 @@ -508,7 +508,12 @@ if (entry->arg_type != arg_type) entry = CommandObject::FindArgumentDataByType (arg_type); - return entry->arg_name; + if (entry) + return entry->arg_name; + + StreamString str; + str << "Arg name for type (" << arg_type << ") not in arg table!"; + return str.GetData(); } bool From johnny.chen at apple.com Fri Oct 8 17:10:42 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 22:10:42 -0000 Subject: [Lldb-commits] [lldb] r116115 - in /lldb/trunk/test: breakpoint_command/TestBreakpointCommand.py settings/TestSettings.py Message-ID: <20101008221042.CCA1E2A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 17:10:42 2010 New Revision: 116115 URL: http://llvm.org/viewvc/llvm-project?rev=116115&view=rev Log: Wrap the rest of file reading operations inside a with block and convert a assertTrue() usage to self.expect() which is more descriptive. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=116115&r1=116114&r2=116115&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Oct 8 17:10:42 2010 @@ -65,10 +65,11 @@ # Check that the file 'output.txt' exists and contains the string "lldb". # Read the output file produced by running the program. - output = open('output.txt', 'r').read() + with open('output.txt', 'r') as f: + output = f.read() - self.assertTrue(output.startswith("lldb"), - "File 'output.txt' and the content matches") + self.expect(output, "File 'output.txt' and the content matches", exe=False, + startstr = "lldb") # Finish the program. self.runCmd("process continue") Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=116115&r1=116114&r2=116115&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Fri Oct 8 17:10:42 2010 @@ -70,7 +70,8 @@ self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - output = open('output.txt', 'r').read() + with open('output.txt', 'r') as f: + output = f.read() self.expect(output, exe=False, substrs = ["argv[1] matches", From johnny.chen at apple.com Fri Oct 8 17:51:03 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 08 Oct 2010 22:51:03 -0000 Subject: [Lldb-commits] [lldb] r116117 - /lldb/trunk/test/conditional_break/TestConditionalBreak.py Message-ID: <20101008225103.A58562A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 17:51:03 2010 New Revision: 116117 URL: http://llvm.org/viewvc/llvm-project?rev=116117&view=rev Log: Update do_conditional_break() method impl to use all lldb Python APIs. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=116117&r1=116116&r2=116117&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Fri Oct 8 17:51:03 2010 @@ -5,7 +5,7 @@ import os, time import re import unittest2 -import lldb +import lldb, lldbutil from lldbtest import * class ConditionalBreakTestCase(TestBase): @@ -37,17 +37,22 @@ def do_conditional_break(self): """Exercise some thread and frame APIs to break if c() is called by a().""" exe = os.path.join(os.getcwd(), "a.out") - self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break on c(). - self.expect("breakpoint set -n c", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: name = 'c', locations = 1") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) - self.runCmd("run", RUN_SUCCEEDED) + breakpoint = target.BreakpointCreateByName("c", exe) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + rc = lldb.SBError() + self.process = target.Launch([''], [''], os.ctermid(), 0, False, rc) + + self.assertTrue(rc.Success() and self.process.IsValid(), PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['state is Stopped', 'stop reason = breakpoint']) + self.assertTrue(self.process.GetState() == lldb.eStateStopped, + STOPPED_DUE_TO_BREAKPOINT) # Suppose we are only interested in the call scenario where c()'s # immediate caller is a() and we want to find out the value passed from @@ -56,15 +61,14 @@ # The 10 in range(10) is just an arbitrary number, which means we would # like to try for at most 10 times. for j in range(10): - target = self.dbg.GetSelectedTarget() - process = target.GetProcess() - thread = process.GetThreadAtIndex(0) + thread = self.process.GetThreadAtIndex(0) if thread.GetNumFrames() >= 2: frame0 = thread.GetFrameAtIndex(0) name0 = frame0.GetFunction().GetName() frame1 = thread.GetFrameAtIndex(1) name1 = frame1.GetFunction().GetName() + #lldbutil.PrintStackTrace(thread) self.assertTrue(name0 == "c", "Break on function c()") if (name1 == "a"): line = frame1.GetLineEntry().GetLine() @@ -72,15 +76,14 @@ # In reality, similar logic can be used to find out the call # site. self.assertTrue(line == 27, "Immediate caller a() at main.c:27") - self.expect("thread backtrace", "Call site at a()", - substrs = ["main.c:27"]) - self.expect("frame variable", "Passed in arg (int) val of 3", - startstr = "(int) val = 3") + + # And the local variable 'val' should have a value of (int) 3. + val = frame1.LookupVar("val") + self.assertTrue(val.GetTypeName() == "int", "'val' has int type") + self.assertTrue(val.GetValue(frame1) == "3", "'val' has a value of 3") break - # This doesn't work? - #process.Continue() - self.runCmd("process continue") + self.process.Continue() def simulate_conditional_break_by_user(self): """Simulate a user using lldb commands to break on c() if called from a().""" From johnny.chen at apple.com Fri Oct 8 19:15:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 09 Oct 2010 00:15:46 -0000 Subject: [Lldb-commits] [lldb] r116127 - /lldb/trunk/examples/python/disasm.py Message-ID: <20101009001546.D7F8A2A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 19:15:46 2010 New Revision: 116127 URL: http://llvm.org/viewvc/llvm-project?rev=116127&view=rev Log: Minor change. 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=116127&r1=116126&r2=116127&view=diff ============================================================================== --- lldb/trunk/examples/python/disasm.py (original) +++ lldb/trunk/examples/python/disasm.py Fri Oct 8 19:15:46 2010 @@ -14,7 +14,7 @@ import time def disassemble_instructions (insts): - for i in range(0, insts.GetSize()): + for i in range(insts.GetSize()): print insts.GetInstructionAtIndex(i) # Initialize LLDB so we can use it From gclayton at apple.com Fri Oct 8 19:16:01 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 09 Oct 2010 00:16:01 -0000 Subject: [Lldb-commits] [lldb] r116128 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20101009001601.E367F2A6C12E@llvm.org> Author: gclayton Date: Fri Oct 8 19:16:01 2010 New Revision: 116128 URL: http://llvm.org/viewvc/llvm-project?rev=116128&view=rev Log: Added support for LC_LOAD_UPWARD_DYLIB in mach-o files. Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=116128&r1=116127&r2=116128&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Oct 8 19:16:01 2010 @@ -1403,6 +1403,7 @@ case LoadCommandDylibReexport: case LoadCommandDynamicLinkerLoad: case LoadCommandFixedVMShlibLoad: + case LoadCommandDylibLoadUpward; { uint32_t name_offset = cmd_offset + m_data.GetU32(&offset); const char *path = m_data.PeekCStr(name_offset); From gclayton at apple.com Fri Oct 8 19:48:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 09 Oct 2010 00:48:53 -0000 Subject: [Lldb-commits] [lldb] r116132 - /lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20101009004853.42F2C2A6C12E@llvm.org> Author: gclayton Date: Fri Oct 8 19:48:53 2010 New Revision: 116132 URL: http://llvm.org/viewvc/llvm-project?rev=116132&view=rev Log: Fixed a typo from my previous "Added support for LC_LOAD_UPWARD_DYLIB in mach-o files". Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=116132&r1=116131&r2=116132&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Oct 8 19:48:53 2010 @@ -1403,7 +1403,7 @@ case LoadCommandDylibReexport: case LoadCommandDynamicLinkerLoad: case LoadCommandFixedVMShlibLoad: - case LoadCommandDylibLoadUpward; + case LoadCommandDylibLoadUpward: { uint32_t name_offset = cmd_offset + m_data.GetU32(&offset); const char *path = m_data.PeekCStr(name_offset); From gclayton at apple.com Fri Oct 8 19:51:35 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 09 Oct 2010 00:51:35 -0000 Subject: [Lldb-commits] [lldb] r116133 - /lldb/trunk/source/Commands/CommandObjectApropos.cpp Message-ID: <20101009005135.CADE72A6C12E@llvm.org> Author: gclayton Date: Fri Oct 8 19:51:35 2010 New Revision: 116133 URL: http://llvm.org/viewvc/llvm-project?rev=116133&view=rev Log: Fixed a missing space when using the "apropos" command and you don't find any matches. Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=116133&r1=116132&r2=116133&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Fri Oct 8 19:51:35 2010 @@ -73,8 +73,7 @@ m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { - result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); - result.AppendMessage ("Try 'help' to see a complete list of debugger commands."); + result.AppendMessageWithFormat ("No commands found pertaining to '%s'. Try 'help' to see a complete list of debugger commands.", search_word); } else { From johnny.chen at apple.com Fri Oct 8 20:31:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 09 Oct 2010 01:31:09 -0000 Subject: [Lldb-commits] [lldb] r116137 - /lldb/trunk/test/lldbutil.py Message-ID: <20101009013109.8EBC42A6C12E@llvm.org> Author: johnny Date: Fri Oct 8 20:31:09 2010 New Revision: 116137 URL: http://llvm.org/viewvc/llvm-project?rev=116137&view=rev Log: Add a generator adaptor class named 'Iterator' which turns lldb aggregate data structures into an iterable Python object. Example: def disassemble_instructions (insts): from lldbutil import Iterator for i in Iterator(insts, 'GetSize', 'GetInstructionAtIndex'): print i 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=116137&r1=116136&r2=116137&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Fri Oct 8 20:31:09 2010 @@ -6,6 +6,30 @@ import sys import StringIO +class Iterator(object): + """ + A generator adaptor for lldb aggregate data structures. + + API clients pass in the aggregate object, and the names of the methods to + get the size of the object and its individual element. + + Example usage: + + def disassemble_instructions (insts): + from lldbutil import Iterator + for i in Iterator(insts, 'GetSize', 'GetInstructionAtIndex'): + print i + """ + def __init__(self, obj, getsize, getelem): + self.obj = obj + self.getsize = getattr(obj, getsize) + self.getelem = getattr(obj, getelem) + + def __iter__(self): + for i in range(self.getsize()): + yield self.getelem(i) + + ######################################################## # # # Convert some enum value to its string's counterpart. # From gclayton at apple.com Fri Oct 8 20:40:57 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 09 Oct 2010 01:40:57 -0000 Subject: [Lldb-commits] [lldb] r116139 - in /lldb/trunk/source: Commands/CommandObjectProcess.cpp Interpreter/CommandObject.cpp Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Target/UnixSignals.cpp Message-ID: <20101009014057.B05D52A6C12E@llvm.org> Author: gclayton Date: Fri Oct 8 20:40:57 2010 New Revision: 116139 URL: http://llvm.org/viewvc/llvm-project?rev=116139&view=rev Log: Fixed process.gdb-remote to be able to properly propagate the signals and obey the UnixSignals table that we have in the process. Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Target/UnixSignals.cpp Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=116139&r1=116138&r2=116139&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Oct 8 20:40:57 2010 @@ -846,8 +846,15 @@ if (command.GetArgumentCount() == 1) { - int signo = Args::StringToSInt32(command.GetArgumentAtIndex(0), -1, 0); - if (signo == -1) + int signo = LLDB_INVALID_SIGNAL_NUMBER; + + const char *signal_name = command.GetArgumentAtIndex(0); + if (::isxdigit (signal_name[0])) + signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0); + else + signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name); + + if (signo == LLDB_INVALID_SIGNAL_NUMBER) { result.AppendErrorWithFormat ("Invalid signal argument '%s'.\n", command.GetArgumentAtIndex(0)); result.SetStatus (eReturnStatusFailed); Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=116139&r1=116138&r2=116139&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Oct 8 20:40:57 2010 @@ -633,7 +633,7 @@ { { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "A valid address in the target program's execution space." }, { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, NULL, "The name of an abbreviation (alias) for a debugger command." }, - { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" }, + { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition. (See 'help commands alias' for more information.)" }, { eArgTypeArchitecture, "arch", CommandCompletions::eNoCompletion, NULL, "The architecture name, e.g. i386 or x86_64." }, { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" }, { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL }, @@ -678,7 +678,7 @@ { eArgTypeSettingVariableName, "setting-variable-name", CommandCompletions::eNoCompletion, NULL, "The name of a settable internal debugger variable. Type 'settings list' to see a complete list of such variables." }, { eArgTypeShlibName, "shlib-name", CommandCompletions::eNoCompletion, NULL, "The name of a shared library." }, { eArgTypeSourceFile, "source-file", CommandCompletions::eNoCompletion, NULL, "The name of a source file.." }, - { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, NULL, "The sort order when dumping the symbol table." }, + { eArgTypeSortOrder, "sort-order", CommandCompletions::eNoCompletion, NULL, "Specify a sort order when dumping lists." }, { eArgTypeStartAddress, "start-address", CommandCompletions::eNoCompletion, NULL, "Help text goes here." }, { eArgTypeSymbol, "symbol", CommandCompletions::eNoCompletion, NULL, "Any symbol name (function name, variable, argument, etc.)" }, { eArgTypeThreadID, "thread-id", CommandCompletions::eNoCompletion, NULL, "Thread ID number." }, Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=116139&r1=116138&r2=116139&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Fri Oct 8 20:40:57 2010 @@ -78,8 +78,12 @@ bool ThreadGDBRemote::WillResume (StateType resume_state) { - // TODO: cache for next time in case we can match things up?? ClearStackFrames(); + // Call the Thread::WillResume first. If we stop at a signal, the stop info + // class for signal will set the resume signal that we need below. The signal + // stuff obeys the Process::UnixSignal defaults. + Thread::WillResume(resume_state); + int signo = GetResumeSignal(); switch (resume_state) @@ -106,7 +110,6 @@ default: break; } - Thread::WillResume(resume_state); return true; } Modified: lldb/trunk/source/Target/UnixSignals.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/UnixSignals.cpp?rev=116139&r1=116138&r2=116139&view=diff ============================================================================== --- lldb/trunk/source/Target/UnixSignals.cpp (original) +++ lldb/trunk/source/Target/UnixSignals.cpp Fri Oct 8 20:40:57 2010 @@ -47,39 +47,41 @@ // order, you can either subclass this class, and use Add & Remove to change them // or you can subclass and build them afresh in your constructor; m_signals.clear(); - - AddSignal(1, "SIGHUP", false, true, true ); // 1 hangup - AddSignal(2, "SIGINT", true, true, true ); // 2 interrupt - AddSignal(3, "SIGQUIT", false, true, true ); // 3 quit - AddSignal(4, "SIGILL", false, true, true ); // 4 illegal instruction (not reset when caught) - AddSignal(5, "SIGTRAP", true, true, true ); // 5 trace trap (not reset when caught) - AddSignal(6, "SIGABRT", false, true, true ); // 6 abort() - AddSignal(7, "SIGEMT", false, true, true ); // 7 pollable event ([XSR] generated, not supported) - AddSignal(8, "SIGFPE", false, true, true ); // 8 floating point exception - AddSignal(9, "SIGKILL", false, true, true ); // 9 kill (cannot be caught or ignored) - AddSignal(10, "SIGBUS", false, true, true ); // 10 bus error - AddSignal(11, "SIGSEGV", false, true, true ); // 11 segmentation violation - AddSignal(12, "SIGSYS", false, true, true ); // 12 bad argument to system call - AddSignal(13, "SIGPIPE", false, true, true ); // 13 write on a pipe with no one to read it - AddSignal(14, "SIGALRM", false, false, true ); // 14 alarm clock - AddSignal(15, "SIGTERM", false, true, true ); // 15 software termination signal from kill - AddSignal(16, "SIGURG", false, false, false); // 16 urgent condition on IO channel - AddSignal(17, "SIGSTOP", false, true, true ); // 17 sendable stop signal not from tty - AddSignal(18, "SIGTSTP", false, true, true ); // 18 stop signal from tty - AddSignal(19, "SIGCONT", false, true, true ); // 19 continue a stopped process - AddSignal(20, "SIGCHLD", false, false, true ); // 20 to parent on child stop or exit - AddSignal(21, "SIGTTIN", false, true, true ); // 21 to readers pgrp upon background tty read - AddSignal(22, "SIGTTOU", false, true, true ); // 22 like TTIN for output if (tp->t_local<OSTOP) - AddSignal(23, "SIGIO", false, false, false); // 23 input/output possible signal - AddSignal(24, "SIGXCPU", false, true, true ); // 24 exceeded CPU time limit - AddSignal(25, "SIGXFSZ", false, true, true ); // 25 exceeded file size limit - AddSignal(26, "SIGVTALRM", false, false, false); // 26 virtual time alarm - AddSignal(27, "SIGPROF", false, false, false); // 27 profiling time alarm - AddSignal(28, "SIGWINCH", false, false, false); // 28 window size changes - AddSignal(29, "SIGINFO", false, true, true ); // 29 information request - AddSignal(30, "SIGUSR1", false, true, true ); // 30 user defined signal 1 - AddSignal(31, "SIGUSR2", false, true, true ); // 31 user defined signal 2 + // SIGNO NAME SUPPRESS STOP NOTIFY + // ===== ============ ========= ====== ====== + AddSignal(1, "SIGHUP", false, true, true ); // 1 hangup + AddSignal(2, "SIGINT", true, true, true ); // 2 interrupt + AddSignal(3, "SIGQUIT", false, true, true ); // 3 quit + AddSignal(4, "SIGILL", false, true, true ); // 4 illegal instruction (not reset when caught) + AddSignal(5, "SIGTRAP", true, true, true ); // 5 trace trap (not reset when caught) + AddSignal(6, "SIGABRT", false, true, true ); // 6 abort() + AddSignal(7, "SIGEMT", false, true, true ); // 7 pollable event ([XSR] generated, not supported) + AddSignal(8, "SIGFPE", false, true, true ); // 8 floating point exception + AddSignal(9, "SIGKILL", false, true, true ); // 9 kill (cannot be caught or ignored) + AddSignal(10, "SIGBUS", false, true, true ); // 10 bus error + AddSignal(11, "SIGSEGV", false, true, true ); // 11 segmentation violation + AddSignal(12, "SIGSYS", false, true, true ); // 12 bad argument to system call + AddSignal(13, "SIGPIPE", false, true, true ); // 13 write on a pipe with no one to read it + AddSignal(14, "SIGALRM", false, false, true ); // 14 alarm clock + AddSignal(15, "SIGTERM", false, true, true ); // 15 software termination signal from kill + AddSignal(16, "SIGURG", false, false, false); // 16 urgent condition on IO channel + AddSignal(17, "SIGSTOP", false, true, true ); // 17 sendable stop signal not from tty + AddSignal(18, "SIGTSTP", false, true, true ); // 18 stop signal from tty + AddSignal(19, "SIGCONT", false, true, true ); // 19 continue a stopped process + AddSignal(20, "SIGCHLD", false, false, true ); // 20 to parent on child stop or exit + AddSignal(21, "SIGTTIN", false, true, true ); // 21 to readers pgrp upon background tty read + AddSignal(22, "SIGTTOU", false, true, true ); // 22 like TTIN for output if (tp->t_local<OSTOP) + AddSignal(23, "SIGIO", false, false, false); // 23 input/output possible signal + AddSignal(24, "SIGXCPU", false, true, true ); // 24 exceeded CPU time limit + AddSignal(25, "SIGXFSZ", false, true, true ); // 25 exceeded file size limit + AddSignal(26, "SIGVTALRM", false, false, false); // 26 virtual time alarm + AddSignal(27, "SIGPROF", false, false, false); // 27 profiling time alarm + AddSignal(28, "SIGWINCH", false, false, false); // 28 window size changes + AddSignal(29, "SIGINFO", false, true, true ); // 29 information request + AddSignal(30, "SIGUSR1", false, true, true ); // 30 user defined signal 1 + AddSignal(31, "SIGUSR2", false, true, true ); // 31 user defined signal 2 } + void UnixSignals::AddSignal (int signo, const char *name, bool default_suppress, bool default_stop, bool default_notify) { From johnny.chen at apple.com Sun Oct 10 15:25:10 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sun, 10 Oct 2010 20:25:10 -0000 Subject: [Lldb-commits] [lldb] r116171 - /lldb/trunk/test/lldbutil.py Message-ID: <20101010202510.D662A2A6C12E@llvm.org> Author: johnny Date: Sun Oct 10 15:25:10 2010 New Revision: 116171 URL: http://llvm.org/viewvc/llvm-project?rev=116171&view=rev Log: Simplify the generator adaptor to a Python function instead of a class definition, with the function name 'lldb_iter'. Example: def disassemble_instructions (insts): from lldbutil import lldb_iter for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): print i 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=116171&r1=116170&r2=116171&view=diff ============================================================================== --- lldb/trunk/test/lldbutil.py (original) +++ lldb/trunk/test/lldbutil.py Sun Oct 10 15:25:10 2010 @@ -6,28 +6,25 @@ import sys import StringIO -class Iterator(object): +def lldb_iter(obj, getsize, getelem): """ A generator adaptor for lldb aggregate data structures. - API clients pass in the aggregate object, and the names of the methods to - get the size of the object and its individual element. + API clients pass in the aggregate object, the name of the method to get the + size of the object, and the name of the method to get the element given an + index. Example usage: def disassemble_instructions (insts): - from lldbutil import Iterator - for i in Iterator(insts, 'GetSize', 'GetInstructionAtIndex'): + from lldbutil import lldb_iter + for i in lldb_iter(insts, 'GetSize', 'GetInstructionAtIndex'): print i """ - def __init__(self, obj, getsize, getelem): - self.obj = obj - self.getsize = getattr(obj, getsize) - self.getelem = getattr(obj, getelem) - - def __iter__(self): - for i in range(self.getsize()): - yield self.getelem(i) + size = getattr(obj, getsize) + elem = getattr(obj, getelem) + for i in range(size()): + yield elem(i) ######################################################## From gclayton at apple.com Sun Oct 10 15:52:20 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 10 Oct 2010 20:52:20 -0000 Subject: [Lldb-commits] [lldb] r116172 - /lldb/trunk/source/Commands/CommandObjectMemory.cpp Message-ID: <20101010205220.5A7BD2A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 15:52:20 2010 New Revision: 116172 URL: http://llvm.org/viewvc/llvm-project?rev=116172&view=rev Log: Added new options to memory read to allow saving memory to disk as binary bytes or as an ASCII text dump. - The output file is specified with the "--outfile FILE" option. - The memory can be appended to an existing file using the "--append" option. - The memory will be written as an ASCII text dump by default, or as binary with the "--binary" option. Added new options to memory write to allow writing all or part of a file on disk to target memory: - The input file is specified using the "--infile FILE" option - The offset at which to start in the file defaults to zero, but can be overridden using the "--offset OFFSET" option. If the size is not specified, the remaining number of bytes in the file will be used as the default byte size. - The number of bytes to write defaults to the entire file byte size, but can be changed with the "--size COUNT" option. Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=116172&r1=116171&r2=116172&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Sun Oct 10 15:52:20 2010 @@ -142,6 +142,18 @@ error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg); break; + case 'o': + m_outfile_filespec.SetFile (option_arg); + break; + + case 'b': + m_output_as_binary = true; + break; + + case 'a': + m_append_to_outfile = true; + break; + default: error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); break; @@ -157,6 +169,9 @@ m_byte_size = 0; m_count = 0; m_num_per_line = 0; + m_outfile_filespec.Clear(); + m_append_to_outfile = false; + m_output_as_binary = false; } const lldb::OptionDefinition* @@ -174,6 +189,9 @@ uint32_t m_byte_size; uint32_t m_count; uint32_t m_num_per_line; + FileSpec m_outfile_filespec; + bool m_append_to_outfile; + bool m_output_as_binary; }; CommandObjectMemoryRead (CommandInterpreter &interpreter) : @@ -318,17 +336,67 @@ result.SetStatus(eReturnStatusSuccessFinishResult); DataExtractor data(data_sp, process->GetByteOrder(), process->GetAddressByteSize()); - Stream &output_stream = result.GetOutputStream(); - data.Dump(&output_stream, - 0, - m_options.m_format, - item_byte_size, - item_count, - num_per_line, - addr, - 0, - 0); - output_stream.EOL(); + StreamFile outfile_stream; + Stream *output_stream = NULL; + + if (m_options.m_outfile_filespec) + { + char path[PATH_MAX]; + m_options.m_outfile_filespec.GetPath (path, sizeof(path)); + char mode[16] = { 'w', '\0' }; + if (m_options.m_append_to_outfile) + mode[0] = 'a'; + + if (outfile_stream.Open (path, mode)) + { + if (m_options.m_output_as_binary) + { + int bytes_written = outfile_stream.Write (data_sp->GetBytes(), bytes_read); + if (bytes_written > 0) + { + result.GetOutputStream().Printf ("%i bytes %s to '%s'\n", + bytes_written, + m_options.m_append_to_outfile ? "appended" : "written", + path); + return true; + } + else + { + result.AppendErrorWithFormat("Failed to write %zu bytes to '%s'.\n", bytes_read, path); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + else + { + // We are going to write ASCII to the file just point the + // output_stream to our outfile_stream... + output_stream = &outfile_stream; + } + } + else + { + result.AppendErrorWithFormat("Failed to open file '%s' with a mode of '%s'.\n", path, mode); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + else + { + output_stream = &result.GetOutputStream(); + } + + assert (output_stream); + data.Dump (output_stream, + 0, + m_options.m_format, + item_byte_size, + item_count, + num_per_line, + addr, + 0, + 0); + output_stream->EOL(); return true; } @@ -336,16 +404,24 @@ CommandOptions m_options; }; +#define SET1 LLDB_OPT_SET_1 +#define SET2 LLDB_OPT_SET_2 + lldb::OptionDefinition CommandObjectMemoryRead::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, - { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize,"The size in bytes to use when displaying with the selected format."}, - { LLDB_OPT_SET_1, false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine, "The number of items per line to display."}, - { LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, - { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +{ SET1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, +{ SET1 , false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes to use when displaying with the selected format."}, +{ SET1 , false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine,"The number of items per line to display."}, +{ SET1 , false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, +{ SET1 | SET2, false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename, "Dump memory read results into a file."}, +{ SET1 | SET2, false, "append", 'a', no_argument, NULL, 0, eArgTypeNone, "Append memory read results to 'outfile'."}, +{ SET2, false, "binary", 'b', no_argument, NULL, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, +{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; +#undef SET1 +#undef SET2 //---------------------------------------------------------------------- // Write memory to the inferior process @@ -385,6 +461,25 @@ error.SetErrorStringWithFormat("Invalid value for --size option '%s'. Must be positive integer value.\n", option_arg); break; + case 'i': + m_infile.SetFile (option_arg); + if (!m_infile.Exists()) + { + m_infile.Clear(); + error.SetErrorStringWithFormat("Input file does not exist: '%s'\n", option_arg); + } + break; + + case 'o': + { + bool success; + m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success); + if (!success) + { + error.SetErrorStringWithFormat("Invalid offset string '%s'\n", option_arg); + } + } + break; default: error.SetErrorStringWithFormat("Unrecognized short option '%c'\n", short_option); @@ -399,6 +494,8 @@ Options::ResetOptionValues(); m_format = eFormatBytes; m_byte_size = 1; + m_infile.Clear(); + m_infile_offset = 0; } const lldb::OptionDefinition* @@ -414,6 +511,8 @@ // Instance variables to hold the values for command options. lldb::Format m_format; uint32_t m_byte_size; + FileSpec m_infile; + off_t m_infile_offset; }; CommandObjectMemoryWrite (CommandInterpreter &interpreter) : @@ -500,9 +599,18 @@ const size_t argc = command.GetArgumentCount(); - if (argc < 2) + if (m_options.m_infile) { - result.AppendErrorWithFormat ("%s takes an address and at least one value.\n", m_cmd_name.c_str()); + if (argc < 1) + { + result.AppendErrorWithFormat ("%s takes a destination address when writing file contents.\n", m_cmd_name.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + else if (argc < 2) + { + result.AppendErrorWithFormat ("%s takes a destination address and at least one value.\n", m_cmd_name.c_str()); result.SetStatus(eReturnStatusFailed); return false; } @@ -512,14 +620,6 @@ process->GetByteOrder()); size_t item_byte_size = m_options.m_byte_size; - - if (m_options.m_byte_size == 0) - { - if (m_options.m_format == eFormatPointer) - item_byte_size = buffer.GetAddressByteSize(); - else - item_byte_size = 1; - } lldb::addr_t addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0); @@ -529,6 +629,55 @@ result.SetStatus(eReturnStatusFailed); return false; } + + if (m_options.m_infile) + { + size_t length = SIZE_MAX; + if (m_options.m_byte_size > 0) + length = m_options.m_byte_size; + lldb::DataBufferSP data_sp (m_options.m_infile.ReadFileContents (m_options.m_infile_offset, length)); + if (data_sp) + { + length = data_sp->GetByteSize(); + if (length > 0) + { + Error error; + size_t bytes_written = process->WriteMemory (addr, data_sp->GetBytes(), length, error); + + if (bytes_written == length) + { + // All bytes written + result.GetOutputStream().Printf("%zu bytes were written to 0x%llx\n", bytes_written, addr); + result.SetStatus(eReturnStatusSuccessFinishResult); + } + else if (bytes_written > 0) + { + // Some byte written + result.GetOutputStream().Printf("%zu bytes of %zu requested were written to 0x%llx\n", bytes_written, length, addr); + result.SetStatus(eReturnStatusSuccessFinishResult); + } + else + { + result.AppendErrorWithFormat ("Memory write to 0x%llx failed: %s.\n", addr, error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } + } + } + else + { + result.AppendErrorWithFormat ("Unable to read contents of file.\n"); + result.SetStatus(eReturnStatusFailed); + } + return result.Succeeded(); + } + else if (m_options.m_byte_size == 0) + { + if (m_options.m_format == eFormatPointer) + item_byte_size = buffer.GetAddressByteSize(); + else + item_byte_size = 1; + } + command.Shift(); // shift off the address argument uint64_t uval64; int64_t sval64; @@ -708,14 +857,21 @@ CommandOptions m_options; }; +#define SET1 LLDB_OPT_SET_1 +#define SET2 LLDB_OPT_SET_2 + lldb::OptionDefinition CommandObjectMemoryWrite::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format value types that will be decoded and written to memory."}, - { LLDB_OPT_SET_1, false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize,"The size in bytes of the values to write to memory."}, - { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +{ SET1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format value types that will be decoded and written to memory."}, +{ SET1 | SET2, false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes of the values to write to memory."}, +{ SET2, true, "infile", 'i', required_argument, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."}, +{ SET2, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "Start writng bytes from an offset within the input file."}, +{ 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone, NULL } }; +#undef SET1 +#undef SET2 //------------------------------------------------------------------------- // CommandObjectMemory From gclayton at apple.com Sun Oct 10 17:07:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 10 Oct 2010 22:07:18 -0000 Subject: [Lldb-commits] [lldb] r116175 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20101010220718.7E5542A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 17:07:18 2010 New Revision: 116175 URL: http://llvm.org/viewvc/llvm-project?rev=116175&view=rev Log: Plugged memory leak. Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=116175&r1=116174&r2=116175&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Sun Oct 10 17:07:18 2010 @@ -640,15 +640,16 @@ #if defined (__APPLE__) int num_pids; int size_of_pids; - int *pid_list; + std::vector pid_list; size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0); if (size_of_pids == -1) return 0; num_pids = size_of_pids/sizeof(int); - pid_list = (int *) malloc(size_of_pids); - size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, pid_list, size_of_pids); + + pid_list.resize (size_of_pids); + size_of_pids = proc_listpids(PROC_ALL_PIDS, 0, &pid_list[0], size_of_pids); if (size_of_pids == -1) return 0; From gclayton at apple.com Sun Oct 10 17:28:11 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 10 Oct 2010 22:28:11 -0000 Subject: [Lldb-commits] [lldb] r116176 - in /lldb/trunk: include/lldb/Target/Thread.h source/Commands/CommandObjectArgs.cpp source/Commands/CommandObjectFrame.cpp source/Target/Thread.cpp test/signal/ test/signal/Makefile test/signal/main.c Message-ID: <20101010222811.62A192A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 17:28:11 2010 New Revision: 116176 URL: http://llvm.org/viewvc/llvm-project?rev=116176&view=rev Log: Added a new test case to test signals with. Added frame relative frame selection to "frame select". You can now select frames relative to the current frame (which defaults to zero if the current frame hasn't yet been set for a thread): The gdb "up" command can be done as: (lldb) frame select -r 1 The gdb "down" command can be done as: (lldb) frame select -r -1 Place the following in your ~/.lldbinit file for "up" and "down": command alias up frame select -r 1 command alias down frame select -r -1 Added: lldb/trunk/test/signal/ lldb/trunk/test/signal/Makefile lldb/trunk/test/signal/main.c Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=116176&r1=116175&r2=116176&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Sun Oct 10 17:28:11 2010 @@ -262,6 +262,9 @@ virtual lldb::StackFrameSP GetStackFrameAtIndex (uint32_t idx); + uint32_t + GetSelectedFrameIndex (); + lldb::StackFrameSP GetSelectedFrame (); Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=116176&r1=116175&r2=116176&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Sun Oct 10 17:28:11 2010 @@ -37,7 +37,7 @@ // CommandObjectArgs::CommandOptions::CommandOptions () : -Options() + Options() { // Keep only one place to reset the values to their defaults ResetOptionValues(); Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=116176&r1=116175&r2=116176&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Oct 10 17:28:11 2010 @@ -94,6 +94,62 @@ { public: + class CommandOptions : public Options + { + public: + + CommandOptions () : + Options() + { + ResetOptionValues (); + } + + virtual + ~CommandOptions () + { + } + + virtual Error + SetOptionValue (int option_idx, const char *option_arg) + { + Error error; + bool success = false; + char short_option = (char) m_getopt_table[option_idx].val; + switch (short_option) + { + case 'r': + relative_frame_offset = Args::StringToSInt32 (option_arg, INT32_MIN, 0, &success); + if (!success) + error.SetErrorStringWithFormat ("invalid frame offset argument '%s'.\n", option_arg); + break; + + default: + ("Invalid short option character '%c'.\n", short_option); + break; + } + + return error; + } + + void + ResetOptionValues () + { + Options::ResetOptionValues(); + relative_frame_offset = INT32_MIN; + } + + const lldb::OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static lldb::OptionDefinition g_option_table[]; + int32_t relative_frame_offset; + }; + CommandObjectFrameSelect (CommandInterpreter &interpreter) : CommandObject (interpreter, "frame select", @@ -106,7 +162,7 @@ // Define the first (and only) variant of this arg. index_arg.arg_type = eArgTypeFrameIndex; - index_arg.arg_repetition = eArgRepeatPlain; + index_arg.arg_repetition = eArgRepeatOptional; // There is only one variant this argument could be; put it into the argument entry. arg.push_back (index_arg); @@ -119,6 +175,14 @@ { } + virtual + Options * + GetOptions () + { + return &m_options; + } + + bool Execute (Args& command, CommandReturnObject &result) @@ -126,50 +190,73 @@ ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { - if (command.GetArgumentCount() == 1) + const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount(); + uint32_t frame_idx = UINT32_MAX; + if (m_options.relative_frame_offset != INT32_MIN) { - const char *frame_idx_cstr = command.GetArgumentAtIndex(0); - - const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount(); - const uint32_t frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0); - if (frame_idx < num_frames) + // The one and only argument is a signed relative frame index + frame_idx = exe_ctx.thread->GetSelectedFrameIndex (); + if (frame_idx == UINT32_MAX) + frame_idx = 0; + + if (m_options.relative_frame_offset < 0) + { + if (frame_idx >= -m_options.relative_frame_offset) + frame_idx += m_options.relative_frame_offset; + else + frame_idx = 0; + } + else if (m_options.relative_frame_offset > 0) + { + if (num_frames - frame_idx > m_options.relative_frame_offset) + frame_idx += m_options.relative_frame_offset; + else + frame_idx = num_frames - 1; + } + } + else + { + if (command.GetArgumentCount() == 1) + { + const char *frame_idx_cstr = command.GetArgumentAtIndex(0); + frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0); + } + else { - exe_ctx.thread->SetSelectedFrameByIndex (frame_idx); - exe_ctx.frame = exe_ctx.thread->GetSelectedFrame ().get(); + result.AppendError ("invalid arguments.\n"); + m_options.GenerateOptionUsage (m_interpreter, result.GetErrorStream(), this); + } + } + + if (frame_idx < num_frames) + { + exe_ctx.thread->SetSelectedFrameByIndex (frame_idx); + exe_ctx.frame = exe_ctx.thread->GetSelectedFrame ().get(); - if (exe_ctx.frame) + if (exe_ctx.frame) + { + bool already_shown = false; + SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); + if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { - bool already_shown = false; - SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); - if (m_interpreter.GetDebugger().GetUseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) - { - already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); - } + already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + } - if (DisplayFrameForExecutionContext (exe_ctx.thread, - exe_ctx.frame, - m_interpreter, - result.GetOutputStream(), - true, - !already_shown, - 3, - 3)) - { - result.SetStatus (eReturnStatusSuccessFinishResult); - return result.Succeeded(); - } + if (DisplayFrameForExecutionContext (exe_ctx.thread, + exe_ctx.frame, + m_interpreter, + result.GetOutputStream(), + true, + !already_shown, + 3, + 3)) + { + result.SetStatus (eReturnStatusSuccessFinishResult); + return result.Succeeded(); } } - if (frame_idx == UINT32_MAX) - result.AppendErrorWithFormat ("Invalid frame index: %s.\n", frame_idx_cstr); - else - result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx); - } - else - { - result.AppendError ("invalid arguments"); - result.AppendErrorWithFormat ("Usage: %s\n", m_cmd_syntax.c_str()); } + result.AppendErrorWithFormat ("Frame index (%u) out of range.\n", frame_idx); } else { @@ -178,6 +265,16 @@ result.SetStatus (eReturnStatusFailed); return false; } +protected: + + CommandOptions m_options; +}; + +lldb::OptionDefinition +CommandObjectFrameSelect::CommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_1, false, "relative", 'r', required_argument, NULL, 0, eArgTypeOffset, "A relative frame index offset from the current frame index."}, +{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; #pragma mark CommandObjectFrameVariable Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=116176&r1=116175&r2=116176&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Sun Oct 10 17:28:11 2010 @@ -854,6 +854,13 @@ return GetStackFrameList().GetFrameAtIndex(idx); } +uint32_t +Thread::GetSelectedFrameIndex () +{ + return GetStackFrameList().GetSelectedFrameIndex(); +} + + lldb::StackFrameSP Thread::GetSelectedFrame () { Added: lldb/trunk/test/signal/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signal/Makefile?rev=116176&view=auto ============================================================================== --- lldb/trunk/test/signal/Makefile (added) +++ lldb/trunk/test/signal/Makefile Sun Oct 10 17:28:11 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/signal/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signal/main.c?rev=116176&view=auto ============================================================================== --- lldb/trunk/test/signal/main.c (added) +++ lldb/trunk/test/signal/main.c Sun Oct 10 17:28:11 2010 @@ -0,0 +1,25 @@ +#include + +void handler_usr1 (int i) +{ + puts ("got signal usr1"); +} + +void handler_alrm (int i) +{ + puts ("got signal ALRM"); +} + +main () +{ + int i = 0; + + signal (SIGUSR1, handler_usr1); + signal (SIGALRM, handler_alrm); + + puts ("Put breakpoint here"); + + while (i++ < 20) + sleep (1); +} + From gclayton at apple.com Sun Oct 10 18:55:27 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 10 Oct 2010 23:55:27 -0000 Subject: [Lldb-commits] [lldb] r116178 - in /lldb/trunk: include/lldb/Core/RegularExpression.h include/lldb/Symbol/VariableList.h source/Commands/CommandObjectFrame.cpp source/Core/RegularExpression.cpp source/Symbol/VariableList.cpp Message-ID: <20101010235527.4392E2A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 18:55:27 2010 New Revision: 116178 URL: http://llvm.org/viewvc/llvm-project?rev=116178&view=rev Log: Added the ability to get error strings back from failed lldb_private::RegularExpression compiles and matches with: size_t RegularExpression::GetErrorAsCString (char *err_str, size_t err_str_max_len) const; Added the ability to search a variable list for variables whose names match a regular expression: size_t VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableList &var_list, size_t& total_matches); Also added the ability to append a variable to a VariableList only if it is not already in the list: bool VariableList::AddVariableIfUnique (const lldb::VariableSP &var_sp); Cleaned up the "frame variable" command: - Removed the "-n NAME" option as this is the default way for the command to work. - Enable uniqued regex searches on variable names by fixing the "--regex RE" command to work correctly. It will match all variables that match any regular expressions and only print each variable the first time it matches. - Fixed the option type for the "--regex" command to by eArgTypeRegularExpression instead of eArgTypeCount Modified: lldb/trunk/include/lldb/Core/RegularExpression.h lldb/trunk/include/lldb/Symbol/VariableList.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/RegularExpression.cpp lldb/trunk/source/Symbol/VariableList.cpp Modified: lldb/trunk/include/lldb/Core/RegularExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=116178&r1=116177&r2=116178&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegularExpression.h (original) +++ lldb/trunk/include/lldb/Core/RegularExpression.h Sun Oct 10 18:55:27 2010 @@ -115,6 +115,9 @@ bool Execute (const char* string, size_t match_count = 0, int execute_flags = 0) const; + size_t + GetErrorAsCString (char *err_str, size_t err_str_max_len) const; + bool GetMatchAtIndex (const char* s, uint32_t idx, std::string& match_str) const; //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/VariableList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/VariableList.h?rev=116178&r1=116177&r2=116178&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/VariableList.h (original) +++ lldb/trunk/include/lldb/Symbol/VariableList.h Sun Oct 10 18:55:27 2010 @@ -29,8 +29,11 @@ void AddVariable (const lldb::VariableSP &var_sp); + bool + AddVariableIfUnique (const lldb::VariableSP &var_sp); + void - AddVariables(VariableList *variable_list); + AddVariables (VariableList *variable_list); void Clear(); @@ -45,6 +48,19 @@ FindVariable (const ConstString& name); uint32_t + FindVariableIndex (const lldb::VariableSP &var_sp); + + // Returns the actual number of unique variables that were added to the + // list. "total_matches" will get updated with the actualy number of + // matches that were found regardless of whether they were unique or not + // to allow for error conditions when nothing is found, versus conditions + // where any varaibles that match "regex" were already in "var_list". + size_t + AppendVariablesIfUnique (const RegularExpression& regex, + VariableList &var_list, + size_t& total_matches); + + uint32_t FindIndexForVariable (Variable* variable); size_t Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=116178&r1=116177&r2=116178&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Oct 10 18:55:27 2010 @@ -309,7 +309,6 @@ switch (short_option) { case 'o': use_objc = true; break; - case 'n': name = option_arg; break; case 'r': use_regex = true; break; case 'a': show_args = false; break; case 'l': show_locals = false; break; @@ -352,7 +351,6 @@ { Options::ResetOptionValues(); - name.clear(); use_objc = false; use_regex = false; show_args = true; @@ -378,7 +376,6 @@ // Options table: Required for subclasses of Options. static lldb::OptionDefinition g_option_table[]; - std::string name; bool use_objc:1, use_regex:1, show_args:1, @@ -520,168 +517,230 @@ { if (command.GetArgumentCount() > 0) { + VariableList regex_var_list; + // If we have any args to the variable command, we will make // variable objects from them... for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx) { uint32_t ptr_depth = m_options.ptr_depth; - // If first character is a '*', then show pointer contents - if (name_cstr[0] == '*') + + if (m_options.use_regex) { - ++ptr_depth; - name_cstr++; // Skip the '*' + const uint32_t regex_start_index = regex_var_list.GetSize(); + RegularExpression regex (name_cstr); + if (regex.Compile(name_cstr)) + { + size_t num_matches = 0; + const size_t num_new_regex_vars = variable_list->AppendVariablesIfUnique(regex, regex_var_list, num_matches); + if (num_new_regex_vars > 0) + { + for (uint32_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize(); + regex_idx < end_index; + ++regex_idx) + { + var_sp = regex_var_list.GetVariableAtIndex (regex_idx); + if (var_sp) + { + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + if (valobj_sp) + { + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } + + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + var_sp->GetName().AsCString(), + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false); + s.EOL(); + } + } + } + } + else if (num_matches == 0) + { + result.GetErrorStream().Printf ("error: no variables matched the regular expression '%s'.\n", name_cstr); + } + } + else + { + char regex_error[1024]; + if (regex.GetErrorAsCString(regex_error, sizeof(regex_error))) + result.GetErrorStream().Printf ("error: %s\n", regex_error); + else + result.GetErrorStream().Printf ("error: unkown regex error when compiling '%s'\n", name_cstr); + } } - - std::string var_path (name_cstr); - size_t separator_idx = var_path.find_first_of(".-["); - - ConstString name_const_string; - if (separator_idx == std::string::npos) - name_const_string.SetCString (var_path.c_str()); else - name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - - var_sp = variable_list->FindVariable(name_const_string); - if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); + // If first character is a '*', then show pointer contents + if (name_cstr[0] == '*') + { + ++ptr_depth; + name_cstr++; // Skip the '*' + } - var_path.erase (0, name_const_string.GetLength ()); - // We are dumping at least one child - while (separator_idx != std::string::npos) + std::string var_path (name_cstr); + size_t separator_idx = var_path.find_first_of(".-["); + + ConstString name_const_string; + if (separator_idx == std::string::npos) + name_const_string.SetCString (var_path.c_str()); + else + name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); + + var_sp = variable_list->FindVariable(name_const_string); + if (var_sp) { - // Calculate the next separator index ahead of time - ValueObjectSP child_valobj_sp; - const char separator_type = var_path[0]; - switch (separator_type) - { + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); - case '-': - if (var_path.size() >= 2 && var_path[1] != '>') - { - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; - } - var_path.erase (0, 1); // Remove the '-' - // Fall through - case '.': + var_path.erase (0, name_const_string.GetLength ()); + // We are dumping at least one child + while (separator_idx != std::string::npos) + { + // Calculate the next separator index ahead of time + ValueObjectSP child_valobj_sp; + const char separator_type = var_path[0]; + switch (separator_type) { - var_path.erase (0, 1); // Remove the '.' or '>' - separator_idx = var_path.find_first_of(".-["); - ConstString child_name; - if (separator_idx == std::string::npos) - child_name.SetCString (var_path.c_str()); - else - child_name.SetCStringWithLength(var_path.c_str(), separator_idx); - child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); - if (!child_valobj_sp) + case '-': + if (var_path.size() >= 2 && var_path[1] != '>') { - result.GetErrorStream().Printf ("error: can't find child of '%s' named '%s'\n", - valobj_sp->GetName().AsCString(), - child_name.GetCString()); + result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", + var_path.c_str()); var_path.clear(); valobj_sp.reset(); break; } - // Remove the child name from the path - var_path.erase(0, child_name.GetLength()); - } - break; - - case '[': - // Array member access, or treating pointer as an array - if (var_path.size() > 2) // Need at least two brackets and a number - { - char *end = NULL; - int32_t child_index = ::strtol (&var_path[1], &end, 0); - if (end && *end == ']') + var_path.erase (0, 1); // Remove the '-' + // Fall through + case '.': { - - if (valobj_sp->IsPointerType ()) - { - child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); - } + var_path.erase (0, 1); // Remove the '.' or '>' + separator_idx = var_path.find_first_of(".-["); + ConstString child_name; + if (separator_idx == std::string::npos) + child_name.SetCString (var_path.c_str()); else - { - child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); - } + child_name.SetCStringWithLength(var_path.c_str(), separator_idx); + child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { - result.GetErrorStream().Printf ("error: invalid array index %u in '%s'\n", - child_index, - valobj_sp->GetName().AsCString()); + result.GetErrorStream().Printf ("error: can't find child of '%s' named '%s'\n", + valobj_sp->GetName().AsCString(), + child_name.GetCString()); var_path.clear(); valobj_sp.reset(); break; } + // Remove the child name from the path + var_path.erase(0, child_name.GetLength()); + } + break; - // Erase the array member specification '[%i]' where %i is the array index - var_path.erase(0, (end - var_path.c_str()) + 1); - separator_idx = var_path.find_first_of(".-["); + case '[': + // Array member access, or treating pointer as an array + if (var_path.size() > 2) // Need at least two brackets and a number + { + char *end = NULL; + int32_t child_index = ::strtol (&var_path[1], &end, 0); + if (end && *end == ']') + { - // Break out early from the switch since we were able to find the child member - break; + if (valobj_sp->IsPointerType ()) + { + child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); + } + else + { + child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); + } + + if (!child_valobj_sp) + { + result.GetErrorStream().Printf ("error: invalid array index %u in '%s'\n", + child_index, + valobj_sp->GetName().AsCString()); + var_path.clear(); + valobj_sp.reset(); + break; + } + + // Erase the array member specification '[%i]' where %i is the array index + var_path.erase(0, (end - var_path.c_str()) + 1); + separator_idx = var_path.find_first_of(".-["); + + // Break out early from the switch since we were able to find the child member + break; + } } - } - result.GetErrorStream().Printf ("error: invalid array member specification for '%s' starting at '%s'\n", - valobj_sp->GetName().AsCString(), - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; + result.GetErrorStream().Printf ("error: invalid array member specification for '%s' starting at '%s'\n", + valobj_sp->GetName().AsCString(), + var_path.c_str()); + var_path.clear(); + valobj_sp.reset(); + break; - break; + break; - default: - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - separator_idx = std::string::npos; - break; - } + default: + result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", + var_path.c_str()); + var_path.clear(); + valobj_sp.reset(); + separator_idx = std::string::npos; + break; + } - if (child_valobj_sp) - valobj_sp = child_valobj_sp; + if (child_valobj_sp) + valobj_sp = child_valobj_sp; - if (var_path.empty()) - break; + if (var_path.empty()) + break; - } + } - if (valobj_sp) - { - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + if (valobj_sp) { - var_sp->GetDeclaration ().DumpStopContext (&s, false); - s.PutCString (": "); - } + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } - ValueObject::DumpValueObject (result.GetOutputStream(), - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - ptr_depth, - 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - false); + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false); - s.EOL(); + s.EOL(); + } + } + else + { + result.GetErrorStream().Printf ("error: unable to find any variables named '%s'\n", name_cstr); + var_path.clear(); } - } - else - { - result.GetErrorStream().Printf ("error: unable to find any variables named '%s'\n", name_cstr); - var_path.clear(); } } } @@ -782,7 +841,6 @@ { LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, eArgTypeVarName, "Find a global variable by name (which might not be in the current stack frame source file)."}, { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, { LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, eArgTypeNone, "Show variable declaration information (source file and line where the variable was declared)."}, -{ LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, eArgTypeVarName, "Lookup a variable by name or regex (--regex) for the current execution context."}, { LLDB_OPT_SET_1, false, "no-args", 'a', no_argument, NULL, 0, eArgTypeNone, "Omit function arguments."}, { LLDB_OPT_SET_1, false, "no-locals", 'l', no_argument, NULL, 0, eArgTypeNone, "Omit local variables."}, { LLDB_OPT_SET_1, false, "no-types", 't', no_argument, NULL, 0, eArgTypeNone, "Omit variable type names."}, @@ -790,7 +848,7 @@ { LLDB_OPT_SET_1, false, "scope", 's', no_argument, NULL, 0, eArgTypeNone, "Show variable scope (argument, local, global, static)."}, { LLDB_OPT_SET_1, false, "objc", 'o', no_argument, NULL, 0, eArgTypeNone, "When looking up a variable by name (--name), print as an Objective-C object."}, { LLDB_OPT_SET_1, false, "ptr-depth", 'p', required_argument, NULL, 0, eArgTypeCount, "The number of pointers to be traversed when dumping values (default is zero)."}, -{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeCount, "The argument for name lookups are regular expressions."}, +{ LLDB_OPT_SET_1, false, "regex", 'r', no_argument, NULL, 0, eArgTypeRegularExpression, "The argument for name lookups are regular expressions."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; #pragma mark CommandObjectMultiwordFrame Modified: lldb/trunk/source/Core/RegularExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegularExpression.cpp?rev=116178&r1=116177&r2=116178&view=diff ============================================================================== --- lldb/trunk/source/Core/RegularExpression.cpp (original) +++ lldb/trunk/source/Core/RegularExpression.cpp Sun Oct 10 18:55:27 2010 @@ -153,3 +153,18 @@ m_comp_err = 1; } } + +size_t +RegularExpression::GetErrorAsCString (char *err_str, size_t err_str_max_len) const +{ + if (m_comp_err == 0) + { + if (err_str && err_str_max_len) + *err_str = '\0'; + return 0; + } + + return ::regerror (m_comp_err, &m_preg, err_str, err_str_max_len); +} + + Modified: lldb/trunk/source/Symbol/VariableList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VariableList.cpp?rev=116178&r1=116177&r2=116178&view=diff ============================================================================== --- lldb/trunk/source/Symbol/VariableList.cpp (original) +++ lldb/trunk/source/Symbol/VariableList.cpp Sun Oct 10 18:55:27 2010 @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/VariableList.h" + +#include "lldb/Core/RegularExpression.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/CompileUnit.h" @@ -30,13 +32,22 @@ { } - void -VariableList::AddVariable(const VariableSP &variable_sp) +VariableList::AddVariable(const VariableSP &var_sp) { - m_variables.push_back(variable_sp); + m_variables.push_back(var_sp); } +bool +VariableList::AddVariableIfUnique (const lldb::VariableSP &var_sp) +{ + if (FindVariableIndex (var_sp) == UINT32_MAX) + { + m_variables.push_back(var_sp); + return true; + } + return false; +} void VariableList::AddVariables(VariableList *variable_list) @@ -46,25 +57,32 @@ back_inserter(m_variables)); // destination } - void VariableList::Clear() { m_variables.clear(); } - - VariableSP VariableList::GetVariableAtIndex(uint32_t idx) { - VariableSP variable_sp; + VariableSP var_sp; if (idx < m_variables.size()) - variable_sp = m_variables[idx]; - return variable_sp; + var_sp = m_variables[idx]; + return var_sp; } - +uint32_t +VariableList::FindVariableIndex (const VariableSP &var_sp) +{ + iterator pos, end = m_variables.end(); + for (pos = m_variables.begin(); pos != end; ++pos) + { + if (pos->get() == var_sp.get()) + return std::distance (m_variables.begin(), pos); + } + return UINT32_MAX; +} VariableSP VariableList::FindVariable(const ConstString& name) @@ -82,6 +100,25 @@ return var_sp; } +size_t +VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableList &var_list, size_t& total_matches) +{ + const size_t initial_size = var_list.GetSize(); + iterator pos, end = m_variables.end(); + for (pos = m_variables.begin(); pos != end; ++pos) + { + if (regex.Execute ((*pos)->GetName().AsCString())) + { + // Note the total matches found + total_matches++; + // Only add this variable if it isn't already in the "var_list" + var_list.AddVariableIfUnique (*pos); + } + } + // Return the number of new unique variables added to "var_list" + return var_list.GetSize() - initial_size; +} + uint32_t VariableList::FindIndexForVariable (Variable* variable) { @@ -113,7 +150,6 @@ return m_variables.size(); } - void VariableList::Dump(Stream *s, bool show_context) const { From gclayton at apple.com Sun Oct 10 20:05:37 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 11 Oct 2010 01:05:37 -0000 Subject: [Lldb-commits] [lldb] r116179 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Interpreter/CommandInterpreter.h source/API/SBDebugger.cpp source/Commands/CommandObjectBreakpoint.cpp source/Interpreter/CommandInterpreter.cpp tools/driver/Driver.cpp Message-ID: <20101011010537.677F32A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 20:05:37 2010 New Revision: 116179 URL: http://llvm.org/viewvc/llvm-project?rev=116179&view=rev Log: Added a "--no-lldbinit" option (-n for short (which magically matches what gdb uses)) so we can tell our "lldb" driver program to not automatically parse any .lldbinit files. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Interpreter/CommandInterpreter.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=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Sun Oct 10 20:05:37 2010 @@ -42,6 +42,9 @@ SetAsync (bool b); void + SkipLLDBInitFiles (bool b); + + void SetInputFileHandle (FILE *f, bool transfer_ownership); void Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Sun Oct 10 20:05:37 2010 @@ -202,6 +202,12 @@ ScriptInterpreter * GetScriptInterpreter (); + void + SkipLLDBInitFiles (bool skip_lldbinit_files) + { + m_skip_lldbinit_files = skip_lldbinit_files; + } + bool GetSynchronous (); @@ -239,6 +245,7 @@ Debugger &m_debugger; // The debugger session that this interpreter is associated with bool m_synchronous_execution; + bool m_skip_lldbinit_files; CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands CommandObject::CommandMap m_user_dict; // Stores user-defined commands Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Sun Oct 10 20:05:37 2010 @@ -10,11 +10,6 @@ #include "lldb/API/SBDebugger.h" #include "lldb/lldb-include.h" -#include "lldb/Interpreter/Args.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/TargetList.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBBroadcaster.h" @@ -29,6 +24,12 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBTarget.h" #include "lldb/API/SBThread.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/State.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/TargetList.h" using namespace lldb; using namespace lldb_private; @@ -82,6 +83,13 @@ m_opaque_sp->SetAsyncExecution(b); } +void +SBDebugger::SkipLLDBInitFiles (bool b) +{ + if (m_opaque_sp) + m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b); +} + // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users // trying to switch modes in the middle of a debugging session. void Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Sun Oct 10 20:05:37 2010 @@ -309,78 +309,79 @@ switch (break_type) { case eSetTypeFileAndLine: // Breakpoint by source position - { - FileSpec file; - if (m_options.m_filename.empty()) { - StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; - if (cur_frame == NULL) - { - result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); - result.SetStatus (eReturnStatusFailed); - break; - } - else if (!cur_frame->HasDebugInformation()) - { - result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); - result.SetStatus (eReturnStatusFailed); - break; - } - else + FileSpec file; + if (m_options.m_filename.empty()) { - const SymbolContext &context = cur_frame->GetSymbolContext(true); - if (context.line_entry.file) + StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; + if (cur_frame == NULL) { - file = context.line_entry.file; - } - else if (context.comp_unit != NULL) - { file = context.comp_unit; + result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); + result.SetStatus (eReturnStatusFailed); + break; } - else + else if (!cur_frame->HasDebugInformation()) { - result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); + result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info."); result.SetStatus (eReturnStatusFailed); break; } + else + { + const SymbolContext &context = cur_frame->GetSymbolContext(true); + if (context.line_entry.file) + { + file = context.line_entry.file; + } + else if (context.comp_unit != NULL) + { file = context.comp_unit; + } + else + { + result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame."); + result.SetStatus (eReturnStatusFailed); + break; + } + } + } + else + { + file.SetFile(m_options.m_filename.c_str()); } - } - else - { - file.SetFile(m_options.m_filename.c_str()); - } - if (use_module) - { - for (int i = 0; i < num_modules; ++i) + if (use_module) { - module.SetFile(m_options.m_modules[i].c_str()); - bp = target->CreateBreakpoint (&module, - file, - m_options.m_line_num, - m_options.m_ignore_inlines).get(); - if (bp) - { - StreamString &output_stream = result.GetOutputStream(); - output_stream.Printf ("Breakpoint created: "); - bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); - output_stream.EOL(); - result.SetStatus (eReturnStatusSuccessFinishResult); - } - else + for (int i = 0; i < num_modules; ++i) { - result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", - m_options.m_modules[i].c_str()); - result.SetStatus (eReturnStatusFailed); + module.SetFile(m_options.m_modules[i].c_str()); + bp = target->CreateBreakpoint (&module, + file, + m_options.m_line_num, + m_options.m_ignore_inlines).get(); + if (bp) + { + StreamString &output_stream = result.GetOutputStream(); + output_stream.Printf ("Breakpoint created: "); + bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief); + output_stream.EOL(); + result.SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n", + m_options.m_modules[i].c_str()); + result.SetStatus (eReturnStatusFailed); + } } } + else + bp = target->CreateBreakpoint (NULL, + file, + m_options.m_line_num, + m_options.m_ignore_inlines).get(); } - else - bp = target->CreateBreakpoint (NULL, - file, - m_options.m_line_num, - m_options.m_ignore_inlines).get(); - } - break; + break; + case eSetTypeAddress: // Breakpoint by address bp = target->CreateBreakpoint (m_options.m_load_addr, false).get(); break; Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Sun Oct 10 20:05:37 2010 @@ -59,7 +59,8 @@ ) : Broadcaster ("CommandInterpreter"), m_debugger (debugger), - m_synchronous_execution (synchronous_execution) + m_synchronous_execution (synchronous_execution), + m_skip_lldbinit_files (false) { const char *dbg_name = debugger.GetInstanceName().AsCString(); std::string lang_name = ScriptInterpreter::LanguageToString (script_language); @@ -1060,6 +1061,10 @@ void CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result) { + // Don't parse any .lldbinit files if we were asked not to + if (m_skip_lldbinit_files) + return; + const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit"; FileSpec init_file (init_file_path); // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=116179&r1=116178&r2=116179&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Sun Oct 10 20:05:37 2010 @@ -75,6 +75,9 @@ { LLDB_OPT_SET_ALL, false, "editor", 'e', no_argument, NULL, NULL, eArgTypeNone, "Tells the debugger to open source files using the host's \"external editor\" mechanism." }, + { LLDB_OPT_SET_ALL, false, "no-lldbinit", 'n', no_argument, NULL, NULL, eArgTypeNone, + "Do not automatically parse any '.lldbinit' files." }, + // { LLDB_OPT_SET_4, true, "crash-log", 'c', required_argument, NULL, NULL, eArgTypeFilename, // "Load executable images from a crash log for symbolication." }, @@ -554,10 +557,15 @@ case 'c': m_option_data.m_crash_log = optarg; break; + case 'e': m_option_data.m_use_external_editor = true; break; - + + case 'n': + m_debugger.SkipLLDBInitFiles (true); + break; + case 'f': { SBFileSpec file(optarg); From gclayton at apple.com Sun Oct 10 20:13:37 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 11 Oct 2010 01:13:37 -0000 Subject: [Lldb-commits] [lldb] r116180 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20101011011337.F30A72A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 20:13:37 2010 New Revision: 116180 URL: http://llvm.org/viewvc/llvm-project?rev=116180&view=rev Log: Exit if the command line is started with "--help". Modified: lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=116180&r1=116179&r2=116180&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Sun Oct 10 20:13:37 2010 @@ -651,6 +651,7 @@ if (error.Fail() || m_option_data.m_print_help) { ShowUsage (out_fh, g_options, m_option_data); + exit = true; } else if (m_option_data.m_print_version) { From gclayton at apple.com Sun Oct 10 21:25:35 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 11 Oct 2010 02:25:35 -0000 Subject: [Lldb-commits] [lldb] r116181 - in /lldb/trunk/source/Symbol: ClangASTContext.cpp ClangASTType.cpp Type.cpp Message-ID: <20101011022535.0FA9F2A6C12E@llvm.org> Author: gclayton Date: Sun Oct 10 21:25:34 2010 New Revision: 116181 URL: http://llvm.org/viewvc/llvm-project?rev=116181&view=rev Log: Fixed an issue where objc types weren't ever getting fully resolved (beyond forward declarations). Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=116181&r1=116180&r2=116181&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Oct 10 21:25:34 2010 @@ -784,7 +784,7 @@ if (language == eLanguageTypeObjC) { - bool isForwardDecl = false; + bool isForwardDecl = true; bool isInternal = false; return CreateObjCClass (name, decl_ctx, isForwardDecl, isInternal); } Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=116181&r1=116180&r2=116181&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Sun Oct 10 21:25:34 2010 @@ -825,6 +825,16 @@ return tag_decl->getDefinition() != NULL; return false; } + else + { + clang::ObjCObjectType *objc_class_type = dyn_cast(qual_type); + if (objc_class_type) + { + clang::ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + if (class_interface_decl->isForwardDecl()) + return false; + } + } return true; } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=116181&r1=116180&r2=116181&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Sun Oct 10 21:25:34 2010 @@ -529,15 +529,14 @@ // definition. m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_qual_type); } - else - { - // If we have an encoding type, then we need to make sure it is - // resolved appropriately - Type *encoding_type = GetEncodingType (); - if (encoding_type != NULL) - encoding_type->ResolveClangType (forward_decl_is_ok); - } } + + // If we have an encoding type, then we need to make sure it is + // resolved appropriately + Type *encoding_type = GetEncodingType (); + if (encoding_type != NULL) + encoding_type->ResolveClangType (forward_decl_is_ok); + // if (g_depth > 0) // --g_depth; return m_clang_qual_type != NULL;