From jingham at apple.com Mon Aug 8 19:00:49 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 00:00:49 -0000 Subject: [Lldb-commits] [lldb] r137077 - in /lldb/trunk: include/lldb/Expression/ClangUserExpression.h source/Expression/ClangUserExpression.cpp Message-ID: <20110809000049.AAB372A6C12C@llvm.org> Author: jingham Date: Mon Aug 8 19:00:49 2011 New Revision: 137077 URL: http://llvm.org/viewvc/llvm-project?rev=137077&view=rev Log: Add EvaluateWithError static method. Fix a bug in handling constant expressions - we weren't setting the result even though the expression evaluation succeeded... Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=137077&r1=137076&r2=137077&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Aug 8 19:00:49 2011 @@ -282,6 +282,14 @@ const char *expr_cstr, const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp); + + static ExecutionResults + EvaluateWithError (ExecutionContext &exe_ctx, + bool discard_on_error, + const char *expr_cstr, + const char *expr_prefix, + lldb::ValueObjectSP &result_valobj_sp, + Error &error); private: //------------------------------------------------------------------ Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=137077&r1=137076&r2=137077&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Aug 8 19:00:49 2011 @@ -605,9 +605,20 @@ const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp) { + Error error; + return EvaluateWithError (exe_ctx, discard_on_error, expr_cstr, expr_prefix, result_valobj_sp, error); +} + +ExecutionResults +ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx, + bool discard_on_error, + const char *expr_cstr, + const char *expr_prefix, + lldb::ValueObjectSP &result_valobj_sp, + Error &error) +{ lldb::LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP)); - Error error; ExecutionResults execution_results = eExecutionSetupError; if (exe_ctx.process == NULL || exe_ctx.process->GetState() != lldb::eStateStopped) @@ -668,6 +679,7 @@ log->Printf("== [ClangUserExpression::Evaluate] Expression evaluated as a constant =="); result_valobj_sp = user_expression_sp->m_const_result->GetValueObject(); + execution_results = eExecutionCompleted; } else { From gclayton at apple.com Mon Aug 8 19:01:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Aug 2011 00:01:09 -0000 Subject: [Lldb-commits] [lldb] r137078 - in /lldb/trunk: include/lldb/Core/Module.h source/Commands/CommandObjectTarget.cpp source/Core/Module.cpp Message-ID: <20110809000109.A8E992A6C12C@llvm.org> Author: gclayton Date: Mon Aug 8 19:01:09 2011 New Revision: 137078 URL: http://llvm.org/viewvc/llvm-project?rev=137078&view=rev Log: Added a "--global" option to the "target modules list" command that allows us to see all modules that exist and their corresponding global shared pointer count. This will help us track down memory issues when modules aren't being removed and cleaned up from the module list. Modified: lldb/trunk/include/lldb/Core/Module.h lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/Module.cpp Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=137078&r1=137077&r2=137078&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Mon Aug 8 19:01:09 2011 @@ -50,6 +50,22 @@ friend class ModuleList; friend bool ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch); + // Static functions that can track the lifetime of moodule objects. + // This is handy because we might have Module objects that are in + // shared pointers that aren't in the global module list (from + // ModuleList). If this is the case we need to know about it. + // The modules in the global list maintained by these functions + // can be viewed using the "target modules list" command using the + // "--global" (-g for short). + static size_t + GetNumberAllocatedModules (); + + static Module * + GetAllocatedModuleAtIndex (size_t idx); + + static Mutex & + GetAllocationModuleCollectionMutex(); + //------------------------------------------------------------------ /// Construct with file specification and architecture. /// Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137078&r1=137077&r2=137078&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Aug 8 19:01:09 2011 @@ -2467,8 +2467,8 @@ public: CommandOptions (CommandInterpreter &interpreter) : - Options(interpreter), - m_format_array() + Options(interpreter), + m_format_array() { } @@ -2481,10 +2481,17 @@ SetOptionValue (uint32_t option_idx, const char *option_arg) { char short_option = (char) m_getopt_table[option_idx].val; - uint32_t width = 0; - if (option_arg) - width = strtoul (option_arg, NULL, 0); - m_format_array.push_back(std::make_pair(short_option, width)); + if (short_option == 'g') + { + m_use_global_module_list = true; + } + else + { + uint32_t width = 0; + if (option_arg) + width = strtoul (option_arg, NULL, 0); + m_format_array.push_back(std::make_pair(short_option, width)); + } Error error; return error; } @@ -2493,6 +2500,7 @@ OptionParsingStarting () { m_format_array.clear(); + m_use_global_module_list = false; } const OptionDefinition* @@ -2508,6 +2516,7 @@ // Instance variables to hold the values for command options. typedef std::vector< std::pair > FormatWidthCollection; FormatWidthCollection m_format_array; + bool m_use_global_module_list; }; CommandObjectTargetModulesList (CommandInterpreter &interpreter) : @@ -2548,15 +2557,35 @@ result.GetOutputStream().SetAddressByteSize(addr_byte_size); result.GetErrorStream().SetAddressByteSize(addr_byte_size); // Dump all sections for all modules images - const uint32_t num_modules = target->GetImages().GetSize(); + uint32_t num_modules = 0; + Mutex::Locker locker; + if (m_options.m_use_global_module_list) + { + locker.Reset (Module::GetAllocationModuleCollectionMutex().GetMutex()); + num_modules = Module::GetNumberAllocatedModules(); + } + else + num_modules = target->GetImages().GetSize(); + if (num_modules > 0) { Stream &strm = result.GetOutputStream(); for (uint32_t image_idx = 0; image_idxGetImages().GetModulePointerAtIndex(image_idx); - strm.Printf("[%3u] ", image_idx); + Module *module; + if (m_options.m_use_global_module_list) + { + module = Module::GetAllocatedModuleAtIndex(image_idx); + ModuleSP module_sp(module->GetSP()); + // Show the module reference count when showing the global module index + strm.Printf("[%3u] ref_count = %lu ", image_idx, module_sp ? module_sp.use_count() - 1 : 0); + } + else + { + module = target->GetImages().GetModulePointerAtIndex(image_idx); + strm.Printf("[%3u] ", image_idx); + } bool dump_object_name = false; if (m_options.m_format_array.empty()) @@ -2663,6 +2692,7 @@ { LLDB_OPT_SET_1, false, "basename", 'b', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename with optional width for the image object file."}, { LLDB_OPT_SET_1, false, "symfile", 's', optional_argument, NULL, 0, eArgTypeWidth, "Display the fullpath to the image symbol file with optional width."}, { LLDB_OPT_SET_1, false, "symfile-basename", 'S', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename to the image symbol file with optional width."}, + { LLDB_OPT_SET_1, false, "global", 'g', no_argument, NULL, 0, eArgTypeNone, "Display the modules from the global module list, not just the current target."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=137078&r1=137077&r2=137078&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Mon Aug 8 19:01:09 2011 @@ -20,6 +20,45 @@ using namespace lldb; using namespace lldb_private; +// Shared pointers to modules track module lifetimes in +// targets and in the global module, but this collection +// will track all module objects that are still alive +typedef std::vector ModuleCollection; + +static ModuleCollection & +GetModuleCollection() +{ + static ModuleCollection g_module_collection; + return g_module_collection; +} + +Mutex & +Module::GetAllocationModuleCollectionMutex() +{ + static Mutex g_module_collection_mutex(Mutex::eMutexTypeRecursive); + return g_module_collection_mutex; +} + +size_t +Module::GetNumberAllocatedModules () +{ + Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + return GetModuleCollection().size(); +} + +Module * +Module::GetAllocatedModuleAtIndex (size_t idx) +{ + Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + ModuleCollection &modules = GetModuleCollection(); + if (idx < modules.size()) + return modules[idx]; + return NULL; +} + + + + Module::Module(const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name, off_t object_offset) : m_mutex (Mutex::eMutexTypeRecursive), m_mod_time (file_spec.GetModificationTime()), @@ -38,6 +77,12 @@ m_did_init_ast (false), m_is_dynamic_loader_module (false) { + // Scope for locker below... + { + Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + GetModuleCollection().push_back(this); + } + if (object_name) m_object_name = *object_name; LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); @@ -54,6 +99,15 @@ Module::~Module() { + // Scope for locker below... + { + Mutex::Locker locker (GetAllocationModuleCollectionMutex()); + ModuleCollection &modules = GetModuleCollection(); + ModuleCollection::iterator end = modules.end(); + ModuleCollection::iterator pos = std::find(modules.begin(), end, this); + if (pos != end) + modules.erase(pos); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); if (log) log->Printf ("%p Module::~Module((%s) '%s/%s%s%s%s')", From jingham at apple.com Mon Aug 8 19:26:56 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 00:26:56 -0000 Subject: [Lldb-commits] [lldb] r137081 - /lldb/trunk/tools/driver/Driver.cpp Message-ID: <20110809002656.7368E2A6C12C@llvm.org> Author: jingham Date: Mon Aug 8 19:26:56 2011 New Revision: 137081 URL: http://llvm.org/viewvc/llvm-project?rev=137081&view=rev Log: Remove some commented out code that doesn't connect to anything yet... 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=137081&r1=137080&r2=137081&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon Aug 8 19:26:56 2011 @@ -1066,12 +1066,6 @@ exit(5); } -// const char *crash_log = GetCrashLogFilename(); -// if (crash_log) -// { -// ParseCrashLog (crash_log); -// } -// SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter(); m_io_channel_ap.reset (new IOChannel(m_editline_slave_fh, editline_output_slave_fh, stdout, stderr, this)); From jingham at apple.com Mon Aug 8 19:32:53 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 00:32:53 -0000 Subject: [Lldb-commits] [lldb] r137084 - /lldb/trunk/source/Target/Thread.cpp Message-ID: <20110809003253.2233E2A6C12C@llvm.org> Author: jingham Date: Mon Aug 8 19:32:52 2011 New Revision: 137084 URL: http://llvm.org/viewvc/llvm-project?rev=137084&view=rev Log: Don't create a new stop info if we've already calculated one and it is still valid. Modified: lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=137084&r1=137083&r2=137084&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Mon Aug 8 19:32:52 2011 @@ -93,13 +93,22 @@ if (plan_sp) return StopInfo::CreateStopReasonWithPlan (plan_sp); else - return GetPrivateStopReason (); + { + if (m_actual_stop_info_sp + && m_actual_stop_info_sp->IsValid() + && m_thread_stop_reason_stop_id == m_process.GetStopID()) + return m_actual_stop_info_sp; + else + return GetPrivateStopReason (); + } } void Thread::SetStopInfo (const lldb::StopInfoSP &stop_info_sp) { m_actual_stop_info_sp = stop_info_sp; + if (m_actual_stop_info_sp) + m_actual_stop_info_sp->MakeStopInfoValid(); m_thread_stop_reason_stop_id = GetProcess().GetStopID(); } From johnny.chen at apple.com Mon Aug 8 19:56:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 00:56:07 -0000 Subject: [Lldb-commits] [lldb] r137092 - /lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Message-ID: <20110809005607.768F32A6C12C@llvm.org> Author: johnny Date: Mon Aug 8 19:56:07 2011 New Revision: 137092 URL: http://llvm.org/viewvc/llvm-project?rev=137092&view=rev Log: Check in a customized benchmark which compares the Xcode 4.1 vs. Xcode 4.2's gdb disassembly speed on lldb's Driver::MainLoop function which is ~1190 lines of x86 assembly code. This file is not exercised during the normal test suite run, i.e., no +b option specified. So it should be ok. The following is the benchmark result on my MBP running OSX Lion: [17:38:46] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v +b -p TestFlintVsSlate /Volumes/data/lldb/svn/trunk/build/Debug LLDB-71 Path: /Volumes/data/lldb/svn/trunk URL: https://johnny at llvm.org/svn/llvm-project/lldb/trunk Repository Root: https://johnny at llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 137008 Node Kind: directory Schedule: normal Last Changed Author: gclayton Last Changed Rev: 137008 Last Changed Date: 2011-08-05 17:50:36 -0700 (Fri, 05 Aug 2011) Session logs for test failures/errors/unexpected successes will go into directory '2011-08-08-17_38_52' Command invoked: python ./dotest.py -v +b -p TestFlintVsSlate ---------------------------------------------------------------------- Collected 2 tests 1: test_run_41_then_42 (TestFlintVsSlateGDBDisassembly.FlintVsSlateGDBDisassembly) Test disassembly on a large function with 4.1 vs. 4.2's gdb. ... 4.1 gdb benchmark: Avg: 0.205623 (Laps: 5, Total Elapsed Time: 1.028113) 4.2 gdb benchmark: Avg: 0.201970 (Laps: 5, Total Elapsed Time: 1.009849) gdb_42_avg/gdb_41_avg: 0.982236 ok 2: test_run_42_then_41 (TestFlintVsSlateGDBDisassembly.FlintVsSlateGDBDisassembly) Test disassembly on a large function with 4.1 vs. 4.2's gdb. ... 4.2 gdb benchmark: Avg: 0.202602 (Laps: 5, Total Elapsed Time: 1.013012) 4.1 gdb benchmark: Avg: 0.204418 (Laps: 5, Total Elapsed Time: 1.022089) gdb_42_avg/gdb_41_avg: 0.991119 ok ---------------------------------------------------------------------- Ran 2 tests in 15.688s OK Added: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Added: lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py?rev=137092&view=auto ============================================================================== --- lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py (added) +++ lldb/trunk/test/benchmarks/disassembly/TestFlintVsSlateGDBDisassembly.py Mon Aug 8 19:56:07 2011 @@ -0,0 +1,92 @@ +"""Disassemble lldb's Driver::MainLoop() functions comparing Xcode 4.1 vs. 4.2's gdb.""" + +import os, sys +import unittest2 +import lldb +import pexpect +from lldbbench import * + +class FlintVsSlateGDBDisassembly(BenchBase): + + mydir = os.path.join("benchmarks", "example") + + def setUp(self): + BenchBase.setUp(self) + self.gdb_41_exe = '/Flint/usr/bin/gdb' + self.gdb_42_exe = '/Developer/usr/bin/gdb' + self.exe = self.lldbExec + self.function = 'Driver::MainLoop()' + self.gdb_41_avg = None + self.gdb_42_avg = None + + @benchmarks_test + def test_run_41_then_42(self): + """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" + print + self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, 5) + print "4.1 gdb benchmark:", self.stopwatch + self.gdb_41_avg = self.stopwatch.avg() + self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, 5) + print "4.2 gdb benchmark:", self.stopwatch + self.gdb_42_avg = self.stopwatch.avg() + print "gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg) + + @benchmarks_test + def test_run_42_then_41(self): + """Test disassembly on a large function with 4.1 vs. 4.2's gdb.""" + print + self.run_gdb_disassembly(self.gdb_42_exe, self.exe, self.function, 5) + print "4.2 gdb benchmark:", self.stopwatch + self.gdb_42_avg = self.stopwatch.avg() + self.run_gdb_disassembly(self.gdb_41_exe, self.exe, self.function, 5) + print "4.1 gdb benchmark:", self.stopwatch + self.gdb_41_avg = self.stopwatch.avg() + print "gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg) + + def run_gdb_disassembly(self, gdb_exe_path, exe, function, count): + # Set self.child_prompt, which is "(gdb) ". + self.child_prompt = '(gdb) ' + prompt = self.child_prompt + + # So that the child gets torn down after the test. + self.child = pexpect.spawn('%s %s' % (gdb_exe_path, exe)) + child = self.child + + # Turn on logging for what the child sends back. + if self.TraceOn(): + child.logfile_read = sys.stdout + + child.expect_exact(prompt) + child.sendline('break %s' % function) + child.expect_exact(prompt) + child.sendline('run') + child.expect_exact(prompt) + + # Reset the stopwatch now. + self.stopwatch.reset() + for i in range(count): + with self.stopwatch: + # Disassemble the function. + child.sendline('disassemble') + child.expect_exact(prompt) + child.sendline('next') + child.expect_exact(prompt) + + child.sendline('quit') + child.expect_exact('The program is running. Exit anyway?') + child.sendline('y') + try: + self.child.expect(pexpect.EOF) + except: + pass + + if self.TraceOn(): + print "gdb disassembly benchmark:", str(self.stopwatch) + self.child = None + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() From granata.enrico at gmail.com Mon Aug 8 20:04:57 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 09 Aug 2011 01:04:57 -0000 Subject: [Lldb-commits] [lldb] r137097 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Target/StackFrame.h source/Core/ValueObject.cpp source/Symbol/ClangASTType.cpp source/Target/StackFrame.cpp source/Target/Target.cpp test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Message-ID: <20110809010457.205FD2A6C12C@llvm.org> Author: enrico Date: Mon Aug 8 20:04:56 2011 New Revision: 137097 URL: http://llvm.org/viewvc/llvm-project?rev=137097&view=rev Log: Basic support for reading synthetic children by index: if your datatype provides synthetic children, "frame variable object[index]" should now do the right thing in cases where the above syntax would have been rejected before, i.e. object is not a pointer nor an array (frame variable ignores potential overload of []) object is a pointer to an Objective-C class (which cannot be dereferenced) expression will still run operator[] if available and complain if it cannot do so synthetic children by name do not work yet Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Aug 8 20:04:56 2011 @@ -122,13 +122,16 @@ bool m_check_dot_vs_arrow_syntax; bool m_no_fragile_ivar; bool m_allow_bitfields_syntax; + bool m_no_synthetic_children; GetValueForExpressionPathOptions(bool dot = false, bool no_ivar = false, - bool bitfield = true) : + bool bitfield = true, + bool no_synth = false) : m_check_dot_vs_arrow_syntax(dot), m_no_fragile_ivar(no_ivar), - m_allow_bitfields_syntax(bitfield) + m_allow_bitfields_syntax(bitfield), + m_no_synthetic_children(no_synth) { } @@ -174,6 +177,20 @@ return *this; } + GetValueForExpressionPathOptions& + DoAllowSyntheticChildren() + { + m_no_synthetic_children = false; + return *this; + } + + GetValueForExpressionPathOptions& + DontAllowSyntheticChildren() + { + m_no_synthetic_children = true; + return *this; + } + static const GetValueForExpressionPathOptions DefaultOptions() { @@ -565,6 +582,9 @@ lldb::ValueObjectSP GetSyntheticValue (lldb::SyntheticValueType use_synthetic); + bool + HasSyntheticValue(); + virtual lldb::ValueObjectSP CreateConstantValue (const ConstString &name); Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Mon Aug 8 20:04:56 2011 @@ -32,8 +32,9 @@ public: enum ExpressionPathOption { - eExpressionPathOptionCheckPtrVsMember = (1u << 0), - eExpressionPathOptionsNoFragileObjcIvar = (1u << 1) + eExpressionPathOptionCheckPtrVsMember = (1u << 0), + eExpressionPathOptionsNoFragileObjcIvar = (1u << 1), + eExpressionPathOptionsNoSyntheticChildren = (1u << 2) }; //------------------------------------------------------------------ // Constructors and Destructors Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Aug 8 20:04:56 2011 @@ -1668,6 +1668,22 @@ } bool +ValueObject::HasSyntheticValue() +{ + UpdateFormatsIfNeeded(m_last_format_mgr_dynamic); + + if (m_last_synthetic_filter.get() == NULL) + return false; + + CalculateSyntheticValue(lldb::eUseSyntheticFilter); + + if (m_synthetic_value) + return true; + else + return false; +} + +bool ValueObject::GetBaseClassPath (Stream &s) { if (IsBaseClass()) @@ -2042,12 +2058,15 @@ { if (!root_clang_type_info.Test(ClangASTContext::eTypeIsArray) && !root_clang_type_info.Test(ClangASTContext::eTypeIsPointer)) // if this is not a T[] nor a T* { - if (!root_clang_type_info.Test(ClangASTContext::eTypeIsScalar)) // if this is not even a scalar, this syntax is just plain wrong! + if (!root_clang_type_info.Test(ClangASTContext::eTypeIsScalar)) // if this is not even a scalar... { - *first_unparsed = expression_cstr; - *reason_to_stop = ValueObject::eRangeOperatorInvalid; - *final_result = ValueObject::eInvalid; - return ValueObjectSP(); + if (options.m_no_synthetic_children) // ...only chance left is synthetic + { + *first_unparsed = expression_cstr; + *reason_to_stop = ValueObject::eRangeOperatorInvalid; + *final_result = ValueObject::eInvalid; + return ValueObjectSP(); + } } else if (!options.m_allow_bitfields_syntax) // if this is a scalar, check that we can expand bitfields { @@ -2117,6 +2136,9 @@ ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index, true); if (!child_valobj_sp) child_valobj_sp = root->GetSyntheticArrayMemberFromArray(index, true); + if (!child_valobj_sp) + if (root->HasSyntheticValue() && root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetNumChildren() > index) + child_valobj_sp = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildAtIndex(index, true); if (child_valobj_sp) { root = child_valobj_sp; @@ -2154,7 +2176,19 @@ } else { - root = root->GetSyntheticArrayMemberFromPointer(index, true); + if (ClangASTType::GetMinimumLanguage(root->GetClangAST(), + root->GetClangType()) == lldb::eLanguageTypeObjC + && + ClangASTContext::IsPointerType(ClangASTType::GetPointeeType(root->GetClangType())) == false + && + root->HasSyntheticValue() + && + options.m_no_synthetic_children == false) + { + root = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildAtIndex(index, true); + } + else + root = root->GetSyntheticArrayMemberFromPointer(index, true); if (!root.get()) { *first_unparsed = expression_cstr; @@ -2170,7 +2204,7 @@ } } } - else /*if (ClangASTContext::IsScalarType(root_clang_type))*/ + else if (ClangASTContext::IsScalarType(root_clang_type)) { root = root->GetSyntheticBitFieldChild(index, index, true); if (!root.get()) @@ -2188,6 +2222,24 @@ return root; } } + else if (root->HasSyntheticValue() && options.m_no_synthetic_children) + { + root = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildAtIndex(index, true); + if (!root.get()) + { + *first_unparsed = expression_cstr; + *reason_to_stop = ValueObject::eNoSuchChild; + *final_result = ValueObject::eInvalid; + return ValueObjectSP(); + } + } + else + { + *first_unparsed = expression_cstr; + *reason_to_stop = ValueObject::eNoSuchChild; + *final_result = ValueObject::eInvalid; + return ValueObjectSP(); + } } else // we have a low and a high index { Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Mon Aug 8 20:04:56 2011 @@ -115,6 +115,8 @@ ConstString ClangASTType::GetConstTypeName () { + if (!ClangASTContext::GetCompleteType (this->m_ast, this->m_type)) + return ConstString(""); return GetConstTypeName (m_type); } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Aug 8 20:04:56 2011 @@ -525,6 +525,7 @@ { const bool check_ptr_vs_member = (options & eExpressionPathOptionCheckPtrVsMember) != 0; const bool no_fragile_ivar = (options & eExpressionPathOptionsNoFragileObjcIvar) != 0; + const bool no_synth_child = (options & eExpressionPathOptionsNoSyntheticChildren) != 0; error.Clear(); bool deref = false; bool address_of = false; @@ -718,14 +719,55 @@ if (valobj_sp->IsPointerType ()) { - child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); - if (!child_valobj_sp) + if (no_synth_child == false + && + ClangASTType::GetMinimumLanguage(valobj_sp->GetClangAST(), + valobj_sp->GetClangType()) == lldb::eLanguageTypeObjC /* is ObjC pointer */ + && + ClangASTContext::IsPointerType(ClangASTType::GetPointeeType(valobj_sp->GetClangType())) == false /* is not double-ptr */) { - valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", - child_index, - valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + // dereferencing ObjC variables is not valid.. so let's try and recur to synthetic children + lldb::ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter); + if (synthetic.get() == NULL /* no synthetic */ + || synthetic == valobj_sp) /* synthetic is the same as the original object */ + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else + { + child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + } + } + else + { + child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } } } else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL)) @@ -757,10 +799,36 @@ } else { - valobj_sp->GetExpressionPath (var_expr_path_strm, false); - error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", - valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + lldb::ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter); + if (no_synth_child /* synthetic is forbidden */ || + synthetic.get() == NULL /* no synthetic */ + || synthetic == valobj_sp) /* synthetic is the same as the original object */ + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else if (child_index >= synthetic->GetNumChildren() /* synthetic does not have that many values */) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else + { + child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + } } if (!child_valobj_sp) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Aug 8 20:04:56 2011 @@ -1035,7 +1035,8 @@ frame->CalculateExecutionContext(exe_ctx); Error error; const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | - StackFrame::eExpressionPathOptionsNoFragileObjcIvar; + StackFrame::eExpressionPathOptionsNoFragileObjcIvar | + StackFrame::eExpressionPathOptionsNoSyntheticChildren; lldb::VariableSP var_sp; result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, use_dynamic, Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=137097&r1=137096&r2=137097&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Mon Aug 8 20:04:56 2011 @@ -164,6 +164,22 @@ '[5] = 123456', '[6] = 1234567', '}']) + + # check access-by-index + self.expect("frame variable numbers[0]", + substrs = ['1']); + self.expect("frame variable numbers[1]", + substrs = ['12']); + self.expect("frame variable numbers[2]", + substrs = ['123']); + self.expect("frame variable numbers[3]", + substrs = ['1234']); + + # but check that expression does not rely on us + # (when expression gets to call into STL code correctly, we will have to find + # another way to check this) + self.expect("expression numbers[6]", matching=False, error=True, + substrs = ['1234567']) # clear out the vector and see that we do the right thing once again self.runCmd("n") @@ -202,6 +218,18 @@ self.expect("frame variable strings", substrs = ['vector has 4 items']) + + # check access-by-index + self.expect("frame variable strings[0]", + substrs = ['goofy']); + self.expect("frame variable strings[1]", + substrs = ['is']); + + # but check that expression does not rely on us + # (when expression gets to call into STL code correctly, we will have to find + # another way to check this) + self.expect("expression strings[0]", matching=False, error=True, + substrs = ['goofy']) self.runCmd("n") @@ -255,6 +283,16 @@ '0x0abcdef0', '[5] =', '0x0cab0cab']) + + # check access-by-index + self.expect("frame variable numbers_list[0]", + substrs = ['0x12345678']); + self.expect("frame variable numbers_list[1]", + substrs = ['0x11223344']); + + # but check that expression does not rely on us + self.expect("expression numbers_list[0]", matching=False, error=True, + substrs = ['0x12345678']) self.runCmd("n") @@ -298,6 +336,16 @@ '[1] = \"is\"', '[2] = \"smart\"', '[3] = \"!!!\"']) + + # check access-by-index + self.expect("frame variable text_list[0]", + substrs = ['goofy']); + self.expect("frame variable text_list[3]", + substrs = ['!!!']); + + # but check that expression does not rely on us + self.expect("expression text_list[0]", matching=False, error=True, + substrs = ['goofy']) # now std::map # also take a chance to test regex synth here @@ -347,6 +395,18 @@ '[7] = {', 'first = 7', 'second = 1']) + + # check access-by-index + self.expect("frame variable ii[0]", + substrs = ['first = 0', + 'second = 0']); + self.expect("frame variable ii[3]", + substrs = ['first =', + 'second =']); + + # but check that expression does not rely on us + self.expect("expression ii[0]", matching=False, error=True, + substrs = ['first = 0']) self.runCmd("n") @@ -391,6 +451,15 @@ '[4] = ', 'first = \"four\"', 'second = 4']) + + # check access-by-index + self.expect("frame variable si[0]", + substrs = ['first = ', 'four', + 'second = 4']); + + # but check that expression does not rely on us + self.expect("expression si[0]", matching=False, error=True, + substrs = ['first = ', 'zero']) self.runCmd("n") @@ -424,6 +493,15 @@ '[3] = ', 'second = \"!!!\"', 'first = 3']) + + # check access-by-index + self.expect("frame variable is[0]", + substrs = ['first = ', '0', + 'second =', 'goofy']); + + # but check that expression does not rely on us + self.expect("expression is[0]", matching=False, error=True, + substrs = ['first = ', 'goofy']) self.runCmd("n") @@ -457,6 +535,14 @@ '[3] = ', 'second = \"..is always a Mac!\"', 'first = \"a Mac..\"']) + + # check access-by-index + self.expect("frame variable ss[3]", + substrs = ['gatto', 'cat']); + + # but check that expression does not rely on us + self.expect("expression ss[3]", matching=False, error=True, + substrs = ['gatto']) self.runCmd("n") From jingham at apple.com Mon Aug 8 21:12:22 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 02:12:22 -0000 Subject: [Lldb-commits] [lldb] r137102 - in /lldb/trunk: include/lldb/Breakpoint/Breakpoint.h include/lldb/Core/UserID.h include/lldb/Core/ValueObject.h include/lldb/Target/Process.h include/lldb/Target/StopInfo.h include/lldb/lldb-forward.h source/Breakpoint/BreakpointLocation.cpp source/Core/ValueObject.cpp source/Target/Process.cpp source/Target/StopInfo.cpp test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20110809021222.547212A6C12C@llvm.org> Author: jingham Date: Mon Aug 8 21:12:22 2011 New Revision: 137102 URL: http://llvm.org/viewvc/llvm-project?rev=137102&view=rev Log: Move the handling of breakpoint conditions from the Private event loop to the StopInfoBreakpoint::DoActions, which happens as the event is removed. Also use the return value of asynchronous breakpoint callbacks, they get checked before, and override the breakpoint conditions. Added ProcessModInfo class, to unify "stop_id generation" and "memory modification generation", and use where needed. Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h lldb/trunk/include/lldb/Core/UserID.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/StopInfo.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StopInfo.cpp lldb/trunk/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original) +++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Mon Aug 8 21:12:22 2011 @@ -349,12 +349,20 @@ GetThreadID (); //------------------------------------------------------------------ - /// Set the callback action invoked when the breakpoint is hit. The callback - /// Will return a bool indicating whether the target should stop at this breakpoint or not. + /// Set the callback action invoked when the breakpoint is hit. + /// /// @param[in] callback /// The method that will get called when the breakpoint is hit. /// @param[in] baton /// A void * pointer that will get passed back to the callback function. + /// @param[in] is_synchronous + /// If \b true the callback will be run on the private event thread + /// before the stop event gets reported. If false, the callback will get + /// handled on the public event thead after the stop has been posted. + /// + /// @return + /// \b true if the process should stop when you hit the breakpoint. + /// \b false if it should continue. //------------------------------------------------------------------ void SetCallback (BreakpointHitCallback callback, Modified: lldb/trunk/include/lldb/Core/UserID.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserID.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserID.h (original) +++ lldb/trunk/include/lldb/Core/UserID.h Mon Aug 8 21:12:22 2011 @@ -111,9 +111,6 @@ lldb::user_id_t m_uid; ///< The user ID that uniquely identifies an object. }; -//-------------------------------------------------------------- -/// Stream the UserID object to a Stream. -//-------------------------------------------------------------- inline bool operator== (const UserID& lhs, const UserID& rhs) { return lhs.GetID() == rhs.GetID(); @@ -124,6 +121,9 @@ return lhs.GetID() != rhs.GetID(); } +//-------------------------------------------------------------- +/// Stream the UserID object to a Stream. +//-------------------------------------------------------------- Stream& operator << (Stream& strm, const UserID& uid); } // namespace lldb_private Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Aug 8 21:12:22 2011 @@ -26,6 +26,7 @@ #include "lldb/Core/Value.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/ExecutionContextScope.h" +#include "lldb/Target/Process.h" #include "lldb/Target/StackID.h" #include "lldb/Utility/PriorityPointerPair.h" #include "lldb/Utility/SharedCluster.h" @@ -240,25 +241,25 @@ SetIsConstant () { SetUpdated(); - m_stop_id = LLDB_INVALID_UID; + m_mod_id.SetInvalid(); } bool IsConstant () const { - return m_stop_id == LLDB_INVALID_UID; + return !m_mod_id.IsValid(); } - lldb::user_id_t - GetUpdateID () const + ProcessModID + GetModID () const { - return m_stop_id; + return m_mod_id; } void - SetUpdateID (lldb::user_id_t new_id) + SetUpdateID (ProcessModID new_id) { - m_stop_id = new_id; + m_mod_id = new_id; } bool @@ -286,11 +287,11 @@ bool IsValid () { - if (m_stop_id == LLDB_INVALID_UID) + if (!m_mod_id.IsValid()) return false; else if (SyncWithProcessState ()) { - if (m_stop_id == LLDB_INVALID_UID) + if (!m_mod_id.IsValid()) return false; } return true; @@ -301,13 +302,11 @@ { // Use the stop id to mark us as invalid, leave the thread id and the stack id around for logging and // history purposes. - m_stop_id = LLDB_INVALID_UID; + m_mod_id.SetInvalid(); // Can't update an invalid state. m_needs_update = false; -// m_thread_id = LLDB_INVALID_THREAD_ID; -// m_stack_id.Clear(); } private: @@ -323,7 +322,7 @@ lldb::ProcessSP m_process_sp; lldb::user_id_t m_thread_id; StackID m_stack_id; - lldb::user_id_t m_stop_id; // This is the stop id when this ValueObject was last evaluated. + ProcessModID m_mod_id; // This is the stop id when this ValueObject was last evaluated. }; const EvaluationPoint & @@ -691,7 +690,7 @@ SetCustomSummaryFormat(lldb::SummaryFormatSP format) { m_forced_summary_format = format; - m_user_id_of_forced_summary = m_update_point.GetUpdateID(); + m_user_id_of_forced_summary = m_update_point.GetModID(); m_summary_str.clear(); } @@ -789,7 +788,7 @@ lldb::SummaryFormatSP m_forced_summary_format; lldb::ValueFormatSP m_last_value_format; lldb::SyntheticChildrenSP m_last_synthetic_filter; - lldb::user_id_t m_user_id_of_forced_summary; + ProcessModID m_user_id_of_forced_summary; bool m_value_is_valid:1, m_value_did_change:1, Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Aug 8 21:12:22 2011 @@ -911,6 +911,84 @@ }; +// This class tracks the Modification state of the process. Things that can currently modify +// the program are running the program (which will up the StopID) and writing memory (which +// will up the MemoryID.) +// FIXME: Should we also include modification of register states? + +class ProcessModID +{ +friend bool operator== (const ProcessModID &lhs, const ProcessModID &rhs); +public: + ProcessModID () : + m_stop_id (0), + m_memory_id (0) + {} + + ProcessModID (const ProcessModID &rhs) : + m_stop_id (rhs.m_stop_id), + m_memory_id (rhs.m_memory_id) + {} + + const ProcessModID & operator= (const ProcessModID &rhs) + { + if (this != &rhs) + { + m_stop_id = rhs.m_stop_id; + m_memory_id = rhs.m_memory_id; + } + return *this; + } + + ~ProcessModID () {} + + void BumpStopID () { m_stop_id++; } + void BumpMemoryID () { m_memory_id++; } + + uint32_t GetStopID() const { return m_stop_id; } + uint32_t GetMemoryID () const { return m_memory_id; } + + bool MemoryIDEqual (const ProcessModID &compare) const + { + return m_memory_id == compare.m_memory_id; + } + + bool StopIDEqual (const ProcessModID &compare) const + { + return m_stop_id == compare.m_stop_id; + } + + void SetInvalid () + { + m_stop_id = UINT32_MAX; + } + + bool IsValid () const + { + return m_stop_id != UINT32_MAX; + } +private: + uint32_t m_stop_id; + uint32_t m_memory_id; +}; +inline bool operator== (const ProcessModID &lhs, const ProcessModID &rhs) +{ + if (lhs.StopIDEqual (rhs) + && lhs.MemoryIDEqual (rhs)) + return true; + else + return false; +} + +inline bool operator!= (const ProcessModID &lhs, const ProcessModID &rhs) +{ + if (!lhs.StopIDEqual (rhs) + || !lhs.MemoryIDEqual (rhs)) + return true; + else + return false; +} + //---------------------------------------------------------------------- /// @class Process Process.h "lldb/Target/Process.h" /// @brief A plug-in interface definition class for debugging a process. @@ -924,6 +1002,10 @@ { friend class ThreadList; friend class ClangFunction; // For WaitForStateChangeEventsPrivate +friend class CommandObjectProcessLaunch; +friend class ProcessEventData; +friend class CommandObjectBreakpointCommand; +friend class StopInfo; public: @@ -1079,6 +1161,7 @@ DISALLOW_COPY_AND_ASSIGN (SettingsController); }; + #endif static void @@ -1909,9 +1992,6 @@ uint32_t num_frames_with_source); protected: - friend class CommandObjectProcessLaunch; - friend class ProcessEventData; - friend class CommandObjectBreakpointCommand; void SetState (lldb::EventSP &event_sp); @@ -1953,15 +2033,23 @@ } //------------------------------------------------------------------ - /// Get the number of times this process has posted a stop event. + /// Get the Modification ID of the process. /// /// @return - /// The number of times this process has stopped while being - /// debugged. + /// The modification ID of the process. //------------------------------------------------------------------ + ProcessModID + GetModID () const + { + return m_mod_id; + } + uint32_t - GetStopID () const; - + GetStopID () const + { + return m_mod_id.GetStopID(); + } + //------------------------------------------------------------------ /// Set accessor for the process exit status (return code). /// @@ -2619,7 +2707,12 @@ protected: //------------------------------------------------------------------ - // lldb::ExecutionContextScope pure virtual functions + // NextEventAction provides a way to register an action on the next + // event that is delivered to this process. There is currently only + // one next event action allowed in the process at one time. If a + // new "NextEventAction" is added while one is already present, the + // old action will be discarded (with HandleBeingUnshipped called + // after it is discarded.) //------------------------------------------------------------------ class NextEventAction { @@ -2691,7 +2784,7 @@ Listener m_private_state_listener; // This is the listener for the private state thread. Predicate m_private_state_control_wait; /// This Predicate is used to signal that a control operation is complete. lldb::thread_t m_private_state_thread; // Thread ID for the thread that watches interal state events - uint32_t m_stop_id; ///< A count of many times the process has stopped. + ProcessModID m_mod_id; ///< Tracks the state of the process over stops and other alterations. uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index that won't get re-used. int m_exit_status; ///< The exit status of the process, or -1 if not set. std::string m_exit_string; ///< A textual description of why a process exited. Modified: lldb/trunk/include/lldb/Target/StopInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StopInfo.h (original) +++ lldb/trunk/include/lldb/Target/StopInfo.h Mon Aug 8 21:12:22 2011 @@ -138,6 +138,12 @@ uint32_t m_stop_id; // The process stop ID for which this stop info is valid uint64_t m_value; // A generic value that can be used for things pertaining to this stop info std::string m_description; // A textual description describing this stop. + + // This provides an accessor to the PrivateEventState of the process for StopInfo's w/o having to make each + // StopInfo subclass a friend of Process. + lldb::StateType + GetPrivateState (); + private: friend class Thread; @@ -149,7 +155,6 @@ DISALLOW_COPY_AND_ASSIGN (StopInfo); }; - } // namespace lldb_private #endif // liblldb_StopInfo_h_ Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Aug 8 21:12:22 2011 @@ -104,6 +104,7 @@ class PathMappingList; class Platform; class Process; +class ProcessModID; class ProcessInfo; class ProcessInstanceInfo; class ProcessInstanceInfoList; Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Mon Aug 8 21:12:22 2011 @@ -224,37 +224,6 @@ context->is_synchronous = true; should_stop = InvokeCallback (context); - // The SYNCHRONOUS callback says we should stop, next try the condition. - - if (should_stop && GetConditionText() != NULL) - { - // We need to make sure the user sees any parse errors in their condition, so we'll hook the - // constructor errors up to the debugger's Async I/O. - - StreamString errors; - ThreadPlanSP condition_plan_sp(GetThreadPlanToTestCondition(context->exe_ctx, errors)); - - if (condition_plan_sp == NULL) - { - if (log) - log->Printf("Error evaluating condition: \"%s\"\n", errors.GetData()); - - Debugger &debugger = context->exe_ctx.target->GetDebugger(); - StreamSP error_sp = debugger.GetAsyncErrorStream (); - error_sp->PutCString ("Error parsing breakpoint condition:\n"); - error_sp->PutCString (errors.GetData()); - error_sp->EOL(); - error_sp->Flush(); - - } - else - { - // Queue our condition, then continue so that we can run it. - context->exe_ctx.thread->QueueThreadPlan(condition_plan_sp, false); - should_stop = false; - } - } - if (log) { StreamString s; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Aug 8 21:12:22 2011 @@ -82,7 +82,7 @@ m_forced_summary_format(), m_last_value_format(), m_last_synthetic_filter(), - m_user_id_of_forced_summary(0), + m_user_id_of_forced_summary(), m_value_is_valid (false), m_value_did_change (false), m_children_count_valid (false), @@ -128,7 +128,7 @@ m_forced_summary_format(), m_last_value_format(), m_last_synthetic_filter(), - m_user_id_of_forced_summary(0), + m_user_id_of_forced_summary(), m_value_is_valid (false), m_value_did_change (false), m_children_count_valid (false), @@ -223,7 +223,7 @@ GetName().GetCString(), m_last_format_mgr_revision, Debugger::Formatting::ValueFormats::GetCurrentRevision()); - if (HasCustomSummaryFormat() && m_update_point.GetUpdateID() != m_user_id_of_forced_summary) + if (HasCustomSummaryFormat() && m_update_point.GetModID() != m_user_id_of_forced_summary) { ClearCustomSummaryFormat(); m_summary_str.clear(); @@ -1236,7 +1236,21 @@ unsigned long long ull_val = strtoull(value_str, &end, 0); if (end && *end != '\0') return false; - m_value.GetScalar() = ull_val; + Value::ValueType value_type = m_value.GetValueType(); + switch (value_type) + { + case Value::eValueTypeLoadAddress: + case Value::eValueTypeHostAddress: + // The value in these cases lives in the data. So update the data: + + break; + case Value::eValueTypeScalar: + m_value.GetScalar() = ull_val; + break; + case Value::eValueTypeFileAddress: + // Try to convert the file address to a load address and then write the new value there. + break; + } // Limit the bytes in our m_data appropriately. m_value.GetScalar().GetData (m_data, byte_size); } @@ -3093,7 +3107,7 @@ ValueObject::EvaluationPoint::EvaluationPoint () : m_thread_id (LLDB_INVALID_UID), - m_stop_id (0) + m_mod_id () { } @@ -3101,7 +3115,7 @@ m_needs_update (true), m_first_update (true), m_thread_id (LLDB_INVALID_THREAD_ID), - m_stop_id (0) + m_mod_id () { ExecutionContext exe_ctx; @@ -3120,7 +3134,8 @@ if (m_process_sp != NULL) { - m_stop_id = m_process_sp->GetStopID(); + m_mod_id = m_process_sp->GetModID(); + Thread *thread = NULL; if (exe_ctx.thread == NULL) @@ -3166,7 +3181,7 @@ m_process_sp (rhs.m_process_sp), m_thread_id (rhs.m_thread_id), m_stack_id (rhs.m_stack_id), - m_stop_id (0) + m_mod_id () { } @@ -3193,7 +3208,7 @@ ValueObject::EvaluationPoint::SyncWithProcessState() { // If we're already invalid, we don't need to do anything, and nothing has changed: - if (m_stop_id == LLDB_INVALID_UID) + if (!m_mod_id.IsValid()) { // Can't update with an invalid state. m_needs_update = false; @@ -3205,16 +3220,17 @@ return false; // If our stop id is the current stop ID, nothing has changed: - uint32_t cur_stop_id = m_process_sp->GetStopID(); - if (m_stop_id == cur_stop_id) + ProcessModID current_mod_id = m_process_sp->GetModID(); + + if (m_mod_id == current_mod_id) return false; // If the current stop id is 0, either we haven't run yet, or the process state has been cleared. // In either case, we aren't going to be able to sync with the process state. - if (cur_stop_id == 0) + if (current_mod_id.GetStopID() == 0) return false; - m_stop_id = cur_stop_id; + m_mod_id = current_mod_id; m_needs_update = true; m_exe_scope = m_process_sp.get(); @@ -3251,7 +3267,9 @@ m_first_update = false; m_needs_update = false; if (m_process_sp) - m_stop_id = m_process_sp->GetStopID(); + { + m_mod_id = m_process_sp->GetModID(); + } } @@ -3276,12 +3294,11 @@ // FOR NOW - assume you can't update variable objects across process boundaries. Process *old_process = m_process_sp.get(); assert (process == old_process); - - lldb::user_id_t stop_id = process->GetStopID(); - if (stop_id != m_stop_id) + ProcessModID current_mod_id = process->GetModID(); + if (m_mod_id != current_mod_id) { needs_update = true; - m_stop_id = stop_id; + m_mod_id = current_mod_id; } // See if we're switching the thread or stack context. If no thread is given, this is // being evaluated in a global context. Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Aug 8 21:12:22 2011 @@ -581,7 +581,7 @@ m_private_state_listener ("lldb.process.internal_state_listener"), m_private_state_control_wait(), m_private_state_thread (LLDB_INVALID_HOST_THREAD), - m_stop_id (0), + m_mod_id (), m_thread_index_id (0), m_exit_status (-1), m_exit_string (), @@ -709,8 +709,36 @@ StateType Process::WaitForProcessToStop (const TimeValue *timeout) { - StateType match_states[] = { eStateStopped, eStateCrashed, eStateDetached, eStateExited, eStateUnloaded }; - return WaitForState (timeout, match_states, sizeof(match_states) / sizeof(StateType)); + // We can't just wait for a "stopped" event, because the stopped event may have restarted the target. + // We have to actually check each event, and in the case of a stopped event check the restarted flag + // on the event. + EventSP event_sp; + StateType state = GetState(); + // If we are exited or detached, we won't ever get back to any + // other valid state... + if (state == eStateDetached || state == eStateExited) + return state; + + while (state != eStateInvalid) + { + state = WaitForStateChangedEvents (timeout, event_sp); + switch (state) + { + case eStateCrashed: + case eStateDetached: + case eStateExited: + case eStateUnloaded: + return state; + case eStateStopped: + if (Process::ProcessEventData::GetRestartedFromEvent(event_sp.get())) + continue; + else + return state; + default: + continue; + } + } + return state; } @@ -1047,10 +1075,10 @@ m_private_state.SetValueNoLock (new_state); if (StateIsStoppedState(new_state)) { - m_stop_id++; + m_mod_id.BumpStopID(); m_memory_cache.Clear(); if (log) - log->Printf("Process::SetPrivateState (%s) stop_id = %u", StateAsCString(new_state), m_stop_id); + log->Printf("Process::SetPrivateState (%s) stop_id = %u", StateAsCString(new_state), m_mod_id.GetStopID()); } // Use our target to get a shared pointer to ourselves... m_private_state_broadcaster.BroadcastEvent (eBroadcastBitStateChanged, new ProcessEventData (GetTarget().GetProcessSP(), new_state)); @@ -1062,13 +1090,6 @@ } } - -uint32_t -Process::GetStopID() const -{ - return m_stop_id; -} - addr_t Process::GetImageInfoAddress() { @@ -1774,10 +1795,7 @@ if (buf == NULL || size == 0) return 0; - // Need to bump the stop ID after writing so that ValueObjects will know to re-read themselves. - // FUTURE: Doing this should be okay, but if anybody else gets upset about the stop_id changing when - // the target hasn't run, then we will need to add a "memory generation" as well as a stop_id... - m_stop_id++; + m_mod_id.BumpMemoryID(); // We need to write any data that would go where any current software traps // (enabled software breakpoints) any software traps (breakpoints) that we @@ -1910,11 +1928,12 @@ addr_t allocated_addr = DoAllocateMemory (size, permissions, error); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) - log->Printf("Process::AllocateMemory(size=%4zu, permissions=%s) => 0x%16.16llx (m_stop_id = %u)", + log->Printf("Process::AllocateMemory(size=%4zu, permissions=%s) => 0x%16.16llx (m_stop_id = %u m_memory_id = %u)", size, GetPermissionsAsCString (permissions), (uint64_t)allocated_addr, - m_stop_id); + m_mod_id.GetStopID(), + m_mod_id.GetMemoryID()); return allocated_addr; #endif } @@ -1933,10 +1952,11 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) - log->Printf("Process::DeallocateMemory(addr=0x%16.16llx) => err = %s (m_stop_id = %u)", + log->Printf("Process::DeallocateMemory(addr=0x%16.16llx) => err = %s (m_stop_id = %u, m_memory_id = %u)", ptr, error.AsCString("SUCCESS"), - m_stop_id); + m_mod_id.GetStopID(), + m_mod_id.GetMemoryID()); #endif return error; } @@ -2360,7 +2380,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) log->Printf("Process::Resume() m_stop_id = %u, public state: %s private state: %s", - m_stop_id, + m_mod_id.GetStopID(), StateAsCString(m_public_state.GetValue()), StateAsCString(m_private_state.GetValue())); @@ -2944,6 +2964,10 @@ int num_threads = m_process_sp->GetThreadList().GetSize(); int idx; + // The actions might change one of the thread's stop_info's opinions about whether we should + // stop the process, so we need to query that as we go. + bool still_should_stop = true; + for (idx = 0; idx < num_threads; ++idx) { lldb::ThreadSP thread_sp = m_process_sp->GetThreadList().GetThreadAtIndex(idx); @@ -2952,22 +2976,39 @@ if (stop_info_sp) { stop_info_sp->PerformAction(event_ptr); + // The stop action might restart the target. If it does, then we want to mark that in the + // event so that whoever is receiving it will know to wait for the running event and reflect + // that state appropriately. + // We also need to stop processing actions, since they aren't expecting the target to be running. + if (m_process_sp->GetPrivateState() == eStateRunning) + { + SetRestarted (true); + break; + } + else if (!stop_info_sp->ShouldStop(event_ptr)) + { + still_should_stop = false; + } } } - - // The stop action might restart the target. If it does, then we want to mark that in the - // event so that whoever is receiving it will know to wait for the running event and reflect - // that state appropriately. - if (m_process_sp->GetPrivateState() == eStateRunning) - SetRestarted(true); - else + + if (m_process_sp->GetPrivateState() != eStateRunning) { - // Finally, if we didn't restart, run the Stop Hooks here: - // They might also restart the target, so watch for that. - m_process_sp->GetTarget().RunStopHooks(); - if (m_process_sp->GetPrivateState() == eStateRunning) + if (!still_should_stop) + { + // We've been asked to continue, so do that here. SetRestarted(true); + m_process_sp->Resume(); + } + else + { + // If we didn't restart, run the Stop Hooks here: + // They might also restart the target, so watch for that. + m_process_sp->GetTarget().RunStopHooks(); + if (m_process_sp->GetPrivateState() == eStateRunning) + SetRestarted(true); + } } } @@ -3776,6 +3817,7 @@ if (discard_on_error && thread_plan_sp) { exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread_plan_sp->SetPrivate (orig_plan_private); } } } @@ -3787,6 +3829,7 @@ if (discard_on_error && thread_plan_sp) { exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread_plan_sp->SetPrivate (orig_plan_private); } } else @@ -3812,6 +3855,7 @@ if (log) log->Printf("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set."); exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); + thread_plan_sp->SetPrivate (orig_plan_private); } } } Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Mon Aug 8 21:12:22 2011 @@ -19,7 +19,10 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/Process.h" @@ -47,10 +50,18 @@ m_stop_id = m_thread.GetProcess().GetStopID(); } +lldb::StateType +StopInfo::GetPrivateState () +{ + return m_thread.GetProcess().GetPrivateState(); +} + //---------------------------------------------------------------------- // StopInfoBreakpoint //---------------------------------------------------------------------- +namespace lldb_private +{ class StopInfoBreakpoint : public StopInfo { public: @@ -121,21 +132,122 @@ return; m_should_perform_action = false; + LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); + // We're going to calculate whether we should stop or not in some way during the course of + // this code. So set the valid flag here. Also by default we're going to stop, so + // set that here too. + // m_should_stop_is_valid = true; + m_should_stop = true; + BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value)); if (bp_site_sp) { size_t num_owners = bp_site_sp->GetNumberOfOwners(); + + // We only continue from the callbacks if ALL the callbacks want us to continue. + // However we want to run all the callbacks, except of course if one of them actually + // resumes the target. + // So we use stop_requested to track what we're were asked to do. + bool stop_requested = true; for (size_t j = 0; j < num_owners; j++) { - // The breakpoint action is an asynchronous breakpoint callback. If we ever need to have both - // callbacks and actions on the same breakpoint, we'll have to split this into two. lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j); StoppointCallbackContext context (event_ptr, &m_thread.GetProcess(), &m_thread, m_thread.GetStackFrameAtIndex(0).get(), false); - bp_loc_sp->InvokeCallback (&context); + stop_requested = bp_loc_sp->InvokeCallback (&context); + // Also make sure that the callback hasn't continued the target. + // If it did, when we'll set m_should_start to false and get out of here. + if (GetPrivateState() == eStateRunning) + m_should_stop = false; + } + + if (m_should_stop && !stop_requested) + { + m_should_stop_is_valid = true; + m_should_stop = false; + } + + // Okay, so now if all the callbacks say we should stop, let's try the Conditions: + if (m_should_stop) + { + size_t num_owners = bp_site_sp->GetNumberOfOwners(); + for (size_t j = 0; j < num_owners; j++) + { + lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j); + if (bp_loc_sp->GetConditionText() != NULL) + { + // We need to make sure the user sees any parse errors in their condition, so we'll hook the + // constructor errors up to the debugger's Async I/O. + + StoppointCallbackContext context (event_ptr, + &m_thread.GetProcess(), + &m_thread, + m_thread.GetStackFrameAtIndex(0).get(), + false); + ValueObjectSP result_valobj_sp; + + ExecutionResults result_code; + ValueObjectSP result_value_sp; + const bool discard_on_error = true; + Error error; + result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx, + discard_on_error, + bp_loc_sp->GetConditionText(), + NULL, + result_value_sp, + error); + if (result_code == eExecutionCompleted) + { + if (result_value_sp) + { + Scalar scalar_value; + if (result_value_sp->ResolveValue (scalar_value)) + { + if (scalar_value.ULongLong(1) == 0) + m_should_stop = false; + else + m_should_stop = true; + if (log) + log->Printf("Condition successfully evaluated, result is %s.\n", + m_should_stop ? "true" : "false"); + } + else + { + m_should_stop = true; + if (log) + log->Printf("Failed to get an integer result from the expression."); + } + } + } + else + { + Debugger &debugger = context.exe_ctx.target->GetDebugger(); + StreamSP error_sp = debugger.GetAsyncErrorStream (); + error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint "); + bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief); + error_sp->Printf (": \"%s\"", + bp_loc_sp->GetConditionText()); + error_sp->EOL(); + const char *err_str = error.AsCString(""); + if (log) + log->Printf("Error evaluating condition: \"%s\"\n", err_str); + + error_sp->PutCString (err_str); + error_sp->EOL(); + error_sp->Flush(); + // If the condition fails to be parsed or run, we should stop. + m_should_stop = true; + } + } + + // If any condition says we should stop, then we're going to stop, so we don't need + // to evaluate the others. + if (m_should_stop) + break; + } } } else @@ -145,6 +257,8 @@ if (log) log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value); } + if (log) + log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop); } virtual bool @@ -417,6 +531,7 @@ private: ThreadPlanSP m_plan_sp; }; +} // namespace lldb_private StopInfoSP StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id) Modified: lldb/trunk/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py?rev=137102&r1=137101&r2=137102&view=diff ============================================================================== --- lldb/trunk/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/functionalities/breakpoint/breakpoint_conditions/TestBreakpointConditions.py Mon Aug 8 21:12:22 2011 @@ -144,7 +144,7 @@ # Frame #0 should be on self.line1 and the break condition should hold. from lldbutil import get_stopped_thread - thread = get_stopped_thread(process, lldb.eStopReasonPlanComplete) + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") frame0 = thread.GetFrameAtIndex(0) var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) From gclayton at apple.com Tue Aug 9 00:20:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Aug 2011 05:20:29 -0000 Subject: [Lldb-commits] [lldb] r137112 - in /lldb/trunk: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp tools/debugserver/source/MacOSX/MachThread.cpp tools/debugserver/source/MacOSX/MachThread.h Message-ID: <20110809052030.085362A6C12C@llvm.org> Author: gclayton Date: Tue Aug 9 00:20:29 2011 New Revision: 137112 URL: http://llvm.org/viewvc/llvm-project?rev=137112&view=rev Log: Added some logging and did some member renaming. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h 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=137112&r1=137111&r2=137112&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Aug 9 00:20:29 2011 @@ -435,6 +435,7 @@ // ::LogSetBitMask (GDBR_LOG_DEFAULT); // ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD); // ::LogSetLogFile ("/dev/stdout"); + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); ObjectFile * object_file = module->GetObjectFile(); if (object_file) @@ -449,7 +450,10 @@ { error = StartDebugserverProcess (host_port); if (error.Fail()) + { + log->Printf("failed to start debugserver process: %s", error.AsCString()); return error; + } error = ConnectToDebugserver (connect_url); } @@ -546,6 +550,7 @@ if (GetID() == LLDB_INVALID_PROCESS_ID) { + log->Printf("failed to connect to debugserver: %s", error.AsCString()); KillDebugserverProcess (); return error; } @@ -561,6 +566,10 @@ } } } + else + { + log->Printf("failed to connect to debugserver: %s", error.AsCString()); + } } else { Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=137112&r1=137111&r2=137112&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Tue Aug 9 00:20:29 2011 @@ -23,17 +23,28 @@ return ++g_nextID; } -MachThread::MachThread (MachProcess *process, thread_t thread) : +MachThread::MachThread (MachProcess *process, thread_t tid) : m_process (process), - m_tid (thread), + m_tid (tid), m_seq_id (GetSequenceID()), m_state (eStateUnloaded), m_state_mutex (PTHREAD_MUTEX_RECURSIVE), - m_breakID (INVALID_NUB_BREAK_ID), - m_suspendCount (0), + m_break_id (INVALID_NUB_BREAK_ID), + m_suspend_count (0), + m_stop_exception (), m_arch_ap (DNBArchProtocol::Create (this)), - m_reg_sets (m_arch_ap->GetRegisterSetInfo (&n_num_reg_sets)) + m_reg_sets (NULL), + m_num_reg_sets (0) +#ifdef THREAD_IDENTIFIER_INFO_COUNT + , m_ident_info(), + m_proc_threadinfo(), + m_dispatch_queue_name() +#endif { + nub_size_t num_reg_sets = 0; + m_reg_sets = m_arch_ap->GetRegisterSetInfo (&num_reg_sets); + m_num_reg_sets = num_reg_sets; + // Get the thread state so we know if a thread is in a state where we can't // muck with it and also so we get the suspend count correct in case it was // already suspended @@ -56,7 +67,7 @@ { DNBError err(::thread_suspend (m_tid), DNBError::MachKernel); if (err.Success()) - m_suspendCount++; + m_suspend_count++; if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) err.LogThreaded("::thread_suspend (%4.4x)", m_tid); } @@ -85,12 +96,12 @@ if (others_stopped) { times_to_resume = GetBasicInfo()->suspend_count; - m_suspendCount = - (times_to_resume - m_suspendCount); + m_suspend_count = - (times_to_resume - m_suspend_count); } else { - times_to_resume = m_suspendCount; - m_suspendCount = 0; + times_to_resume = m_suspend_count; + m_suspend_count = 0; } if (times_to_resume > 0) @@ -105,7 +116,7 @@ else { if (GetBasicInfo()) - times_to_resume = m_basicInfo.suspend_count; + times_to_resume = m_basic_info.suspend_count; else times_to_resume = 0; return false; // ??? @@ -123,32 +134,32 @@ if (ThreadIDIsValid(m_tid) == false) return false; - if (m_suspendCount > 0) + if (m_suspend_count > 0) { - while (m_suspendCount > 0) + while (m_suspend_count > 0) { err = ::thread_resume (m_tid); if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) err.LogThreaded("::thread_resume (%4.4x)", m_tid); if (err.Success()) - --m_suspendCount; + --m_suspend_count; else { if (GetBasicInfo()) - m_suspendCount = m_basicInfo.suspend_count; + m_suspend_count = m_basic_info.suspend_count; else - m_suspendCount = 0; + m_suspend_count = 0; return false; // ??? } } } - else if (m_suspendCount < 0) + else if (m_suspend_count < 0) { - while (m_suspendCount < 0) + while (m_suspend_count < 0) { err = ::thread_suspend (m_tid); if (err.Success()) - ++m_suspendCount; + ++m_suspend_count; if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) err.LogThreaded("::thread_suspend (%4.4x)", m_tid); } @@ -232,10 +243,10 @@ bool MachThread::IsUserReady() { - if (m_basicInfo.run_state == 0) + if (m_basic_info.run_state == 0) GetBasicInfo (); - switch (m_basicInfo.run_state) + switch (m_basic_info.run_state) { default: case TH_STATE_UNINTERRUPTIBLE: @@ -253,8 +264,8 @@ struct thread_basic_info * MachThread::GetBasicInfo () { - if (MachThread::GetBasicInfo(m_tid, &m_basicInfo)) - return &m_basicInfo; + if (MachThread::GetBasicInfo(m_tid, &m_basic_info)) + return &m_basic_info; return NULL; } @@ -326,7 +337,7 @@ { const char * thread_run_state = NULL; - switch (m_basicInfo.run_state) + switch (m_basic_info.run_state) { case TH_STATE_RUNNING: thread_run_state = "running"; break; // 1 thread is running normally case TH_STATE_STOPPED: thread_run_state = "stopped"; break; // 2 thread is stopped @@ -342,16 +353,16 @@ m_tid, GetPC(INVALID_NUB_ADDRESS), GetSP(INVALID_NUB_ADDRESS), - m_breakID, - m_basicInfo.user_time.seconds, m_basicInfo.user_time.microseconds, - m_basicInfo.system_time.seconds, m_basicInfo.system_time.microseconds, - m_basicInfo.cpu_usage, - m_basicInfo.policy, - m_basicInfo.run_state, + m_break_id, + m_basic_info.user_time.seconds, m_basic_info.user_time.microseconds, + m_basic_info.system_time.seconds, m_basic_info.system_time.microseconds, + m_basic_info.cpu_usage, + m_basic_info.policy, + m_basic_info.run_state, thread_run_state, - m_basicInfo.flags, - m_basicInfo.suspend_count, m_suspendCount, - m_basicInfo.sleep_time); + m_basic_info.flags, + m_basic_info.suspend_count, m_suspend_count, + m_basic_info.sleep_time); //DumpRegisterState(0); } @@ -480,7 +491,7 @@ RestoreSuspendCountAfterStop(); // Update the basic information for a thread - MachThread::GetBasicInfo(m_tid, &m_basicInfo); + MachThread::GetBasicInfo(m_tid, &m_basic_info); #if ENABLE_AUTO_STEPPING_OVER_BP // See if we were at a breakpoint when we last resumed that we disabled, @@ -490,7 +501,7 @@ if (NUB_BREAK_ID_IS_VALID(breakID)) { m_process->EnableBreakpoint(breakID); - if (m_basicInfo.suspend_count > 0) + if (m_basic_info.suspend_count > 0) { SetState(eStateSuspended); } @@ -513,7 +524,7 @@ } else { - if (m_basicInfo.suspend_count > 0) + if (m_basic_info.suspend_count > 0) { SetState(eStateSuspended); } @@ -523,7 +534,7 @@ } } #else - if (m_basicInfo.suspend_count > 0) + if (m_basic_info.suspend_count > 0) SetState(eStateSuspended); else SetState(eStateStopped); @@ -596,7 +607,7 @@ uint32_t MachThread::GetNumRegistersInSet(int regSet) const { - if (regSet < n_num_reg_sets) + if (regSet < m_num_reg_sets) return m_reg_sets[regSet].num_registers; return 0; } @@ -604,7 +615,7 @@ const char * MachThread::GetRegisterSetName(int regSet) const { - if (regSet < n_num_reg_sets) + if (regSet < m_num_reg_sets) return m_reg_sets[regSet].name; return NULL; } @@ -612,7 +623,7 @@ const DNBRegisterInfo * MachThread::GetRegisterInfo(int regSet, int regIndex) const { - if (regSet < n_num_reg_sets) + if (regSet < m_num_reg_sets) if (regIndex < m_reg_sets[regSet].num_registers) return &m_reg_sets[regSet].registers[regIndex]; return NULL; @@ -622,7 +633,7 @@ { if (regSet == REGISTER_SET_ALL) { - for (regSet = 1; regSet < n_num_reg_sets; regSet++) + for (regSet = 1; regSet < m_num_reg_sets; regSet++) DumpRegisterState(regSet); } else @@ -650,7 +661,7 @@ const DNBRegisterSetInfo * MachThread::GetRegisterSetInfo(nub_size_t *num_reg_sets ) const { - *num_reg_sets = n_num_reg_sets; + *num_reg_sets = m_num_reg_sets; return &m_reg_sets[0]; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=137112&r1=137111&r2=137112&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Tue Aug 9 00:20:29 2011 @@ -117,14 +117,14 @@ uint32_t m_seq_id; // A Sequential ID that increments with each new thread nub_state_t m_state; // The state of our process PThreadMutex m_state_mutex; // Multithreaded protection for m_state - nub_break_t m_breakID; // Breakpoint that this thread is (stopped)/was(running) at (NULL for none) - struct thread_basic_info m_basicInfo; // Basic information for a thread used to see if a thread is valid - int32_t m_suspendCount; // The current suspend count > 0 means we have suspended m_suspendCount times, + nub_break_t m_break_id; // Breakpoint that this thread is (stopped)/was(running) at (NULL for none) + struct thread_basic_info m_basic_info; // Basic information for a thread used to see if a thread is valid + int32_t m_suspend_count; // The current suspend count > 0 means we have suspended m_suspendCount times, // < 0 means we have resumed it m_suspendCount times. MachException::Data m_stop_exception; // The best exception that describes why this thread is stopped std::auto_ptr m_arch_ap; // Arch specific information for register state and more - const DNBRegisterSetInfo *const m_reg_sets; // Register set information for this thread - nub_size_t n_num_reg_sets; + const DNBRegisterSetInfo * m_reg_sets; // Register set information for this thread + nub_size_t m_num_reg_sets; #ifdef THREAD_IDENTIFIER_INFO_COUNT thread_identifier_info_data_t m_ident_info; struct proc_threadinfo m_proc_threadinfo; From gclayton at apple.com Tue Aug 9 00:27:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Aug 2011 05:27:15 -0000 Subject: [Lldb-commits] [lldb] r137113 - in /lldb/trunk/tools/debugserver/source/MacOSX: i386/DNBArchImplI386.h x86_64/DNBArchImplX86_64.h Message-ID: <20110809052715.31B1D2A6C12C@llvm.org> Author: gclayton Date: Tue Aug 9 00:27:14 2011 New Revision: 137113 URL: http://llvm.org/viewvc/llvm-project?rev=137113&view=rev Log: The "bool HasAVX()" function doesn't backup and restore the cpu registers it uses and it crashes the release version of debugserver. We just get lucky in Debug builds. Until this is fixed I am disabling AVX detection to avoid the crashes. Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=137113&r1=137112&r2=137113&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Tue Aug 9 00:27:14 2011 @@ -202,10 +202,17 @@ static bool CPUHasAVX() { +#if 0 if (s_has_avx == kAVXUnknown) s_has_avx = (::HasAVX() ? kAVXPresent : kAVXNotPresent); return (s_has_avx == kAVXPresent); +#else + // ::HasAVX() will cause this code to crash because the + // assembly function doesn't backup and restore the registers + // it uses. Until this is fixed, AVX will be disabled. + return 0; +#endif } MachThread *m_thread; Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=137113&r1=137112&r2=137113&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Tue Aug 9 00:27:14 2011 @@ -209,10 +209,17 @@ static bool CPUHasAVX() { +#if 0 if (s_has_avx == kAVXUnknown) s_has_avx = (::HasAVX() ? kAVXPresent : kAVXNotPresent); return (s_has_avx == kAVXPresent); +#else + // ::HasAVX() will cause this code to crash because the + // assembly function doesn't backup and restore the registers + // it uses. Until this is fixed, AVX will be disabled. + return 0; +#endif } MachThread *m_thread; From johnny.chen at apple.com Tue Aug 9 12:48:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 17:48:29 -0000 Subject: [Lldb-commits] [lldb] r137129 - /lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py Message-ID: <20110809174829.B89072A6C12E@llvm.org> Author: johnny Date: Tue Aug 9 12:48:29 2011 New Revision: 137129 URL: http://llvm.org/viewvc/llvm-project?rev=137129&view=rev Log: Add a negative self.expect() to verify that the bug has been fixed. rdar://problem/9747668 Modified: lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py Modified: lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py?rev=137129&r1=137128&r2=137129&view=diff ============================================================================== --- lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py (original) +++ lldb/trunk/test/lang/c/global_variables/TestGlobalVariables.py Tue Aug 9 12:48:29 2011 @@ -71,6 +71,8 @@ # > self.expect("target variable g_marked_spot.y", VARIABLES_DISPLAYED_CORRECTLY, substrs = ['g_marked_spot.y', '21']) + self.expect("target variable g_marked_spot.y", VARIABLES_DISPLAYED_CORRECTLY, matching=False, + substrs = ["can't be resolved"]) if __name__ == '__main__': From scallanan at apple.com Tue Aug 9 13:10:15 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 09 Aug 2011 18:10:15 -0000 Subject: [Lldb-commits] [lldb] r137131 - in /lldb/trunk/tools/debugserver/source/MacOSX: HasAVX.s i386/DNBArchImplI386.h x86_64/DNBArchImplX86_64.h Message-ID: <20110809181015.C23AA2A6C12E@llvm.org> Author: spyffe Date: Tue Aug 9 13:10:15 2011 New Revision: 137131 URL: http://llvm.org/viewvc/llvm-project?rev=137131&view=rev Log: Fixed a problem where the HasAVX() code in debugserver did not back up %ebx/%rbx, even though it was being clobbered by the CPUID instruction. Modified: lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Modified: lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s?rev=137131&r1=137130&r2=137131&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/HasAVX.s Tue Aug 9 13:10:15 2011 @@ -12,8 +12,17 @@ .globl _HasAVX _HasAVX: +#if defined (__x86_64__) + pushq %rbp + movq %rsp, %rbp + pushq %rbx +#else + pushl %ebp + movl %esp, %ebp + pushl %ebx +#endif mov $1, %eax - cpuid + cpuid // clobbers ebx and $0x018000000, %ecx cmp $0x018000000, %ecx jne not_supported @@ -27,6 +36,15 @@ not_supported: mov $0, %eax done: - ret +#if defined (__x86_64__) + popq %rbx + movq %rbp, %rsp + popq %rbp +#else + popl %ebx + movl %ebp, %esp + popl %ebp +#endif + ret // return #endif \ No newline at end of file Modified: lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h?rev=137131&r1=137130&r2=137131&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/i386/DNBArchImplI386.h Tue Aug 9 13:10:15 2011 @@ -202,17 +202,10 @@ static bool CPUHasAVX() { -#if 0 if (s_has_avx == kAVXUnknown) s_has_avx = (::HasAVX() ? kAVXPresent : kAVXNotPresent); return (s_has_avx == kAVXPresent); -#else - // ::HasAVX() will cause this code to crash because the - // assembly function doesn't backup and restore the registers - // it uses. Until this is fixed, AVX will be disabled. - return 0; -#endif } MachThread *m_thread; Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h?rev=137131&r1=137130&r2=137131&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.h Tue Aug 9 13:10:15 2011 @@ -209,17 +209,10 @@ static bool CPUHasAVX() { -#if 0 if (s_has_avx == kAVXUnknown) s_has_avx = (::HasAVX() ? kAVXPresent : kAVXNotPresent); return (s_has_avx == kAVXPresent); -#else - // ::HasAVX() will cause this code to crash because the - // assembly function doesn't backup and restore the registers - // it uses. Until this is fixed, AVX will be disabled. - return 0; -#endif } MachThread *m_thread; From johnny.chen at apple.com Tue Aug 9 13:56:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 18:56:45 -0000 Subject: [Lldb-commits] [lldb] r137136 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110809185645.DF5E12A6C12E@llvm.org> Author: johnny Date: Tue Aug 9 13:56:45 2011 New Revision: 137136 URL: http://llvm.org/viewvc/llvm-project?rev=137136&view=rev Log: Fix a crash while running the test suite. Need to check the (LogSP)log shared pointer before using it. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 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=137136&r1=137135&r2=137136&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Aug 9 13:56:45 2011 @@ -451,7 +451,8 @@ error = StartDebugserverProcess (host_port); if (error.Fail()) { - log->Printf("failed to start debugserver process: %s", error.AsCString()); + if (log) + log->Printf("failed to start debugserver process: %s", error.AsCString()); return error; } @@ -550,7 +551,8 @@ if (GetID() == LLDB_INVALID_PROCESS_ID) { - log->Printf("failed to connect to debugserver: %s", error.AsCString()); + if (log) + log->Printf("failed to connect to debugserver: %s", error.AsCString()); KillDebugserverProcess (); return error; } @@ -568,7 +570,8 @@ } else { - log->Printf("failed to connect to debugserver: %s", error.AsCString()); + if (log) + log->Printf("failed to connect to debugserver: %s", error.AsCString()); } } else From johnny.chen at apple.com Tue Aug 9 15:07:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 20:07:16 -0000 Subject: [Lldb-commits] [lldb] r137140 - in /lldb/trunk/test: lang/objc/self/Makefile make/Makefile.rules Message-ID: <20110809200716.73D0F2A6C12E@llvm.org> Author: johnny Date: Tue Aug 9 15:07:16 2011 New Revision: 137140 URL: http://llvm.org/viewvc/llvm-project?rev=137140&view=rev Log: Simplify lang/objc/self/Makefile, plus it's wrong. :-) For Makefile.rules, the modification of CFLAGS (addition of -arch $(ARCH) for Darwin) needs to come before the consuming of CFLAGS, not after. Modified: lldb/trunk/test/lang/objc/self/Makefile lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/lang/objc/self/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/self/Makefile?rev=137140&r1=137139&r2=137140&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/self/Makefile (original) +++ lldb/trunk/test/lang/objc/self/Makefile Tue Aug 9 15:07:16 2011 @@ -1,6 +1,6 @@ LEVEL = ../../../make OBJC_SOURCES := main.m -LDFLAGS := $(CFLAGS) -lobjc -framework Foundation +LD_EXTRAS ?= -framework Foundation include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=137140&r1=137139&r2=137140&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Tue Aug 9 15:07:16 2011 @@ -38,13 +38,6 @@ #---------------------------------------------------------------------- CFLAGS ?= -gdwarf-2 -O0 CFLAGS += $(FRAMEWORK_INCLUDES) -CXXFLAGS +=$(CFLAGS) -LD = $(CC) -LDFLAGS ?= $(CFLAGS) -LDFLAGS += $(LD_EXTRAS) -OBJECTS = -EXE ?= a.out - ifeq "$(OS)" "Darwin" CFLAGS += -arch $(ARCH) DS := /usr/bin/dsymutil @@ -52,6 +45,13 @@ DSYM = $(EXE).dSYM endif +CXXFLAGS +=$(CFLAGS) +LD = $(CC) +LDFLAGS ?= $(CFLAGS) +LDFLAGS += $(LD_EXTRAS) +OBJECTS = +EXE ?= a.out + ifneq "$(DYLIB_NAME)" "" ifeq "$(OS)" "Darwin" DYLIB_FILENAME = lib$(DYLIB_NAME).dylib From johnny.chen at apple.com Tue Aug 9 15:22:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 20:22:44 -0000 Subject: [Lldb-commits] [lldb] r137141 - /lldb/trunk/test/lang/objc/self/main.m Message-ID: <20110809202244.B89412A6C12E@llvm.org> Author: johnny Date: Tue Aug 9 15:22:44 2011 New Revision: 137141 URL: http://llvm.org/viewvc/llvm-project?rev=137141&view=rev Log: Silence clang warning. Modified: lldb/trunk/test/lang/objc/self/main.m Modified: lldb/trunk/test/lang/objc/self/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/self/main.m?rev=137141&r1=137140&r2=137141&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/self/main.m (original) +++ lldb/trunk/test/lang/objc/self/main.m Tue Aug 9 15:22:44 2011 @@ -37,6 +37,7 @@ +(int)accessStaticMember:(int)a { s_a = a; // breakpoint 2 + return 0; } @end @@ -49,4 +50,4 @@ [A accessStaticMember:5]; [pool release]; -} \ No newline at end of file +} From scallanan at apple.com Tue Aug 9 15:28:32 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 09 Aug 2011 20:28:32 -0000 Subject: [Lldb-commits] [lldb] r137142 - /lldb/trunk/test/lang/objc/self/main.m Message-ID: <20110809202832.9E3BB2A6C12E@llvm.org> Author: spyffe Date: Tue Aug 9 15:28:32 2011 New Revision: 137142 URL: http://llvm.org/viewvc/llvm-project?rev=137142&view=rev Log: Fixed the Objective-C "self" test case, which was behaving erratically because it didn't have a return statement in -[A init]. Also made minor cosmetic changes to that test case. Modified: lldb/trunk/test/lang/objc/self/main.m Modified: lldb/trunk/test/lang/objc/self/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/self/main.m?rev=137142&r1=137141&r2=137142&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/self/main.m (original) +++ lldb/trunk/test/lang/objc/self/main.m Tue Aug 9 15:28:32 2011 @@ -15,7 +15,7 @@ } -(id)init; -(void)accessMember:(int)a; -+(int)accessStaticMember:(int)a; ++(void)accessStaticMember:(int)a; @end static int s_a = 5; @@ -27,6 +27,8 @@ if (self) m_a = 2; + + return self; } -(void)accessMember:(int)a @@ -34,10 +36,9 @@ m_a = a; // breakpoint 1 } -+(int)accessStaticMember:(int)a ++(void)accessStaticMember:(int)a { s_a = a; // breakpoint 2 - return 0; } @end From jingham at apple.com Tue Aug 9 15:45:45 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 20:45:45 -0000 Subject: [Lldb-commits] [lldb] r137143 - /lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Message-ID: <20110809204545.F366B2A6C12E@llvm.org> Author: jingham Date: Tue Aug 9 15:45:45 2011 New Revision: 137143 URL: http://llvm.org/viewvc/llvm-project?rev=137143&view=rev Log: When unloading a library, pass the old complete version of the library to UnloadImageLoadAddress, since that one is completely filled in. The one we make up from the event doesn't have section info since the library has already been unloaded by the time we get to it. Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=137143&r1=137142&r2=137143&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Aug 9 15:45:45 2011 @@ -829,7 +829,9 @@ ModuleSP unload_image_module_sp (FindTargetModuleForDYLDImageInfo (image_infos[idx], false, NULL)); if (unload_image_module_sp.get()) { - UnloadImageLoadAddress (unload_image_module_sp.get(), image_infos[idx]); + // When we unload, be sure to use the image info from the old list, + // since that has sections correctly filled in. + UnloadImageLoadAddress (unload_image_module_sp.get(), *pos); unloaded_module_list.AppendIfNeeded (unload_image_module_sp); } else From jingham at apple.com Tue Aug 9 16:27:48 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 21:27:48 -0000 Subject: [Lldb-commits] [lldb] r137149 - /lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h Message-ID: <20110809212749.077F62A6C12E@llvm.org> Author: jingham Date: Tue Aug 9 16:27:48 2011 New Revision: 137149 URL: http://llvm.org/viewvc/llvm-project?rev=137149&view=rev Log: Typo in the test case for i386. Modified: lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h Modified: lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h?rev=137149&r1=137148&r2=137149&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h (original) +++ lldb/trunk/test/lang/objc/objc-ivar-offsets/objc-ivar-offsets.h Tue Aug 9 16:27:48 2011 @@ -15,7 +15,7 @@ { int _derived_backed_int; #if !__OBJC2__ - int _unbacked_int; + int _derived_unbacked_int; #endif } @property int derived_backed_int; From scallanan at apple.com Tue Aug 9 17:07:08 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 09 Aug 2011 22:07:08 -0000 Subject: [Lldb-commits] [lldb] r137157 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20110809220708.93DC62A6C12C@llvm.org> Author: spyffe Date: Tue Aug 9 17:07:08 2011 New Revision: 137157 URL: http://llvm.org/viewvc/llvm-project?rev=137157&view=rev Log: Fixed a potential crash in Process.cpp when we used a log unchecked. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=137157&r1=137156&r2=137157&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Aug 9 17:07:08 2011 @@ -3724,8 +3724,9 @@ } else { - log->Printf ("Process::RunThreadPlan(): halt failed, I waited and didn't get" - " a stopped event, instead got %s.", StateAsCString(stop_state)); + if (log) + log->Printf ("Process::RunThreadPlan(): halt failed, I waited and didn't get" + " a stopped event, instead got %s.", StateAsCString(stop_state)); return_value = eExecutionInterrupted; break; } From jingham at apple.com Tue Aug 9 17:24:33 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 09 Aug 2011 22:24:33 -0000 Subject: [Lldb-commits] [lldb] r137164 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20110809222433.981A02A6C12C@llvm.org> Author: jingham Date: Tue Aug 9 17:24:33 2011 New Revision: 137164 URL: http://llvm.org/viewvc/llvm-project?rev=137164&view=rev Log: Fix a bunch of places where we were calling log->Printf to put CStrings. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=137164&r1=137163&r2=137164&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Aug 9 17:24:33 2011 @@ -3436,7 +3436,7 @@ if (!got_event) { if (log) - log->Printf("Didn't get any event after initial resume, exiting."); + log->PutCString("Didn't get any event after initial resume, exiting."); errors.Printf("Didn't get any event after initial resume, exiting."); return_value = eExecutionSetupError; @@ -3455,7 +3455,7 @@ } if (log) - log->Printf ("Resuming succeeded."); + log->PutCString ("Resuming succeeded."); // We need to call the function synchronously, so spin waiting for it to return. // If we get interrupted while executing, we're going to lose our context, and // won't be able to gather the result at this point. @@ -3476,7 +3476,7 @@ else { if (log) - log->Printf ("Handled an extra running event."); + log->PutCString ("Handled an extra running event."); do_resume = true; } @@ -3516,7 +3516,7 @@ if (stop_reason == eStopReasonPlanComplete) { if (log) - log->Printf ("Execution completed successfully."); + log->PutCString ("Execution completed successfully."); // Now mark this plan as private so it doesn't get reported as the stop reason // after this point. if (thread_plan_sp) @@ -3526,7 +3526,7 @@ else { if (log) - log->Printf ("Thread plan didn't successfully complete."); + log->PutCString ("Thread plan didn't successfully complete."); return_value = eExecutionInterrupted; } @@ -3536,7 +3536,7 @@ case lldb::eStateCrashed: if (log) - log->Printf ("Execution crashed."); + log->PutCString ("Execution crashed."); return_value = eExecutionInterrupted; break; @@ -3561,7 +3561,7 @@ else { if (log) - log->Printf ("got_event was true, but the event pointer was null. How odd..."); + log->PutCString ("got_event was true, but the event pointer was null. How odd..."); return_value = eExecutionInterrupted; break; } @@ -3595,7 +3595,7 @@ if (halt_error.Success()) { if (log) - log->Printf ("Process::RunThreadPlan(): Halt succeeded."); + log->PutCString ("Process::RunThreadPlan(): Halt succeeded."); // If halt succeeds, it always produces a stopped event. Wait for that: @@ -3612,7 +3612,7 @@ log->Printf ("Process::RunThreadPlan(): Stopped with event: %s", StateAsCString(stop_state)); if (stop_state == lldb::eStateStopped && Process::ProcessEventData::GetInterruptedFromEvent(event_sp.get())) - log->Printf (" Event was the Halt interruption event."); + log->PutCString (" Event was the Halt interruption event."); } if (stop_state == lldb::eStateStopped) @@ -3623,7 +3623,7 @@ if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) - log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " + log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " "Exiting wait loop."); return_value = eExecutionCompleted; break; @@ -3632,7 +3632,7 @@ if (!try_all_threads) { if (log) - log->Printf ("try_all_threads was false, we stopped so now we're quitting."); + log->PutCString ("try_all_threads was false, we stopped so now we're quitting."); return_value = eExecutionInterrupted; break; } @@ -3643,7 +3643,7 @@ first_timeout = false; thread_plan_sp->SetStopOthers (false); if (log) - log->Printf ("Process::RunThreadPlan(): About to resume."); + log->PutCString ("Process::RunThreadPlan(): About to resume."); continue; } @@ -3651,7 +3651,7 @@ { // Running all threads failed, so return Interrupted. if (log) - log->Printf("Process::RunThreadPlan(): running all threads timed out."); + log->PutCString("Process::RunThreadPlan(): running all threads timed out."); return_value = eExecutionInterrupted; break; } @@ -3659,7 +3659,7 @@ } else { if (log) - log->Printf("Process::RunThreadPlan(): halt said it succeeded, but I got no event. " + log->PutCString("Process::RunThreadPlan(): halt said it succeeded, but I got no event. " "I'm getting out of here passing Interrupted."); return_value = eExecutionInterrupted; break; @@ -3680,7 +3680,7 @@ { // This is not going anywhere, bag out. if (log) - log->Printf ("Process::RunThreadPlan(): halt failed: and waiting for the stopped event failed."); + log->PutCString ("Process::RunThreadPlan(): halt failed: and waiting for the stopped event failed."); return_value = eExecutionInterrupted; break; } @@ -3688,7 +3688,7 @@ { stop_state = Process::ProcessEventData::GetStateFromEvent(event_sp.get()); if (log) - log->Printf ("Process::RunThreadPlan(): halt failed: but then I got a stopped event. Whatever..."); + log->PutCString ("Process::RunThreadPlan(): halt failed: but then I got a stopped event. Whatever..."); if (stop_state == lldb::eStateStopped) { // Between the time we initiated the Halt and the time we delivered it, the process could have @@ -3697,7 +3697,7 @@ if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) - log->Printf ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " + log->PutCString ("Process::RunThreadPlan(): Even though we timed out, the call plan was done. " "Exiting wait loop."); return_value = eExecutionCompleted; break; @@ -3709,7 +3709,7 @@ first_timeout = false; thread_plan_sp->SetStopOthers (false); if (log) - log->Printf ("Process::RunThreadPlan(): About to resume."); + log->PutCString ("Process::RunThreadPlan(): About to resume."); continue; } @@ -3717,7 +3717,7 @@ { // Running all threads failed, so return Interrupted. if (log) - log->Printf("Process::RunThreadPlan(): running all threads timed out."); + log->PutCString ("Process::RunThreadPlan(): running all threads timed out."); return_value = eExecutionInterrupted; break; } @@ -3747,12 +3747,12 @@ event_sp->Dump (&s); else { - log->Printf ("Process::RunThreadPlan(): Stop event that interrupted us is NULL."); + log->PutCString ("Process::RunThreadPlan(): Stop event that interrupted us is NULL."); } StreamString ts; - const char *event_explanation; + const char *event_explanation = NULL; do { @@ -3813,7 +3813,12 @@ } while (0); if (log) - log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s", s.GetData(), event_explanation); + { + if (event_explanation) + log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s", s.GetData(), event_explanation); + else + log->Printf("Process::RunThreadPlan(): execution interrupted: %s", s.GetData()); + } if (discard_on_error && thread_plan_sp) { @@ -3825,7 +3830,7 @@ else if (return_value == eExecutionSetupError) { if (log) - log->Printf("Process::RunThreadPlan(): execution set up error."); + log->PutCString("Process::RunThreadPlan(): execution set up error."); if (discard_on_error && thread_plan_sp) { @@ -3838,23 +3843,23 @@ if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) { if (log) - log->Printf("Process::RunThreadPlan(): thread plan is done"); + log->PutCString("Process::RunThreadPlan(): thread plan is done"); return_value = eExecutionCompleted; } else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) { if (log) - log->Printf("Process::RunThreadPlan(): thread plan was discarded"); + log->PutCString("Process::RunThreadPlan(): thread plan was discarded"); return_value = eExecutionDiscarded; } else { if (log) - log->Printf("Process::RunThreadPlan(): thread plan stopped in mid course"); + log->PutCString("Process::RunThreadPlan(): thread plan stopped in mid course"); if (discard_on_error && thread_plan_sp) { if (log) - log->Printf("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set."); + log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause discard_on_error is set."); exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); thread_plan_sp->SetPrivate (orig_plan_private); } From johnny.chen at apple.com Tue Aug 9 17:38:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 22:38:07 -0000 Subject: [Lldb-commits] [lldb] r137165 - /lldb/trunk/source/API/SBValue.cpp Message-ID: <20110809223807.7429D2A6C12C@llvm.org> Author: johnny Date: Tue Aug 9 17:38:07 2011 New Revision: 137165 URL: http://llvm.org/viewvc/llvm-project?rev=137165&view=rev Log: Fix indentation. Modified: lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137165&r1=137164&r2=137165&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Tue Aug 9 17:38:07 2011 @@ -473,9 +473,9 @@ { if (result.IsValid()) log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); - else - log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); - } + else + log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); + } return result; } @@ -988,4 +988,4 @@ log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); return sb_value; -} \ No newline at end of file +} From scallanan at apple.com Tue Aug 9 17:42:51 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 09 Aug 2011 22:42:51 -0000 Subject: [Lldb-commits] [lldb] r137167 - /lldb/trunk/source/Symbol/ClangASTType.cpp Message-ID: <20110809224251.3C9302A6C12C@llvm.org> Author: spyffe Date: Tue Aug 9 17:42:51 2011 New Revision: 137167 URL: http://llvm.org/viewvc/llvm-project?rev=137167&view=rev Log: Fixed the type code to print "" for NULL types instead of letting Clang crash. Modified: lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=137167&r1=137166&r2=137167&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Tue Aug 9 17:42:51 2011 @@ -123,6 +123,9 @@ ConstString ClangASTType::GetConstTypeName (clang_type_t clang_type) { + if (!clang_type) + return ConstString(""); + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); std::string type_name (GetTypeNameForQualType (qual_type)); ConstString const_type_name; From johnny.chen at apple.com Tue Aug 9 17:52:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 22:52:27 -0000 Subject: [Lldb-commits] [lldb] r137169 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20110809225227.C00112A6C12C@llvm.org> Author: johnny Date: Tue Aug 9 17:52:27 2011 New Revision: 137169 URL: http://llvm.org/viewvc/llvm-project?rev=137169&view=rev Log: Check log shared pointer before using it. 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=137169&r1=137168&r2=137169&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Aug 9 17:52:27 2011 @@ -2393,7 +2393,8 @@ if (!ast_type) { - log->Printf("Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str()); + if (log) + log->Printf("Tried to add a type for %s, but couldn't get one", context.m_decl_name.getAsString().c_str()); return; } From johnny.chen at apple.com Tue Aug 9 18:10:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 23:10:20 -0000 Subject: [Lldb-commits] [lldb] r137173 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20110809231020.523372A6C12C@llvm.org> Author: johnny Date: Tue Aug 9 18:10:20 2011 New Revision: 137173 URL: http://llvm.org/viewvc/llvm-project?rev=137173&view=rev Log: Check log shared pointer before using it. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=137173&r1=137172&r2=137173&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Aug 9 18:10:20 2011 @@ -697,6 +697,7 @@ return true; } +#if 0 static void DebugUsers(lldb::LogSP &log, Value *value, uint8_t depth) { if (!depth) @@ -704,18 +705,22 @@ depth--; - log->Printf(" ", value->getNumUses()); + if (log) + log->Printf(" ", value->getNumUses()); for (Value::use_iterator ui = value->use_begin(), ue = value->use_end(); ui != ue; ++ui) { - log->Printf(" %s", *ui, PrintValue(*ui).c_str()); + if (log) + log->Printf(" %s", *ui, PrintValue(*ui).c_str()); DebugUsers(log, *ui, depth); } - log->Printf(" "); + if (log) + log->Printf(" "); } +#endif bool IRForTarget::RewriteObjCConstString (llvm::GlobalVariable *ns_str, From johnny.chen at apple.com Tue Aug 9 18:26:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Aug 2011 23:26:20 -0000 Subject: [Lldb-commits] [lldb] r137178 - /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Message-ID: <20110809232620.CEF302A6C12D@llvm.org> Author: johnny Date: Tue Aug 9 18:26:20 2011 New Revision: 137178 URL: http://llvm.org/viewvc/llvm-project?rev=137178&view=rev Log: Fix indentation for a log statement. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=137178&r1=137177&r2=137178&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Tue Aug 9 18:26:20 2011 @@ -214,7 +214,7 @@ if (results != eExecutionCompleted) { if (log) - log->Printf("Error evaluating our find class name function: %d.\n", results); + log->Printf("Error evaluating our find class name function: %d.\n", results); return false; } From granata.enrico at gmail.com Tue Aug 9 18:50:01 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Tue, 09 Aug 2011 23:50:01 -0000 Subject: [Lldb-commits] [lldb] r137185 - in /lldb/trunk: examples/synthetic/CFString.py include/lldb/Interpreter/OptionGroupValueObjectDisplay.h source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectMemory.cpp source/Commands/CommandObjectTarget.cpp source/Commands/CommandObjectType.cpp source/Interpreter/OptionGroupValueObjectDisplay.cpp test/functionalities/data-formatter/data-formatter-objc/CFString.py test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Message-ID: <20110809235001.7A6092A6C12C@llvm.org> Author: enrico Date: Tue Aug 9 18:50:01 2011 New Revision: 137185 URL: http://llvm.org/viewvc/llvm-project?rev=137185&view=rev Log: CFString.py now shows contents in a more NSString-like way (e.g. you get @"Hello" instead of "Hello") new --raw-output (-R) option to frame variable prevents using summaries and synthetic children other future formatting enhancements will be excluded by using the -R option test case enhanced to check that -R works correctly Modified: lldb/trunk/examples/synthetic/CFString.py lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Modified: lldb/trunk/examples/synthetic/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/synthetic/CFString.py?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/examples/synthetic/CFString.py (original) +++ lldb/trunk/examples/synthetic/CFString.py Tue Aug 9 18:50:01 2011 @@ -1,7 +1,13 @@ -# synthetic children provider for CFString +# synthetic children and summary provider for CFString # (and related NSString class) import lldb +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == False: + return '@'+provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + return '' + class CFStringSynthProvider: def __init__(self,valobj,dict): self.valobj = valobj; @@ -228,11 +234,4 @@ def update(self): self.adjust_for_architecture(); - self.compute_flags(); - -def CFString_SummaryProvider (valobj,dict): - provider = CFStringSynthProvider(valobj,dict); - if provider.invalid == False: - return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); - return '' - + self.compute_flags(); \ No newline at end of file Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Tue Aug 9 18:50:01 2011 @@ -55,6 +55,7 @@ uint32_t ptr_depth; lldb::DynamicValueType use_dynamic; bool use_synth; + bool be_raw; }; } // namespace lldb_private Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Aug 9 18:50:01 2011 @@ -500,10 +500,10 @@ m_varobj_options.show_location, m_varobj_options.use_objc, m_varobj_options.use_dynamic, - m_varobj_options.use_synth, + m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); } } } @@ -553,10 +553,10 @@ m_varobj_options.show_location, m_varobj_options.use_objc, m_varobj_options.use_dynamic, - m_varobj_options.use_synth, + m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); } else { @@ -645,10 +645,10 @@ m_varobj_options.show_location, m_varobj_options.use_objc, m_varobj_options.use_dynamic, - m_varobj_options.use_synth, + m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); } } } Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Aug 9 18:50:01 2011 @@ -657,10 +657,10 @@ m_varobj_options.show_location, m_varobj_options.use_objc, m_varobj_options.use_dynamic, - m_varobj_options.use_synth, + m_varobj_options.be_raw ? false : m_varobj_options.use_synth, scope_already_checked, m_varobj_options.flat_output, - 0); + m_varobj_options.be_raw ? UINT32_MAX : 0); } else { Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Aug 9 18:50:01 2011 @@ -488,10 +488,10 @@ m_varobj_options.show_location, m_varobj_options.use_objc, m_varobj_options.use_dynamic, - m_varobj_options.use_synth, + m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); } Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Tue Aug 9 18:50:01 2011 @@ -660,6 +660,7 @@ m_name = NULL; m_python_script = ""; m_python_function = ""; + m_format_string = ""; m_is_add_script = false; m_category = NULL; } Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Tue Aug 9 18:50:01 2011 @@ -40,6 +40,7 @@ { 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, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, { LLDB_OPT_SET_1, false, "no-summary-depth",'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."}, + { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; @@ -83,7 +84,9 @@ case 'T': show_types = true; break; case 'L': show_location= true; break; case 'F': flat_output = true; break; - case 'O': use_objc = true; break; + case 'O': use_objc = true; break; + case 'R': be_raw = true; break; + case 'D': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); if (!success) @@ -131,6 +134,7 @@ max_depth = UINT32_MAX; ptr_depth = 0; use_synth = true; + be_raw = false; Target *target = interpreter.GetExecutionContext().target; if (target != NULL) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/CFString.py Tue Aug 9 18:50:01 2011 @@ -1,7 +1,13 @@ -# synthetic children provider for CFString +# synthetic children and summary provider for CFString # (and related NSString class) import lldb +def CFString_SummaryProvider (valobj,dict): + provider = CFStringSynthProvider(valobj,dict); + if provider.invalid == False: + return '@'+provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); + return '' + class CFStringSynthProvider: def __init__(self,valobj,dict): self.valobj = valobj; @@ -228,11 +234,4 @@ def update(self): self.adjust_for_architecture(); - self.compute_flags(); - -def CFString_SummaryProvider (valobj,dict): - provider = CFStringSynthProvider(valobj,dict); - if provider.invalid == False: - return provider.get_child_at_index(provider.get_child_index("content")).GetSummary(); - return '' - + self.compute_flags(); \ No newline at end of file Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=137185&r1=137184&r2=137185&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Tue Aug 9 18:50:01 2011 @@ -69,7 +69,19 @@ self.expect("frame variable int_bag", matching=False, substrs = ['x = 6', 'z = 8']) + + # if we skip synth and summary show y + self.expect("frame variable int_bag -S false -Y1", + substrs = ['x = 6', + 'y = 7', + 'z = 8']) + # if we ask for raw output same happens + self.expect("frame variable int_bag --raw-output", + substrs = ['x = 6', + 'y = 7', + 'z = 8']) + # Summary+Synth must work together self.runCmd("type summary add BagOfInts -f \"y=${var.y}\" -e") self.expect('frame variable int_bag', From gclayton at apple.com Tue Aug 9 21:10:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 10 Aug 2011 02:10:13 -0000 Subject: [Lldb-commits] [lldb] r137196 - in /lldb/trunk: include/lldb/Expression/ include/lldb/Host/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Host/common/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/ Message-ID: <20110810021013.8A51D2A6C12C@llvm.org> Author: gclayton Date: Tue Aug 9 21:10:13 2011 New Revision: 137196 URL: http://llvm.org/viewvc/llvm-project?rev=137196&view=rev Log: While tracking down memory consumption issue a few things were needed: the ability to dump more information about modules in "target modules list". We can now dump the shared pointer reference count for modules, the pointer to the module itself (in case performance tools can help track down who has references to said pointer), and the modification time. Added "target delete [target-idx ...]" to be able to delete targets when they are no longer needed. This will help track down memory usage issues and help to resolve when module ref counts keep getting incremented. If the command gets no arguments, the currently selected target will be deleted. If any arguments are given, they must all be valid target indexes (use the "target list" command to get the current target indexes). Took care of a bunch of "no newline at end of file" warnings. TimeValue objects can now dump their time to a lldb_private::Stream object. Modified the "target modules list --global" command to not error out if there are no targets since it doesn't require a target. Fixed an issue in the MacOSX DYLD dynamic loader plug-in where if a shared library was updated on disk, we would keep using the older one, even if it was updated. Don't allow the ModuleList::GetSharedModule(...) to return an empty module. Previously we could specify a valid path on disc to a module, and specify an architecture that wasn't contained in that module and get a shared pointer to a module that wouldn't be able to return an object file or a symbol file. We now make sure an object file can be extracted prior to adding the shared pointer to the module to get added to the shared list. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/include/lldb/Host/TimeValue.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/FormatClasses.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/InputReader.cpp lldb/trunk/source/Core/InputReaderEZ.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/StringList.cpp lldb/trunk/source/Expression/ProcessDataAllocator.cpp lldb/trunk/source/Host/common/TimeValue.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Tue Aug 9 21:10:13 2011 @@ -381,6 +381,12 @@ return var_sp; } + void + Clear() + { + m_variables.clear(); + } + private: std::vector m_variables; }; Modified: lldb/trunk/include/lldb/Host/TimeValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/TimeValue.h (original) +++ lldb/trunk/include/lldb/Host/TimeValue.h Tue Aug 9 21:10:13 2011 @@ -23,6 +23,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/lldb-private.h" namespace lldb_private { @@ -57,6 +58,9 @@ uint64_t GetAsMicroSecondsSinceJan1_1970() const; + uint64_t + GetAsSecondsSinceJan1_1970() const; + struct timespec GetAsTimeSpec () const; @@ -77,6 +81,9 @@ static TimeValue Now(); + + void + Dump (Stream *s, uint32_t width = 0) const; protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Aug 9 21:10:13 2011 @@ -199,6 +199,9 @@ lldb::TargetSP GetSP(); + + void + Destroy(); //------------------------------------------------------------------ // This part handles the breakpoints. Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Tue Aug 9 21:10:13 2011 @@ -395,4 +395,4 @@ } return retval; -} \ No newline at end of file +} Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Aug 9 21:10:13 2011 @@ -400,6 +400,101 @@ } }; +#pragma mark CommandObjectTargetSelect + +//---------------------------------------------------------------------- +// "target delete" +//---------------------------------------------------------------------- + +class CommandObjectTargetDelete : public CommandObject +{ +public: + CommandObjectTargetDelete (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target delete", + "Delete one or more targets by target index.", + NULL, + 0) + { + } + + virtual + ~CommandObjectTargetDelete () + { + } + + virtual bool + Execute (Args& args, CommandReturnObject &result) + { + const size_t argc = args.GetArgumentCount(); + std::vector delete_target_list; + TargetList &target_list = m_interpreter.GetDebugger().GetTargetList(); + bool success = true; + TargetSP target_sp; + if (argc > 0) + { + const uint32_t num_targets = target_list.GetNumTargets(); + for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx) + { + const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx); + uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success); + if (success) + { + if (target_idx < num_targets) + { + target_sp = target_list.GetTargetAtIndex (target_idx); + if (target_sp) + { + delete_target_list.push_back (target_sp); + continue; + } + } + result.AppendErrorWithFormat ("target index %u is out of range, valid target indexes are 0 - %u\n", + target_idx, + num_targets - 1); + result.SetStatus (eReturnStatusFailed); + success = false; + } + else + { + result.AppendErrorWithFormat("invalid target index '%s'\n", target_idx_arg); + result.SetStatus (eReturnStatusFailed); + success = false; + } + } + + } + else + { + target_sp = target_list.GetSelectedTarget(); + if (target_sp) + { + delete_target_list.push_back (target_sp); + } + else + { + result.AppendErrorWithFormat("no target is currently selected\n"); + result.SetStatus (eReturnStatusFailed); + success = false; + } + } + if (success) + { + const size_t num_targets_to_delete = delete_target_list.size(); + for (size_t idx = 0; idx < num_targets_to_delete; ++idx) + { + target_sp = delete_target_list[idx]; + target_list.DeleteTarget(target_sp); + target_sp->Destroy(); + } + result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete); + result.SetStatus(eReturnStatusSuccessFinishResult); + } + + return result.Succeeded(); + } +}; + #pragma mark CommandObjectTargetVariable @@ -991,7 +1086,10 @@ static void DumpModuleUUID (Stream &strm, Module *module) { - module->GetUUID().Dump (&strm); + if (module->GetUUID().IsValid()) + module->GetUUID().Dump (&strm); + else + strm.PutCString(" "); } static uint32_t @@ -2545,7 +2643,8 @@ CommandReturnObject &result) { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) + const bool use_global_module_list = m_options.m_use_global_module_list; + if (target == NULL && use_global_module_list == false) { result.AppendError ("invalid target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -2553,13 +2652,16 @@ } else { - uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); + if (target) + { + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); + } // Dump all sections for all modules images uint32_t num_modules = 0; Mutex::Locker locker; - if (m_options.m_use_global_module_list) + if (use_global_module_list) { locker.Reset (Module::GetAllocationModuleCollectionMutex().GetMutex()); num_modules = Module::GetNumberAllocatedModules(); @@ -2573,20 +2675,21 @@ for (uint32_t image_idx = 0; image_idxGetSP()); - // Show the module reference count when showing the global module index - strm.Printf("[%3u] ref_count = %lu ", image_idx, module_sp ? module_sp.use_count() - 1 : 0); + module_sp = module->GetSP(); } else { - module = target->GetImages().GetModulePointerAtIndex(image_idx); - strm.Printf("[%3u] ", image_idx); + module_sp = target->GetImages().GetModuleAtIndex(image_idx); + module = module_sp.get(); } - + + strm.Printf("[%3u] ", image_idx); + bool dump_object_name = false; if (m_options.m_format_array.empty()) { @@ -2626,27 +2729,50 @@ dump_object_name = true; break; + case 'r': + { + uint32_t ref_count = 0; + if (module_sp) + { + // Take one away to make sure we don't count our local "module_sp" + ref_count = module_sp.use_count() - 1; + } + if (width) + strm.Printf("{%*u}", width, ref_count); + else + strm.Printf("{%u}", ref_count); + } + break; + case 's': case 'S': - { - SymbolVendor *symbol_vendor = module->GetSymbolVendor(); - if (symbol_vendor) { - SymbolFile *symbol_file = symbol_vendor->GetSymbolFile(); - if (symbol_file) + SymbolVendor *symbol_vendor = module->GetSymbolVendor(); + if (symbol_vendor) { - if (format_char == 'S') - DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); - else - DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); - dump_object_name = true; - break; + SymbolFile *symbol_file = symbol_vendor->GetSymbolFile(); + if (symbol_file) + { + if (format_char == 'S') + DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); + else + DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); + dump_object_name = true; + break; + } } + strm.Printf("%.*s", width, ""); } - strm.Printf("%.*s", width, ""); - } break; + case 'm': + module->GetModificationTime().Dump(&strm, width); + break; + + case 'p': + strm.Printf("%p", module); + break; + case 'u': DumpModuleUUID(strm, module); break; @@ -2669,7 +2795,10 @@ } else { - result.AppendError ("the target has no associated executable images"); + if (use_global_module_list) + result.AppendError ("the global module list is empty"); + else + result.AppendError ("the target has no associated executable images"); result.SetStatus (eReturnStatusFailed); return false; } @@ -2692,6 +2821,9 @@ { LLDB_OPT_SET_1, false, "basename", 'b', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename with optional width for the image object file."}, { LLDB_OPT_SET_1, false, "symfile", 's', optional_argument, NULL, 0, eArgTypeWidth, "Display the fullpath to the image symbol file with optional width."}, { LLDB_OPT_SET_1, false, "symfile-basename", 'S', optional_argument, NULL, 0, eArgTypeWidth, "Display the basename to the image symbol file with optional width."}, + { LLDB_OPT_SET_1, false, "mod-time", 'm', optional_argument, NULL, 0, eArgTypeWidth, "Display the modification time with optional width of the module."}, + { LLDB_OPT_SET_1, false, "ref-count", 'r', optional_argument, NULL, 0, eArgTypeWidth, "Display the reference count if the module is still in the shared module cache."}, + { LLDB_OPT_SET_1, false, "pointer", 'p', optional_argument, NULL, 0, eArgTypeNone, "Display the module pointer."}, { LLDB_OPT_SET_1, false, "global", 'g', no_argument, NULL, 0, eArgTypeNone, "Display the modules from the global module list, not just the current target."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -3811,6 +3943,7 @@ { LoadSubCommand ("create", CommandObjectSP (new CommandObjectTargetCreate (interpreter))); + LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTargetDelete (interpreter))); LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetList (interpreter))); LoadSubCommand ("select", CommandObjectSP (new CommandObjectTargetSelect (interpreter))); LoadSubCommand ("stop-hook", CommandObjectSP (new CommandObjectMultiwordTargetStopHooks (interpreter))); Modified: lldb/trunk/source/Core/FormatClasses.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatClasses.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatClasses.cpp (original) +++ lldb/trunk/source/Core/FormatClasses.cpp Tue Aug 9 21:10:13 2011 @@ -231,4 +231,4 @@ m_python_class.c_str()); return sstr.GetString(); -} \ No newline at end of file +} Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Tue Aug 9 21:10:13 2011 @@ -258,4 +258,4 @@ default: return lldb::eFormatInvalid; } -} \ No newline at end of file +} Modified: lldb/trunk/source/Core/InputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReader.cpp (original) +++ lldb/trunk/source/Core/InputReader.cpp Tue Aug 9 21:10:13 2011 @@ -382,4 +382,4 @@ InputReader::HandlerData::GetOutStream() { return reader.GetDebugger().GetAsyncOutputStream(); -} \ No newline at end of file +} Modified: lldb/trunk/source/Core/InputReaderEZ.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReaderEZ.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReaderEZ.cpp (original) +++ lldb/trunk/source/Core/InputReaderEZ.cpp Tue Aug 9 21:10:13 2011 @@ -93,4 +93,4 @@ InputReaderEZ::~InputReaderEZ () { -} \ No newline at end of file +} Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Tue Aug 9 21:10:13 2011 @@ -756,7 +756,10 @@ else { module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset)); - if (module_sp) + // Make sure there are a module and an object file since we can specify + // a valid file path with an architecture that might not be in that file. + // By getting the object file we can guarantee that the architecture matches + if (module_sp && module_sp->GetObjectFile()) { // If we get in here we got the correct arch, now we just need // to verify the UUID if one was given @@ -766,7 +769,7 @@ { if (did_create_ptr) *did_create_ptr = true; - + shared_module_list.Append(module_sp); return error; } @@ -844,7 +847,10 @@ if (module_sp.get() == NULL) { module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset)); - if (module_sp) + // Make sure there are a module and an object file since we can specify + // a valid file path with an architecture that might not be in that file. + // By getting the object file we can guarantee that the architecture matches + if (module_sp && module_sp->GetObjectFile()) { if (did_create_ptr) *did_create_ptr = true; Modified: lldb/trunk/source/Core/StringList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StringList.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Core/StringList.cpp (original) +++ lldb/trunk/source/Core/StringList.cpp Tue Aug 9 21:10:13 2011 @@ -236,4 +236,4 @@ { AppendList(strings); return *this; -} \ No newline at end of file +} Modified: lldb/trunk/source/Expression/ProcessDataAllocator.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ProcessDataAllocator.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Expression/ProcessDataAllocator.cpp (original) +++ lldb/trunk/source/Expression/ProcessDataAllocator.cpp Tue Aug 9 21:10:13 2011 @@ -40,4 +40,4 @@ 0); // bit alignment (bitfields only; 0 means ignore) stream.PutChar('\n'); -} \ No newline at end of file +} Modified: lldb/trunk/source/Host/common/TimeValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Host/common/TimeValue.cpp (original) +++ lldb/trunk/source/Host/common/TimeValue.cpp Tue Aug 9 21:10:13 2011 @@ -8,12 +8,15 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/TimeValue.h" -#include // C Includes +#include +#include // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Stream.h" + using namespace lldb_private; @@ -63,6 +66,14 @@ return m_nano_seconds / NanoSecPerMicroSec; } +uint64_t +TimeValue::GetAsSecondsSinceJan1_1970() const +{ + return m_nano_seconds / NanoSecPerSec; +} + + + struct timespec TimeValue::GetAsTimeSpec () const { @@ -130,6 +141,28 @@ return *this; } +void +TimeValue::Dump (Stream *s, uint32_t width) const +{ + if (s == NULL) + return; + + char time_buf[32]; + time_t time = GetAsSecondsSinceJan1_1970(); + char *time_cstr = ::ctime_r(&time, time_buf); + if (time_cstr) + { + char *newline = ::strpbrk(time_cstr, "\n\r"); + if (newline) + *newline = '\0'; + if (width > 0) + s->Printf("%-*s", width, time_cstr); + else + s->PutCString(time_cstr); + } + else if (width > 0) + s->Printf("%-*s", width, ""); +} bool lldb_private::operator == (const TimeValue &lhs, const TimeValue &rhs) Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Aug 9 21:10:13 2011 @@ -263,13 +263,32 @@ module_sp = target_images.FindFirstModuleForFileSpec (image_info.file_spec, &arch, NULL); - if (can_create && !module_sp) + if (can_create) { - module_sp = m_process->GetTarget().GetSharedModule (image_info.file_spec, - arch, - image_info_uuid_is_valid ? &image_info.uuid : NULL); - if (did_create_ptr) - *did_create_ptr = module_sp; + if (module_sp) + { + if (image_info.UUIDValid()) + { + if (module_sp->GetUUID() != image_info.uuid) + module_sp.reset(); + } + else + { + // No UUID, we must rely upon the cached module modification + // time and the modification time of the file on disk + if (module_sp->GetModificationTime() != module_sp->GetFileSpec().GetModificationTime()) + module_sp.reset(); + } + } + + if (!module_sp) + { + module_sp = m_process->GetTarget().GetSharedModule (image_info.file_spec, + arch, + image_info_uuid_is_valid ? &image_info.uuid : NULL); + if (did_create_ptr) + *did_create_ptr = module_sp; + } } } return module_sp; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Tue Aug 9 21:10:13 2011 @@ -1446,7 +1446,7 @@ end_time = TimeValue::Now(); total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970(); packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec; - printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%09.9llu sec for %f packets/sec.\n", + printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%9.9llu sec for %f packets/sec.\n", num_packets, send_size, recv_size, @@ -1470,7 +1470,7 @@ end_time = TimeValue::Now(); total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970(); packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec; - printf ("%u 'qC' packets packets in 0x%llu%09.9llu sec for %f packets/sec.\n", + printf ("%u 'qC' packets packets in 0x%llu%9.9llu sec for %f packets/sec.\n", num_packets, total_time_nsec / TimeValue::NanoSecPerSec, total_time_nsec % TimeValue::NanoSecPerSec, 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=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Aug 9 21:10:13 2011 @@ -1331,7 +1331,7 @@ if (stop_info_sp) { stop_info_sp->SetDescription (description.c_str()); - } + } else { gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str())); Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Tue Aug 9 21:10:13 2011 @@ -121,4 +121,4 @@ } return clang::ASTImporter::Imported(from, to); -} \ No newline at end of file +} Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=137196&r1=137195&r2=137196&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Aug 9 21:10:13 2011 @@ -145,6 +145,29 @@ return m_debugger.GetTargetList().GetTargetSP(this); } +void +Target::Destroy() +{ + Mutex::Locker locker (m_mutex); + DeleteCurrentProcess (); + m_platform_sp.reset(); + m_arch.Clear(); + m_images.Clear(); + m_section_load_list.Clear(); + const bool notify = false; + m_breakpoint_list.RemoveAll(notify); + m_internal_breakpoint_list.RemoveAll(notify); + m_last_created_breakpoint.reset(); + m_search_filter_sp.reset(); + m_image_search_paths.Clear(notify); + m_scratch_ast_context_ap.reset(); + m_persistent_variables.Clear(); + m_stop_hooks.clear(); + m_stop_hook_next_id = 0; + m_suppress_stop_hooks = false; +} + + BreakpointList & Target::GetBreakpointList(bool internal) { From jmolenda at apple.com Wed Aug 10 05:51:24 2011 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 10 Aug 2011 10:51:24 -0000 Subject: [Lldb-commits] [lldb] r137208 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20110810105124.419DC2A6C12C@llvm.org> Author: jmolenda Date: Wed Aug 10 05:51:24 2011 New Revision: 137208 URL: http://llvm.org/viewvc/llvm-project?rev=137208&view=rev Log: Remove extra newline from end of 'frame info' command output. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137208&r1=137207&r2=137208&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Aug 10 05:51:24 2011 @@ -73,7 +73,6 @@ if (exe_ctx.frame) { exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream()); - result.GetOutputStream().EOL(); result.SetStatus (eReturnStatusSuccessFinishResult); } else From granata.enrico at gmail.com Wed Aug 10 10:29:15 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Wed, 10 Aug 2011 15:29:15 -0000 Subject: [Lldb-commits] [lldb] r137213 - /lldb/trunk/source/Commands/CommandObjectType.cpp Message-ID: <20110810152915.BC6EE2A6C12C@llvm.org> Author: enrico Date: Wed Aug 10 10:29:15 2011 New Revision: 137213 URL: http://llvm.org/viewvc/llvm-project?rev=137213&view=rev Log: renaming command "type synth" to "type synthetic" for added readability Modified: lldb/trunk/source/Commands/CommandObjectType.cpp Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137213&r1=137212&r2=137213&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Aug 10 10:29:15 2011 @@ -1973,7 +1973,7 @@ public: CommandObjectTypeSynthList (CommandInterpreter &interpreter) : CommandObject (interpreter, - "type synth list", + "type synthetic list", "Show a list of current synthetic providers.", NULL), m_options(interpreter) { @@ -2180,7 +2180,7 @@ public: CommandObjectTypeSynthDelete (CommandInterpreter &interpreter) : CommandObject (interpreter, - "type synth delete", + "type synthetic delete", "Delete an existing synthetic provider for a type.", NULL), m_options(interpreter) { @@ -2340,7 +2340,7 @@ public: CommandObjectTypeSynthClear (CommandInterpreter &interpreter) : CommandObject (interpreter, - "type synth clear", + "type synthetic clear", "Delete all existing synthetic providers.", NULL), m_options(interpreter) { @@ -2711,7 +2711,7 @@ CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd (CommandInterpreter &interpreter) : CommandObject (interpreter, - "type synth add", + "type synthetic add", "Add a new synthetic provider for a type.", NULL), m_options (interpreter) { @@ -2816,9 +2816,9 @@ public: CommandObjectTypeSynth (CommandInterpreter &interpreter) : CommandObjectMultiword (interpreter, - "type synth", + "type synthetic", "A set of commands for operating on synthetic type representations", - "type synth [] ") + "type synthetic [] ") { LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeSynthAdd (interpreter))); LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeSynthClear (interpreter))); @@ -2887,7 +2887,7 @@ LoadSubCommand ("category", CommandObjectSP (new CommandObjectTypeCategory (interpreter))); LoadSubCommand ("format", CommandObjectSP (new CommandObjectTypeFormat (interpreter))); LoadSubCommand ("summary", CommandObjectSP (new CommandObjectTypeSummary (interpreter))); - LoadSubCommand ("synth", CommandObjectSP (new CommandObjectTypeSynth (interpreter))); + LoadSubCommand ("synthetic", CommandObjectSP (new CommandObjectTypeSynth (interpreter))); } From johnny.chen at apple.com Wed Aug 10 12:58:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Aug 2011 17:58:11 -0000 Subject: [Lldb-commits] [lldb] r137228 - /lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110810175811.DD1DB2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 12:58:11 2011 New Revision: 137228 URL: http://llvm.org/viewvc/llvm-project?rev=137228&view=rev Log: Check log shared pointer before using it. Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=137228&r1=137227&r2=137228&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Aug 10 12:58:11 2011 @@ -69,7 +69,8 @@ if (!executableModuleSP) { - log->Printf ("Can't execute code without an executable module."); + if (log) + log->Printf ("Can't execute code without an executable module."); return; } else @@ -77,15 +78,17 @@ ObjectFile *objectFile = executableModuleSP->GetObjectFile(); if (!objectFile) { - log->Printf ("Could not find object file for module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + if (log) + log->Printf ("Could not find object file for module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); return; } m_start_addr = objectFile->GetEntryPointAddress(); if (!m_start_addr.IsValid()) { - log->Printf ("Could not find entry point address for executable module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + if (log) + log->Printf ("Could not find entry point address for executable module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); return; } } @@ -182,7 +185,8 @@ if (!executableModuleSP) { - log->Printf ("Can't execute code without an executable module."); + if (log) + log->Printf ("Can't execute code without an executable module."); return; } else @@ -190,8 +194,9 @@ ObjectFile *objectFile = executableModuleSP->GetObjectFile(); if (!objectFile) { - log->Printf ("Could not find object file for module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + if (log) + log->Printf ("Could not find object file for module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); return; } m_start_addr = objectFile->GetEntryPointAddress(); From scallanan at apple.com Wed Aug 10 16:05:52 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 10 Aug 2011 21:05:52 -0000 Subject: [Lldb-commits] [lldb] r137247 - in /lldb/trunk: source/Expression/IRForTarget.cpp test/lang/c/strings/ test/lang/c/strings/Makefile test/lang/c/strings/TestCStrings.py test/lang/c/strings/main.c Message-ID: <20110810210552.B68F92A6C12C@llvm.org> Author: spyffe Date: Wed Aug 10 16:05:52 2011 New Revision: 137247 URL: http://llvm.org/viewvc/llvm-project?rev=137247&view=rev Log: Fixed a problem that prevented access to members of string literals ("hello"[2]). Also fixed a problem in which empty string literals were not being compiled correctly ((int)printf("") would print garbage). Added a testcase that covers both. Added: lldb/trunk/test/lang/c/strings/ lldb/trunk/test/lang/c/strings/Makefile lldb/trunk/test/lang/c/strings/TestCStrings.py lldb/trunk/test/lang/c/strings/main.c Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=137247&r1=137246&r2=137247&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Aug 10 16:05:52 2011 @@ -1634,19 +1634,42 @@ Constant *gc = gv->getInitializer(); - ConstantArray *gc_array = dyn_cast(gc); + std::string str; - if (!gc_array) - continue; - - if (!gc_array->isCString()) - continue; + if (gc->isNullValue()) + { + Type *gc_type = gc->getType(); + + ArrayType *gc_array_type = dyn_cast(gc_type); + + if (!gc_array_type) + continue; + + Type *gc_element_type = gc_array_type->getElementType(); + + IntegerType *gc_integer_type = dyn_cast(gc_element_type); + + if (gc_integer_type->getBitWidth() != 8) + continue; + + str = ""; + } + else + { + ConstantArray *gc_array = dyn_cast(gc); + + if (!gc_array) + continue; - if (log) - log->Printf("Found a GlobalVariable with string initializer %s", PrintValue(gc).c_str()); + if (!gc_array->isCString()) + continue; - std::string str = gc_array->getAsString(); + if (log) + log->Printf("Found a GlobalVariable with string initializer %s", PrintValue(gc).c_str()); + str = gc_array->getAsString(); + } + offsets[gv] = m_data_allocator->GetStream().GetSize(); m_data_allocator->GetStream().Write(str.c_str(), str.length() + 1); @@ -1686,7 +1709,10 @@ return false; } - const_expr->replaceAllUsesWith(new_initializer); + Constant *bit_cast = ConstantExpr::getBitCast(new_initializer, const_expr->getOperand(0)->getType()); + Constant *new_gep = const_expr->getWithOperandReplaced(0, bit_cast); + + const_expr->replaceAllUsesWith(new_gep); } else if (store_inst) { Added: lldb/trunk/test/lang/c/strings/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/Makefile?rev=137247&view=auto ============================================================================== --- lldb/trunk/test/lang/c/strings/Makefile (added) +++ lldb/trunk/test/lang/c/strings/Makefile Wed Aug 10 16:05:52 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/lang/c/strings/TestCStrings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/TestCStrings.py?rev=137247&view=auto ============================================================================== --- lldb/trunk/test/lang/c/strings/TestCStrings.py (added) +++ lldb/trunk/test/lang/c/strings/TestCStrings.py Wed Aug 10 16:05:52 2011 @@ -0,0 +1,57 @@ +""" +Tests that C strings work as expected in expressions +""" + +from lldbtest import * + +class CStringsTestCase(TestBase): + + mydir = os.path.join("lang", "c", "strings") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Tests that C strings work as expected in expressions""" + self.buildDsym() + self.static_method_commands() + + def test_with_dwarf_and_run_command(self): + """Tests that C strings work as expected in expressions""" + self.buildDwarf() + self.static_method_commands() + + def setUp(self): + TestBase.setUp(self) + + def set_breakpoint(self, line): + self.expect("breakpoint set -f main.c -l %d" % line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created") + + def static_method_commands(self): + """Tests that C strings work as expected in expressions""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.set_breakpoint(line_number('main.c', '// breakpoint 1')) + + self.runCmd("process launch", RUN_SUCCEEDED) + + self.expect("expression -- a[2]", + startstr = "(char) $0 = 'c'") + + self.expect("expression -- z[2]", + startstr = "(const char) $1 = 'x'") + + self.expect("expression -- (int)strlen(\"hello\")", + startstr = "(int) $2 = 5") + + self.expect("expression -- \"world\"[2]", + startstr = "(const char) $3 = 'r'") + + self.expect("expression -- \"\"[0]", + startstr = "(const char) $4 = '\\0'") + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/lang/c/strings/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/strings/main.c?rev=137247&view=auto ============================================================================== --- lldb/trunk/test/lang/c/strings/main.c (added) +++ lldb/trunk/test/lang/c/strings/main.c Wed Aug 10 16:05:52 2011 @@ -0,0 +1,18 @@ +//===-- main.c ----------------------------------------------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +int main() +{ + const char a[] = "abcde"; + const char *z = "vwxyz"; + + printf("%s %s", a, z); // breakpoint 1 +} From gclayton at apple.com Wed Aug 10 17:05:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 10 Aug 2011 22:05:39 -0000 Subject: [Lldb-commits] [lldb] r137256 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110810220539.4394C2A6C12C@llvm.org> Author: gclayton Date: Wed Aug 10 17:05:39 2011 New Revision: 137256 URL: http://llvm.org/viewvc/llvm-project?rev=137256&view=rev Log: Include the qLaunchSuccess and qC packets in the 10 second timeout zone. When launching we increase the timeout to 10 seconds to ensure we have time to launch a process, and then set it back. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 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=137256&r1=137255&r2=137256&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Aug 10 17:05:39 2011 @@ -531,7 +531,6 @@ const uint32_t old_packet_timeout = m_gdb_comm.SetPacketTimeout (10); int arg_packet_err = m_gdb_comm.SendArgumentsPacket (argv); - m_gdb_comm.SetPacketTimeout (old_packet_timeout); if (arg_packet_err == 0) { std::string error_str; @@ -548,6 +547,8 @@ { error.SetErrorStringWithFormat("'A' packet returned an error: %i.\n", arg_packet_err); } + + m_gdb_comm.SetPacketTimeout (old_packet_timeout); if (GetID() == LLDB_INVALID_PROCESS_ID) { From johnny.chen at apple.com Wed Aug 10 17:06:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Aug 2011 22:06:24 -0000 Subject: [Lldb-commits] [lldb] r137257 - in /lldb/trunk: source/API/SBFrame.cpp tools/driver/Driver.cpp tools/driver/IOChannel.cpp Message-ID: <20110810220624.7872E2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 17:06:24 2011 New Revision: 137257 URL: http://llvm.org/viewvc/llvm-project?rev=137257&view=rev Log: Incremental fixes of issues found by Xcode static analyzer. Modified: lldb/trunk/source/API/SBFrame.cpp lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/driver/IOChannel.cpp Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=137257&r1=137256&r2=137257&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Wed Aug 10 17:06:24 2011 @@ -739,6 +739,7 @@ LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + ExecutionResults exe_results; SBValue expr_result; if (log) log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", m_opaque_sp.get(), expr); @@ -754,7 +755,6 @@ Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", expr, fetch_dynamic_value, frame_description.GetString().c_str()); - ExecutionResults exe_results; const bool unwind_on_error = true; const bool keep_in_memory = false; @@ -772,9 +772,10 @@ expr_result.GetSummary()); if (log) - log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), + log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", m_opaque_sp.get(), expr, - expr_result.get()); + expr_result.get(), + exe_results); return expr_result; } Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=137257&r1=137256&r2=137257&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Wed Aug 10 17:06:24 2011 @@ -554,8 +554,7 @@ else if (file.ResolveExecutableLocation()) { char path[PATH_MAX]; - int path_len; - file.GetPath (path, path_len); + file.GetPath (path, sizeof(path)); m_option_data.m_args.push_back (path); } else @@ -584,8 +583,7 @@ else if (file.ResolveExecutableLocation()) { char final_path[PATH_MAX]; - size_t path_len; - file.GetPath (final_path, path_len); + file.GetPath (final_path, sizeof(final_path)); std::string path_str (final_path); m_option_data.m_source_command_files.push_back (path_str); } @@ -1225,7 +1223,6 @@ done = true; if (event_type & IOChannel::eBroadcastBitThreadDidExit) iochannel_thread_exited = true; - break; } else done = HandleIOEvent (event); Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=137257&r1=137256&r2=137257&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Wed Aug 10 17:06:24 2011 @@ -411,7 +411,7 @@ else if (event_type & Driver::eBroadcastBitThreadShouldExit) { done = true; - break; + continue; } } else if (event.BroadcasterMatchesRef (interpreter_broadcaster)) @@ -437,7 +437,7 @@ if (event_type & IOChannel::eBroadcastBitThreadShouldExit) { done = true; - break; + continue; } } } From johnny.chen at apple.com Wed Aug 10 18:01:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Aug 2011 23:01:39 -0000 Subject: [Lldb-commits] [lldb] r137267 - in /lldb/trunk/tools/debugserver/source: MacOSX/MachProcess.cpp debugserver.cpp Message-ID: <20110810230139.94E4D2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 18:01:39 2011 New Revision: 137267 URL: http://llvm.org/viewvc/llvm-project?rev=137267&view=rev Log: Incremental fixes of issues found by Xcode static analyzer. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/debugserver.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=137267&r1=137266&r2=137267&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Aug 10 18:01:39 2011 @@ -418,7 +418,8 @@ { DisableAllBreakpoints (true); DisableAllWatchpoints (true); - clear_bps_and_wps = false; + // Silence static analyzer. + // clear_bps_and_wps = false; } uint32_t thread_idx = m_thread_list.GetThreadIndexForThreadStoppedWithSignal (SIGSTOP); if (thread_idx_ptr) Modified: lldb/trunk/tools/debugserver/source/debugserver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/debugserver.cpp?rev=137267&r1=137266&r2=137267&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/debugserver.cpp (original) +++ lldb/trunk/tools/debugserver/source/debugserver.cpp Wed Aug 10 18:01:39 2011 @@ -1003,7 +1003,7 @@ case 'g': debug = 1; - DNBLogSetDebug(1); + DNBLogSetDebug(debug); break; case 't': From johnny.chen at apple.com Wed Aug 10 18:19:32 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Aug 2011 23:19:32 -0000 Subject: [Lldb-commits] [lldb] r137275 - /lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Message-ID: <20110810231932.6994F2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 18:19:32 2011 New Revision: 137275 URL: http://llvm.org/viewvc/llvm-project?rev=137275&view=rev Log: Ignore the static analyzer, instead; and add comment why. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=137275&r1=137274&r2=137275&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Aug 10 18:19:32 2011 @@ -418,8 +418,8 @@ { DisableAllBreakpoints (true); DisableAllWatchpoints (true); - // Silence static analyzer. - // clear_bps_and_wps = false; + // The static analyzer complains about this, but just leave the following line in. + clear_bps_and_wps = false; } uint32_t thread_idx = m_thread_list.GetThreadIndexForThreadStoppedWithSignal (SIGSTOP); if (thread_idx_ptr) From johnny.chen at apple.com Wed Aug 10 19:16:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 00:16:28 -0000 Subject: [Lldb-commits] [lldb] r137285 - /lldb/trunk/test/lldbtest.py Message-ID: <20110811001628.7218A2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 19:16:28 2011 New Revision: 137285 URL: http://llvm.org/viewvc/llvm-project?rev=137285&view=rev Log: When a benchmarks test fails, the re-run command should include the '+b' option instead of the '-t' option. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=137285&r1=137284&r2=137285&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Aug 10 19:16:28 2011 @@ -701,6 +701,12 @@ if test is self: print >> self.session, traceback + testMethod = getattr(self, self._testMethodName) + if getattr(testMethod, "__benchmarks_test__", False): + benchmarks = True + else: + benchmarks = False + dname = os.path.join(os.environ["LLDB_TEST"], os.environ["LLDB_SESSION_DIRNAME"]) if not os.path.isdir(dname): @@ -711,7 +717,8 @@ print >> f, "Session info generated @", datetime.datetime.now().ctime() print >> f, self.session.getvalue() print >> f, "To rerun this test, issue the following command from the 'test' directory:\n" - print >> f, "./dotest.py %s -v -t -f %s.%s" % (self.getRunOptions(), + print >> f, "./dotest.py %s -v %s -f %s.%s" % (self.getRunOptions(), + ('+b' if benchmarks else '-t'), self.__class__.__name__, self._testMethodName) From jingham at apple.com Wed Aug 10 19:38:52 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 11 Aug 2011 00:38:52 -0000 Subject: [Lldb-commits] [lldb] r137287 - /lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Message-ID: <20110811003852.66EB62A6C12C@llvm.org> Author: jingham Date: Wed Aug 10 19:38:52 2011 New Revision: 137287 URL: http://llvm.org/viewvc/llvm-project?rev=137287&view=rev Log: In the case where we are trying to resume a thread all the way to 0, if we get Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=137287&r1=137286&r2=137287&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Wed Aug 10 19:38:52 2011 @@ -119,7 +119,6 @@ times_to_resume = m_basic_info.suspend_count; else times_to_resume = 0; - return false; // ??? } } } @@ -161,7 +160,10 @@ if (err.Success()) ++m_suspend_count; if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) + { err.LogThreaded("::thread_suspend (%4.4x)", m_tid); + return false; + } } } return true; From johnny.chen at apple.com Wed Aug 10 19:43:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 00:43:20 -0000 Subject: [Lldb-commits] [lldb] r137288 - /lldb/trunk/tools/debugserver/source/RNBRemote.cpp Message-ID: <20110811004320.807882A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 19:43:20 2011 New Revision: 137288 URL: http://llvm.org/viewvc/llvm-project?rev=137288&view=rev Log: Incremental fixes of issues found by Xcode static analyzer. Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=137288&r1=137287&r2=137288&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Wed Aug 10 19:43:20 2011 @@ -429,7 +429,6 @@ return err; const nub_event_t events_to_wait_for = RNBContext::event_read_packet_available | RNBContext::event_read_thread_exiting; - set_events = 0; while ((set_events = events.WaitForSetEvents(events_to_wait_for)) != 0) { @@ -2068,7 +2067,7 @@ // Output the T packet with the thread ostrm << 'T'; int signum = tid_stop_info.details.signal.signo; - DNBLogThreadedIf (LOG_RNB_PROC, "%8d %s got signal signo = %u, exc_type = %u", (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__, tid_stop_info.details.signal.signo, tid_stop_info.details.exception.type); + DNBLogThreadedIf (LOG_RNB_PROC, "%8d %s got signal signo = %u, exc_type = %u", (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__, signum, tid_stop_info.details.exception.type); // Translate any mach exceptions to gdb versions, unless they are // common exceptions like a breakpoint or a soft signal. From johnny.chen at apple.com Wed Aug 10 19:49:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 00:49:03 -0000 Subject: [Lldb-commits] [lldb] r137289 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/main.cpp Message-ID: <20110811004903.E21272A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 19:49:03 2011 New Revision: 137289 URL: http://llvm.org/viewvc/llvm-project?rev=137289&view=rev Log: Change the SBValue.linked_list_iter() to treat the value object as a homogeneous linked list data structure where an empty linked list is represented as a value object with a NULL value, instead of a special value object which 'points' to NULL. Also modifies the test case to comply. rdar://problem/9933692 Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/value/linked_list/main.cpp Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=137289&r1=137288&r2=137289&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Aug 10 19:49:03 2011 @@ -95,7 +95,7 @@ Return True if val is invalid or it corresponds to a null pointer. Otherwise, return False. """ - if not val or int(val.GetValue(), 0) == 0: + if not val or val.GetValueAsUnsigned() == 0: return True else: return False @@ -127,8 +127,10 @@ for t in task_head.linked_list_iter('next'): print t """ + if end_of_list_test(self): + return + item = self try: - item = self.GetChildMemberWithName(next_item_name) while not end_of_list_test(item): yield item # Prepare for the next iteration. Modified: lldb/trunk/test/python_api/value/linked_list/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/main.cpp?rev=137289&r1=137288&r2=137289&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/main.cpp (original) +++ lldb/trunk/test/python_api/value/linked_list/main.cpp Wed Aug 10 19:49:03 2011 @@ -21,14 +21,14 @@ int main (int argc, char const *argv[]) { - Task *task_head = new Task(-1, NULL); + Task *task_head = NULL; Task *task1 = new Task(1, NULL); Task *task2 = new Task(2, NULL); Task *task3 = new Task(3, NULL); // Orphaned. Task *task4 = new Task(4, NULL); Task *task5 = new Task(5, NULL); - task_head->next = task1; + task_head = task1; task1->next = task2; task2->next = task4; task4->next = task5; @@ -43,7 +43,7 @@ printf("We have a total number of %d tasks\n", total); // This corresponds to an empty task list. - Task *empty_task_head = new Task(-1, NULL); + Task *empty_task_head = NULL; return 0; // Break at this line } From johnny.chen at apple.com Wed Aug 10 20:19:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 01:19:46 -0000 Subject: [Lldb-commits] [lldb] r137291 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/value/linked_list/TestValueAPILinkedList.py test/python_api/value/linked_list/main.cpp Message-ID: <20110811011946.3A10C2A6C12C@llvm.org> Author: johnny Date: Wed Aug 10 20:19:46 2011 New Revision: 137291 URL: http://llvm.org/viewvc/llvm-project?rev=137291&view=rev Log: Add logic to SBValue.linked_list_iter() to detect infinite loop and to bail out early. Add code to test case to create an evil linked list with: task_evil -> task_2 -> task_3 -> task_evil ... and to check that the linked list iterator only iterates 3 times. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py lldb/trunk/test/python_api/value/linked_list/main.cpp Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=137291&r1=137290&r2=137291&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Aug 10 20:19:46 2011 @@ -112,6 +112,8 @@ end-of-list test function which takes an SBValue for an item and returns True if EOL is reached and False if not. + linked_list_iter() also detects infinite loop and bails out early. + The end_of_list_test arg, if omitted, defaults to the __eol_test__ function above. @@ -130,8 +132,10 @@ if end_of_list_test(self): return item = self + visited = set() try: - while not end_of_list_test(item): + while not end_of_list_test(item) and not item.GetValueAsUnsigned() in visited: + visited.add(item.GetValueAsUnsigned()) yield item # Prepare for the next iteration. item = item.GetChildMemberWithName(next_item_name) Modified: lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py?rev=137291&r1=137290&r2=137291&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py (original) +++ lldb/trunk/test/python_api/value/linked_list/TestValueAPILinkedList.py Wed Aug 10 20:19:46 2011 @@ -127,6 +127,20 @@ self.assertTrue(len(list) == 0) + # Get variable 'task_evil'. + task_evil = frame0.FindVariable('task_evil') + self.assertTrue(task_evil, VALID_VARIABLE) + self.DebugSBValue(task_evil) + + list = [] + # There 3 iterable items from task_evil.linked_list_iter(). :-) + for t in task_evil.linked_list_iter('next'): + if self.TraceOn(): + print cvf.format(t) + list.append(int(t.GetChildMemberWithName("id").GetValue())) + + self.assertTrue(len(list) == 3) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Modified: lldb/trunk/test/python_api/value/linked_list/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/linked_list/main.cpp?rev=137291&r1=137290&r2=137291&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/linked_list/main.cpp (original) +++ lldb/trunk/test/python_api/value/linked_list/main.cpp Wed Aug 10 20:19:46 2011 @@ -45,5 +45,12 @@ // This corresponds to an empty task list. Task *empty_task_head = NULL; + Task *task_evil = new Task(1, NULL); + Task *task_2 = new Task(2, NULL); + Task *task_3 = new Task(3, NULL); + task_evil->next = task_2; + task_2->next = task_3; + task_3->next = task_evil; // In order to cause inifinite loop. :-) + return 0; // Break at this line } From gclayton at apple.com Wed Aug 10 21:48:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Aug 2011 02:48:45 -0000 Subject: [Lldb-commits] [lldb] r137294 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/DynamicLoader/MacOSX-Kernel/ source/Plugins/Process/MacOSX-Kernel/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20110811024845.AB9462A6C12C@llvm.org> Author: gclayton Date: Wed Aug 10 21:48:45 2011 New Revision: 137294 URL: http://llvm.org/viewvc/llvm-project?rev=137294&view=rev Log: Added the ability to remove orphaned module shared pointers from a ModuleList. This is helping us track down some extra references to ModuleSP objects that are causing things to get kept around for too long. Added a module pointer accessor to target and change a lot of code to use it where it would be more efficient. "taret delete" can now specify "--clean=1" which will cleanup the global module list for any orphaned module in the shared module cache which can save memory and also help track down module reference leaks like we have now. Modified: lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/TargetList.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Wed Aug 10 21:48:45 2011 @@ -363,6 +363,9 @@ size_t Remove (ModuleList &module_list); + size_t + RemoveOrphans (); + bool ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr); @@ -428,6 +431,9 @@ const ConstString *object_name_ptr, ModuleList &matching_module_list); + static uint32_t + RemoveOrphanSharedModules (); + protected: //------------------------------------------------------------------ // Class typedefs. Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Wed Aug 10 21:48:45 2011 @@ -347,6 +347,9 @@ lldb::ModuleSP GetExecutableModule (); + Module* + GetExecutableModulePointer (); + //------------------------------------------------------------------ /// Set the main executable module. /// Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Aug 10 21:48:45 2011 @@ -804,7 +804,7 @@ { char path[PATH_MAX]; GetTarget().GetExecutable().GetPath (path, sizeof(path)); - Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModule ().get(); + Module *exe_module = m_opaque_sp->GetTarget().GetExecutableModulePointer(); const char *exe_name = NULL; if (exe_module) exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Wed Aug 10 21:48:45 2011 @@ -459,9 +459,9 @@ SBFileSpec exe_file_spec; if (m_opaque_sp) { - ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ()); - if (exe_module_sp) - exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec()); + Module *exe_module = m_opaque_sp->GetExecutableModulePointer(); + if (exe_module) + exe_file_spec.SetFileSpec (exe_module->GetFileSpec()); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Aug 10 21:48:45 2011 @@ -306,7 +306,6 @@ else if (!m_options.m_func_regexp.empty()) break_type = eSetTypeFunctionRegexp; - ModuleSP module_sp = target->GetExecutableModule(); Breakpoint *bp = NULL; FileSpec module_spec; bool use_module = false; Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Aug 10 21:48:45 2011 @@ -374,17 +374,16 @@ Error error; const uint32_t argc = args.GetArgumentCount(); Target *target = m_interpreter.GetExecutionContext().target; - ModuleSP exe_module_sp; if (target) { - exe_module_sp = target->GetExecutableModule(); - if (exe_module_sp) + Module *exe_module = target->GetExecutableModulePointer(); + if (exe_module) { - m_options.launch_info.GetExecutableFile () = exe_module_sp->GetFileSpec(); + m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec(); char exe_path[PATH_MAX]; if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path))) m_options.launch_info.GetArguments().AppendArgument (exe_path); - m_options.launch_info.GetArchitecture() = exe_module_sp->GetArchitecture(); + m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture(); } } Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Aug 10 21:48:45 2011 @@ -162,7 +162,7 @@ // If our listener is NULL, users aren't allows to launch char filename[PATH_MAX]; - const Module *exe_module = target->GetExecutableModule().get(); + const Module *exe_module = target->GetExecutableModulePointer(); if (exe_module == NULL) { @@ -762,22 +762,22 @@ { // Okay, we're done. Last step is to warn if the executable module has changed: char new_path[PATH_MAX]; + ModuleSP new_exec_module_sp (target->GetExecutableModule()); if (!old_exec_module_sp) { // We might not have a module if we attached to a raw pid... - ModuleSP new_module_sp (target->GetExecutableModule()); - if (new_module_sp) + if (new_exec_module_sp) { - new_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX); + new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX); result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path); } } - else if (old_exec_module_sp->GetFileSpec() != target->GetExecutableModule()->GetFileSpec()) + else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec()) { char old_path[PATH_MAX]; - old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX); - target->GetExecutableModule()->GetFileSpec().GetPath (new_path, PATH_MAX); + old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX); + new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX); result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n", old_path, new_path); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Aug 10 21:48:45 2011 @@ -26,6 +26,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/OptionGroupArchitecture.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" #include "lldb/Interpreter/OptionGroupFile.h" #include "lldb/Interpreter/OptionGroupVariable.h" #include "lldb/Interpreter/OptionGroupPlatform.h" @@ -52,11 +53,11 @@ { const ArchSpec &target_arch = target->GetArchitecture(); - ModuleSP exe_module_sp (target->GetExecutableModule ()); + Module *exe_module = target->GetExecutableModulePointer(); char exe_path[PATH_MAX]; bool exe_valid = false; - if (exe_module_sp) - exe_valid = exe_module_sp->GetFileSpec().GetPath (exe_path, sizeof(exe_path)); + if (exe_module) + exe_valid = exe_module->GetFileSpec().GetPath (exe_path, sizeof(exe_path)); if (!exe_valid) ::strcpy (exe_path, ""); @@ -410,12 +411,16 @@ { public: CommandObjectTargetDelete (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "target delete", - "Delete one or more targets by target index.", - NULL, - 0) + CommandObject (interpreter, + "target delete", + "Delete one or more targets by target index.", + NULL, + 0), + m_option_group (interpreter), + m_cleanup_option (LLDB_OPT_SET_1, false, "clean", 'c', 0, eArgTypeNone, "Perform extra cleanup to minimize memory consumption after deleting the target.", false) { + m_option_group.Append (&m_cleanup_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); + m_option_group.Finalize(); } virtual @@ -487,12 +492,28 @@ target_list.DeleteTarget(target_sp); target_sp->Destroy(); } + // If "--clean" was specified, prune any orphaned shared modules from + // the global shared module list + if (m_cleanup_option.GetOptionValue ()) + { + ModuleList::RemoveOrphanSharedModules(); + } result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete); result.SetStatus(eReturnStatusSuccessFinishResult); } return result.Succeeded(); } + + Options * + GetOptions () + { + return &m_option_group; + } + +protected: + OptionGroupOptions m_option_group; + OptionGroupBoolean m_cleanup_option; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Aug 10 21:48:45 2011 @@ -1256,17 +1256,17 @@ (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) || (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0)) { - ModuleSP exe_module_sp (exe_ctx->process->GetTarget().GetExecutableModule()); - if (exe_module_sp) + Module *exe_module = exe_ctx->process->GetTarget().GetExecutableModulePointer(); + if (exe_module) { if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f') { - format_file_spec.GetFilename() = exe_module_sp->GetFileSpec().GetFilename(); + format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename(); var_success = format_file_spec; } else { - format_file_spec = exe_module_sp->GetFileSpec(); + format_file_spec = exe_module->GetFileSpec(); var_success = format_file_spec; } } Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Wed Aug 10 21:48:45 2011 @@ -108,6 +108,28 @@ return false; } + +size_t +ModuleList::RemoveOrphans () +{ + Mutex::Locker locker(m_modules_mutex); + collection::reverse_iterator pos = m_modules.rbegin(); + size_t remove_count = 0; + while (pos != m_modules.rend()) + { + if (pos->unique()) + { + pos = m_modules.erase (pos); + ++remove_count; + } + else + { + ++pos; + } + } + return remove_count; +} + size_t ModuleList::Remove (ModuleList &module_list) { @@ -680,6 +702,12 @@ return shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list); } +uint32_t +ModuleList::RemoveOrphanSharedModules () +{ + return GetSharedModuleList ().RemoveOrphans(); +} + Error ModuleList::GetSharedModule ( Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Wed Aug 10 21:48:45 2011 @@ -307,7 +307,7 @@ Process *process = m_reg_ctx_sp->CalculateProcess (); if (process) { - Module *exe_module = process->GetTarget().GetExecutableModule ().get(); + Module *exe_module = process->GetTarget().GetExecutableModulePointer(); if (exe_module) { m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding, @@ -338,7 +338,7 @@ Process *process = m_reg_ctx_sp->CalculateProcess (); if (process) { - Module *exe_module = process->GetTarget().GetExecutableModule ().get(); + Module *exe_module = process->GetTarget().GetExecutableModulePointer(); if (exe_module) return exe_module->GetClangASTContext().getASTContext(); } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Aug 10 21:48:45 2011 @@ -89,7 +89,7 @@ if (!create) { create = true; - Module* exe_module = process->GetTarget().GetExecutableModule().get(); + Module* exe_module = process->GetTarget().GetExecutableModulePointer(); if (exe_module) { ObjectFile *object_file = exe_module->GetObjectFile(); @@ -225,7 +225,7 @@ } // Check some default values - Module *executable = m_process->GetTarget().GetExecutableModule().get(); + Module *executable = m_process->GetTarget().GetExecutableModulePointer(); if (executable) { @@ -267,7 +267,7 @@ { if (module_sp) { - if (image_info.UUIDValid()) + if (image_info_uuid_is_valid) { if (module_sp->GetUUID() != image_info.uuid) module_sp.reset(); @@ -1217,7 +1217,7 @@ if (exe_module_sp) { - if (exe_module_sp.get() != m_process->GetTarget().GetExecutableModule().get()) + if (exe_module_sp.get() != m_process->GetTarget().GetExecutableModulePointer()) { // Don't load dependent images since we are in dyld where we will know // and find out about all images that are loaded Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-Kernel/DynamicLoaderMacOSXKernel.cpp Wed Aug 10 21:48:45 2011 @@ -52,7 +52,7 @@ bool create = force; if (!create) { - Module* exe_module = process->GetTarget().GetExecutableModule().get(); + Module* exe_module = process->GetTarget().GetExecutableModulePointer(); if (exe_module) { ObjectFile *object_file = exe_module->GetObjectFile(); Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Wed Aug 10 21:48:45 2011 @@ -59,14 +59,14 @@ ProcessKDP::CanDebug(Target &target, bool plugin_specified_by_name) { // For now we are just making sure the file exists for a given module - ModuleSP exe_module_sp(target.GetExecutableModule()); - if (exe_module_sp.get()) + Module *exe_module = target.GetExecutableModulePointer(); + if (exe_module) { const llvm::Triple &triple_ref = target.GetArchitecture().GetTriple(); if (triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple) { - ObjectFile *exe_objfile = exe_module_sp->GetObjectFile(); + ObjectFile *exe_objfile = exe_module->GetObjectFile(); if (exe_objfile->GetType() == ObjectFile::eTypeExecutable && exe_objfile->GetStrata() == ObjectFile::eStrataKernel) return true; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Aug 10 21:48:45 2011 @@ -104,9 +104,9 @@ ProcessGDBRemote::CanDebug (Target &target, bool plugin_specified_by_name) { // For now we are just making sure the file exists for a given module - ModuleSP exe_module_sp(target.GetExecutableModule()); - if (exe_module_sp.get()) - return exe_module_sp->GetFileSpec().Exists(); + Module *exe_module = target.GetExecutableModulePointer(); + if (exe_module) + return exe_module->GetFileSpec().Exists(); // However, if there is no executable module, we return true since we might be preparing to attach. return true; } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Aug 10 21:48:45 2011 @@ -2019,7 +2019,7 @@ m_dyld_ap.reset(); m_process_input_reader.reset(); - Module *exe_module = m_target.GetExecutableModule().get(); + Module *exe_module = m_target.GetExecutableModulePointer(); if (exe_module) { char local_exec_file_path[PATH_MAX]; @@ -2327,8 +2327,7 @@ ModuleSP module_sp (modules.GetModuleAtIndex(i)); if (module_sp && module_sp->IsExecutable()) { - ModuleSP target_exe_module_sp (m_target.GetExecutableModule()); - if (target_exe_module_sp != module_sp) + if (m_target.GetExecutableModulePointer() != module_sp.get()) m_target.SetExecutableModule (module_sp, false); break; } @@ -3319,11 +3318,11 @@ void Process::UpdateInstanceName () { - ModuleSP module_sp = GetTarget().GetExecutableModule(); - if (module_sp) + Module *module = GetTarget().GetExecutableModulePointer(); + if (module) { StreamString sstr; - sstr.Printf ("%s", module_sp->GetFileSpec().GetFilename().AsCString()); + sstr.Printf ("%s", module->GetFileSpec().GetFilename().AsCString()); GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Aug 10 21:48:45 2011 @@ -98,8 +98,9 @@ } else { - if (GetExecutableModule()) - s->PutCString (GetExecutableModule()->GetFileSpec().GetFilename().GetCString()); + Module *exe_module = GetExecutableModulePointer(); + if (exe_module) + s->PutCString (exe_module->GetFileSpec().GetFilename().GetCString()); else s->PutCString ("No executable module."); } @@ -437,10 +438,13 @@ ModuleSP Target::GetExecutableModule () { - ModuleSP executable_sp; - if (m_images.GetSize() > 0) - executable_sp = m_images.GetModuleAtIndex(0); - return executable_sp; + return m_images.GetModuleAtIndex(0); +} + +Module* +Target::GetExecutableModulePointer () +{ + return m_images.GetModulePointerAtIndex(0); } void @@ -915,14 +919,11 @@ ) { Target *target = (Target *)baton; - if (target->m_images.GetSize() > 1) + ModuleSP exe_module_sp (target->GetExecutableModule()); + if (exe_module_sp) { - ModuleSP exe_module_sp (target->GetExecutableModule()); - if (exe_module_sp) - { - target->m_images.Clear(); - target->SetExecutableModule (exe_module_sp, true); - } + target->m_images.Clear(); + target->SetExecutableModule (exe_module_sp, true); } } @@ -1013,14 +1014,13 @@ { StreamString sstr; - ModuleSP module_sp = GetExecutableModule(); - if (module_sp) + Module *exe_module = GetExecutableModulePointer(); + if (exe_module) { sstr.Printf ("%s_%s", - module_sp->GetFileSpec().GetFilename().AsCString(), - module_sp->GetArchitecture().GetArchitectureName()); - GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), - sstr.GetData()); + exe_module->GetFileSpec().GetFilename().AsCString(), + exe_module->GetArchitecture().GetArchitectureName()); + GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); } } Modified: lldb/trunk/source/Target/TargetList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Target/TargetList.cpp (original) +++ lldb/trunk/source/Target/TargetList.cpp Wed Aug 10 21:48:45 2011 @@ -148,15 +148,15 @@ collection::const_iterator pos, end = m_target_list.end(); for (pos = m_target_list.begin(); pos != end; ++pos) { - ModuleSP module_sp ((*pos)->GetExecutableModule()); + Module *exe_module = (*pos)->GetExecutableModulePointer(); - if (module_sp) + if (exe_module) { - if (FileSpec::Equal (exe_file_spec, module_sp->GetFileSpec(), full_match)) + if (FileSpec::Equal (exe_file_spec, exe_module->GetFileSpec(), full_match)) { if (exe_arch_ptr) { - if (*exe_arch_ptr != module_sp->GetArchitecture()) + if (*exe_arch_ptr != exe_module->GetArchitecture()) continue; } target_sp = *pos; Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Aug 10 21:48:45 2011 @@ -65,9 +65,9 @@ m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); - ModuleSP executableModuleSP (target.GetExecutableModule()); + Module *exe_module = target.GetExecutableModulePointer(); - if (!executableModuleSP) + if (exe_module == NULL) { if (log) log->Printf ("Can't execute code without an executable module."); @@ -75,7 +75,7 @@ } else { - ObjectFile *objectFile = executableModuleSP->GetObjectFile(); + ObjectFile *objectFile = exe_module->GetObjectFile(); if (!objectFile) { if (log) @@ -181,9 +181,9 @@ m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); - ModuleSP executableModuleSP (target.GetExecutableModule()); + Module *exe_module = target.GetExecutableModulePointer(); - if (!executableModuleSP) + if (exe_module == NULL) { if (log) log->Printf ("Can't execute code without an executable module."); @@ -191,7 +191,7 @@ } else { - ObjectFile *objectFile = executableModuleSP->GetObjectFile(); + ObjectFile *objectFile = exe_module->GetObjectFile(); if (!objectFile) { if (log) @@ -204,7 +204,7 @@ { if (log) log->Printf ("Could not find entry point address for executable module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + exe_module->GetFileSpec().GetFilename().AsCString()); return; } } Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=137294&r1=137293&r2=137294&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Wed Aug 10 21:48:45 2011 @@ -117,12 +117,12 @@ m_abi = process.GetABI().get(); - ModuleSP exe_module_sp (target.GetExecutableModule()); + Module *exe_module = target.GetExecutableModulePointer(); - if (exe_module_sp) + if (exe_module) { - m_intptr_type = TypeFromUser(exe_module_sp->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8), - exe_module_sp->GetClangASTContext().getASTContext()); + m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8), + exe_module->GetClangASTContext().getASTContext()); } const unsigned int buf_size = 32; From gclayton at apple.com Wed Aug 10 23:30:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Aug 2011 04:30:39 -0000 Subject: [Lldb-commits] [lldb] r137300 - in /lldb/trunk/source: Core/ModuleList.cpp Target/ThreadPlanCallFunction.cpp Message-ID: <20110811043039.DC2DF2A6C12C@llvm.org> Author: gclayton Date: Wed Aug 10 23:30:39 2011 New Revision: 137300 URL: http://llvm.org/viewvc/llvm-project?rev=137300&view=rev Log: Fix the broken build that happened with my last checkin. Modified: lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=137300&r1=137299&r2=137300&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Wed Aug 10 23:30:39 2011 @@ -113,9 +113,9 @@ ModuleList::RemoveOrphans () { Mutex::Locker locker(m_modules_mutex); - collection::reverse_iterator pos = m_modules.rbegin(); + collection::iterator pos = m_modules.begin(); size_t remove_count = 0; - while (pos != m_modules.rend()) + while (pos != m_modules.end()) { if (pos->unique()) { Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=137300&r1=137299&r2=137300&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed Aug 10 23:30:39 2011 @@ -80,7 +80,7 @@ { if (log) log->Printf ("Could not find object file for module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + exe_module->GetFileSpec().GetFilename().AsCString()); return; } m_start_addr = objectFile->GetEntryPointAddress(); @@ -88,7 +88,7 @@ { if (log) log->Printf ("Could not find entry point address for executable module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + exe_module->GetFileSpec().GetFilename().AsCString()); return; } } @@ -196,7 +196,7 @@ { if (log) log->Printf ("Could not find object file for module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + exe_module->GetFileSpec().GetFilename().AsCString()); return; } m_start_addr = objectFile->GetEntryPointAddress(); From gclayton at apple.com Thu Aug 11 11:25:18 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Aug 2011 16:25:18 -0000 Subject: [Lldb-commits] [lldb] r137307 - in /lldb/trunk: include/lldb/Target/Platform.h source/Commands/CommandObjectProcess.cpp source/Target/Platform.cpp Message-ID: <20110811162518.509562A6C12C@llvm.org> Author: gclayton Date: Thu Aug 11 11:25:18 2011 New Revision: 137307 URL: http://llvm.org/viewvc/llvm-project?rev=137307&view=rev Log: Patch for "process load" by Filipe Cabecinhas. Filipe was attempting to do a: (lldb) process load ~/path/foo.dylib But the process load command wasn't resolving the path. We have to be careful about resolving the path here because we want to do it in terms of the platform we are using. the "~/" can mean a completely different path if you are remotely debugging on another machine as another user. So to support this, platforms now can resolve remote paths: bool Platform::ResolveRemotePath (const FileSpec &platform_path, FileSpec &resolved_platform_path); The host/local platform will just resolve the path. Modified: lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Target/Platform.cpp Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=137307&r1=137306&r2=137307&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Thu Aug 11 11:25:18 2011 @@ -110,6 +110,15 @@ const ArchSpec &arch, lldb::ModuleSP &module_sp); + //------------------------------------------------------------------ + /// Resolves the FileSpec to a (possibly) remote path. Remote + /// platforms must override this to resolve to a path on the remote + /// side. + //------------------------------------------------------------------ + virtual bool + ResolveRemotePath (const FileSpec &platform_path, + FileSpec &resolved_platform_path); + bool GetOSVersion (uint32_t &major, uint32_t &minor, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=137307&r1=137306&r2=137307&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Aug 11 11:25:18 2011 @@ -1172,6 +1172,7 @@ Error error; const char *image_path = command.GetArgumentAtIndex(i); FileSpec image_spec (image_path, false); + process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec); uint32_t image_token = process->LoadImage(image_spec, error); if (image_token != LLDB_INVALID_IMAGE_TOKEN) { Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=137307&r1=137306&r2=137307&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Thu Aug 11 11:25:18 2011 @@ -451,6 +451,14 @@ return error; } +bool +Platform::ResolveRemotePath (const FileSpec &platform_path, + FileSpec &resolved_platform_path) +{ + resolved_platform_path = platform_path; + return resolved_platform_path.ResolvePath(); +} + const ArchSpec & Platform::GetSystemArchitecture() From granata.enrico at gmail.com Thu Aug 11 12:08:01 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Thu, 11 Aug 2011 17:08:01 -0000 Subject: [Lldb-commits] [lldb] r137314 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectSyntheticFilter.h lldb.xcodeproj/project.pbxproj source/Core/Debugger.cpp source/Core/ValueObject.cpp source/Target/StackFrame.cpp test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Message-ID: <20110811170802.1A2A62A6C12C@llvm.org> Author: enrico Date: Thu Aug 11 12:08:01 2011 New Revision: 137314 URL: http://llvm.org/viewvc/llvm-project?rev=137314&view=rev Log: Fixed an issue where a pointer's address was being logged instead of its value Access to synthetic children by name: if your object has a synthetic child named foo you can now type frame variable object.foo (or ->foo if you have a pointer) and that will print the value of the synthetic child (if your object has an actual child named foo, the actual child prevails!) this behavior should also work in summaries, and you should be able to use ${var.foo} and ${svar.foo} interchangeably (but using svar.foo will mask an actual child named foo) Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug 11 12:08:01 2011 @@ -581,7 +581,7 @@ lldb::ValueObjectSP GetSyntheticValue (lldb::SyntheticValueType use_synthetic); - bool + virtual bool HasSyntheticValue(); virtual lldb::ValueObjectSP Modified: lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectSyntheticFilter.h Thu Aug 11 12:08:01 2011 @@ -65,6 +65,18 @@ IsInScope (); virtual bool + HasSyntheticValue() + { + return true; // we are our own synthetic value + } + + virtual void + CalculateSyntheticValue (lldb::SyntheticValueType use_synthetic) + { + m_synthetic_value = this; + } + + virtual bool IsDynamic () { if (m_parent) Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 11 12:08:01 2011 @@ -1161,6 +1161,7 @@ 69A01E1E1236C5D400C660B5 /* Mutex.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Mutex.cpp; sourceTree = ""; }; 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = ""; }; 69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = ""; }; + 94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = ""; }; 94031A9B13CF484600DCFF3C /* InputReaderEZ.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InputReaderEZ.h; path = include/lldb/Core/InputReaderEZ.h; sourceTree = ""; }; 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderEZ.cpp; path = source/Core/InputReaderEZ.cpp; sourceTree = ""; }; 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = ""; }; @@ -1734,6 +1735,7 @@ 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */, 266960621199F4230075C61A /* finish-swig-Python-lldb.sh */, 9A48A3A7124AAA5A00922451 /* python-extensions.swig */, + 94005E0313F438DF001EF42D /* python-wrapper.swig */, ); path = Python; sourceTree = ""; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 11 12:08:01 2011 @@ -795,7 +795,7 @@ *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_higher = *index_lower; if (log) - log->Printf("[%d] detected, high index is same",index_lower); + log->Printf("[%d] detected, high index is same", *index_lower); } else if (*close_bracket_position && *close_bracket_position < var_name_end) { @@ -803,7 +803,7 @@ *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); *index_higher = ::strtoul (*separator_position+1, &end, 0); if (log) - log->Printf("[%d-%d] detected",index_lower,index_higher); + log->Printf("[%d-%d] detected", *index_lower, *index_higher); } else { @@ -1044,7 +1044,7 @@ ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ? ValueObject::eDereference : ValueObject::eNothing); ValueObject::GetValueForExpressionPathOptions options; - options.DontCheckDotVsArrowSyntax().DoAllowBitfieldSyntax().DoAllowFragileIVar(); + options.DontCheckDotVsArrowSyntax().DoAllowBitfieldSyntax().DoAllowFragileIVar().DoAllowSyntheticChildren(); ValueObject::ValueObjectRepresentationStyle val_obj_display = ValueObject::eDisplaySummary; ValueObject* target = NULL; lldb::Format custom_format = eFormatInvalid; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug 11 12:08:01 2011 @@ -2032,13 +2032,28 @@ if (!next_separator) // if no other separator just expand this last layer { child_name.SetCString (expression_cstr); - root = root->GetChildMemberWithName(child_name, true); - if (root.get()) // we know we are done, so just return + ValueObjectSP child_valobj_sp = root->GetChildMemberWithName(child_name, true); + + if (child_valobj_sp.get()) // we know we are done, so just return { *first_unparsed = '\0'; *reason_to_stop = ValueObject::eEndOfString; *final_result = ValueObject::ePlain; - return root; + return child_valobj_sp; + } + else if (options.m_no_synthetic_children == false) // let's try with synthetic children + { + child_valobj_sp = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildMemberWithName(child_name, true); + } + + // if we are here and options.m_no_synthetic_children is true, child_valobj_sp is going to be a NULL SP, + // so we hit the "else" branch, and return an error + if(child_valobj_sp.get()) // if it worked, just return + { + *first_unparsed = '\0'; + *reason_to_stop = ValueObject::eEndOfString; + *final_result = ValueObject::ePlain; + return child_valobj_sp; } else { @@ -2051,9 +2066,24 @@ else // other layers do expand { child_name.SetCStringWithLength(expression_cstr, next_separator - expression_cstr); - root = root->GetChildMemberWithName(child_name, true); - if (root.get()) // store the new root and move on + ValueObjectSP child_valobj_sp = root->GetChildMemberWithName(child_name, true); + if (child_valobj_sp.get()) // store the new root and move on + { + root = child_valobj_sp; + *first_unparsed = next_separator; + *final_result = ValueObject::ePlain; + continue; + } + else if (options.m_no_synthetic_children == false) // let's try with synthetic children + { + child_valobj_sp = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildMemberWithName(child_name, true); + } + + // if we are here and options.m_no_synthetic_children is true, child_valobj_sp is going to be a NULL SP, + // so we hit the "else" branch, and return an error + if(child_valobj_sp.get()) // if it worked, move on { + root = child_valobj_sp; *first_unparsed = next_separator; *final_result = ValueObject::ePlain; continue; @@ -2236,7 +2266,7 @@ return root; } } - else if (root->HasSyntheticValue() && options.m_no_synthetic_children) + else if (root->HasSyntheticValue() && options.m_no_synthetic_children == false) { root = root->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildAtIndex(index, true); if (!root.get()) @@ -2246,6 +2276,12 @@ *final_result = ValueObject::eInvalid; return ValueObjectSP(); } + else + { + *first_unparsed = end+1; // skip ] + *final_result = ValueObject::ePlain; + continue; + } } else { Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Thu Aug 11 12:08:01 2011 @@ -641,23 +641,28 @@ child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { - // No child member with name "child_name" - valobj_sp->GetExpressionPath (var_expr_path_strm, false); - if (child_name) - { - error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", - child_name.GetCString(), - valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); - } - else + if (no_synth_child == false) + child_valobj_sp = valobj_sp->GetSyntheticValue(lldb::eUseSyntheticFilter)->GetChildMemberWithName (child_name, true); + + if (no_synth_child || !child_valobj_sp) { - error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"", - var_expr_path_strm.GetString().c_str(), - var_expr_cstr); + // No child member with name "child_name" + valobj_sp->GetExpressionPath (var_expr_path_strm, false); + if (child_name) + { + error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", + child_name.GetCString(), + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else + { + error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"", + var_expr_path_strm.GetString().c_str(), + var_expr_cstr); + } + return ValueObjectSP(); } - - return ValueObjectSP(); } // Remove the child name from the path var_path.erase(0, child_name.GetLength()); Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Thu Aug 11 12:08:01 2011 @@ -194,6 +194,10 @@ 'content = ', 'Process Name: a.out Process Id:']) + # check that access to synthetic children by name works + self.expect("frame variable str12->mutable", + substrs = ['(int) mutable = 0']) + # delete the synth and set a summary self.runCmd("type synth delete NSString") self.runCmd("type summary add -F CFString_SummaryProvider NSString") Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=137314&r1=137313&r2=137314&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Thu Aug 11 12:08:01 2011 @@ -70,10 +70,34 @@ 'fake_a = 16777216', 'a = 0']); - # check that we do not get the extra vars and that we cache results + # check that we do not get the extra vars self.expect("frame variable f00_1", matching=False, - substrs = ['looking for', - 'b = 1']); + substrs = ['b = 1']); + + # check access to members by name + self.expect('frame variable f00_1.fake_a', + substrs = ['16777216']) + + # check access to members by index + self.expect('frame variable f00_1[1]', + substrs = ['16777216']) + + # put synthetic children in summary in several combinations + self.runCmd("type summary add -f \"fake_a=${svar.fake_a}\" foo") + self.expect('frame variable f00_1', + substrs = ['fake_a=16777216']) + self.runCmd("type summary add -f \"fake_a=${var.fake_a}\" foo") + self.expect('frame variable f00_1', + substrs = ['fake_a=16777216']) + self.runCmd("type summary add -f \"fake_a=${var[1]}\" foo") + self.expect('frame variable f00_1', + substrs = ['fake_a=16777216']) + self.runCmd("type summary add -f \"fake_a=${svar[1]}\" foo") + self.expect('frame variable f00_1', + substrs = ['fake_a=16777216']) + + # clear the summary + self.runCmd("type summary delete foo") # check that the caching does not span beyond the stopoint self.runCmd("n") @@ -150,6 +174,20 @@ '[2] = 123', '[3] = 1234', '}']) + + # check access to synthetic children + self.runCmd("type summary add -f \"item 0 is ${var[0]}\" std::int_vect int_vect") + self.expect('frame variable numbers', + substrs = ['item 0 is 1']); + + self.runCmd("type summary add -f \"item 0 is ${svar[0]}\" std::int_vect int_vect") + #import time + #time.sleep(19) + self.expect('frame variable numbers', + substrs = ['item 0 is 1']); + # move on with synths + self.runCmd("type summary delete std::int_vect") + self.runCmd("type summary delete int_vect") # add some more data self.runCmd("n");self.runCmd("n");self.runCmd("n"); From johnny.chen at apple.com Thu Aug 11 13:21:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 18:21:06 -0000 Subject: [Lldb-commits] [lldb] r137319 - /lldb/trunk/tools/debugserver/source/DNBDataRef.cpp Message-ID: <20110811182106.881D62A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 13:21:06 2011 New Revision: 137319 URL: http://llvm.org/viewvc/llvm-project?rev=137319&view=rev Log: To silence the static analyzer. Modified: lldb/trunk/tools/debugserver/source/DNBDataRef.cpp Modified: lldb/trunk/tools/debugserver/source/DNBDataRef.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDataRef.cpp?rev=137319&r1=137318&r2=137319&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBDataRef.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNBDataRef.cpp Thu Aug 11 13:21:06 2011 @@ -375,7 +375,7 @@ int size = sizeof (uint32_t) * 8; const uint8_t *src = m_start + *offset_ptr; - uint8_t byte; + uint8_t byte = 0; int bytecount = 0; while (src < m_end) From johnny.chen at apple.com Thu Aug 11 14:03:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 19:03:45 -0000 Subject: [Lldb-commits] [lldb] r137326 - /lldb/trunk/tools/debugserver/source/DNB.cpp Message-ID: <20110811190345.15A082A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 14:03:44 2011 New Revision: 137326 URL: http://llvm.org/viewvc/llvm-project?rev=137326&view=rev Log: To silence the static analyzer. Modified: lldb/trunk/tools/debugserver/source/DNB.cpp Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=137326&r1=137325&r2=137326&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Thu Aug 11 14:03:44 2011 @@ -302,7 +302,7 @@ if (err_str && err_len > 0) err_str[0] = '\0'; - pid_t pid; + pid_t pid = INVALID_NUB_PROCESS; MachProcessSP processSP(new MachProcess); if (processSP.get()) { From johnny.chen at apple.com Thu Aug 11 14:12:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 19:12:11 -0000 Subject: [Lldb-commits] [lldb] r137328 - /lldb/trunk/source/Core/Scalar.cpp Message-ID: <20110811191211.0CA162A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 14:12:10 2011 New Revision: 137328 URL: http://llvm.org/viewvc/llvm-project?rev=137328&view=rev Log: Fix a logic error caught by the static analyzer. Modified: lldb/trunk/source/Core/Scalar.cpp Modified: lldb/trunk/source/Core/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=137328&r1=137327&r2=137328&view=diff ============================================================================== --- lldb/trunk/source/Core/Scalar.cpp (original) +++ lldb/trunk/source/Core/Scalar.cpp Thu Aug 11 14:12:10 2011 @@ -1811,7 +1811,7 @@ Scalar::SetValueFromCString (const char *value_str, Encoding encoding, uint32_t byte_size) { Error error; - if (value_str == NULL && value_str[0] == '\0') + if (value_str == NULL || value_str[0] == '\0') { error.SetErrorString ("Invalid c-string value string."); return error; From johnny.chen at apple.com Thu Aug 11 14:17:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 19:17:45 -0000 Subject: [Lldb-commits] [lldb] r137329 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110811191746.048ED2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 14:17:45 2011 New Revision: 137329 URL: http://llvm.org/viewvc/llvm-project?rev=137329&view=rev Log: To silence the static analyzer. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=137329&r1=137328&r2=137329&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Aug 11 14:17:45 2011 @@ -700,7 +700,7 @@ PyObject *globals = PyModule_GetDict (mainmod); PyObject *locals = NULL; PyObject *py_error = NULL; - bool ret_success; + bool ret_success = false; bool should_decrement_locals = false; int success; From granata.enrico at gmail.com Thu Aug 11 14:20:44 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Thu, 11 Aug 2011 19:20:44 -0000 Subject: [Lldb-commits] [lldb] r137330 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj scripts/Python/python-wrapper.swig Message-ID: <20110811192044.BC5BE2A6C12C@llvm.org> Author: enrico Date: Thu Aug 11 14:20:44 2011 New Revision: 137330 URL: http://llvm.org/viewvc/llvm-project?rev=137330&view=rev Log: Fixed an issue where LLDB was complaining about the lack of 'update' in a synthetic provider, despite it being optional Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/Python/python-wrapper.swig Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137330&r1=137329&r2=137330&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 11 14:20:44 2011 @@ -1162,6 +1162,7 @@ 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = ""; }; 69A01E201236C5D400C660B5 /* TimeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeValue.cpp; sourceTree = ""; }; 94005E0313F438DF001EF42D /* python-wrapper.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-wrapper.swig"; sourceTree = ""; }; + 94005E0513F45A1B001EF42D /* embedded_interpreter.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; name = embedded_interpreter.py; path = source/Interpreter/embedded_interpreter.py; sourceTree = ""; }; 94031A9B13CF484600DCFF3C /* InputReaderEZ.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InputReaderEZ.h; path = include/lldb/Core/InputReaderEZ.h; sourceTree = ""; }; 94031A9D13CF486600DCFF3C /* InputReaderEZ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderEZ.cpp; path = source/Core/InputReaderEZ.cpp; sourceTree = ""; }; 94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PriorityPointerPair.h; path = include/lldb/Utility/PriorityPointerPair.h; sourceTree = ""; }; @@ -2231,6 +2232,7 @@ 26DFBC59113B48F300DD817F /* CommandObjectRegexCommand.cpp */, 26BC7DE410F1B7F900F91463 /* CommandReturnObject.h */, 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */, + 94005E0513F45A1B001EF42D /* embedded_interpreter.py */, 26A7A036135E6E5300FB369E /* NamedOptionValue.h */, 26A7A034135E6E4200FB369E /* NamedOptionValue.cpp */, 26BC7D6D10F1B77400F91463 /* Options.h */, Modified: lldb/trunk/scripts/Python/python-wrapper.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=137330&r1=137329&r2=137330&view=diff ============================================================================== --- lldb/trunk/scripts/Python/python-wrapper.swig (original) +++ lldb/trunk/scripts/Python/python-wrapper.swig Thu Aug 11 14:20:44 2011 @@ -523,6 +523,11 @@ // other synth provider calls are mandatory, so we want to fail in a very obvious way if they are missing! PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name); + if (PyErr_Occurred()) + { + PyErr_Clear(); + } + if (pmeth == NULL || pmeth == Py_None) { Py_XDECREF(pmeth); @@ -531,10 +536,20 @@ if (PyCallable_Check(pmeth) == 0) { + if (PyErr_Occurred()) + { + PyErr_Clear(); + } + Py_XDECREF(pmeth); return; } + if (PyErr_Occurred()) + { + PyErr_Clear(); + } + Py_XDECREF(pmeth); // right now we know this function exists and is callable.. From johnny.chen at apple.com Thu Aug 11 14:40:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 19:40:36 -0000 Subject: [Lldb-commits] [lldb] r137334 - /lldb/trunk/source/Core/ArchSpec.cpp Message-ID: <20110811194036.BB39B2A6C12D@llvm.org> Author: johnny Date: Thu Aug 11 14:40:36 2011 New Revision: 137334 URL: http://llvm.org/viewvc/llvm-project?rev=137334&view=rev Log: Fix a logic error caught by the static analyzer. Modified: lldb/trunk/source/Core/ArchSpec.cpp Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=137334&r1=137333&r2=137334&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Thu Aug 11 14:40:36 2011 @@ -457,7 +457,7 @@ bool ArchSpec::SetTriple (const char *triple_cstr, Platform *platform) { - if (triple_cstr || triple_cstr[0]) + if (triple_cstr && !triple_cstr[0]) { llvm::StringRef triple_stref (triple_cstr); if (triple_stref.startswith (LLDB_ARCH_DEFAULT)) From scallanan at apple.com Thu Aug 11 15:11:19 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 11 Aug 2011 20:11:19 -0000 Subject: [Lldb-commits] [lldb] r137338 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj llvm.zip scripts/build-llvm.pl scripts/checkpoint-llvm.pl test/lang/c/function_types/TestFunctionTypes.py Message-ID: <20110811201119.357842A6C12C@llvm.org> Author: spyffe Date: Thu Aug 11 15:11:18 2011 New Revision: 137338 URL: http://llvm.org/viewvc/llvm-project?rev=137338&view=rev Log: Updated LLVM/Clang to to pick up fixes for a problem in which the following cast: ? expr (int (*)(const char*, ...))printf - caused a crash. This had several causes: - First, Clang did not support implicit casts of a function of unknown type to a function pointer. - Second, after this was fixed, the Clang AST importer did not support importing function pointer types produced by resolving these casts. These two problems are now resolved, and I have added a test case to verify that they work. I also did a little bit of build-system cleanup because we now use libEnhancedDisassembly.a instead of the .dylib. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/scripts/checkpoint-llvm.pl lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=137338&r1=137337&r2=137338&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 11 15:11:18 2011 @@ -2842,7 +2842,6 @@ ); name = "Build llvm and clang"; outputPaths = ( - "$(CONFIGURATION_BUILD_DIR)/libEnhancedDisassembly.dylib", "$(LLVM_BUILD_DIR)/libllvmclang.a", ); runOnlyForDeploymentPostprocessing = 0; Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=137338&r1=137337&r2=137338&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=137338&r1=137337&r2=137338&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Thu Aug 11 15:11:18 2011 @@ -16,13 +16,13 @@ our $llvm_srcroot = $ENV{SCRIPT_INPUT_FILE_0}; our $llvm_dstroot = $ENV{SCRIPT_INPUT_FILE_1}; -our $llvm_clang_outfile = $ENV{SCRIPT_OUTPUT_FILE_1}; +our $llvm_clang_outfile = $ENV{SCRIPT_OUTPUT_FILE_0}; our ($llvm_clang_basename, $llvm_clang_dirname) = fileparse ($llvm_clang_outfile); our @llvm_clang_slices; # paths to the single architecture static libraries (archives) our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "136552"; +our $llvm_revision = "137311"; our $llvm_source_dir = "$ENV{SRCROOT}"; our @archs = split (/\s+/, $ENV{ARCHS}); Modified: lldb/trunk/scripts/checkpoint-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/checkpoint-llvm.pl?rev=137338&r1=137337&r2=137338&view=diff ============================================================================== --- lldb/trunk/scripts/checkpoint-llvm.pl (original) +++ lldb/trunk/scripts/checkpoint-llvm.pl Thu Aug 11 15:11:18 2011 @@ -90,7 +90,6 @@ } do_command ("cp '$llvm_build_dir/libllvmclang.a' '$llvm_checkpoint_dir'", "Copying libllvmclang.a", 1); - do_command ("cp '$lldb_build_dir/libEnhancedDisassembly.dylib' '$llvm_checkpoint_dir'", "Copying libEnhancedDisassembly.dylib", 1); do_command ("rm -rf '$llvm_zip_file'", "Removing old llvm checkpoint file '$llvm_zip_file'", 1); do_command ("(cd '$temp_dir' ; zip -r '$llvm_zip_file' 'llvm')", "Zipping llvm checkpoint directory '$llvm_checkpoint_dir' to '$llvm_zip_file'", 1); } Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py?rev=137338&r1=137337&r2=137338&view=diff ============================================================================== --- lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Thu Aug 11 15:11:18 2011 @@ -19,6 +19,17 @@ """Test 'callback' has function ptr type, then break on the function.""" self.buildDwarf() self.function_types() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_pointers_with_dsym(self): + """Test that a function pointer to 'printf' works and can be called.""" + self.buildDsym() + self.function_pointers() + + def test_pointers_with_dwarf(self): + """Test that a function pointer to 'printf' works and can be called.""" + self.buildDwarf() + self.function_pointers() def setUp(self): # Call super's setUp(). @@ -26,27 +37,31 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') - def function_types(self): - """Test 'callback' has function ptr type, then break on the function.""" + def runToBreakpoint(self): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - + # Break inside the main. self.expect("breakpoint set -f main.c -l %d" % self.line, BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" % - self.line) - + startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" % + self.line) + self.runCmd("run", RUN_SUCCEEDED) - + # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, - substrs = ['stopped', - 'stop reason = breakpoint']) - + substrs = ['stopped', + 'stop reason = breakpoint']) + # The breakpoint should have a hit count of 1. self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, - substrs = [' resolved, hit count = 1']) + substrs = [' resolved, hit count = 1']) + + def function_types(self): + """Test 'callback' has function ptr type, then break on the function.""" + + self.runToBreakpoint() # Check that the 'callback' variable display properly. self.expect("frame variable -T callback", VARIABLES_DISPLAYED_CORRECTLY, @@ -61,6 +76,19 @@ substrs = ['a.out`string_not_empty', 'stop reason = breakpoint']) + def function_pointers(self): + """Test that a function pointer to 'printf' works and can be called.""" + + self.runToBreakpoint() + + self.expect("expr string_not_empty", + substrs = ['(int (*)(const char *)) $0 = ', '(a.out`']) + + self.expect("expr (int (*)(const char*, ...))printf", + substrs = ['(int (*)(const char *, ...)) $1 = ', '(libSystem.']) + + self.expect("expr $1(\"Hello world\\n\")", + startstr = '(int) $2 = 12') if __name__ == '__main__': import atexit From johnso87 at crhc.illinois.edu Thu Aug 11 15:22:24 2011 From: johnso87 at crhc.illinois.edu (Matt Johnson) Date: Thu, 11 Aug 2011 15:22:24 -0500 Subject: [Lldb-commits] [PATCH] Include cstring in TimeValue.cpp, fix Linux/libstdc++ build Message-ID: <4E443A00.7020607@crhc.illinois.edu> Hi all, strpbrk() is used in TimeValue.cpp, but the header file it lives in, cstring/string.h, is not #included explicitly. The other headers included in the file must transitively #include cstring on the developers' machines, but the build breaks on Linux with recent versions of libstdc++ and glibc. The attached patch fixes the build on my machine. As a side note, the C++ convention for including libc headers is to use the version with 'c' prepended and no '.h', unless that version happens to be broken in your C++ library. The main difference is that the 'c' versions put all functions in the std namespace, rather than the global namespace. This convention is followed in other LLVM projects as far as I can tell, but LLDB mixes both conventions (for example, grep for 'cassert' and 'assert.h'). I didn't prepare a patch for this because I wasn't sure if this was intentional or if the 'c' header versions caused problems on the developers' machines, but if not, standardizing on the 'c' versions will reduce global namespace pollution. Best, Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: cstring.diff Type: text/x-diff Size: 389 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110811/26b11fe4/attachment.bin From johnny.chen at apple.com Thu Aug 11 15:40:21 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 20:40:21 -0000 Subject: [Lldb-commits] [lldb] r137343 - /lldb/trunk/source/Host/common/TimeValue.cpp Message-ID: <20110811204021.B9D6D2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 15:40:21 2011 New Revision: 137343 URL: http://llvm.org/viewvc/llvm-project?rev=137343&view=rev Log: Patch by Matt Johnson to build on his Linux machine with recent versions of libstdc++ and glibc! Modified: lldb/trunk/source/Host/common/TimeValue.cpp Modified: lldb/trunk/source/Host/common/TimeValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=137343&r1=137342&r2=137343&view=diff ============================================================================== --- lldb/trunk/source/Host/common/TimeValue.cpp (original) +++ lldb/trunk/source/Host/common/TimeValue.cpp Thu Aug 11 15:40:21 2011 @@ -12,6 +12,7 @@ // C Includes #include #include +#include // C++ Includes // Other libraries and framework includes // Project includes From johnny.chen at apple.com Thu Aug 11 15:43:02 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 13:43:02 -0700 Subject: [Lldb-commits] [PATCH] Include cstring in TimeValue.cpp, fix Linux/libstdc++ build In-Reply-To: <4E443A00.7020607@crhc.illinois.edu> References: <4E443A00.7020607@crhc.illinois.edu> Message-ID: <521D0137-7E4D-43DA-B5BB-D79FC4BAEBAA@apple.com> Thanks, Matt. URL: http://llvm.org/viewvc/llvm-project?rev=137343&view=rev Log: Patch by Matt Johnson to build on his Linux machine with recent versions of libstdc++ and glibc! On Aug 11, 2011, at 1:22 PM, Matt Johnson wrote: > Hi all, > strpbrk() is used in TimeValue.cpp, but the header file it lives in, cstring/string.h, is not #included explicitly. The other headers included in the file must transitively #include cstring on the developers' machines, but the build breaks on Linux with recent versions of libstdc++ and glibc. The attached patch fixes the build on my machine. > > As a side note, the C++ convention for including libc headers is to use the version with 'c' prepended and no '.h', unless that version happens to be broken in your C++ library. The main difference is that the 'c' versions put all functions in the std namespace, rather than the global namespace. This convention is followed in other LLVM projects as far as I can tell, but LLDB mixes both conventions (for example, grep for 'cassert' and 'assert.h'). I didn't prepare a patch for this because I wasn't sure if this was intentional or if the 'c' header versions caused problems on the developers' machines, but if not, standardizing on the 'c' versions will reduce global namespace pollution. > > Best, > Matt > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110811/ee05f689/attachment-0001.html From johnny.chen at apple.com Thu Aug 11 15:51:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 20:51:45 -0000 Subject: [Lldb-commits] [lldb] r137348 - /lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Message-ID: <20110811205145.86C1C2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 15:51:45 2011 New Revision: 137348 URL: http://llvm.org/viewvc/llvm-project?rev=137348&view=rev Log: Fix the expect patterns to work for both OSX SnowLeopard and Lion. On Lion, printf is defined in libsystem_c.dylib. Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Modified: lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py?rev=137348&r1=137347&r2=137348&view=diff ============================================================================== --- lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py (original) +++ lldb/trunk/test/lang/c/function_types/TestFunctionTypes.py Thu Aug 11 15:51:45 2011 @@ -84,8 +84,13 @@ self.expect("expr string_not_empty", substrs = ['(int (*)(const char *)) $0 = ', '(a.out`']) + if sys.platform.startswith("darwin"): + regexps = ['lib.*\.dylib`printf'] + else: + regexps = ['printf'] self.expect("expr (int (*)(const char*, ...))printf", - substrs = ['(int (*)(const char *, ...)) $1 = ', '(libSystem.']) + substrs = ['(int (*)(const char *, ...)) $1 = '], + patterns = regexps) self.expect("expr $1(\"Hello world\\n\")", startstr = '(int) $2 = 12') From johnny.chen at apple.com Thu Aug 11 16:24:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 21:24:08 -0000 Subject: [Lldb-commits] [lldb] r137355 - /lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Message-ID: <20110811212408.639DD2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 16:24:08 2011 New Revision: 137355 URL: http://llvm.org/viewvc/llvm-project?rev=137355&view=rev Log: To silence the static analyzer. Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=137355&r1=137354&r2=137355&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Thu Aug 11 16:24:08 2011 @@ -91,7 +91,6 @@ bool BreakpointIDList::FindBreakpointID (BreakpointID &bp_id, uint32_t *position) { - bool success = false; BreakpointIDArray::iterator tmp_pos; for (size_t i = 0; i < m_breakpoint_ids.size(); ++i) @@ -100,7 +99,6 @@ if (tmp_id.GetBreakpointID() == bp_id.GetBreakpointID() && tmp_id.GetLocationID() == bp_id.GetLocationID()) { - success = true; *position = i; return true; } From granata.enrico at gmail.com Thu Aug 11 16:37:21 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Thu, 11 Aug 2011 21:37:21 -0000 Subject: [Lldb-commits] [lldb] r137357 - in /lldb/trunk/source/Commands: CommandObjectType.cpp CommandObjectType.h Message-ID: <20110811213721.CF0B82A6C12C@llvm.org> Author: enrico Date: Thu Aug 11 16:37:21 2011 New Revision: 137357 URL: http://llvm.org/viewvc/llvm-project?rev=137357&view=rev Log: changed some variables from char* to std::string Modified: lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectType.h Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137357&r1=137356&r2=137357&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 11 16:37:21 2011 @@ -637,7 +637,7 @@ m_is_add_script = true; break; case 'w': - m_category = ConstString(option_arg).GetCString(); + m_category = std::string(option_arg); break; default: error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); @@ -662,7 +662,7 @@ m_python_function = ""; m_format_string = ""; m_is_add_script = false; - m_category = NULL; + m_category = "default"; } void @@ -1036,11 +1036,11 @@ CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name, SummaryFormatSP entry, SummaryFormatType type, - const char* category_name, + std::string category_name, Error* error) { lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(category_name), category); + Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); if (type == eRegexSummary) { @@ -2518,7 +2518,7 @@ lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(options->m_category), category); + Debugger::Formatting::Categories::Get(ConstString(options->m_category.c_str()), category); for (size_t i = 0; i < options->m_target_types.GetSize(); i++) { const char *type_name = options->m_target_types.GetStringAtIndex(i); @@ -2632,7 +2632,7 @@ // now I have a valid provider, let's add it to every type lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category); + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); for (size_t i = 0; i < argc; i++) { const char* typeA = command.GetArgumentAtIndex(i); @@ -2686,7 +2686,7 @@ // now I have a valid provider, let's add it to every type lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category); + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); for (size_t i = 0; i < argc; i++) { const char* typeA = command.GetArgumentAtIndex(i); @@ -2731,11 +2731,11 @@ CommandObjectTypeSynthAdd::AddSynth(const ConstString& type_name, SyntheticChildrenSP entry, SynthFormatType type, - const char* category_name, + std::string category_name, Error* error) { lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(category_name), category); + Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); if (type == eRegexSynth) { Modified: lldb/trunk/source/Commands/CommandObjectType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=137357&r1=137356&r2=137357&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.h (original) +++ lldb/trunk/source/Commands/CommandObjectType.h Thu Aug 11 16:37:21 2011 @@ -41,7 +41,7 @@ ConstString* m_name; - const char* m_category; + std::string m_category; ScriptAddOptions(bool sptr, bool sref, @@ -51,7 +51,7 @@ bool onel, bool regx, ConstString* name, - const char* catg) : + std::string catg) : m_skip_pointers(sptr), m_skip_references(sref), m_cascade(casc), @@ -82,13 +82,13 @@ StringList m_user_source; StringList m_target_types; - const char* m_category; + std::string m_category; SynthAddOptions(bool sptr, bool sref, bool casc, bool regx, - const char* catg) : + std::string catg) : m_skip_pointers(sptr), m_skip_references(sref), m_cascade(casc), @@ -160,7 +160,7 @@ std::string m_python_script; std::string m_python_function; bool m_is_add_script; - const char* m_category; + std::string m_category; }; CommandOptions m_options; @@ -203,7 +203,7 @@ AddSummary(const ConstString& type_name, lldb::SummaryFormatSP entry, SummaryFormatType type, - const char* category, + std::string category, Error* error = NULL); }; @@ -257,7 +257,7 @@ m_skip_references = true; break; case 'w': - m_category = ConstString(option_arg).GetCString(); + m_category = std::string(option_arg); break; case 'x': m_regex = true; @@ -277,7 +277,7 @@ m_class_name = ""; m_skip_pointers = false; m_skip_references = false; - m_category = NULL; + m_category = "default"; m_expr_paths.clear(); is_class_based = false; handwrite_python = false; @@ -303,7 +303,7 @@ std::string m_class_name; bool m_input_python; option_vector m_expr_paths; - const char* m_category; + std::string m_category; bool is_class_based; @@ -354,7 +354,7 @@ AddSynth(const ConstString& type_name, lldb::SyntheticChildrenSP entry, SynthFormatType type, - const char* category_name, + std::string category_name, Error* error); }; From johnny.chen at apple.com Thu Aug 11 16:43:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 21:43:13 -0000 Subject: [Lldb-commits] [lldb] r137360 - /lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Message-ID: <20110811214313.BF4F02A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 16:43:13 2011 New Revision: 137360 URL: http://llvm.org/viewvc/llvm-project?rev=137360&view=rev Log: Silence the static analyzer. Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=137360&r1=137359&r2=137360&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Thu Aug 11 16:43:13 2011 @@ -95,20 +95,11 @@ for (pos = m_locations.begin(); pos != end; ++pos) { - bool seen = false; BreakpointLocationSP break_loc = (*pos); const Section *section = break_loc->GetAddress().GetSection(); - if (section) + if (section && section->GetModule() == module) { - if (section->GetModule() == module) - { - if (!seen) - { - seen = true; - bp_loc_list.Add (break_loc); - } - - } + bp_loc_list.Add (break_loc); } } return bp_loc_list.GetSize() - orig_size; From johnny.chen at apple.com Thu Aug 11 17:23:44 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 22:23:44 -0000 Subject: [Lldb-commits] [lldb] r137374 - /lldb/trunk/source/Core/ValueObjectRegister.cpp Message-ID: <20110811222344.C6F6C2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 17:23:44 2011 New Revision: 137374 URL: http://llvm.org/viewvc/llvm-project?rev=137374&view=rev Log: Fix 'Undefined or garbage value returned to caller' (static analyzer). Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=137374&r1=137373&r2=137374&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Thu Aug 11 17:23:44 2011 @@ -210,7 +210,7 @@ ValueObject * ValueObjectRegisterSet::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index) { - ValueObject *valobj; + ValueObject *valobj = NULL; if (m_reg_ctx_sp && m_reg_set) { const uint32_t num_children = GetNumChildren(); From johnny.chen at apple.com Thu Aug 11 18:47:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Aug 2011 23:47:22 -0000 Subject: [Lldb-commits] [lldb] r137387 - /lldb/trunk/source/Symbol/ClangASTType.cpp Message-ID: <20110811234722.1DB4A2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 18:47:21 2011 New Revision: 137387 URL: http://llvm.org/viewvc/llvm-project?rev=137387&view=rev Log: Silence the static analyzer. Modified: lldb/trunk/source/Symbol/ClangASTType.cpp Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=137387&r1=137386&r2=137387&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Thu Aug 11 18:47:21 2011 @@ -945,17 +945,17 @@ case eFormatCharArray: case eFormatBytes: case eFormatBytesWithASCII: - item_count = (byte_size * item_count); + item_count = byte_size; byte_size = 1; break; case eFormatUnicode16: - item_count = (byte_size * item_count) / 2; + item_count = byte_size / 2; byte_size = 2; break; case eFormatUnicode32: - item_count = (byte_size * item_count) / 4; + item_count = byte_size / 4; byte_size = 4; break; } From scallanan at apple.com Thu Aug 11 18:56:13 2011 From: scallanan at apple.com (Sean Callanan) Date: Thu, 11 Aug 2011 23:56:13 -0000 Subject: [Lldb-commits] [lldb] r137392 - in /lldb/trunk/source: Expression/ClangExpressionDeclMap.cpp Symbol/ClangASTContext.cpp Message-ID: <20110811235613.EDFAD2A6C12C@llvm.org> Author: spyffe Date: Thu Aug 11 18:56:13 2011 New Revision: 137392 URL: http://llvm.org/viewvc/llvm-project?rev=137392&view=rev Log: Fixed LLDB's handling of ElaboratedTypes, which was causing problems with printing the values of persistent variables with struct types. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=137392&r1=137391&r2=137392&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Aug 11 18:56:13 2011 @@ -2012,13 +2012,8 @@ { ExternalASTSource *external_source = original_ctx->getExternalSource(); - if (!external_source) - return ELR_Failure; - - if (!original_tag_decl) - return ELR_Failure; - - external_source->CompleteType (original_tag_decl); + if (external_source) + external_source->CompleteType (original_tag_decl); } DeclContext *original_decl_context = dyn_cast(original_decl); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=137392&r1=137391&r2=137392&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Aug 11 18:56:13 2011 @@ -143,6 +143,9 @@ case clang::Type::Typedef: return GetCompleteQualType (ast, cast(qual_type)->getDecl()->getUnderlyingType()); + + case clang::Type::Elaborated: + return GetCompleteQualType (ast, cast(qual_type)->getNamedType()); default: break; @@ -1143,6 +1146,9 @@ case clang::Type::Typedef: return ClangASTContext::SetHasExternalStorage (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), has_extern); + + case clang::Type::Elaborated: + return ClangASTContext::SetHasExternalStorage (cast(qual_type)->getNamedType().getAsOpaquePtr(), has_extern); default: break; @@ -2131,7 +2137,10 @@ *pointee_or_element_clang_type = cast(qual_type)->getDecl()->getIntegerType().getAsOpaquePtr(); return eTypeIsEnumeration | eTypeHasValue; - case clang::Type::Elaborated: return 0; + case clang::Type::Elaborated: + return ClangASTContext::GetTypeInfo (cast(qual_type)->getNamedType().getAsOpaquePtr(), + ast, + pointee_or_element_clang_type); case clang::Type::ExtVector: return eTypeHasChildren | eTypeIsVector; case clang::Type::FunctionProto: return eTypeIsFuncPrototype | eTypeHasValue; case clang::Type::FunctionNoProto: return eTypeIsFuncPrototype | eTypeHasValue; @@ -2205,7 +2214,8 @@ case clang::Type::ObjCObject: case clang::Type::ObjCInterface: return true; - + case clang::Type::Elaborated: + return ClangASTContext::IsAggregateType (cast(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::Typedef: return ClangASTContext::IsAggregateType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); @@ -2374,6 +2384,12 @@ cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), omit_empty_base_classes); break; + + case clang::Type::Elaborated: + num_children = ClangASTContext::GetNumChildren (ast, + cast(qual_type)->getNamedType().getAsOpaquePtr(), + omit_empty_base_classes); + break; default: break; @@ -2453,12 +2469,12 @@ case clang::Type::UnresolvedUsing: return 0; case clang::Type::Paren: return 0; case clang::Type::Typedef: return ClangASTContext::GetNumPointeeChildren (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + case clang::Type::Elaborated: return ClangASTContext::GetNumPointeeChildren (cast(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::TypeOfExpr: return 0; case clang::Type::TypeOf: return 0; case clang::Type::Decltype: return 0; case clang::Type::Record: return 0; case clang::Type::Enum: return 1; - case clang::Type::Elaborated: return 1; case clang::Type::TemplateTypeParm: return 1; case clang::Type::SubstTemplateTypeParm: return 1; case clang::Type::TemplateSpecialization: return 1; @@ -2933,6 +2949,23 @@ child_is_base_class, child_is_deref_of_parent); break; + + case clang::Type::Elaborated: + return GetChildClangTypeAtIndex (exe_ctx, + ast, + parent_name, + cast(parent_qual_type)->getNamedType().getAsOpaquePtr(), + idx, + transparent_pointers, + omit_empty_base_classes, + ignore_array_bounds, + child_name, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class, + child_is_deref_of_parent); default: break; @@ -3665,7 +3698,7 @@ case clang::Type::Record: return cast(qual_type)->getDecl(); case clang::Type::Enum: return cast(qual_type)->getDecl(); case clang::Type::Typedef: return ClangASTContext::GetDeclContextForType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); - + case clang::Type::Elaborated: return ClangASTContext::GetDeclContextForType (cast(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::TypeOfExpr: break; case clang::Type::TypeOf: break; case clang::Type::Decltype: break; @@ -3678,7 +3711,6 @@ case clang::Type::PackExpansion: break; case clang::Type::UnresolvedUsing: break; case clang::Type::Paren: break; - case clang::Type::Elaborated: break; case clang::Type::Attributed: break; case clang::Type::Auto: break; case clang::Type::InjectedClassName: break; @@ -4119,7 +4151,10 @@ case clang::Type::Typedef: return ClangASTContext::IsPossibleDynamicType (ast, cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type); - + + case clang::Type::Elaborated: + return ClangASTContext::IsPossibleDynamicType (ast, cast(qual_type)->getNamedType().getAsOpaquePtr(), dynamic_pointee_type); + default: break; } @@ -4250,6 +4285,9 @@ case clang::Type::Typedef: return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), dynamic_pointee_type); + case clang::Type::Elaborated: + return ClangASTContext::IsPossibleCPlusPlusDynamicType (ast, cast(qual_type)->getNamedType().getAsOpaquePtr()); + default: break; } @@ -4386,6 +4424,8 @@ return true; case clang::Type::Typedef: return ClangASTContext::IsPointerOrReferenceType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + case clang::Type::Elaborated: + return ClangASTContext::IsPointerOrReferenceType (cast(qual_type)->getNamedType().getAsOpaquePtr()); default: break; } @@ -4452,6 +4492,8 @@ return true; case clang::Type::Typedef: return ClangASTContext::IsPointerType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), target_type); + case clang::Type::Elaborated: + return ClangASTContext::IsPointerType (cast(qual_type)->getNamedType().getAsOpaquePtr(), target_type); default: break; } @@ -4636,6 +4678,8 @@ break; case clang::Type::Typedef: return ClangASTContext::IsFunctionPointerType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + case clang::Type::Elaborated: + return ClangASTContext::IsFunctionPointerType (cast(qual_type)->getNamedType().getAsOpaquePtr()); case clang::Type::LValueReference: case clang::Type::RValueReference: @@ -4669,7 +4713,9 @@ case clang::Type::Typedef: return ClangASTContext::GetArraySize(cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); - break; + + case clang::Type::Elaborated: + return ClangASTContext::GetArraySize(cast(qual_type)->getNamedType().getAsOpaquePtr()); default: break; @@ -4724,6 +4770,11 @@ return ClangASTContext::IsArrayType (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(), member_type, size); + + case clang::Type::Elaborated: + return ClangASTContext::IsArrayType (cast(qual_type)->getNamedType().getAsOpaquePtr(), + member_type, + size); } return false; } From johnny.chen at apple.com Thu Aug 11 19:02:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 00:02:24 -0000 Subject: [Lldb-commits] [lldb] r137394 - /lldb/trunk/source/Symbol/UnwindPlan.cpp Message-ID: <20110812000224.B3DA02A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 19:02:24 2011 New Revision: 137394 URL: http://llvm.org/viewvc/llvm-project?rev=137394&view=rev Log: Fix two 'dereference of a null pointer' detected by the static analyzer. Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=137394&r1=137393&r2=137394&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (original) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Thu Aug 11 19:02:24 2011 @@ -106,14 +106,14 @@ if (cfa_reg_info) s.Printf (" (%s%+d)", cfa_reg_info->name, offset); else - s.Printf (" (reg(%u)%+d)", cfa_reg_info->name, offset); + s.Printf (" (reg(%u)%+d)", cfa_reg, offset); } else { if (cfa_reg_info) s.Printf ("%s", cfa_reg_info->name); else - s.Printf ("reg(%u)", cfa_reg_info->name); + s.Printf ("reg(%u)", cfa_reg); if (offset != 0) s.Printf ("%+d", offset); } From johnny.chen at apple.com Thu Aug 11 19:21:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 00:21:20 -0000 Subject: [Lldb-commits] [lldb] r137396 - /lldb/trunk/source/Host/macosx/Host.mm Message-ID: <20110812002120.D44332A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 19:21:20 2011 New Revision: 137396 URL: http://llvm.org/viewvc/llvm-project?rev=137396&view=rev Log: Silence the static analyzer. Modified: lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=137396&r1=137395&r2=137396&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu Aug 11 19:21:20 2011 @@ -951,7 +951,7 @@ mib[mib_len] = process_info.GetProcessID(); mib_len++; - cpu_type_t cpu, sub; + cpu_type_t cpu, sub = 0; size_t cpu_len = sizeof(cpu); if (::sysctl (mib, mib_len, &cpu, &cpu_len, 0, 0) == 0) { From johnny.chen at apple.com Thu Aug 11 20:10:45 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 01:10:45 -0000 Subject: [Lldb-commits] [lldb] r137405 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110812011046.28B512A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 20:10:45 2011 New Revision: 137405 URL: http://llvm.org/viewvc/llvm-project?rev=137405&view=rev Log: Fix some warnings from static analyzer. The initialization of 'replicated_element' to 0 is needed, otherwise we get a garbage value to start with. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=137405&r1=137404&r2=137405&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Aug 11 20:10:45 2011 @@ -794,7 +794,9 @@ { uint32_t Rd; // the destination register uint32_t imm32; // the immediate value to be written to Rd - uint32_t carry; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. + uint32_t carry = 0; // the carry bit after ThumbExpandImm_C or ARMExpandImm_C. + // for setflags == false, this value is a don't care + // initialized to 0 to silence the static analyzer bool setflags; switch (encoding) { case eEncodingT1: @@ -12004,7 +12006,7 @@ if (!success) return false; - uint64_t replicated_element; + uint64_t replicated_element = 0; uint32_t esize = ebytes * 8; for (int e = 0; e < elements; ++e) replicated_element = (replicated_element << esize) | Bits64 (word, esize - 1, 0); @@ -13048,9 +13050,7 @@ { bool privileged = CurrentModeIsPrivileged(); - uint32_t tmp_cpsr = 0; - - tmp_cpsr = tmp_cpsr | (Bits32 (m_opcode_cpsr, 23, 20) << 20); + uint32_t tmp_cpsr = Bits32 (m_opcode_cpsr, 23, 20) << 20; if (BitIsSet (bytemask, 3)) { From johnny.chen at apple.com Thu Aug 11 20:22:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 01:22:56 -0000 Subject: [Lldb-commits] [lldb] r137407 - /lldb/trunk/source/Core/RegisterValue.cpp Message-ID: <20110812012256.60DBA2A6C12C@llvm.org> Author: johnny Date: Thu Aug 11 20:22:56 2011 New Revision: 137407 URL: http://llvm.org/viewvc/llvm-project?rev=137407&view=rev Log: Fix a logic error caught by the static analyzer. Modified: lldb/trunk/source/Core/RegisterValue.cpp Modified: lldb/trunk/source/Core/RegisterValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=137407&r1=137406&r2=137407&view=diff ============================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp (original) +++ lldb/trunk/source/Core/RegisterValue.cpp Thu Aug 11 20:22:56 2011 @@ -373,7 +373,7 @@ return error; } - if (value_str == NULL && value_str[0] == '\0') + if (value_str == NULL || value_str[0] == '\0') { error.SetErrorString ("Invalid c-string value string."); return error; From granata.enrico at gmail.com Thu Aug 11 21:00:07 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 12 Aug 2011 02:00:07 -0000 Subject: [Lldb-commits] [lldb] r137416 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Interpreter/ source/Target/ test/functionalities/data-formatter/data-formatter-advanced/ test/functionalities/data-formatter/data-formatter-categories/ test/functionalities/data-formatter/data-formatter-python-synth/ test/functionalities/data-formatter/data-formatter-synth/ Message-ID: <20110812020007.9CADF2A6C12C@llvm.org> Author: enrico Date: Thu Aug 11 21:00:06 2011 New Revision: 137416 URL: http://llvm.org/viewvc/llvm-project?rev=137416&view=rev Log: *Some more optimizations in usage of ConstString *New setting target.max-children-count gives an upper-bound to the number of child objects that will be displayed at each depth-level This might be a breaking change in some scenarios. To override the new limit you can use the --show-all-children (-A) option to frame variable or increase the limit in your lldbinit file *Command "type synthetic" has been split in two: - "type synthetic" now only handles Python synthetic children providers - the new command "type filter" handles filters Because filters and synthetic providers are both ways to replace the children of a ValueObject, only one can be effective at any given time. Modified: lldb/trunk/include/lldb/Core/FormatClasses.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Commands/CommandObjectType.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/FormatManager.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/main.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Modified: lldb/trunk/include/lldb/Core/FormatClasses.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatClasses.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatClasses.h (original) +++ lldb/trunk/include/lldb/Core/FormatClasses.h Thu Aug 11 21:00:06 2011 @@ -40,6 +40,7 @@ struct ValueFormat { + uint32_t m_my_revision; bool m_cascades; bool m_skip_pointers; bool m_skip_references; @@ -123,6 +124,7 @@ class SyntheticChildren { public: + uint32_t m_my_revision; bool m_cascades; bool m_skip_pointers; bool m_skip_references; @@ -157,6 +159,9 @@ return m_skip_references; } + virtual bool + IsScripted() = 0; + virtual std::string GetDescription() = 0; @@ -207,6 +212,12 @@ return m_expression_paths[i]; } + bool + IsScripted() + { + return false; + } + std::string GetDescription(); @@ -289,6 +300,12 @@ std::string GetDescription(); + bool + IsScripted() + { + return true; + } + class FrontEnd : public SyntheticChildrenFrontEnd { private: @@ -367,6 +384,7 @@ struct SummaryFormat { + uint32_t m_my_revision; bool m_cascades; bool m_skip_pointers; bool m_skip_references; Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Thu Aug 11 21:00:06 2011 @@ -74,6 +74,9 @@ virtual ~IFormatChangeListener() {} + virtual uint32_t + GetCurrentRevision() = 0; + }; template @@ -120,6 +123,11 @@ Add(KeyType name, const ValueSP& entry) { + if (listener) + entry->m_my_revision = listener->GetCurrentRevision(); + else + entry->m_my_revision = 0; + Mutex::Locker(m_map_mutex); m_map[name] = entry; if (listener) @@ -208,7 +216,8 @@ FormatNavigator(std::string name, IFormatChangeListener* lst = NULL) : m_format_map(lst), - m_name(name) + m_name(name), + m_id_cs(ConstString("id")) { } @@ -266,6 +275,8 @@ DISALLOW_COPY_AND_ASSIGN(FormatNavigator); + ConstString m_id_cs; + // using const char* instead of MapKeyType is necessary here // to make the partial template specializations below work bool @@ -442,7 +453,7 @@ if (typePtr->isObjCObjectPointerType()) { if (use_dynamic != lldb::eNoDynamicValues && - name.GetCString() == ConstString("id").GetCString()) + name.GetCString() == m_id_cs.GetCString()) { if (log) log->Printf("this is an ObjC 'id', let's do dynamic search"); @@ -584,6 +595,13 @@ bool FormatNavigator::Delete(const char* type); +template<> +bool +FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value); + +template<> +bool +FormatNavigator::Delete(const char* type); class CategoryMap; @@ -595,16 +613,23 @@ typedef FormatNavigator FilterNavigator; typedef FormatNavigator RegexFilterNavigator; + typedef FormatNavigator SynthNavigator; + typedef FormatNavigator RegexSynthNavigator; + typedef SummaryNavigator::MapType SummaryMap; typedef RegexSummaryNavigator::MapType RegexSummaryMap; typedef FilterNavigator::MapType FilterMap; typedef RegexFilterNavigator::MapType RegexFilterMap; - + typedef SynthNavigator::MapType SynthMap; + typedef RegexSynthNavigator::MapType RegexSynthMap; + SummaryNavigator::SharedPointer m_summary_nav; RegexSummaryNavigator::SharedPointer m_regex_summary_nav; FilterNavigator::SharedPointer m_filter_nav; RegexFilterNavigator::SharedPointer m_regex_filter_nav; - + SynthNavigator::SharedPointer m_synth_nav; + RegexSynthNavigator::SharedPointer m_regex_synth_nav; + bool m_enabled; IFormatChangeListener* m_change_listener; @@ -638,6 +663,8 @@ eRegexSummary = 0x1001, eFilter = 0x0002, eRegexFilter = 0x1002, + eSynth = 0x0004, + eRegexSynth = 0x1004, }; typedef uint16_t FormatCategoryItems; @@ -647,13 +674,17 @@ typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP; typedef FilterNavigator::SharedPointer FilterNavigatorSP; typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP; - + typedef SynthNavigator::SharedPointer SynthNavigatorSP; + typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP; + FormatCategory(IFormatChangeListener* clist, std::string name) : m_summary_nav(new SummaryNavigator("summary",clist)), m_regex_summary_nav(new RegexSummaryNavigator("regex-summary",clist)), m_filter_nav(new FilterNavigator("filter",clist)), m_regex_filter_nav(new RegexFilterNavigator("regex-filter",clist)), + m_synth_nav(new SynthNavigator("synth",clist)), + m_regex_synth_nav(new RegexSynthNavigator("regex-synth",clist)), m_enabled(false), m_change_listener(clist), m_mutex(Mutex::eMutexTypeRecursive), @@ -684,6 +715,18 @@ return RegexFilterNavigatorSP(m_regex_filter_nav); } + SynthNavigatorSP + Synth() + { + return SynthNavigatorSP(m_synth_nav); + } + + RegexSynthNavigatorSP + RegexSynth() + { + return RegexSynthNavigatorSP(m_regex_synth_nav); + } + bool IsEnabled() const { @@ -714,12 +757,53 @@ { if (!IsEnabled()) return false; - if (Filter()->Get(vobj, entry, use_dynamic, reason)) + SyntheticFilter::SharedPointer filter; + SyntheticScriptProvider::SharedPointer synth; + bool regex_filter, regex_synth; + uint32_t reason_filter; + uint32_t reason_synth; + + bool pick_synth = false; + + // first find both Filter and Synth, and then check which is most recent + + if (!Filter()->Get(vobj, filter, use_dynamic, &reason_filter)) + regex_filter = RegexFilter()->Get(vobj, filter, use_dynamic, &reason_filter); + + if (!Synth()->Get(vobj, synth, use_dynamic, &reason_synth)) + regex_synth = RegexSynth()->Get(vobj, synth, use_dynamic, &reason_synth); + + if (!filter.get() && !synth.get()) + return false; + + else if (!filter.get() && synth.get()) + pick_synth = true; + + else if (filter.get() && !synth.get()) + pick_synth = false; + + else /*if (filter.get() && synth.get())*/ + { + if (filter->m_my_revision > synth->m_my_revision) + pick_synth = false; + else + pick_synth = true; + } + + if (pick_synth) + { + if (regex_synth && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; + entry = synth; return true; - bool regex = RegexFilter()->Get(vobj, entry, use_dynamic, reason); - if (regex && reason) - *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; - return regex; + } + else + { + if (regex_filter && reason) + *reason |= lldb::eFormatterChoiceCriterionRegularExpressionFilter; + entry = filter; + return true; + } } // just a shortcut for Summary()->Clear; RegexSummary()->Clear() @@ -748,6 +832,10 @@ m_filter_nav->Clear(); if ( (items & eRegexFilter) ) m_regex_filter_nav->Clear(); + if ( (items & eSynth) ) + m_synth_nav->Clear(); + if ( (items & eRegexSynth) ) + m_regex_synth_nav->Clear(); } bool @@ -763,6 +851,10 @@ success = m_filter_nav->Delete(name) || success; if ( (items & eRegexFilter) ) success = m_regex_filter_nav->Delete(name) || success; + if ( (items & eSynth) ) + success = m_synth_nav->Delete(name) || success; + if ( (items & eRegexSynth) ) + success = m_regex_synth_nav->Delete(name) || success; return success; } @@ -778,6 +870,10 @@ count += m_filter_nav->GetCount(); if ( (items & eRegexFilter) ) count += m_regex_filter_nav->GetCount(); + if ( (items & eSynth) ) + count += m_synth_nav->GetCount(); + if ( (items & eRegexSynth) ) + count += m_regex_synth_nav->GetCount(); return count; } @@ -1048,7 +1144,12 @@ const char* m_system_category_name; typedef CategoryMap::MapType::iterator CategoryMapIterator; - + + ConstString m_default_cs; + ConstString m_system_cs; + ConstString m_charstar_cs; + ConstString m_constcharstar_cs; + public: typedef bool (*CategoryCallback)(void*, const char*, const FormatCategory::SharedPointer&); @@ -1057,13 +1158,17 @@ m_value_nav("format",this), m_named_summaries_map(this), m_last_revision(0), - m_categories_map(this) + m_categories_map(this), + m_default_cs(ConstString("default")), + m_system_cs(ConstString("system")), + m_charstar_cs(ConstString("char *")), + m_constcharstar_cs(ConstString("const char *")) { // build default categories - m_default_category_name = ConstString("default").GetCString(); - m_system_category_name = ConstString("system").GetCString(); + m_default_category_name = m_default_cs.GetCString(); + m_system_category_name = m_system_cs.GetCString(); // add some default stuff // most formats, summaries, ... actually belong to the users' lldbinit file rather than here @@ -1087,8 +1192,8 @@ lldb::RegularExpressionSP any_size_char_arr(new RegularExpression("char \\[[0-9]+\\]")); - Category(m_system_category_name)->Summary()->Add(ConstString("char *").GetCString(), string_format); - Category(m_system_category_name)->Summary()->Add(ConstString("const char *").GetCString(), string_format); + Category(m_system_category_name)->Summary()->Add(m_charstar_cs.GetCString(), string_format); + Category(m_system_category_name)->Summary()->Add(m_constcharstar_cs.GetCString(), string_format); Category(m_system_category_name)->RegexSummary()->Add(any_size_char_arr, string_array_format); Category(m_default_category_name); // this call is there to force LLDB into creating an empty "default" category @@ -1184,7 +1289,7 @@ } uint32_t - GetCurrentRevision() const + GetCurrentRevision() { return m_last_revision; } Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Aug 11 21:00:06 2011 @@ -631,7 +631,8 @@ bool use_synthetic, bool scope_already_checked, bool flat_output, - uint32_t omit_summary_depth); + uint32_t omit_summary_depth, + bool ignore_cap); // returns true if this is a char* or a char[] // if it is a char* and check_pointer is true, Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (original) +++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Thu Aug 11 21:00:06 2011 @@ -56,6 +56,7 @@ lldb::DynamicValueType use_dynamic; bool use_synth; bool be_raw; + bool ignore_cap; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Thu Aug 11 21:00:06 2011 @@ -86,6 +86,12 @@ return m_source_map; } + uint32_t + GetMaximumNumberOfChildrenToDisplay() + { + return m_max_children_display; + } + protected: void @@ -100,6 +106,7 @@ int m_prefer_dynamic_value; OptionValueBoolean m_skip_prologue; PathMappingList m_source_map; + uint32_t m_max_children_display; }; Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Thu Aug 11 21:00:06 2011 @@ -934,6 +934,7 @@ bool flat_output = false; bool use_synthetic = true; uint32_t no_summary_depth = 0; + bool ignore_cap = false; ValueObject::DumpValueObject (description.ref(), m_opaque_sp.get(), m_opaque_sp->GetName().GetCString(), @@ -946,7 +947,8 @@ use_synthetic, scope_already_checked, flat_output, - no_summary_depth); + no_summary_depth, + ignore_cap); } else description.Printf ("No value"); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Aug 11 21:00:06 2011 @@ -340,7 +340,8 @@ true, // Use synthetic children if available true, // Scope is already checked. Const results are always in scope. false, // Don't flatten output - 0); // Always use summaries (you might want an option --no-summary like there is for frame variable) + 0, // Always use summaries (you might want an option --no-summary like there is for frame variable) + false); // Do not show more children than settings allow 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=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Thu Aug 11 21:00:06 2011 @@ -502,7 +502,8 @@ m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, + m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); } } } @@ -555,7 +556,8 @@ m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, + m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); } else { @@ -647,7 +649,8 @@ m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, + m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); } } } Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Thu Aug 11 21:00:06 2011 @@ -660,7 +660,8 @@ m_varobj_options.be_raw ? false : m_varobj_options.use_synth, scope_already_checked, m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : 0); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, + m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); } else { Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Aug 11 21:00:06 2011 @@ -607,7 +607,8 @@ m_varobj_options.be_raw ? false : m_varobj_options.use_synth, false, m_varobj_options.flat_output, - m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth); + m_varobj_options.be_raw ? UINT32_MAX : m_varobj_options.no_summary_depth, + m_varobj_options.be_raw ? true : m_varobj_options.ignore_cap); } Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Thu Aug 11 21:00:06 2011 @@ -1121,7 +1121,7 @@ m_delete_all = true; break; case 'w': - m_category = ConstString(option_arg).GetCString(); + m_category = std::string(option_arg); break; default: error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); @@ -1135,7 +1135,7 @@ OptionParsingStarting () { m_delete_all = false; - m_category = NULL; + m_category = "default"; } const OptionDefinition* @@ -1151,7 +1151,7 @@ // Instance variables to hold the values for command options. bool m_delete_all; - const char* m_category; + std::string m_category; }; @@ -1226,7 +1226,7 @@ } lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category); + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); bool delete_category = category->DeleteSummaries(typeCS.GetCString()); bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS); @@ -1888,11 +1888,219 @@ }; //------------------------------------------------------------------------- +// CommandObjectTypeFilterList +//------------------------------------------------------------------------- + +bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); +bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); + +class CommandObjectTypeFilterList; + +struct CommandObjectTypeFilterList_LoopCallbackParam { + CommandObjectTypeFilterList* self; + CommandReturnObject* result; + RegularExpression* regex; + RegularExpression* cate_regex; + CommandObjectTypeFilterList_LoopCallbackParam(CommandObjectTypeFilterList* S, CommandReturnObject* R, + RegularExpression* X = NULL, + RegularExpression* CX = NULL) : self(S), result(R), regex(X), cate_regex(CX) {} +}; + +class CommandObjectTypeFilterList : public CommandObject +{ + + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter) : + Options (interpreter) + { + } + + virtual + ~CommandOptions (){} + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'w': + m_category_regex = std::string(option_arg); + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; + } + + void + OptionParsingStarting () + { + m_category_regex = ""; + } + + const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + std::string m_category_regex; + + }; + + CommandOptions m_options; + + virtual Options * + GetOptions () + { + return &m_options; + } + +public: + CommandObjectTypeFilterList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "type filter list", + "Show a list of current filters.", + NULL), m_options(interpreter) + { + CommandArgumentEntry type_arg; + CommandArgumentData type_style_arg; + + type_style_arg.arg_type = eArgTypeName; + type_style_arg.arg_repetition = eArgRepeatOptional; + + type_arg.push_back (type_style_arg); + + m_arguments.push_back (type_arg); + } + + ~CommandObjectTypeFilterList () + { + } + + bool + Execute (Args& command, CommandReturnObject &result) + { + const size_t argc = command.GetArgumentCount(); + + CommandObjectTypeFilterList_LoopCallbackParam *param; + RegularExpression* cate_regex = + m_options.m_category_regex.empty() ? NULL : + new RegularExpression(m_options.m_category_regex.c_str()); + + if (argc == 1) { + RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0)); + regex->Compile(command.GetArgumentAtIndex(0)); + param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,regex,cate_regex); + } + else + param = new CommandObjectTypeFilterList_LoopCallbackParam(this,&result,NULL,cate_regex); + + Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param); + + if (cate_regex) + delete cate_regex; + + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); + } + +private: + + static bool + PerCategoryCallback(void* param_vp, + const char* cate_name, + const FormatCategory::SharedPointer& cate) + { + + CommandObjectTypeFilterList_LoopCallbackParam* param = + (CommandObjectTypeFilterList_LoopCallbackParam*)param_vp; + CommandReturnObject* result = param->result; + + // if the category is disabled or empty and there is no regex, just skip it + if ((cate->IsEnabled() == false || cate->Filter()->GetCount() == 0) && param->cate_regex == NULL) + return true; + + // if we have a regex and this category does not match it, just skip it + if(param->cate_regex != NULL && param->cate_regex->Execute(cate_name) == false) + return true; + + result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n", + cate_name, + (cate->IsEnabled() ? "enabled" : "disabled")); + + cate->Filter()->LoopThrough(CommandObjectTypeFilterList_LoopCallback, param_vp); + + if (cate->RegexFilter()->GetCount() > 0) + { + result->GetOutputStream().Printf("Regex-based filters (slower):\n"); + cate->RegexFilter()->LoopThrough(CommandObjectTypeFilterRXList_LoopCallback, param_vp); + } + + return true; + } + + bool + LoopCallback (const char* type, + const SyntheticChildren::SharedPointer& entry, + RegularExpression* regex, + CommandReturnObject *result) + { + if (regex == NULL || regex->Execute(type)) + result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); + return true; + } + + friend bool CommandObjectTypeFilterList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); + friend bool CommandObjectTypeFilterRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); +}; + +bool +CommandObjectTypeFilterList_LoopCallback (void* pt2self, + const char* type, + const SyntheticChildren::SharedPointer& entry) +{ + CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self; + return param->self->LoopCallback(type, entry, param->regex, param->result); +} + +bool +CommandObjectTypeFilterRXList_LoopCallback (void* pt2self, + lldb::RegularExpressionSP regex, + const SyntheticChildren::SharedPointer& entry) +{ + CommandObjectTypeFilterList_LoopCallbackParam* param = (CommandObjectTypeFilterList_LoopCallbackParam*)pt2self; + return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); +} + + +OptionDefinition +CommandObjectTypeFilterList::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_ALL, false, "category-regex", 'w', required_argument, NULL, 0, eArgTypeName, "Only show categories matching this filter."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + +//------------------------------------------------------------------------- // CommandObjectTypeSynthList //------------------------------------------------------------------------- -bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticFilter::SharedPointer& entry); -bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticFilter::SharedPointer& entry); +bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); +bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); class CommandObjectTypeSynthList; @@ -2032,7 +2240,7 @@ CommandReturnObject* result = param->result; // if the category is disabled or empty and there is no regex, just skip it - if ((cate->IsEnabled() == false || cate->Filter()->GetCount() == 0) && param->cate_regex == NULL) + if ((cate->IsEnabled() == false || cate->Synth()->GetCount() == 0) && param->cate_regex == NULL) return true; // if we have a regex and this category does not match it, just skip it @@ -2043,12 +2251,12 @@ cate_name, (cate->IsEnabled() ? "enabled" : "disabled")); - cate->Filter()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp); + cate->Synth()->LoopThrough(CommandObjectTypeSynthList_LoopCallback, param_vp); - if (cate->RegexFilter()->GetCount() > 0) + if (cate->RegexSynth()->GetCount() > 0) { - result->GetOutputStream().Printf("Regex-based filters (slower):\n"); - cate->RegexFilter()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp); + result->GetOutputStream().Printf("Regex-based synthetic providers (slower):\n"); + cate->RegexSynth()->LoopThrough(CommandObjectTypeSynthRXList_LoopCallback, param_vp); } return true; @@ -2056,23 +2264,23 @@ bool LoopCallback (const char* type, - const SyntheticFilter::SharedPointer& entry, + const SyntheticChildren::SharedPointer& entry, RegularExpression* regex, CommandReturnObject *result) { - if (regex == NULL || regex->Execute(type)) + if (regex == NULL || regex->Execute(type)) result->GetOutputStream().Printf ("%s: %s\n", type, entry->GetDescription().c_str()); return true; } - friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticFilter::SharedPointer& entry); - friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticFilter::SharedPointer& entry); + friend bool CommandObjectTypeSynthList_LoopCallback(void* pt2self, const char* type, const SyntheticChildren::SharedPointer& entry); + friend bool CommandObjectTypeSynthRXList_LoopCallback(void* pt2self, lldb::RegularExpressionSP regex, const SyntheticChildren::SharedPointer& entry); }; bool CommandObjectTypeSynthList_LoopCallback (void* pt2self, const char* type, - const SyntheticFilter::SharedPointer& entry) + const SyntheticChildren::SharedPointer& entry) { CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(type, entry, param->regex, param->result); @@ -2081,7 +2289,7 @@ bool CommandObjectTypeSynthRXList_LoopCallback (void* pt2self, lldb::RegularExpressionSP regex, - const SyntheticFilter::SharedPointer& entry) + const SyntheticChildren::SharedPointer& entry) { CommandObjectTypeSynthList_LoopCallbackParam* param = (CommandObjectTypeSynthList_LoopCallbackParam*)pt2self; return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result); @@ -2096,6 +2304,169 @@ }; //------------------------------------------------------------------------- +// CommandObjectTypeFilterDelete +//------------------------------------------------------------------------- + +class CommandObjectTypeFilterDelete : public CommandObject +{ +private: + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter) : + Options (interpreter) + { + } + + virtual + ~CommandOptions (){} + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'a': + m_delete_all = true; + break; + case 'w': + m_category = std::string(option_arg); + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; + } + + void + OptionParsingStarting () + { + m_delete_all = false; + m_category = "default"; + } + + const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_delete_all; + std::string m_category; + + }; + + CommandOptions m_options; + + virtual Options * + GetOptions () + { + return &m_options; + } + + static bool + PerCategoryCallback(void* param, + const char* cate_name, + const FormatCategory::SharedPointer& cate) + { + const char* name = (const char*)param; + return cate->Delete(name, FormatCategory::eFilter | FormatCategory::eRegexFilter); + } + +public: + CommandObjectTypeFilterDelete (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "type filter delete", + "Delete an existing filter for a type.", + NULL), m_options(interpreter) + { + CommandArgumentEntry type_arg; + CommandArgumentData type_style_arg; + + type_style_arg.arg_type = eArgTypeName; + type_style_arg.arg_repetition = eArgRepeatPlain; + + type_arg.push_back (type_style_arg); + + m_arguments.push_back (type_arg); + + } + + ~CommandObjectTypeFilterDelete () + { + } + + bool + Execute (Args& command, CommandReturnObject &result) + { + const size_t argc = command.GetArgumentCount(); + + if (argc != 1) + { + result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + const char* typeA = command.GetArgumentAtIndex(0); + ConstString typeCS(typeA); + + if (!typeCS) + { + result.AppendError("empty typenames not allowed"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (m_options.m_delete_all) + { + Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString()); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + + lldb::FormatCategorySP category; + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + + bool delete_category = category->Filter()->Delete(typeCS.GetCString()); + delete_category = category->RegexFilter()->Delete(typeCS.GetCString()) || delete_category; + + if (delete_category) + { + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + else + { + result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA); + result.SetStatus(eReturnStatusFailed); + return false; + } + + } +}; + +OptionDefinition +CommandObjectTypeFilterDelete::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Delete from every category."}, + { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + +//------------------------------------------------------------------------- // CommandObjectTypeSynthDelete //------------------------------------------------------------------------- @@ -2126,7 +2497,7 @@ m_delete_all = true; break; case 'w': - m_category = ConstString(option_arg).GetCString(); + m_category = std::string(option_arg); break; default: error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); @@ -2140,7 +2511,7 @@ OptionParsingStarting () { m_delete_all = false; - m_category = NULL; + m_category = "default"; } const OptionDefinition* @@ -2156,7 +2527,7 @@ // Instance variables to hold the values for command options. bool m_delete_all; - const char* m_category; + std::string m_category; }; @@ -2174,7 +2545,7 @@ const FormatCategory::SharedPointer& cate) { const char* name = (const char*)param; - return cate->Delete(name, FormatCategory::eFilter | FormatCategory::eRegexFilter); + return cate->Delete(name, FormatCategory::eSynth | FormatCategory::eRegexSynth); } public: @@ -2230,31 +2601,158 @@ } lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category), category); + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); - bool delete_category = category->Filter()->Delete(typeCS.GetCString()); - delete_category = category->RegexFilter()->Delete(typeCS.GetCString()) || delete_category; + bool delete_category = category->Synth()->Delete(typeCS.GetCString()); + delete_category = category->RegexSynth()->Delete(typeCS.GetCString()) || delete_category; + + if (delete_category) + { + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + else + { + result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA); + result.SetStatus(eReturnStatusFailed); + return false; + } + + } +}; + +OptionDefinition +CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Delete from every category."}, + { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + +//------------------------------------------------------------------------- +// CommandObjectTypeFilterClear +//------------------------------------------------------------------------- + +class CommandObjectTypeFilterClear : public CommandObject +{ +private: + + class CommandOptions : public Options + { + public: + + CommandOptions (CommandInterpreter &interpreter) : + Options (interpreter) + { + } + + virtual + ~CommandOptions (){} + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + + switch (short_option) + { + case 'a': + m_delete_all = true; + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; + } + + void + OptionParsingStarting () + { + m_delete_all = false; + } + + const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_delete_all; + bool m_delete_named; + }; + + CommandOptions m_options; + + virtual Options * + GetOptions () + { + return &m_options; + } + + static bool + PerCategoryCallback(void* param, + const char* cate_name, + const FormatCategory::SharedPointer& cate) + { + cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); + return true; + + } + +public: + CommandObjectTypeFilterClear (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "type filter clear", + "Delete all existing filters.", + NULL), m_options(interpreter) + { + } + + ~CommandObjectTypeFilterClear () + { + } + + bool + Execute (Args& command, CommandReturnObject &result) + { + + if (m_options.m_delete_all) + Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL); - if (delete_category) - { - result.SetStatus(eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); - } else - { - result.AppendErrorWithFormat ("no custom synthetic provider for %s.\n", typeA); - result.SetStatus(eReturnStatusFailed); - return false; + { + lldb::FormatCategorySP category; + if (command.GetArgumentCount() > 0) + { + const char* cat_name = command.GetArgumentAtIndex(0); + ConstString cat_nameCS(cat_name); + Debugger::Formatting::Categories::Get(cat_nameCS, category); + } + else + Debugger::Formatting::Categories::Get(ConstString(NULL), category); + category->Filter()->Clear(); + category->RegexFilter()->Clear(); } + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); } + }; OptionDefinition -CommandObjectTypeSynthDelete::CommandOptions::g_option_table[] = +CommandObjectTypeFilterClear::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Delete from every category."}, - { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."}, + { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeNone, "Clear every category."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; @@ -2332,7 +2830,7 @@ const char* cate_name, const FormatCategory::SharedPointer& cate) { - cate->Clear(FormatCategory::eFilter | FormatCategory::eRegexFilter); + cate->Clear(FormatCategory::eSynth | FormatCategory::eRegexSynth); return true; } @@ -2368,8 +2866,8 @@ } else Debugger::Formatting::Categories::Get(ConstString(NULL), category); - category->Filter()->Clear(); - category->RegexFilter()->Clear(); + category->Synth()->Clear(); + category->RegexSynth()->Clear(); } result.SetStatus(eReturnStatusSuccessFinishResult); @@ -2594,67 +3092,7 @@ CollectPythonScript(options,result); return result.Succeeded(); } - -bool -CommandObjectTypeSynthAdd::Execute_ChildrenList (Args& command, CommandReturnObject &result) -{ - const size_t argc = command.GetArgumentCount(); - - if (argc < 1) - { - result.AppendErrorWithFormat ("%s takes one or more args.\n", m_cmd_name.c_str()); - result.SetStatus(eReturnStatusFailed); - return false; - } - - if (m_options.m_expr_paths.size() == 0) - { - result.AppendErrorWithFormat ("%s needs one or more children.\n", m_cmd_name.c_str()); - result.SetStatus(eReturnStatusFailed); - return false; - } - - SyntheticChildrenSP entry; - - SyntheticFilter* impl = new SyntheticFilter(m_options.m_cascade, - m_options.m_skip_pointers, - m_options.m_skip_references); - - entry.reset(impl); - - // go through the expression paths - CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end(); - - for (begin = m_options.m_expr_paths.begin(); begin != end; begin++) - impl->AddExpressionPath(*begin); - - - // now I have a valid provider, let's add it to every type - - lldb::FormatCategorySP category; - Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); - - for (size_t i = 0; i < argc; i++) { - const char* typeA = command.GetArgumentAtIndex(i); - ConstString typeCS(typeA); - if (typeCS) - AddSynth(typeCS, - entry, - m_options.m_regex ? eRegexSynth : eRegularSynth, - m_options.m_category, - NULL); - else - { - result.AppendError("empty typenames not allowed"); - result.SetStatus(eReturnStatusFailed); - return false; - } - } - - result.SetStatus(eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); -} - + bool CommandObjectTypeSynthAdd::Execute_PythonClass (Args& command, CommandReturnObject &result) { @@ -2747,14 +3185,14 @@ return false; } - category->RegexFilter()->Delete(type_name.GetCString()); - category->RegexFilter()->Add(typeRX, entry); + category->RegexSynth()->Delete(type_name.GetCString()); + category->RegexSynth()->Add(typeRX, entry); return true; } else { - category->Filter()->Add(type_name.GetCString(), entry); + category->Synth()->Add(type_name.GetCString(), entry); return true; } } @@ -2766,8 +3204,6 @@ return Execute_HandwritePython(command, result); else if (m_options.is_class_based) return Execute_PythonClass(command, result); - else if (m_options.has_child_list) - return Execute_ChildrenList(command, result); else { result.AppendError("must either provide a children list, a Python class name, or use -P and type a Python class line-by-line"); @@ -2783,13 +3219,252 @@ { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."}, { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."}, { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."}, - { LLDB_OPT_SET_1, false, "child", 'c', required_argument, NULL, 0, eArgTypeName, "Include this expression path in the synthetic view."}, { LLDB_OPT_SET_2, false, "python-class", 'l', required_argument, NULL, 0, eArgTypeName, "Use this Python class to produce synthetic children."}, { LLDB_OPT_SET_3, false, "input-python", 'P', no_argument, NULL, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children."}, { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; +class CommandObjectTypeFilterAdd : public CommandObject +{ + +private: + + class CommandOptions : public Options + { + typedef std::vector option_vector; + public: + + CommandOptions (CommandInterpreter &interpreter) : + Options (interpreter) + { + } + + virtual + ~CommandOptions (){} + + virtual Error + SetOptionValue (uint32_t option_idx, const char *option_arg) + { + Error error; + char short_option = (char) m_getopt_table[option_idx].val; + bool success; + + switch (short_option) + { + case 'C': + m_cascade = Args::StringToBoolean(option_arg, true, &success); + if (!success) + error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_arg); + break; + case 'c': + m_expr_paths.push_back(option_arg); + has_child_list = true; + break; + case 'p': + m_skip_pointers = true; + break; + case 'r': + m_skip_references = true; + break; + case 'w': + m_category = std::string(option_arg); + break; + case 'x': + m_regex = true; + break; + default: + error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); + break; + } + + return error; + } + + void + OptionParsingStarting () + { + m_cascade = true; + m_skip_pointers = false; + m_skip_references = false; + m_category = "default"; + m_expr_paths.clear(); + has_child_list = false; + m_regex = false; + } + + const OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_cascade; + bool m_skip_references; + bool m_skip_pointers; + bool m_input_python; + option_vector m_expr_paths; + std::string m_category; + + bool has_child_list; + + bool m_regex; + + typedef option_vector::iterator ExpressionPathsIterator; + }; + + CommandOptions m_options; + + virtual Options * + GetOptions () + { + return &m_options; + } + + enum SynthFormatType + { + eRegularSynth, + eRegexSynth, + }; + + bool + AddSynth(const ConstString& type_name, + SyntheticChildrenSP entry, + SynthFormatType type, + std::string category_name, + Error* error) + { + lldb::FormatCategorySP category; + Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); + + if (type == eRegexSynth) + { + RegularExpressionSP typeRX(new RegularExpression()); + if (!typeRX->Compile(type_name.GetCString())) + { + if (error) + error->SetErrorString("regex format error (maybe this is not really a regex?)"); + return false; + } + + category->RegexFilter()->Delete(type_name.GetCString()); + category->RegexFilter()->Add(typeRX, entry); + + return true; + } + else + { + category->Filter()->Add(type_name.GetCString(), entry); + return true; + } + } + + +public: + + CommandObjectTypeFilterAdd (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "type filter add", + "Add a new filter for a type.", + NULL), + m_options (interpreter) + { + CommandArgumentEntry type_arg; + CommandArgumentData type_style_arg; + + type_style_arg.arg_type = eArgTypeName; + type_style_arg.arg_repetition = eArgRepeatPlus; + + type_arg.push_back (type_style_arg); + + m_arguments.push_back (type_arg); + + } + + ~CommandObjectTypeFilterAdd () + { + } + + bool + Execute (Args& command, CommandReturnObject &result) + { + const size_t argc = command.GetArgumentCount(); + + if (argc < 1) + { + result.AppendErrorWithFormat ("%s takes one or more args.\n", m_cmd_name.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + if (m_options.m_expr_paths.size() == 0) + { + result.AppendErrorWithFormat ("%s needs one or more children.\n", m_cmd_name.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } + + SyntheticChildrenSP entry; + + SyntheticFilter* impl = new SyntheticFilter(m_options.m_cascade, + m_options.m_skip_pointers, + m_options.m_skip_references); + + entry.reset(impl); + + // go through the expression paths + CommandOptions::ExpressionPathsIterator begin, end = m_options.m_expr_paths.end(); + + for (begin = m_options.m_expr_paths.begin(); begin != end; begin++) + impl->AddExpressionPath(*begin); + + + // now I have a valid provider, let's add it to every type + + lldb::FormatCategorySP category; + Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + + for (size_t i = 0; i < argc; i++) { + const char* typeA = command.GetArgumentAtIndex(i); + ConstString typeCS(typeA); + if (typeCS) + AddSynth(typeCS, + entry, + m_options.m_regex ? eRegexSynth : eRegularSynth, + m_options.m_category, + NULL); + else + { + result.AppendError("empty typenames not allowed"); + result.SetStatus(eReturnStatusFailed); + return false; + } + } + + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } + +}; + +OptionDefinition +CommandObjectTypeFilterAdd::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."}, + { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects."}, + { LLDB_OPT_SET_ALL, false, "skip-references", 'r', no_argument, NULL, 0, eArgTypeNone, "Don't use this format for references-to-type objects."}, + { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."}, + { LLDB_OPT_SET_ALL, false, "child", 'c', required_argument, NULL, 0, eArgTypeName, "Include this expression path in the synthetic view."}, + { LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeNone, "Type names are actually regular expressions."}, + { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +}; + class CommandObjectTypeFormat : public CommandObjectMultiword { public: @@ -2832,6 +3507,27 @@ } }; +class CommandObjectTypeFilter : public CommandObjectMultiword +{ +public: + CommandObjectTypeFilter (CommandInterpreter &interpreter) : + CommandObjectMultiword (interpreter, + "type filter", + "A set of commands for operating on type filters", + "type synthetic [] ") + { + LoadSubCommand ("add", CommandObjectSP (new CommandObjectTypeFilterAdd (interpreter))); + LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTypeFilterClear (interpreter))); + LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeFilterDelete (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectTypeFilterList (interpreter))); + } + + + ~CommandObjectTypeFilter () + { + } +}; + class CommandObjectTypeCategory : public CommandObjectMultiword { public: @@ -2885,9 +3581,10 @@ "type []") { LoadSubCommand ("category", CommandObjectSP (new CommandObjectTypeCategory (interpreter))); + LoadSubCommand ("filter", CommandObjectSP (new CommandObjectTypeFilter (interpreter))); LoadSubCommand ("format", CommandObjectSP (new CommandObjectTypeFormat (interpreter))); LoadSubCommand ("summary", CommandObjectSP (new CommandObjectTypeSummary (interpreter))); - LoadSubCommand ("synthetic", CommandObjectSP (new CommandObjectTypeSynth (interpreter))); + LoadSubCommand ("synthetic", CommandObjectSP (new CommandObjectTypeSynth (interpreter))); } Modified: lldb/trunk/source/Commands/CommandObjectType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.h?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.h (original) +++ lldb/trunk/source/Commands/CommandObjectType.h Thu Aug 11 21:00:06 2011 @@ -214,7 +214,6 @@ class CommandOptions : public Options { - typedef std::vector option_vector; public: CommandOptions (CommandInterpreter &interpreter) : @@ -239,10 +238,6 @@ if (!success) error.SetErrorStringWithFormat("Invalid value for cascade: %s.\n", option_arg); break; - case 'c': - m_expr_paths.push_back(option_arg); - has_child_list = true; - break; case 'P': handwrite_python = true; break; @@ -278,10 +273,8 @@ m_skip_pointers = false; m_skip_references = false; m_category = "default"; - m_expr_paths.clear(); is_class_based = false; handwrite_python = false; - has_child_list = false; m_regex = false; } @@ -302,18 +295,14 @@ bool m_skip_pointers; std::string m_class_name; bool m_input_python; - option_vector m_expr_paths; std::string m_category; bool is_class_based; bool handwrite_python; - - bool has_child_list; - + bool m_regex; - typedef option_vector::iterator ExpressionPathsIterator; }; CommandOptions m_options; @@ -329,10 +318,10 @@ CommandReturnObject &result); bool Execute_HandwritePython (Args& command, CommandReturnObject &result); - bool - Execute_ChildrenList (Args& command, CommandReturnObject &result); + bool Execute_PythonClass (Args& command, CommandReturnObject &result); + bool Execute (Args& command, CommandReturnObject &result); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 11 21:00:06 2011 @@ -1200,6 +1200,8 @@ if (index_higher < 0) index_higher = vobj->GetNumChildren() - 1; + uint32_t max_num_children = target->GetUpdatePoint().GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); + for (;index_lower<=index_higher;index_lower++) { ValueObject* item = ExpandIndexedExpression(target, @@ -1223,6 +1225,12 @@ else var_success &= FormatPrompt(special_directions, sc, exe_ctx, addr, s, NULL, item); + if (--max_num_children == 0) + { + s.PutCString(", ..."); + break; + } + if (index_lower < index_higher) s.PutChar(','); } Modified: lldb/trunk/source/Core/FormatManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatManager.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Core/FormatManager.cpp (original) +++ lldb/trunk/source/Core/FormatManager.cpp Thu Aug 11 21:00:06 2011 @@ -230,6 +230,44 @@ return false; } +template<> +bool +FormatNavigator::Get(const char* key, SyntheticFilter::SharedPointer& value) +{ + Mutex::Locker(m_format_map.mutex()); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if (regex->Execute(key)) + { + value = pos->second; + return true; + } + } + return false; +} + +template<> +bool +FormatNavigator::Delete(const char* type) +{ + Mutex::Locker(m_format_map.mutex()); + MapIterator pos, end = m_format_map.map().end(); + for (pos = m_format_map.map().begin(); pos != end; pos++) + { + lldb::RegularExpressionSP regex = pos->first; + if ( ::strcmp(type,regex->GetText()) == 0) + { + m_format_map.map().erase(pos); + if (m_format_map.listener) + m_format_map.listener->Changed(); + return true; + } + } + return false; +} + lldb::Format FormatManager::GetSingleItemFormat(lldb::Format vector_format) { Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Thu Aug 11 21:00:06 2011 @@ -2687,7 +2687,8 @@ bool use_synth, bool scope_already_checked, bool flat_output, - uint32_t omit_summary_depth + uint32_t omit_summary_depth, + bool ignore_cap ) { if (valobj) @@ -2864,7 +2865,8 @@ ValueObjectSP synth_vobj = valobj->GetSyntheticValue(use_synth ? lldb::eUseSyntheticFilter : lldb::eNoSyntheticFilter); - const uint32_t num_children = synth_vobj->GetNumChildren(); + uint32_t num_children = synth_vobj->GetNumChildren(); + bool print_dotdotdot = false; if (num_children) { if (flat_output) @@ -2878,6 +2880,14 @@ s.PutCString(is_ref ? ": {\n" : " {\n"); s.IndentMore(); } + + uint32_t max_num_children = valobj->GetUpdatePoint().GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); + + if (num_children > max_num_children && !ignore_cap) + { + num_children = max_num_children; + print_dotdotdot = true; + } for (uint32_t idx=0; idx 1 ? omit_summary_depth - 1 : 0); + omit_summary_depth > 1 ? omit_summary_depth - 1 : 0, + ignore_cap); } } if (!flat_output) { + if (print_dotdotdot) + s.Indent("...\n"); s.IndentLess(); s.Indent("}\n"); } Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original) +++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Thu Aug 11 21:00:06 2011 @@ -30,17 +30,18 @@ static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, + { LLDB_OPT_SET_1, false, "dynamic-type", 'd', required_argument, TargetInstanceSettings::g_dynamic_value_types, 0, eArgTypeNone, "Show the object as its full dynamic type, not its static type, if available."}, - { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, - { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, - { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, - { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, - { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "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, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, - { LLDB_OPT_SET_1, false, "no-summary-depth",'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."}, - { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, + { LLDB_OPT_SET_1, false, "synthetic-type", 'S', required_argument, NULL, 0, eArgTypeBoolean, "Show the object obeying its synthetic provider, if available."}, + { LLDB_OPT_SET_1, false, "depth", 'D', required_argument, NULL, 0, eArgTypeCount, "Set the max recurse depth when dumping aggregate types (default is infinity)."}, + { LLDB_OPT_SET_1, false, "flat", 'F', no_argument, NULL, 0, eArgTypeNone, "Display results in a flat format that uses expression paths for each variable or member."}, + { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, eArgTypeNone, "Show variable location information."}, + { LLDB_OPT_SET_1, false, "objc", 'O', no_argument, NULL, 0, eArgTypeNone, "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, "show-types", 'T', no_argument, NULL, 0, eArgTypeNone, "Show variable types when dumping values."}, + { LLDB_OPT_SET_1, false, "no-summary-depth", 'Y', optional_argument, NULL, 0, eArgTypeCount, "Set a depth for omitting summary information (default is 1)."}, + { LLDB_OPT_SET_1, false, "raw-output", 'R', no_argument, NULL, 0, eArgTypeNone, "Don't use formatting options."}, + { LLDB_OPT_SET_1, false, "show-all-children",'A', no_argument, NULL, 0, eArgTypeNone, "Ignore the upper bound on the number of children to show."}, { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL } }; @@ -86,6 +87,7 @@ case 'F': flat_output = true; break; case 'O': use_objc = true; break; case 'R': be_raw = true; break; + case 'A': ignore_cap = true; break; case 'D': max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success); @@ -135,6 +137,7 @@ ptr_depth = 0; use_synth = true; be_raw = false; + ignore_cap = false; Target *target = interpreter.GetExecutionContext().target; if (target != NULL) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Aug 11 21:00:06 2011 @@ -1578,6 +1578,7 @@ #define TSC_PREFER_DYNAMIC "prefer-dynamic-value" #define TSC_SKIP_PROLOGUE "skip-prologue" #define TSC_SOURCE_MAP "source-map" +#define TSC_MAX_CHILDREN "max-children-count" static const ConstString & @@ -1615,6 +1616,12 @@ return g_const_string; } +static const ConstString & +GetSettingNameForMaxChildren () +{ + static ConstString g_const_string (TSC_MAX_CHILDREN); + return g_const_string; +} bool @@ -1668,7 +1675,8 @@ m_expr_prefix_contents_sp (), m_prefer_dynamic_value (2), m_skip_prologue (true, true), - m_source_map (NULL, NULL) + m_source_map (NULL, NULL), + m_max_children_display(256) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -1694,7 +1702,8 @@ m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp), m_prefer_dynamic_value (rhs.m_prefer_dynamic_value), m_skip_prologue (rhs.m_skip_prologue), - m_source_map (rhs.m_source_map) + m_source_map (rhs.m_source_map), + m_max_children_display(rhs.m_max_children_display) { if (m_instance_name != InstanceSettings::GetDefaultName()) { @@ -1771,6 +1780,13 @@ { err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_skip_prologue); } + else if (var_name == GetSettingNameForMaxChildren()) + { + bool ok; + uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok); + if (ok) + m_max_children_display = new_value; + } else if (var_name == GetSettingNameForSourcePathMap ()) { switch (op) @@ -1841,6 +1857,7 @@ m_expr_prefix_contents_sp = new_settings_ptr->m_expr_prefix_contents_sp; m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value; m_skip_prologue = new_settings_ptr->m_skip_prologue; + m_max_children_display = new_settings_ptr->m_max_children_display; } bool @@ -1870,6 +1887,12 @@ else if (var_name == GetSettingNameForSourcePathMap ()) { } + else if (var_name == GetSettingNameForMaxChildren()) + { + StreamString count_str; + count_str.Printf ("%d", m_max_children_display); + value.AppendString (count_str.GetData()); + } else { if (err) @@ -1923,5 +1946,6 @@ { TSC_PREFER_DYNAMIC, eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, { TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, + { TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." }, { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } }; Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py Thu Aug 11 21:00:06 2011 @@ -49,6 +49,8 @@ def cleanup(): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) + self.runCmd("settings set target.max-children-count 256", check=False) + # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -190,6 +192,94 @@ self.expect("frame variable a_simple_object", matching=True, substrs = ['x=0x00000003']) + # check that we can correctly cap the number of children shown + self.runCmd("settings set target.max-children-count 5") + + self.expect('frame variable a_long_guy', matching=True, + substrs = ['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + '...']) + + # check that no further stuff is printed (not ALL values are checked!) + self.expect('frame variable a_long_guy', matching=False, + substrs = ['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) + + self.runCmd("settings set target.max-children-count 1") + self.expect('frame variable a_long_guy', matching=True, + substrs = ['a_1', + '...']) + self.expect('frame variable a_long_guy', matching=False, + substrs = ['b_1', + 'c_1', + 'd_1', + 'e_1']) + self.expect('frame variable a_long_guy', matching=False, + substrs = ['f_1', + 'g_1', + 'h_1', + 'i_1', + 'j_1', + 'q_1', + 'a_2', + 'f_2', + 't_2', + 'w_2']) + + self.runCmd("settings set target.max-children-count 30") + self.expect('frame variable a_long_guy', matching=True, + substrs = ['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2', + '...']) + self.expect('frame variable a_long_guy', matching=False, + substrs = ['e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + + # override the cap + self.expect('frame variable a_long_guy --show-all-children', matching=True, + substrs = ['a_1', + 'b_1', + 'c_1', + 'd_1', + 'e_1', + 'z_1', + 'a_2', + 'b_2', + 'c_2', + 'd_2']) + self.expect('frame variable a_long_guy --show-all-children', matching=True, + substrs = ['e_2', + 'n_2', + 'r_2', + 'i_2', + 'k_2', + 'o_2']) + self.expect('frame variable a_long_guy -A', matching=False, + substrs = ['...']) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/main.cpp?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/main.cpp (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-advanced/main.cpp Thu Aug 11 21:00:06 2011 @@ -73,6 +73,63 @@ s(new Simple(X,Y,Z)) {} }; +struct VeryLong +{ + int a_1; + int b_1; + int c_1; + int d_1; + int e_1; + int f_1; + int g_1; + int h_1; + int i_1; + int j_1; + int k_1; + int l_1; + int m_1; + int n_1; + int o_1; + int p_1; + int q_1; + int r_1; + int s_1; + int t_1; + int u_1; + int v_1; + int w_1; + int x_1; + int y_1; + int z_1; + + int a_2; + int b_2; + int c_2; + int d_2; + int e_2; + int f_2; + int g_2; + int h_2; + int i_2; + int j_2; + int k_2; + int l_2; + int m_2; + int n_2; + int o_2; + int p_2; + int q_2; + int r_2; + int s_2; + int t_2; + int u_2; + int v_2; + int w_2; + int x_2; + int y_2; + int z_2; +}; + int main (int argc, const char * argv[]) { @@ -108,5 +165,7 @@ Simple a_simple_object(3,0.14,'E'); + VeryLong a_long_guy; + return 0; // Set break point at this line. } \ No newline at end of file Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py Thu Aug 11 21:00:06 2011 @@ -319,8 +319,8 @@ 'AShape', 'ARectangleStar']) - # check that synthetic children work into categories - self.runCmd("type synth add Rectangle --child w --category RectangleCategory") + # check that filters work into categories + self.runCmd("type filter add Rectangle --child w --category RectangleCategory") self.runCmd("type category enable RectangleCategory") self.runCmd("type summary add Rectangle -f \" \" -e --category RectangleCategory") self.expect('frame variable r2', @@ -332,7 +332,7 @@ # Now delete all categories self.runCmd("type category delete CircleCategory RectangleStarCategory BaseCategory RectangleCategory") - # last of all, check that a deleted category with synth does not blow us up + # last of all, check that a deleted category with filter does not blow us up self.expect('frame variable r2', substrs = ['w = 9', 'h = 16']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Thu Aug 11 21:00:06 2011 @@ -49,7 +49,9 @@ def cleanup(): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) + self.runCmd('type filter clear', check=False) self.runCmd('type synth clear', check=False) + self.runCmd("settings set target.max-children-count 256", check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -114,18 +116,75 @@ 'fake_a = 16777217', 'a = 280']); + # check that capping works for synthetic children as well + self.runCmd("settings set target.max-children-count 2", check=False) + + self.expect("frame variable f00_1", + substrs = ['...', + 'fake_a = 16777217', + 'a = 280']); + + self.expect("frame variable f00_1", matching=False, + substrs = ['r = 33']); + + + self.runCmd("settings set target.max-children-count 256", check=False) + # check that expanding a pointer does the right thing self.expect("frame variable -P 1 f00_ptr", substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) + # now mix synth and filter and check consistent output + self.runCmd("type filter add foo --child b --child j") + self.expect('frame variable f00_1', + substrs = ['b = 1', + 'j = 17']) + self.expect("frame variable -P 1 f00_ptr", matching=False, + substrs = ['r = 45', + 'fake_a = 218103808', + 'a = 12']) + + # now add the synth again to see that it prevails + self.runCmd("type synth add -l fooSynthProvider foo") + self.expect('frame variable f00_1', matching=False, + substrs = ['b = 1', + 'j = 17']) + self.expect("frame variable -P 1 f00_ptr", + substrs = ['r = 45', + 'fake_a = 218103808', + 'a = 12']) + + # check the listing + self.expect('type synth list', + substrs = ['foo', + 'Python class fooSynthProvider']) + self.expect('type filter list', + substrs = ['foo', + '.b', + '.j']) + # delete the synth and check that we get good output self.runCmd("type synth delete foo") + + # first let the filter win + self.expect('frame variable f00_1', + substrs = ['b = 1', + 'j = 17']) + self.expect("frame variable -P 1 f00_ptr", matching=False, + substrs = ['r = 45', + 'fake_a = 218103808', + 'a = 12']) + + # then delete the filter + self.runCmd("type filter delete foo") + + # and show real children self.expect("frame variable f00_1", substrs = ['a = 280', 'b = 1', - 'r = 33']); + 'j = 17']); self.expect("frame variable f00_1", matching=False, substrs = ['fake_a = ']) Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=137416&r1=137415&r2=137416&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Thu Aug 11 21:00:06 2011 @@ -49,13 +49,13 @@ def cleanup(): self.runCmd('type format clear', check=False) self.runCmd('type summary clear', check=False) - self.runCmd('type synth clear', check=False) + self.runCmd('type filter clear', check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) # Pick some values and check that the basics work - self.runCmd("type synth add BagOfInts --child x --child z") + self.runCmd("type filter add BagOfInts --child x --child z") self.expect("frame variable int_bag", substrs = ['x = 6', 'z = 8']) @@ -102,14 +102,14 @@ 'z = 8']) # Delete synth and check that the view reflects it immediately - self.runCmd("type synth delete BagOfInts") + self.runCmd("type filter delete BagOfInts") self.expect("frame variable int_bag", substrs = ['x = 6', 'y = 7', 'z = 8']) # Add the synth again and check that it's honored deeper in the hierarchy - self.runCmd("type synth add BagOfInts --child x --child z") + self.runCmd("type filter add BagOfInts --child x --child z") self.expect('frame variable bag_bag', substrs = ['x = y=70 {', 'x = 69', @@ -122,25 +122,25 @@ 'y = 67']) # Check that a synth can expand nested stuff - self.runCmd("type synth add BagOfBags --child x.y --child y.z") + self.runCmd("type filter add BagOfBags --child x.y --child y.z") self.expect('frame variable bag_bag', substrs = ['x.y = 70', 'y.z = 68']) # ...even if we get -> and . wrong - self.runCmd("type synth add BagOfBags --child x.y --child \"y->z\"") + self.runCmd("type filter add BagOfBags --child x.y --child \"y->z\"") self.expect('frame variable bag_bag', substrs = ['x.y = 70', 'y->z = 68']) # ...even bitfields - self.runCmd("type synth add BagOfBags --child x.y --child \"y->z[1-2]\"") + self.runCmd("type filter add BagOfBags --child x.y --child \"y->z[1-2]\"") self.expect('frame variable bag_bag -T', substrs = ['x.y = 70', '(int:2) y->z[1-2] = 2']) # ...even if we format the bitfields - self.runCmd("type synth add BagOfBags --child x.y --child \"y->y[0-0]\"") + self.runCmd("type filter add BagOfBags --child x.y --child \"y->y[0-0]\"") self.runCmd("type format add \"int:1\" -f bool") self.expect('frame variable bag_bag -T', substrs = ['x.y = 70', @@ -154,7 +154,7 @@ self.runCmd("type summary delete BagOfBags") # now check we are dynamic (and arrays work) - self.runCmd("type synth add Plenty --child bitfield --child array[0] --child array[2]") + self.runCmd("type filter add Plenty --child bitfield --child array[0] --child array[2]") self.expect('frame variable plenty_of_stuff', substrs = ['bitfield = 1', 'array[0] = 5', @@ -191,7 +191,7 @@ 'z = 7']) # but not if we don't want to - self.runCmd("type synth add BagOfInts --child x --child z -p") + self.runCmd("type filter add BagOfInts --child x --child z -p") self.expect('frame variable plenty_of_stuff.some_values -P1', substrs = ['(BagOfInts *) plenty_of_stuff.some_values', 'x = 5', @@ -199,7 +199,7 @@ 'z = 7']) # check we're dynamic even if nested - self.runCmd("type synth add BagOfBags --child x.z") + self.runCmd("type filter add BagOfBags --child x.z") self.expect('frame variable bag_bag', substrs = ['x.z = 71']) From jmolenda at apple.com Thu Aug 11 21:40:17 2011 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 12 Aug 2011 02:40:17 -0000 Subject: [Lldb-commits] [lldb] r137421 - /lldb/trunk/tools/driver/IOChannel.cpp Message-ID: <20110812024017.685BF2A6C12C@llvm.org> Author: jmolenda Date: Thu Aug 11 21:40:17 2011 New Revision: 137421 URL: http://llvm.org/viewvc/llvm-project?rev=137421&view=rev Log: Fixes the occasional crash on exit when quitting lldb with control-D. If the IOChannel has already freed out its m_driver member, and there's still a character to be read/written (that is, the ^D character), just skip that char instead of trying to write through a null object pointer. Modified: lldb/trunk/tools/driver/IOChannel.cpp Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=137421&r1=137420&r2=137421&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Thu Aug 11 21:40:17 2011 @@ -503,6 +503,15 @@ if (len == 0) return; + // We're in the process of exiting -- IOChannel::Run() has already completed + // and set m_driver to NULL - it is time for us to leave now. We might not + // print the final ^D to stdout in this case. We need to do some re-work on + // how the I/O streams are managed at some point. + if (m_driver == NULL) + { + return; + } + // Use the mutex to make sure OutWrite and ErrWrite do not interfere with each other's output. IOLocker locker (m_output_mutex); if (m_driver->EditlineReaderIsTop() && asynchronous) From gclayton at apple.com Fri Aug 12 01:47:55 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 06:47:55 -0000 Subject: [Lldb-commits] [lldb] r137436 - in /lldb/trunk/source: Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Target/Thread.cpp Message-ID: <20110812064755.311692A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 01:47:54 2011 New Revision: 137436 URL: http://llvm.org/viewvc/llvm-project?rev=137436&view=rev Log: Fixed some issues with parsing C++ methods where our detection was failing if the DWARF was laid out in a certain way. The way we detect C++ classes is now more robust so that a class method can be defined outside of the class and refer to a definition inside the class with a DW_AT_specification or DW_AT_abstract_origin attribute. Fixed a case in Thread.cpp where we were looking up info in the frame when we didn't need to. This was from some changes to support external editors. Now the info is only looked up if needed. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri Aug 12 01:47:54 2011 @@ -851,7 +851,7 @@ } else { - if (mangled_cstr && specification_die_offset != DW_INVALID_OFFSET) + if (specification_die_offset != DW_INVALID_OFFSET) { const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL); if (specification_die) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Aug 12 01:47:54 2011 @@ -1779,6 +1779,23 @@ return false; } +bool +DWARFDebugInfoEntry::Contains (const DWARFDebugInfoEntry *die) const +{ + if (die) + { + const dw_offset_t die_offset = die->GetOffset(); + if (die_offset > GetOffset()) + { + const DWARFDebugInfoEntry *sibling = GetSibling(); + assert (sibling); // TODO: take this out + if (sibling) + return die_offset < sibling->GetOffset(); + } + } + return false; +} + //---------------------------------------------------------------------- // BuildAddressRangeTable //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Fri Aug 12 01:47:54 2011 @@ -109,6 +109,7 @@ { } + bool Contains (const DWARFDebugInfoEntry *die) const; void BuildAddressRangeTable( SymbolFileDWARF* dwarf2Data, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 12 01:47:54 2011 @@ -664,23 +664,35 @@ if (die->Tag() != DW_TAG_subprogram) return NULL; - const DWARFDebugInfoEntry *parent_die = die->GetParent(); - switch (parent_die->Tag()) + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die); + const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); + + switch (containing_decl_kind) { - case DW_TAG_structure_type: - case DW_TAG_class_type: - // We have methods of a class or struct - { - Type *class_type = ResolveType (dwarf_cu, parent_die); - if (class_type) - class_type->GetClangFullType(); - } - break; + case clang::Decl::Record: + case clang::Decl::CXXRecord: + case clang::Decl::ObjCClass: + case clang::Decl::ObjCImplementation: + case clang::Decl::ObjCInterface: + // We have methods of a class or struct + { + const DWARFDebugInfoEntry *containing_decl_die = m_decl_ctx_to_die[containing_decl_ctx]; + assert (containing_decl_die); + Type *class_type = ResolveType (dwarf_cu, containing_decl_die); + if (class_type) + class_type->GetClangFullType(); + // Make sure the class definition contains the funciton DIE + // we wanted to parse. If it does, we are done. Else, we need + // to fall through and parse the function DIE stil... + if (containing_decl_die->Contains (die)) + break; // DIE has been parsed, we are done + } + // Fall through... - default: - // Parse the function prototype as a type that can then be added to concrete function instance - ParseTypes (sc, dwarf_cu, die, false, false); - break; + default: + // Parse the function prototype as a type that can then be added to concrete function instance + ParseTypes (sc, dwarf_cu, die, false, false); + break; } //FixupTypes(); @@ -2403,19 +2415,17 @@ size_t -SymbolFileDWARF::ParseChildParameters -( - const SymbolContext& sc, - TypeSP& type_sp, - DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *parent_die, - bool skip_artificial, - bool &is_static, - TypeList* type_list, - std::vector& function_param_types, - std::vector& function_param_decls, - unsigned &type_quals -) +SymbolFileDWARF::ParseChildParameters (const SymbolContext& sc, + clang::DeclContext *containing_decl_ctx, + TypeSP& type_sp, + DWARFCompileUnit* dwarf_cu, + const DWARFDebugInfoEntry *parent_die, + bool skip_artificial, + bool &is_static, + TypeList* type_list, + std::vector& function_param_types, + std::vector& function_param_decls, + unsigned &type_quals) { if (parent_die == NULL) return 0; @@ -2493,31 +2503,25 @@ // Ugly, but that if (arg_idx == 0) { - const DWARFDebugInfoEntry *grandparent_die = parent_die->GetParent(); - if (grandparent_die && (grandparent_die->Tag() == DW_TAG_structure_type || - grandparent_die->Tag() == DW_TAG_class_type)) + if (containing_decl_ctx->getDeclKind() == clang::Decl::CXXRecord) { - LanguageType language = sc.comp_unit->GetLanguage(); - if (language == eLanguageTypeObjC_plus_plus || language == eLanguageTypeC_plus_plus) + // Often times compilers omit the "this" name for the + // specification DIEs, so we can't rely upon the name + // being in the formal parameter DIE... + if (name == NULL || ::strcmp(name, "this")==0) { - // Often times compilers omit the "this" name for the - // specification DIEs, so we can't rely upon the name - // being in the formal parameter DIE... - if (name == NULL || ::strcmp(name, "this")==0) - { - Type *this_type = ResolveTypeUID (param_type_die_offset); - if (this_type) - { - uint32_t encoding_mask = this_type->GetEncodingMask(); - if (encoding_mask & Type::eEncodingIsPointerUID) - { - is_static = false; - - if (encoding_mask & (1u << Type::eEncodingIsConstUID)) - type_quals |= clang::Qualifiers::Const; - if (encoding_mask & (1u << Type::eEncodingIsVolatileUID)) - type_quals |= clang::Qualifiers::Volatile; - } + Type *this_type = ResolveTypeUID (param_type_die_offset); + if (this_type) + { + uint32_t encoding_mask = this_type->GetEncodingMask(); + if (encoding_mask & Type::eEncodingIsPointerUID) + { + is_static = false; + + if (encoding_mask & (1u << Type::eEncodingIsConstUID)) + type_quals |= clang::Qualifiers::Const; + if (encoding_mask & (1u << Type::eEncodingIsVolatileUID)) + type_quals |= clang::Qualifiers::Volatile; } } } @@ -3620,15 +3624,20 @@ // Parse the function children for the parameters - const DWARFDebugInfoEntry *class_die = die->GetParent(); - if (class_die && (class_die->Tag() == DW_TAG_structure_type || - class_die->Tag() == DW_TAG_class_type)) + clang::DeclContext *containing_decl_ctx = GetClangDeclContextContainingDIE (dwarf_cu, die); + const clang::Decl::Kind containing_decl_kind = containing_decl_ctx->getDeclKind(); + + const bool is_cxx_method = containing_decl_kind == clang::Decl::CXXRecord; + // Start off static. This will be set to false in ParseChildParameters(...) + // if we find a "this" paramters as the first parameter + if (is_cxx_method) is_static = true; if (die->HasChildren()) { bool skip_artificial = true; ParseChildParameters (sc, + containing_decl_ctx, type_sp, dwarf_cu, die, @@ -3650,7 +3659,6 @@ if (type_name_cstr) { bool type_handled = false; - const DWARFDebugInfoEntry *parent_die = die->GetParent(); if (tag == DW_TAG_subprogram) { if (type_name_cstr[1] == '[' && (type_name_cstr[0] == '-' || type_name_cstr[0] == '+')) @@ -3698,13 +3706,12 @@ type_handled = objc_method_decl != NULL; } } - else if (parent_die->Tag() == DW_TAG_class_type || - parent_die->Tag() == DW_TAG_structure_type) + else if (is_cxx_method) { // Look at the parent of this DIE and see if is is // a class or struct and see if this is actually a // C++ method - Type *class_type = ResolveType (dwarf_cu, parent_die); + Type *class_type = ResolveType (dwarf_cu, m_decl_ctx_to_die[containing_decl_ctx]); if (class_type) { clang_type_t class_opaque_type = class_type->GetClangForwardType(); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Aug 12 01:47:54 2011 @@ -278,6 +278,7 @@ size_t ParseChildParameters( const lldb_private::SymbolContext& sc, + clang::DeclContext *containing_decl_ctx, lldb::TypeSP& type_sp, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *parent_die, Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=137436&r1=137435&r2=137436&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Aug 12 01:47:54 2011 @@ -1116,14 +1116,14 @@ size_t num_frames_shown = 0; strm.Indent(); strm.Printf("%c ", GetProcess().GetThreadList().GetSelectedThread().get() == this ? '*' : ' '); - - StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame); - SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); - if (frame_sc.line_entry.line != 0 && - frame_sc.line_entry.file && - GetProcess().GetTarget().GetDebugger().GetUseExternalEditor()) + if (GetProcess().GetTarget().GetDebugger().GetUseExternalEditor()) { - Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + StackFrameSP frame_sp = GetStackFrameAtIndex(start_frame); + SymbolContext frame_sc(frame_sp->GetSymbolContext (eSymbolContextLineEntry)); + if (frame_sc.line_entry.line != 0 && frame_sc.line_entry.file) + { + Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); + } } DumpUsingSettingsFormat (strm, start_frame); From gclayton at apple.com Fri Aug 12 02:35:23 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 07:35:23 -0000 Subject: [Lldb-commits] [lldb] r137438 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110812073523.5BCE42A6C12D@llvm.org> Author: gclayton Date: Fri Aug 12 02:35:23 2011 New Revision: 137438 URL: http://llvm.org/viewvc/llvm-project?rev=137438&view=rev Log: Fixed an assertion issue that can arise when a function is contained inside a function. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=137438&r1=137437&r2=137438&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 12 02:35:23 2011 @@ -1022,7 +1022,7 @@ switch (tag) { case DW_TAG_inlined_subroutine: - case DW_TAG_subprogram: + //case DW_TAG_subprogram: case DW_TAG_lexical_block: { DWARFDebugRanges::RangeList ranges; From gclayton at apple.com Fri Aug 12 11:22:48 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 16:22:48 -0000 Subject: [Lldb-commits] [lldb] r137461 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110812162248.485BB2A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 11:22:48 2011 New Revision: 137461 URL: http://llvm.org/viewvc/llvm-project?rev=137461&view=rev Log: Backout previous fix that was designed to allow functions within functions as this function is what parses the blocks for a function... Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=137461&r1=137460&r2=137461&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 12 11:22:48 2011 @@ -1022,7 +1022,7 @@ switch (tag) { case DW_TAG_inlined_subroutine: - //case DW_TAG_subprogram: + case DW_TAG_subprogram: case DW_TAG_lexical_block: { DWARFDebugRanges::RangeList ranges; From granata.enrico at gmail.com Fri Aug 12 11:42:31 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 12 Aug 2011 16:42:31 -0000 Subject: [Lldb-commits] [lldb] r137462 - in /lldb/trunk: include/lldb/Interpreter/CommandInterpreter.h source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectTarget.cpp source/Core/ValueObject.cpp Message-ID: <20110812164231.A5D4C2A6C12C@llvm.org> Author: enrico Date: Fri Aug 12 11:42:31 2011 New Revision: 137462 URL: http://llvm.org/viewvc/llvm-project?rev=137462&view=rev Log: Giving a warning to the user the first time children are truncated by the new cap setting Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=137462&r1=137461&r2=137462&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Fri Aug 12 11:42:31 2011 @@ -39,6 +39,13 @@ eBroadcastBitAsynchronousOutputData = (1 << 3), eBroadcastBitAsynchronousErrorData = (1 << 4) }; + + enum ChildrenTruncatedWarningStatus // tristate boolean to manage children truncation warning + { + eNoTruncation = 0, // never truncated + eUnwarnedTruncation = 1, // truncated but did not notify + eWarnedTruncation = 2 // truncated and notified + }; void SourceInitFile (bool in_cwd, @@ -385,6 +392,31 @@ void SetBatchCommandMode (bool value) { m_batch_command_mode = value; } + + void + ChildrenTruncated() + { + if (m_truncation_warning == eNoTruncation) + m_truncation_warning = eUnwarnedTruncation; + } + + bool + TruncationWarningNecessary() + { + return (m_truncation_warning == eUnwarnedTruncation); + } + + void + TruncationWarningGiven() + { + m_truncation_warning = eWarnedTruncation; + } + + const char * + TruncationWarningText() + { + return "*** Some of your variables have more members than the debugger will show by default. To show all of them, you can either use the --show-all-children option to %s or raise the limit by changing the target.max-children-count setting.\n"; + } protected: friend class Debugger; @@ -411,6 +443,7 @@ char m_comment_char; char m_repeat_char; bool m_batch_command_mode; + ChildrenTruncatedWarningStatus m_truncation_warning; // Whether we truncated children and whether the user has been told }; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=137462&r1=137461&r2=137462&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Aug 12 11:42:31 2011 @@ -660,6 +660,14 @@ result.SetStatus (eReturnStatusSuccessFinishResult); } } + + if (m_interpreter.TruncationWarningNecessary()) + { + result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(), + m_cmd_name.c_str()); + m_interpreter.TruncationWarningGiven(); + } + return result.Succeeded(); } protected: Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=137462&r1=137461&r2=137462&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Aug 12 11:42:31 2011 @@ -717,6 +717,14 @@ result.SetStatus (eReturnStatusFailed); return false; } + + if (m_interpreter.TruncationWarningNecessary()) + { + result.GetOutputStream().Printf(m_interpreter.TruncationWarningText(), + m_cmd_name.c_str()); + m_interpreter.TruncationWarningGiven(); + } + return result.Succeeded(); } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137462&r1=137461&r2=137462&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 12 11:42:31 2011 @@ -31,6 +31,7 @@ #include "lldb/Host/Endian.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/ScriptInterpreterPython.h" #include "lldb/Symbol/ClangASTType.h" @@ -2915,7 +2916,10 @@ if (!flat_output) { if (print_dotdotdot) + { + valobj->GetUpdatePoint().GetTargetSP()->GetDebugger().GetCommandInterpreter().ChildrenTruncated(); s.Indent("...\n"); + } s.IndentLess(); s.Indent("}\n"); } From gclayton at apple.com Fri Aug 12 12:54:33 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 17:54:33 -0000 Subject: [Lldb-commits] [lldb] r137475 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: SymbolFileDWARF.cpp SymbolFileDWARF.h Message-ID: <20110812175433.6F5EA2A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 12:54:33 2011 New Revision: 137475 URL: http://llvm.org/viewvc/llvm-project?rev=137475&view=rev Log: Fixed the issue of a DW_TAG_subprogram in a DW_TAG_subprogram correctly this time after recently backing out another fix. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=137475&r1=137474&r2=137475&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 12 12:54:33 2011 @@ -1010,8 +1010,7 @@ DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, addr_t subprogram_low_pc, - bool parse_siblings, - bool parse_children + uint32_t depth ) { size_t blocks_added = 0; @@ -1025,20 +1024,27 @@ case DW_TAG_subprogram: case DW_TAG_lexical_block: { - DWARFDebugRanges::RangeList ranges; - const char *name = NULL; - const char *mangled_name = NULL; Block *block = NULL; - if (tag != DW_TAG_subprogram) + if (tag == DW_TAG_subprogram) { - BlockSP block_sp(new Block (die->GetOffset())); - parent_block->AddChild(block_sp); - block = block_sp.get(); + // Skip any DW_TAG_subprogram DIEs that are inside + // of a normal or inlined functions. These will be + // parsed on their own as separate entities. + + if (depth > 0) + break; + + block = parent_block; } else { - block = parent_block; + BlockSP block_sp(new Block (die->GetOffset())); + parent_block->AddChild(block_sp); + block = block_sp.get(); } + DWARFDebugRanges::RangeList ranges; + const char *name = NULL; + const char *mangled_name = NULL; int decl_file = 0; int decl_line = 0; @@ -1094,15 +1100,14 @@ ++blocks_added; - if (parse_children && die->HasChildren()) + if (die->HasChildren()) { blocks_added += ParseFunctionBlocks (sc, block, dwarf_cu, die->GetFirstChild(), subprogram_low_pc, - true, - true); + depth + 1); } } } @@ -1111,10 +1116,14 @@ break; } - if (parse_siblings) - die = die->GetSibling(); - else + // Only parse siblings of the block if we are not at depth zero. A depth + // of zero indicates we are currently parsing the top level + // DW_TAG_subprogram DIE + + if (depth == 0) die = NULL; + else + die = die->GetSibling(); } return blocks_added; } @@ -4020,7 +4029,7 @@ const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(function_die_offset); if (function_die) { - ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, false, true); + ParseFunctionBlocks(sc, &sc.function->GetBlock (false), dwarf_cu, function_die, LLDB_INVALID_ADDRESS, 0); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=137475&r1=137474&r2=137475&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Aug 12 12:54:33 2011 @@ -244,8 +244,7 @@ DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, lldb::addr_t subprogram_low_pc, - bool parse_siblings, - bool parse_children); + uint32_t depth); size_t ParseTypes (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children); lldb::TypeSP ParseType (const lldb_private::SymbolContext& sc, DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die, bool *type_is_new); From johnny.chen at apple.com Fri Aug 12 12:59:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 17:59:58 -0000 Subject: [Lldb-commits] [lldb] r137477 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110812175958.734102A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 12:59:58 2011 New Revision: 137477 URL: http://llvm.org/viewvc/llvm-project?rev=137477&view=rev Log: Fix a logic error (Division by zero) uncovered by the static analyzer. A8.6.391 VST1 (multiple single elements) alignment = if align == '00' then 1 else 4 << UInt(align); Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=137477&r1=137476&r2=137477&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Fri Aug 12 12:59:58 2011 @@ -11640,7 +11640,7 @@ // alignment = if align == ?00? then 1 else 4 << UInt(align); if (align == 0) - alignment = 0; + alignment = 1; else alignment = 4 << align; From granata.enrico at gmail.com Fri Aug 12 13:43:16 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 12 Aug 2011 18:43:16 -0000 Subject: [Lldb-commits] [lldb] r137490 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20110812184316.38EB62A6C12C@llvm.org> Author: enrico Date: Fri Aug 12 13:43:16 2011 New Revision: 137490 URL: http://llvm.org/viewvc/llvm-project?rev=137490&view=rev Log: Taking care of an issue relating to mapping DeclContext's to DIE's Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=137490&r1=137489&r2=137490&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Aug 12 13:43:16 2011 @@ -2952,6 +2952,7 @@ if (type) { decl_ctx = ClangASTContext::GetDeclContextForType (type->GetClangForwardType ()); + LinkDeclContextToDIE (decl_ctx, die); if (decl_ctx) return decl_ctx; } From johnny.chen at apple.com Fri Aug 12 13:54:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 18:54:11 -0000 Subject: [Lldb-commits] [lldb] r137492 - /lldb/trunk/test/dotest.py Message-ID: <20110812185411.5EA582A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 13:54:11 2011 New Revision: 137492 URL: http://llvm.org/viewvc/llvm-project?rev=137492&view=rev Log: When running dotest.py under pdb (the python debugger), define DOTEST_PDB=YES and DOTEST_SCRIPT_DIR=/path/leading/to/your/dotest/script/directory. 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=137492&r1=137491&r2=137492&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Aug 12 13:54:11 2011 @@ -521,7 +521,7 @@ global svn_info # Get the directory containing the current script. - if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ: + if ("DOTEST_PROFILE" in os.environ or "DOTEST_PDB" in os.environ) and "DOTEST_SCRIPT_DIR" in os.environ: scriptPath = os.environ["DOTEST_SCRIPT_DIR"] else: scriptPath = sys.path[0] From granata.enrico at gmail.com Fri Aug 12 14:14:27 2011 From: granata.enrico at gmail.com (Enrico Granata) Date: Fri, 12 Aug 2011 19:14:27 -0000 Subject: [Lldb-commits] [lldb] r137493 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/FormatManager.h source/Commands/CommandObjectType.cpp source/Core/Debugger.cpp source/Core/ValueObject.cpp test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Message-ID: <20110812191427.6E0AF2A6C12C@llvm.org> Author: enrico Date: Fri Aug 12 14:14:27 2011 New Revision: 137493 URL: http://llvm.org/viewvc/llvm-project?rev=137493&view=rev Log: Added an error message when the user tries to add a filter when a synthetic provider for the same type is already defined in the same category The converse is also true: an error is shown when the user tries to add a synthetic provider to a category that already has a filter for the same type Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/source/Commands/CommandObjectType.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Fri Aug 12 14:14:27 2011 @@ -512,9 +512,16 @@ lldb::DynamicValueType use_dynamic, lldb::SummaryFormatSP& entry); static bool - GetSyntheticFilter(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry); + GetSyntheticChildren(ValueObject& vobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry); + + static bool + AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL); class NamedSummaryFormats { Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Fri Aug 12 14:14:27 2011 @@ -608,8 +608,10 @@ class FormatCategory { private: + typedef FormatNavigator SummaryNavigator; typedef FormatNavigator RegexSummaryNavigator; + typedef FormatNavigator FilterNavigator; typedef FormatNavigator RegexFilterNavigator; @@ -655,6 +657,15 @@ friend class CategoryMap; + friend class FormatNavigator; + friend class FormatNavigator; + + friend class FormatNavigator; + friend class FormatNavigator; + + friend class FormatNavigator; + friend class FormatNavigator; + public: enum FormatCategoryItem @@ -824,17 +835,17 @@ void Clear(FormatCategoryItems items = ALL_ITEM_TYPES) { - if ( (items & eSummary) ) + if ( (items & eSummary) == eSummary ) m_summary_nav->Clear(); - if ( (items & eRegexSummary) ) + if ( (items & eRegexSummary) == eRegexSummary ) m_regex_summary_nav->Clear(); - if ( (items & eFilter) ) + if ( (items & eFilter) == eFilter ) m_filter_nav->Clear(); - if ( (items & eRegexFilter) ) + if ( (items & eRegexFilter) == eRegexFilter ) m_regex_filter_nav->Clear(); - if ( (items & eSynth) ) + if ( (items & eSynth) == eSynth ) m_synth_nav->Clear(); - if ( (items & eRegexSynth) ) + if ( (items & eRegexSynth) == eRegexSynth ) m_regex_synth_nav->Clear(); } @@ -843,17 +854,17 @@ FormatCategoryItems items = ALL_ITEM_TYPES) { bool success = false; - if ( (items & eSummary) ) + if ( (items & eSummary) == eSummary ) success = m_summary_nav->Delete(name) || success; - if ( (items & eRegexSummary) ) + if ( (items & eRegexSummary) == eRegexSummary ) success = m_regex_summary_nav->Delete(name) || success; - if ( (items & eFilter) ) + if ( (items & eFilter) == eFilter ) success = m_filter_nav->Delete(name) || success; - if ( (items & eRegexFilter) ) + if ( (items & eRegexFilter) == eRegexFilter ) success = m_regex_filter_nav->Delete(name) || success; - if ( (items & eSynth) ) + if ( (items & eSynth) == eSynth ) success = m_synth_nav->Delete(name) || success; - if ( (items & eRegexSynth) ) + if ( (items & eRegexSynth) == eRegexSynth ) success = m_regex_synth_nav->Delete(name) || success; return success; } @@ -862,17 +873,17 @@ GetCount(FormatCategoryItems items = ALL_ITEM_TYPES) { uint32_t count = 0; - if ( (items & eSummary) ) + if ( (items & eSummary) == eSummary ) count += m_summary_nav->GetCount(); - if ( (items & eRegexSummary) ) + if ( (items & eRegexSummary) == eRegexSummary ) count += m_regex_summary_nav->GetCount(); - if ( (items & eFilter) ) + if ( (items & eFilter) == eFilter ) count += m_filter_nav->GetCount(); - if ( (items & eRegexFilter) ) + if ( (items & eRegexFilter) == eRegexFilter ) count += m_regex_filter_nav->GetCount(); - if ( (items & eSynth) ) + if ( (items & eSynth) == eSynth ) count += m_synth_nav->GetCount(); - if ( (items & eRegexSynth) ) + if ( (items & eRegexSynth) == eRegexSynth ) count += m_regex_synth_nav->GetCount(); return count; } @@ -883,6 +894,89 @@ return m_name; } + bool + AnyMatches(ConstString type_name, + FormatCategoryItems items = ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategoryItems* matching_type = NULL) + { + if (!IsEnabled() && only_enabled) + return false; + + SummaryFormat::SharedPointer summary; + SyntheticFilter::SharedPointer filter; + SyntheticScriptProvider::SharedPointer synth; + + if ( (items & eSummary) == eSummary ) + { + if (m_summary_nav->Get(type_name.AsCString(), summary)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eSummary; + return true; + } + } + if ( (items & eRegexSummary) == eRegexSummary ) + { + if (m_regex_summary_nav->Get(type_name.AsCString(), summary)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexSummary; + return true; + } + } + if ( (items & eFilter) == eFilter ) + { + if (m_filter_nav->Get(type_name.AsCString(), filter)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eFilter; + return true; + } + } + if ( (items & eRegexFilter) == eRegexFilter ) + { + if (m_regex_filter_nav->Get(type_name.AsCString(), filter)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexFilter; + return true; + } + } + if ( (items & eSynth) == eSynth ) + { + if (m_synth_nav->Get(type_name.AsCString(), synth)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eSynth; + return true; + } + } + if ( (items & eRegexSynth) == eRegexSynth ) + { + if (m_regex_synth_nav->Get(type_name.AsCString(), synth)) + { + if (matching_category) + *matching_category = m_name.c_str(); + if (matching_type) + *matching_type = eRegexSynth; + return true; + } + } + return false; + } + typedef lldb::SharedPtr::Type SharedPointer; }; @@ -1052,6 +1146,28 @@ } } + bool + AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL) + { + Mutex::Locker(m_map_mutex); + + MapIterator pos, end = m_map.end(); + for (pos = m_map.begin(); pos != end; pos++) + { + if (pos->second->AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type)) + return true; + } + return false; + } + uint32_t GetCount() { @@ -1265,6 +1381,20 @@ { return m_categories_map.Get(vobj, entry, use_dynamic); } + + bool + AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items = FormatCategory::ALL_ITEM_TYPES, + bool only_enabled = true, + const char** matching_category = NULL, + FormatCategory::FormatCategoryItems* matching_type = NULL) + { + return m_categories_map.AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type); + } static bool GetFormatFromCString (const char *format_cstr, Modified: lldb/trunk/source/Commands/CommandObjectType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectType.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectType.cpp Fri Aug 12 14:14:27 2011 @@ -3018,15 +3018,24 @@ lldb::FormatCategorySP category; Debugger::Formatting::Categories::Get(ConstString(options->m_category.c_str()), category); + Error error; + for (size_t i = 0; i < options->m_target_types.GetSize(); i++) { const char *type_name = options->m_target_types.GetStringAtIndex(i); ConstString typeCS(type_name); if (typeCS) - CommandObjectTypeSynthAdd::AddSynth(typeCS, - synth_provider, - options->m_regex ? CommandObjectTypeSynthAdd::eRegexSynth : CommandObjectTypeSynthAdd::eRegularSynth, - options->m_category, - NULL); + { + if (!CommandObjectTypeSynthAdd::AddSynth(typeCS, + synth_provider, + options->m_regex ? CommandObjectTypeSynthAdd::eRegexSynth : CommandObjectTypeSynthAdd::eRegularSynth, + options->m_category, + &error)) + { + out_stream->Printf("%s\n", error.AsCString()); + out_stream->Flush(); + return; + } + } else { out_stream->Printf ("Internal error #6: no script attached.\n"); @@ -3126,15 +3135,24 @@ lldb::FormatCategorySP category; Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + Error error; + for (size_t i = 0; i < argc; i++) { const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) - AddSynth(typeCS, - entry, - m_options.m_regex ? eRegexSynth : eRegularSynth, - m_options.m_category, - NULL); + { + if (!AddSynth(typeCS, + entry, + m_options.m_regex ? eRegexSynth : eRegularSynth, + m_options.m_category, + &error)) + { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + } else { result.AppendError("empty typenames not allowed"); @@ -3175,6 +3193,15 @@ lldb::FormatCategorySP category; Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); + if (category->AnyMatches(type_name, + FormatCategory::eFilter | FormatCategory::eRegexFilter, + false)) + { + if (error) + error->SetErrorStringWithFormat("cannot add synthetic for type %s when filter is defined in same category!", type_name.AsCString()); + return false; + } + if (type == eRegexSynth) { RegularExpressionSP typeRX(new RegularExpression()); @@ -3327,23 +3354,32 @@ return &m_options; } - enum SynthFormatType + enum FilterFormatType { - eRegularSynth, - eRegexSynth, + eRegularFilter, + eRegexFilter, }; bool - AddSynth(const ConstString& type_name, - SyntheticChildrenSP entry, - SynthFormatType type, - std::string category_name, - Error* error) + AddFilter(const ConstString& type_name, + SyntheticChildrenSP entry, + FilterFormatType type, + std::string category_name, + Error* error) { lldb::FormatCategorySP category; Debugger::Formatting::Categories::Get(ConstString(category_name.c_str()), category); - if (type == eRegexSynth) + if (category->AnyMatches(type_name, + FormatCategory::eSynth | FormatCategory::eRegexSynth, + false)) + { + if (error) + error->SetErrorStringWithFormat("cannot add filter for type %s when synthetic is defined in same category!", type_name.AsCString()); + return false; + } + + if (type == eRegexFilter) { RegularExpressionSP typeRX(new RegularExpression()); if (!typeRX->Compile(type_name.GetCString())) @@ -3430,15 +3466,24 @@ lldb::FormatCategorySP category; Debugger::Formatting::Categories::Get(ConstString(m_options.m_category.c_str()), category); + Error error; + for (size_t i = 0; i < argc; i++) { const char* typeA = command.GetArgumentAtIndex(i); ConstString typeCS(typeA); if (typeCS) - AddSynth(typeCS, - entry, - m_options.m_regex ? eRegexSynth : eRegularSynth, - m_options.m_category, - NULL); + { + if (!AddFilter(typeCS, + entry, + m_options.m_regex ? eRegexFilter : eRegularFilter, + m_options.m_category, + &error)) + { + result.AppendError(error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; + } + } else { result.AppendError("empty typenames not allowed"); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Aug 12 14:14:27 2011 @@ -1837,14 +1837,28 @@ return GetFormatManager().Get(vobj, entry, use_dynamic); } bool -Debugger::Formatting::GetSyntheticFilter(ValueObject& vobj, - lldb::DynamicValueType use_dynamic, - lldb::SyntheticChildrenSP& entry) +Debugger::Formatting::GetSyntheticChildren(ValueObject& vobj, + lldb::DynamicValueType use_dynamic, + lldb::SyntheticChildrenSP& entry) { return GetFormatManager().Get(vobj, entry, use_dynamic); } bool +Debugger::Formatting::AnyMatches(ConstString type_name, + FormatCategory::FormatCategoryItems items, + bool only_enabled, + const char** matching_category, + FormatCategory::FormatCategoryItems* matching_type) +{ + return GetFormatManager().AnyMatches(type_name, + items, + only_enabled, + matching_category, + matching_type); +} + +bool Debugger::Formatting::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) { entry = GetFormatManager().Category(category.GetCString()); Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 12 14:14:27 2011 @@ -243,7 +243,7 @@ Debugger::Formatting::ValueFormats::Get(*this, lldb::eNoDynamicValues, m_last_value_format); Debugger::Formatting::GetSummaryFormat(*this, use_dynamic, m_last_summary_format); - Debugger::Formatting::GetSyntheticFilter(*this, use_dynamic, m_last_synthetic_filter); + Debugger::Formatting::GetSyntheticChildren(*this, use_dynamic, m_last_synthetic_filter); m_last_format_mgr_revision = Debugger::Formatting::ValueFormats::GetCurrentRevision(); m_last_format_mgr_dynamic = use_dynamic; Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py?rev=137493&r1=137492&r2=137493&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py Fri Aug 12 14:14:27 2011 @@ -136,18 +136,48 @@ 'fake_a = 218103808', 'a = 12']) - # now mix synth and filter and check consistent output - self.runCmd("type filter add foo --child b --child j") - self.expect('frame variable f00_1', + # now add a filter.. it should fail + self.expect("type filter add foo --child b --child j", error=True, + substrs = ['cannot add']) + + # we get the synth again.. + self.expect('frame variable f00_1', matching=False, substrs = ['b = 1', 'j = 17']) + self.expect("frame variable -P 1 f00_ptr", + substrs = ['r = 45', + 'fake_a = 218103808', + 'a = 12']) + + # now delete the synth and add the filter + self.runCmd("type synth delete foo") + self.runCmd("type filter add foo --child b --child j") + + self.expect('frame variable f00_1', + substrs = ['b = 1', + 'j = 17']) self.expect("frame variable -P 1 f00_ptr", matching=False, substrs = ['r = 45', 'fake_a = 218103808', 'a = 12']) - # now add the synth again to see that it prevails + # now add the synth and it should fail + self.expect("type synth add -l fooSynthProvider foo", error=True, + substrs = ['cannot add']) + + # check the listing + self.expect('type synth list', matching=False, + substrs = ['foo', + 'Python class fooSynthProvider']) + self.expect('type filter list', + substrs = ['foo', + '.b', + '.j']) + + # delete the filter, add the synth + self.runCmd("type filter delete foo") self.runCmd("type synth add -l fooSynthProvider foo") + self.expect('frame variable f00_1', matching=False, substrs = ['b = 1', 'j = 17']) @@ -160,7 +190,7 @@ self.expect('type synth list', substrs = ['foo', 'Python class fooSynthProvider']) - self.expect('type filter list', + self.expect('type filter list', matching=False, substrs = ['foo', '.b', '.j']) @@ -168,19 +198,6 @@ # delete the synth and check that we get good output self.runCmd("type synth delete foo") - # first let the filter win - self.expect('frame variable f00_1', - substrs = ['b = 1', - 'j = 17']) - self.expect("frame variable -P 1 f00_ptr", matching=False, - substrs = ['r = 45', - 'fake_a = 218103808', - 'a = 12']) - - # then delete the filter - self.runCmd("type filter delete foo") - - # and show real children self.expect("frame variable f00_1", substrs = ['a = 280', 'b = 1', @@ -451,7 +468,11 @@ self.runCmd("frame variable ii -T") self.runCmd("script from StdMapSynthProvider import *") - self.runCmd("type summary add -x \"std::map<\" -f \"map has ${svar%#} items\" -e") + self.runCmd("type summary add -x \"std::map<\" -f \"map has ${svar%#} items\" -e") + + #import time + #time.sleep(30) + self.runCmd("type synth add -x \"std::map<\" -l StdMapSynthProvider") From johnny.chen at apple.com Fri Aug 12 15:19:22 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 20:19:22 -0000 Subject: [Lldb-commits] [lldb] r137500 - in /lldb/trunk/test: functionalities/inferior-changed/ functionalities/inferior-changed/Makefile functionalities/inferior-changed/TestInferiorChanged.py functionalities/inferior-changed/main.c functionalities/inferior-changed/main2.c lldbtest.py Message-ID: <20110812201922.EE6132A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 15:19:22 2011 New Revision: 137500 URL: http://llvm.org/viewvc/llvm-project?rev=137500&view=rev Log: Add TestInferiorChanged.py to test that lldb reloads the inferior after it was changed during the debug session. First, main.c causes a crash, the inferior then gets re-built with main2.c which is not crashing. Add Base.cleanup(self, dictionary=None) for platform specfic way to do cleanup after build. This plugin method is used by the above test case to cleanup the main.c build before rebuild for main2.c. Added: lldb/trunk/test/functionalities/inferior-changed/ lldb/trunk/test/functionalities/inferior-changed/Makefile lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py lldb/trunk/test/functionalities/inferior-changed/main.c lldb/trunk/test/functionalities/inferior-changed/main2.c Modified: lldb/trunk/test/lldbtest.py Added: lldb/trunk/test/functionalities/inferior-changed/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/Makefile?rev=137500&view=auto ============================================================================== --- lldb/trunk/test/functionalities/inferior-changed/Makefile (added) +++ lldb/trunk/test/functionalities/inferior-changed/Makefile Fri Aug 12 15:19:22 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py?rev=137500&view=auto ============================================================================== --- lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py (added) +++ lldb/trunk/test/functionalities/inferior-changed/TestInferiorChanged.py Fri Aug 12 15:19:22 2011 @@ -0,0 +1,90 @@ +"""Test lldb reloads the inferior after it was changed during the session.""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class ChangedInferiorTestCase(TestBase): + + mydir = os.path.join("functionalities", "inferior-changed") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_inferior_crashing_dsym(self): + """Test lldb reloads the inferior after it was changed during the session.""" + self.buildDsym() + self.inferior_crashing() + self.cleanup() + d = {'C_SOURCES': 'main2.c'} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.inferior_not_crashing() + + def test_inferior_crashing_dwarf(self): + """Test lldb reloads the inferior after it was changed during the session.""" + self.buildDwarf() + self.inferior_crashing() + self.cleanup() + d = {'C_SOURCES': 'main2.c'} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.inferior_not_crashing() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number of the crash. + self.line1 = line_number('main.c', '// Crash here.') + self.line2 = line_number('main2.c', '// Not crash here.') + + def inferior_crashing(self): + """Inferior crashes upon launching; lldb should catch the event and stop.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be a bad access exception. + self.expect("thread list", STOPPED_DUE_TO_EXC_BAD_ACCESS, + substrs = ['stopped', + 'stop reason = EXC_BAD_ACCESS']) + + # And it should report the correct line number. + self.expect("thread backtrace all", + substrs = ['stop reason = EXC_BAD_ACCESS', + 'main.c:%d' % self.line1]) + + def inferior_not_crashing(self): + """Test lldb reloads the inferior after it was changed during the session.""" + self.runCmd("process kill") + self.runCmd("run", RUN_SUCCEEDED) + self.runCmd("process status") + + if 'EXC_BAD_ACCESS' in self.res.GetOutput(): + self.fail("Inferior changed, but lldb did not perform a reload") + + # Break inside the main. + self.expect("breakpoint set -f main2.c -l %d" % self.line2, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main2.c', line = %d, locations = 1" % + self.line2) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'stop reason = breakpoint']) + + self.runCmd("frame variable int_ptr") + self.expect("frame variable *int_ptr", + substrs = ['= 7']) + self.expect("expression *int_ptr", + substrs = ['= 7']) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/functionalities/inferior-changed/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/main.c?rev=137500&view=auto ============================================================================== --- lldb/trunk/test/functionalities/inferior-changed/main.c (added) +++ lldb/trunk/test/functionalities/inferior-changed/main.c Fri Aug 12 15:19:22 2011 @@ -0,0 +1,16 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +int main(int argc, const char* argv[]) +{ + int *null_ptr = 0; + printf("Hello, segfault!\n"); + printf("Now crash %d\n", *null_ptr); // Crash here. +} Added: lldb/trunk/test/functionalities/inferior-changed/main2.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/inferior-changed/main2.c?rev=137500&view=auto ============================================================================== --- lldb/trunk/test/functionalities/inferior-changed/main2.c (added) +++ lldb/trunk/test/functionalities/inferior-changed/main2.c Fri Aug 12 15:19:22 2011 @@ -0,0 +1,18 @@ +//===-- main2.c -------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include + +int main(int argc, const char* argv[]) +{ + int *int_ptr = (int *)malloc(sizeof(int)); + *int_ptr = 7; + printf("Hello, world!\n"); + printf("Now not crash %d\n", *int_ptr); // Not crash here. +} Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=137500&r1=137499&r2=137500&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Aug 12 15:19:22 2011 @@ -770,6 +770,12 @@ if not module.buildDwarf(self, architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dwarf") + def cleanup(self, dictionary=None): + """Platform specific way to do cleanup after build.""" + module = builder_module() + if not module.cleanup(self, dictionary): + raise Exception("Don't know how to do cleanup") + class TestBase(Base): """ From johnny.chen at apple.com Fri Aug 12 15:39:00 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 20:39:00 -0000 Subject: [Lldb-commits] [lldb] r137503 - /lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Message-ID: <20110812203900.8A5F52A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 15:39:00 2011 New Revision: 137503 URL: http://llvm.org/viewvc/llvm-project?rev=137503&view=rev Log: Skip the TestObjCDymaicValue.py tests for i386 due to dynamic types for ObjC V1 runtime not implemented yet. Radar to be filed. Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py?rev=137503&r1=137502&r2=137503&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Fri Aug 12 15:39:00 2011 @@ -16,12 +16,16 @@ @python_api_test def test_get_dynamic_objc_vals_with_dsym(self): """Test fetching ObjC dynamic values.""" + if self.getArchitecture() == 'i386': + self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.buildDsym() self.do_get_dynamic_vals() @python_api_test def test_get_objc_dynamic_vals_with_dwarf(self): """Test fetching ObjC dynamic values.""" + if self.getArchitecture() == 'i386': + self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.buildDwarf() self.do_get_dynamic_vals() From johnny.chen at apple.com Fri Aug 12 15:41:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 20:41:20 -0000 Subject: [Lldb-commits] [lldb] r137504 - /lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Message-ID: <20110812204120.A947D2A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 15:41:20 2011 New Revision: 137504 URL: http://llvm.org/viewvc/llvm-project?rev=137504&view=rev Log: Add radar info for self.skipTest(). Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Modified: lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py?rev=137504&r1=137503&r2=137504&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py (original) +++ lldb/trunk/test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py Fri Aug 12 15:41:20 2011 @@ -17,6 +17,7 @@ def test_get_dynamic_objc_vals_with_dsym(self): """Test fetching ObjC dynamic values.""" if self.getArchitecture() == 'i386': + # rdar://problem/9946499 self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.buildDsym() self.do_get_dynamic_vals() @@ -25,6 +26,7 @@ def test_get_objc_dynamic_vals_with_dwarf(self): """Test fetching ObjC dynamic values.""" if self.getArchitecture() == 'i386': + # rdar://problem/9946499 self.skipTest("Dynamic types for ObjC V1 runtime not implemented") self.buildDwarf() self.do_get_dynamic_vals() From gclayton at apple.com Fri Aug 12 16:40:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 21:40:01 -0000 Subject: [Lldb-commits] [lldb] r137516 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ include/lldb/Utility/ source/API/ source/Core/ source/Expression/ source/Symbol/ source/Target/ Message-ID: <20110812214002.771C52A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 16:40:01 2011 New Revision: 137516 URL: http://llvm.org/viewvc/llvm-project?rev=137516&view=rev Log: We were leaking a stack frame in StackFrameList in Thread.cpp which could cause extra shared pointer references to one or more modules to be leaked. This would cause many object files to stay around the life of LLDB, so after a recompile and rexecution, we would keep adding more and more memory. After fixing the leak, we found many cases where leaked stack frames were still being used and causing crashes in the test suite. These are now all resolved. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBLineEntry.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/Core/Address.h lldb/trunk/include/lldb/Core/FormatManager.h lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Symbol/CompileUnit.h lldb/trunk/include/lldb/Symbol/Function.h lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/include/lldb/Symbol/SymbolContextScope.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadPlanTracer.h lldb/trunk/include/lldb/Utility/SharingPtr.h lldb/trunk/include/lldb/lldb-types.h lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Fri Aug 12 16:40:01 2011 @@ -57,8 +57,43 @@ SectionType GetSectionType (); + // The following queries can lookup symbol information for a given address. + // An address might refer to code or data from an existing module, or it + // might refer to something on the stack or heap. The following functions + // will only return valid values if the address has been resolved to a code + // or data address using "void SBAddress::SetLoadAddress(...)" or + // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)". + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope); + + + // The following functions grab individual objects for a given address and + // are less efficient if you want more than one symbol related objects. + // Use one of the following when you want multiple debug symbol related + // objects for an address: + // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); + // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); + // One or more bits from the SymbolContextItem enumerations can be logically + // OR'ed together to more efficiently retrieve multiple symbol objects. + lldb::SBModule GetModule (); + + lldb::SBCompileUnit + GetCompileUnit (); + + lldb::SBFunction + GetFunction (); + + lldb::SBBlock + GetBlock (); + + lldb::SBSymbol + GetSymbol (); + + lldb::SBLineEntry + GetLineEntry (); + protected: Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Fri Aug 12 16:40:01 2011 @@ -60,6 +60,7 @@ GetDescription (lldb::SBStream &description); private: + friend class SBAddress; friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Fri Aug 12 16:40:01 2011 @@ -61,6 +61,7 @@ GetDescription (lldb::SBStream &description); private: + friend class SBAddress; friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Fri Aug 12 16:40:01 2011 @@ -77,6 +77,7 @@ #endif private: + friend class SBAddress; friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBLineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBLineEntry.h (original) +++ lldb/trunk/include/lldb/API/SBLineEntry.h Fri Aug 12 16:40:01 2011 @@ -67,6 +67,7 @@ get (); private: + friend class SBAddress; friend class SBCompileUnit; friend class SBFrame; 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=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Fri Aug 12 16:40:01 2011 @@ -79,6 +79,7 @@ #endif private: + friend class SBAddress; friend class SBFrame; friend class SBModule; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Fri Aug 12 16:40:01 2011 @@ -48,6 +48,7 @@ GetDescription (lldb::SBStream &description); protected: + friend class SBAddress; friend class SBFrame; friend class SBModule; friend class SBThread; Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Fri Aug 12 16:40:01 2011 @@ -496,8 +496,27 @@ /// /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*) //------------------------------------------------------------------ - void - CalculateSymbolContext (SymbolContext *sc); + uint32_t + CalculateSymbolContext (SymbolContext *sc, + uint32_t resolve_scope = lldb::eSymbolContextEverything); + + Module * + CalculateSymbolContextModule (); + + CompileUnit * + CalculateSymbolContextCompileUnit (); + + Function * + CalculateSymbolContextFunction (); + + Block * + CalculateSymbolContextBlock (); + + Symbol * + CalculateSymbolContextSymbol (); + + bool + CalculateSymbolContextLineEntry (LineEntry &line_entry); protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Core/FormatManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatManager.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FormatManager.h (original) +++ lldb/trunk/include/lldb/Core/FormatManager.h Fri Aug 12 16:40:01 2011 @@ -475,12 +475,12 @@ } if (log) log->Printf("stripping ObjC pointer"); - /* - for some reason, C++ can quite easily obtain the type hierarchy for a ValueObject - even if the VO represent a pointer-to-class, as long as the typePtr is right - Objective-C on the other hand cannot really complete an @interface when - the VO refers to a pointer-to- at interface - */ + + // For some reason, C++ can quite easily obtain the type hierarchy for a ValueObject + // even if the VO represent a pointer-to-class, as long as the typePtr is right + // Objective-C on the other hand cannot really complete an @interface when + // the VO refers to a pointer-to- at interface + Error error; ValueObject* target = vobj.Dereference(error).get(); if (error.Fail() || !target) Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Fri Aug 12 16:40:01 2011 @@ -116,6 +116,9 @@ virtual void CalculateSymbolContext (SymbolContext* sc); + virtual Module * + CalculateSymbolContextModule (); + void GetDescription (Stream *s); Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Fri Aug 12 16:40:01 2011 @@ -107,6 +107,18 @@ virtual void CalculateSymbolContext(SymbolContext* sc); + virtual Module * + CalculateSymbolContextModule (); + + virtual CompileUnit * + CalculateSymbolContextCompileUnit (); + + virtual Function * + CalculateSymbolContextFunction (); + + virtual Block * + CalculateSymbolContextBlock (); + //------------------------------------------------------------------ /// Check if an offset is in one of the block offset ranges. /// Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original) +++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Fri Aug 12 16:40:01 2011 @@ -127,6 +127,12 @@ virtual void CalculateSymbolContext(SymbolContext* sc); + virtual Module * + CalculateSymbolContextModule (); + + virtual CompileUnit * + CalculateSymbolContextCompileUnit (); + //------------------------------------------------------------------ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// Modified: lldb/trunk/include/lldb/Symbol/Function.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Function.h (original) +++ lldb/trunk/include/lldb/Symbol/Function.h Fri Aug 12 16:40:01 2011 @@ -422,6 +422,15 @@ virtual void CalculateSymbolContext(SymbolContext* sc); + virtual Module * + CalculateSymbolContextModule (); + + virtual CompileUnit * + CalculateSymbolContextCompileUnit (); + + virtual Function * + CalculateSymbolContextFunction (); + const AddressRange & GetAddressRange() { Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Fri Aug 12 16:40:01 2011 @@ -175,6 +175,12 @@ virtual void CalculateSymbolContext (SymbolContext *sc); + virtual Module * + CalculateSymbolContextModule (); + + virtual Symbol * + CalculateSymbolContextSymbol (); + //------------------------------------------------------------------ /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// Modified: lldb/trunk/include/lldb/Symbol/SymbolContextScope.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContextScope.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContextScope.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContextScope.h Fri Aug 12 16:40:01 2011 @@ -87,6 +87,37 @@ virtual void CalculateSymbolContext (SymbolContext *sc) = 0; + + virtual Module * + CalculateSymbolContextModule () + { + return NULL; + } + + virtual CompileUnit * + CalculateSymbolContextCompileUnit () + { + return NULL; + } + + virtual Function * + CalculateSymbolContextFunction () + { + return NULL; + } + + virtual Block * + CalculateSymbolContextBlock () + { + return NULL; + } + + virtual Symbol * + CalculateSymbolContextSymbol () + { + return NULL; + } + //------------------------------------------------------------------ /// Dump the object's symbolc context to the stream \a s. /// Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Fri Aug 12 16:40:01 2011 @@ -781,7 +781,7 @@ plan_stack m_plan_stack; ///< The stack of plans this thread is executing. plan_stack m_completed_plan_stack; ///< Plans that have been completed by this stop. They get deleted when the thread resumes. plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this stop. They get deleted when the thread resumes. - std::auto_ptr m_curr_frames_ap; ///< The stack frames that get lazily populated after a thread stops. + lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily populated after a thread stops. lldb::StackFrameListSP m_prev_frames_sp; ///< The previous stack frames from the last time this thread stopped. int m_resume_signal; ///< The signal that should be used when continuing this thread. lldb::StateType m_resume_state; ///< The state that indicates what this thread should do when the process is resumed. Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Fri Aug 12 16:40:01 2011 @@ -111,12 +111,14 @@ virtual void TracingEnded (); virtual void Log(); private: - void InitializeTracer(); - Process &m_process; - Target &m_target; - Disassembler *m_disassembler; - const ABI *m_abi; + Disassembler * + GetDisassembler (); + + TypeFromUser + GetIntPointerType(); + + std::auto_ptr m_disassembler_ap; TypeFromUser m_intptr_type; std::vector m_register_values; lldb::DataBufferSP m_buffer_sp; Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/SharingPtr.h (original) +++ lldb/trunk/include/lldb/Utility/SharingPtr.h Fri Aug 12 16:40:01 2011 @@ -441,6 +441,97 @@ return SharingPtr(r, const_cast(r.get())); } +template +class LoggingSharingPtr + : public SharingPtr +{ + typedef SharingPtr base; + +public: + typedef void (*Callback)(void*, const LoggingSharingPtr&, bool action); + // action: false means increment just happened + // true means decrement is about to happen + +private: + Callback cb_; + void* baton_; + +public: + LoggingSharingPtr() : cb_(0), baton_(0) {} + LoggingSharingPtr(Callback cb, void* baton) + : cb_(cb), baton_(baton) + { + if (cb_) + cb_(baton_, *this, false); + } + + template + LoggingSharingPtr(Y* p) + : base(p), cb_(0), baton_(0) {} + + template + LoggingSharingPtr(Y* p, Callback cb, void* baton) + : base(p), cb_(cb), baton_(baton) + { + if (cb_) + cb_(baton_, *this, false); + } + + ~LoggingSharingPtr() + { + if (cb_) + cb_(baton_, *this, true); + } + + LoggingSharingPtr(const LoggingSharingPtr& p) + : base(p), cb_(p.cb_), baton_(p.baton_) + { + if (cb_) + cb_(baton_, *this, false); + } + + LoggingSharingPtr& operator=(const LoggingSharingPtr& p) + { + if (cb_) + cb_(baton_, *this, true); + base::operator=(p); + cb_ = p.cb_; + baton_ = p.baton_; + if (cb_) + cb_(baton_, *this, false); + return *this; + } + + void reset() + { + if (cb_) + cb_(baton_, *this, true); + base::reset(); + } + + template + void reset(Y* p) + { + if (cb_) + cb_(baton_, *this, true); + base::reset(p); + if (cb_) + cb_(baton_, *this, false); + } + + void SetCallback(Callback cb, void* baton) + { + cb_ = cb; + baton_ = baton; + } + + void ClearCallback() + { + cb_ = 0; + baton_ = 0; + } +}; + } // namespace lldb #endif // utility_SharingPtr_h_ Modified: lldb/trunk/include/lldb/lldb-types.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-types.h?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-types.h (original) +++ lldb/trunk/include/lldb/lldb-types.h Fri Aug 12 16:40:01 2011 @@ -64,6 +64,11 @@ { typedef lldb_private::SharingPtr<_Tp> Type; }; + template + struct LoggingSharedPtr + { + typedef lldb_private::LoggingSharingPtr<_Tp> Type; + }; } // namespace lldb Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Fri Aug 12 16:40:01 2011 @@ -228,4 +228,62 @@ return sb_module; } +SBSymbolContext +SBAddress::GetSymbolContext (uint32_t resolve_scope) +{ + SBSymbolContext sb_sc; + if (m_opaque_ap.get()) + m_opaque_ap->CalculateSymbolContext (&sb_sc.ref(), resolve_scope); + return sb_sc; +} + +SBCompileUnit +SBAddress::GetCompileUnit () +{ + SBCompileUnit sb_comp_unit; + if (m_opaque_ap.get()) + sb_comp_unit.reset(m_opaque_ap->CalculateSymbolContextCompileUnit()); + return sb_comp_unit; +} + +SBFunction +SBAddress::GetFunction () +{ + SBFunction sb_function; + if (m_opaque_ap.get()) + sb_function.reset(m_opaque_ap->CalculateSymbolContextFunction()); + return sb_function; +} + +SBBlock +SBAddress::GetBlock () +{ + SBBlock sb_block; + if (m_opaque_ap.get()) + sb_block.reset(m_opaque_ap->CalculateSymbolContextBlock()); + return sb_block; +} + +SBSymbol +SBAddress::GetSymbol () +{ + SBSymbol sb_symbol; + if (m_opaque_ap.get()) + sb_symbol.reset(m_opaque_ap->CalculateSymbolContextSymbol()); + return sb_symbol; +} + +SBLineEntry +SBAddress::GetLineEntry () +{ + SBLineEntry sb_line_entry; + if (m_opaque_ap.get()) + { + LineEntry line_entry; + if (m_opaque_ap->CalculateSymbolContextLineEntry (line_entry)) + sb_line_entry.SetLineEntry (line_entry); + } + return sb_line_entry; +} + Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Fri Aug 12 16:40:01 2011 @@ -727,20 +727,115 @@ return true; } -void -Address::CalculateSymbolContext (SymbolContext *sc) +uint32_t +Address::CalculateSymbolContext (SymbolContext *sc, uint32_t resolve_scope) { sc->Clear(); // Absolute addresses don't have enough information to reconstruct even their target. - if (m_section == NULL) - return; + if (m_section) + { + Module *address_module = m_section->GetModule(); + if (address_module) + { + sc->module_sp = address_module->GetSP(); + if (sc->module_sp) + return sc->module_sp->ResolveSymbolContextForAddress (*this, resolve_scope, *sc); + } + } + return 0; +} + +Module * +Address::CalculateSymbolContextModule () +{ + if (m_section) + return m_section->GetModule(); + return NULL; +} + +CompileUnit * +Address::CalculateSymbolContextCompileUnit () +{ + if (m_section) + { + SymbolContext sc; + sc.module_sp = m_section->GetModule()->GetSP(); + if (sc.module_sp) + { + sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextCompUnit, sc); + return sc.comp_unit; + } + } + return NULL; +} + +Function * +Address::CalculateSymbolContextFunction () +{ + if (m_section) + { + SymbolContext sc; + sc.module_sp = m_section->GetModule()->GetSP(); + if (sc.module_sp) + { + sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextFunction, sc); + return sc.function; + } + } + return NULL; +} - if (m_section->GetModule()) +Block * +Address::CalculateSymbolContextBlock () +{ + if (m_section) { - sc->module_sp = m_section->GetModule()->GetSP(); - if (sc->module_sp) - sc->module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextEverything, *sc); + SymbolContext sc; + sc.module_sp = m_section->GetModule()->GetSP(); + if (sc.module_sp) + { + sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextBlock, sc); + return sc.block; + } } + return NULL; +} + +Symbol * +Address::CalculateSymbolContextSymbol () +{ + if (m_section) + { + SymbolContext sc; + sc.module_sp = m_section->GetModule()->GetSP(); + if (sc.module_sp) + { + sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextSymbol, sc); + return sc.symbol; + } + } + return NULL; +} + +bool +Address::CalculateSymbolContextLineEntry (LineEntry &line_entry) +{ + if (m_section) + { + SymbolContext sc; + sc.module_sp = m_section->GetModule()->GetSP(); + if (sc.module_sp) + { + sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextLineEntry, sc); + if (sc.line_entry.IsValid()) + { + line_entry = sc.line_entry; + return true; + } + } + } + line_entry.Clear(); + return false; } int Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Fri Aug 12 16:40:01 2011 @@ -214,6 +214,12 @@ sc->module_sp = GetSP(); } +Module * +Module::CalculateSymbolContextModule () +{ + return this; +} + void Module::DumpSymbolContext(Stream *s) { Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Fri Aug 12 16:40:01 2011 @@ -707,6 +707,33 @@ { return GetSharedModuleList ().RemoveOrphans(); } +//#define ENABLE_MODULE_SP_LOGGING +#if defined (ENABLE_MODULE_SP_LOGGING) +#include "lldb/Core/StreamFile.h" +#include "lldb/Host/Host.h" +static void +ModuleSharedPtrLogger(void* p, const ModuleSP& sp, bool will_decrement) +{ + if (sp.get()) + { + const char *module_basename = sp->GetFileSpec().GetFilename().GetCString(); + // If "p" is set, then it is the basename of a module to watch for. This + // basename MUST be uniqued first by getting it from a ConstString or this + // won't work. + if (p && p != module_basename) + { + return; + } + long use_count = sp.use_count(); + if (will_decrement) + --use_count; + + printf("\nModuleSP(%p): %c %p {%lu} %s/%s\n", &sp, will_decrement ? '-' : '+', sp.get(), use_count, sp->GetFileSpec().GetDirectory().GetCString(), module_basename); + StreamFile stdout_strm(stdout, false); + Host::Backtrace (stdout_strm, 512); + } +} +#endif Error ModuleList::GetSharedModule @@ -783,7 +810,12 @@ return error; else { +#if defined ENABLE_MODULE_SP_LOGGING + ModuleSP logging_module_sp (new Module (in_file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, (void *)ConstString("a.out").GetCString()); + module_sp = logging_module_sp; +#else module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset)); +#endif // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches @@ -874,7 +906,12 @@ if (module_sp.get() == NULL) { +#if defined ENABLE_MODULE_SP_LOGGING + ModuleSP logging_module_sp (new Module (file_spec, arch, object_name_ptr, object_offset), ModuleSharedPtrLogger, 0); + module_sp = logging_module_sp; +#else module_sp.reset (new Module (file_spec, arch, object_name_ptr, object_offset)); +#endif // Make sure there are a module and an object file since we can specify // a valid file path with an architecture that might not be in that file. // By getting the object file we can guarantee that the architecture matches Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 12 16:40:01 2011 @@ -3260,31 +3260,35 @@ bool ValueObject::EvaluationPoint::SyncWithProcessState() { - // If we're already invalid, we don't need to do anything, and nothing has changed: - if (!m_mod_id.IsValid()) - { - // Can't update with an invalid state. - m_needs_update = false; - return false; - } - // If we don't have a process nothing can change. if (!m_process_sp) + { + m_exe_scope = m_target_sp.get(); return false; + } // If our stop id is the current stop ID, nothing has changed: ProcessModID current_mod_id = m_process_sp->GetModID(); - if (m_mod_id == current_mod_id) - return false; - // If the current stop id is 0, either we haven't run yet, or the process state has been cleared. // In either case, we aren't going to be able to sync with the process state. if (current_mod_id.GetStopID() == 0) + { + m_exe_scope = m_target_sp.get(); return false; + } - m_mod_id = current_mod_id; - m_needs_update = true; + if (m_mod_id.IsValid()) + { + if (m_mod_id == current_mod_id) + { + // Everything is already up to date in this object, no need do + // update the execution context scope. + return false; + } + m_mod_id = current_mod_id; + m_needs_update = true; + } m_exe_scope = m_process_sp.get(); // Something has changed, so we will return true. Now make sure the thread & frame still exist, and if either @@ -3317,12 +3321,10 @@ void ValueObject::EvaluationPoint::SetUpdated () { + // this will update the execution context scope and the m_mod_id + SyncWithProcessState(); m_first_update = false; m_needs_update = false; - if (m_process_sp) - { - m_mod_id = m_process_sp->GetModID(); - } } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Fri Aug 12 16:40:01 2011 @@ -386,11 +386,9 @@ { // FIXME: Use the errors Stream for better error reporting. - Process *process = exe_ctx.process; - - if (process == NULL) + if (exe_ctx.thread == NULL) { - errors.Printf("Can't call a function without a process."); + errors.Printf("Can't call a function without a valid thread."); return NULL; } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Fri Aug 12 16:40:01 2011 @@ -152,6 +152,36 @@ sc->block = this; } +Module * +Block::CalculateSymbolContextModule () +{ + if (m_parent_scope) + return m_parent_scope->CalculateSymbolContextModule (); + return NULL; +} + +CompileUnit * +Block::CalculateSymbolContextCompileUnit () +{ + if (m_parent_scope) + return m_parent_scope->CalculateSymbolContextCompileUnit (); + return NULL; +} + +Function * +Block::CalculateSymbolContextFunction () +{ + if (m_parent_scope) + return m_parent_scope->CalculateSymbolContextFunction (); + return NULL; +} + +Block * +Block::CalculateSymbolContextBlock () +{ + return this; +} + void Block::DumpStopContext ( @@ -225,12 +255,11 @@ } else if (child_inline_call_site) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.function) + Function *function = CalculateSymbolContextFunction(); + if (function) { s->EOL(); - s->Indent (sc.function->GetMangled().GetName().AsCString()); + s->Indent (function->GetMangled().GetName().AsCString()); if (child_inline_call_site && child_inline_call_site->IsValid()) { s->PutCString(" at "); @@ -245,10 +274,9 @@ void Block::DumpSymbolContext(Stream *s) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.function) - sc.function->DumpSymbolContext(s); + Function *function = CalculateSymbolContextFunction(); + if (function) + function->DumpSymbolContext(s); s->Printf(", Block{0x%8.8x}", GetID()); } @@ -297,12 +325,7 @@ Block::GetParent () const { if (m_parent_scope) - { - SymbolContext sc; - m_parent_scope->CalculateSymbolContext(&sc); - if (sc.block) - return sc.block; - } + return m_parent_scope->CalculateSymbolContextBlock(); return NULL; } @@ -346,11 +369,10 @@ bool Block::GetRangeContainingAddress (const Address& addr, AddressRange &range) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.function) + Function *function = CalculateSymbolContextFunction(); + if (function) { - const AddressRange &func_range = sc.function->GetAddressRange(); + const AddressRange &func_range = function->GetAddressRange(); if (addr.GetSection() == func_range.GetBaseAddress().GetSection()) { const addr_t addr_offset = addr.GetOffset(); @@ -379,11 +401,10 @@ { if (range_idx < m_ranges.size()) { - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.function) + Function *function = CalculateSymbolContextFunction(); + if (function) { - range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress(); + range.GetBaseAddress() = function->GetAddressRange().GetBaseAddress(); range.GetBaseAddress().Slide(m_ranges[range_idx].GetBaseAddress ()); range.SetByteSize (m_ranges[range_idx].GetByteSize()); return true; @@ -398,11 +419,10 @@ if (m_ranges.empty()) return false; - SymbolContext sc; - CalculateSymbolContext(&sc); - if (sc.function) + Function *function = CalculateSymbolContextFunction(); + if (function) { - addr = sc.function->GetAddressRange().GetBaseAddress(); + addr = function->GetAddressRange().GetBaseAddress(); addr.Slide(m_ranges.front().GetBaseAddress ()); return true; } Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Fri Aug 12 16:40:01 2011 @@ -57,6 +57,18 @@ GetModule()->CalculateSymbolContext(sc); } +Module * +CompileUnit::CalculateSymbolContextModule () +{ + return GetModule(); +} + +CompileUnit * +CompileUnit::CalculateSymbolContextCompileUnit () +{ + return this; +} + void CompileUnit::DumpSymbolContext(Stream *s) { Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Fri Aug 12 16:40:01 2011 @@ -386,6 +386,31 @@ m_comp_unit->CalculateSymbolContext(sc); } +Module * +Function::CalculateSymbolContextModule () +{ + return this->GetCompileUnit()->GetModule(); +} + +CompileUnit * +Function::CalculateSymbolContextCompileUnit () +{ + return this->GetCompileUnit(); +} + +Function * +Function::CalculateSymbolContextFunction () +{ + return this; +} + +//Symbol * +//Function::CalculateSymbolContextSymbol () +//{ +// return // TODO: find the symbol for the function??? +//} + + void Function::DumpSymbolContext(Stream *s) { Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Fri Aug 12 16:40:01 2011 @@ -366,6 +366,22 @@ sc->module_sp.reset(); } +Module * +Symbol::CalculateSymbolContextModule () +{ + const AddressRange *range = GetAddressRangePtr(); + if (range) + return range->GetBaseAddress().GetModule (); + return NULL; +} + +Symbol * +Symbol::CalculateSymbolContextSymbol () +{ + return this; +} + + void Symbol::DumpSymbolContext (Stream *s) { Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Aug 12 16:40:01 2011 @@ -51,7 +51,8 @@ m_state_mutex (Mutex::eMutexTypeRecursive), m_plan_stack (), m_completed_plan_stack(), - m_curr_frames_ap (), + m_curr_frames_sp (), + m_prev_frames_sp (), m_resume_signal (LLDB_INVALID_SIGNAL_NUMBER), m_resume_state (eStateRunning), m_unwinder_ap (), @@ -916,9 +917,9 @@ StackFrameList & Thread::GetStackFrameList () { - if (m_curr_frames_ap.get() == NULL) - m_curr_frames_ap.reset (new StackFrameList (*this, m_prev_frames_sp, true)); - return *m_curr_frames_ap; + if (!m_curr_frames_sp) + m_curr_frames_sp.reset (new StackFrameList (*this, m_prev_frames_sp, true)); + return *m_curr_frames_sp; } @@ -933,13 +934,9 @@ void Thread::ClearStackFrames () { - if (m_curr_frames_ap.get() && m_curr_frames_ap->GetNumFrames (false) > 1) - m_prev_frames_sp.reset (m_curr_frames_ap.release()); - else - m_curr_frames_ap.release(); - -// StackFrameList::Merge (m_curr_frames_ap, m_prev_frames_sp); -// assert (m_curr_frames_ap.get() == NULL); + if (m_curr_frames_sp && m_curr_frames_sp->GetNumFrames (false) > 1) + m_prev_frames_sp.swap (m_curr_frames_sp); + m_curr_frames_sp.reset(); } lldb::StackFrameSP Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=137516&r1=137515&r2=137516&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Fri Aug 12 16:40:01 2011 @@ -91,45 +91,47 @@ ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) : ThreadPlanTracer (thread, stream_sp), - m_process(thread.GetProcess()), - m_target(thread.GetProcess().GetTarget()) + m_disassembler_ap (), + m_intptr_type (), + m_register_values () { - InitializeTracer (); } ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) : ThreadPlanTracer (thread), - m_process(thread.GetProcess()), - m_target(thread.GetProcess().GetTarget()) + m_disassembler_ap (), + m_intptr_type (), + m_register_values () { - InitializeTracer (); } -void -ThreadPlanAssemblyTracer::InitializeTracer() +Disassembler * +ThreadPlanAssemblyTracer::GetDisassembler () { - Process &process = m_thread.GetProcess(); - Target &target = process.GetTarget(); - - ArchSpec arch(target.GetArchitecture()); - - m_disassembler = Disassembler::FindPlugin(arch, NULL); - - m_abi = process.GetABI().get(); - - Module *exe_module = target.GetExecutableModulePointer(); - - if (exe_module) + if (m_disassembler_ap.get() == NULL) + m_disassembler_ap.reset(Disassembler::FindPlugin(m_thread.GetProcess().GetTarget().GetArchitecture(), NULL)); + return m_disassembler_ap.get(); +} + +TypeFromUser +ThreadPlanAssemblyTracer::GetIntPointerType() +{ + if (!m_intptr_type.IsValid ()) { - m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8), - exe_module->GetClangASTContext().getASTContext()); + Target &target = m_thread.GetProcess().GetTarget(); + Module *exe_module = target.GetExecutableModulePointer(); + + if (exe_module) + { + m_intptr_type = TypeFromUser(exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, m_thread.GetProcess().GetAddressByteSize() * 8), + exe_module->GetClangASTContext().getASTContext()); + } } - - const unsigned int buf_size = 32; - - m_buffer_sp.reset(new DataBufferHeap(buf_size, 0)); + return m_intptr_type; } + + ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() { } @@ -171,33 +173,33 @@ RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); lldb::addr_t pc = reg_ctx->GetPC(); + Process &process = m_thread.GetProcess(); Address pc_addr; bool addr_valid = false; - - addr_valid = m_process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr); + uint8_t buffer[16] = {0}; // Must be big enough for any single instruction + addr_valid = process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr); pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress); stream->PutCString (" "); - if (m_disassembler) + Disassembler *disassembler = GetDisassembler(); + if (disassembler) { - ::memset(m_buffer_sp->GetBytes(), 0, m_buffer_sp->GetByteSize()); - Error err; - m_process.ReadMemory(pc, m_buffer_sp->GetBytes(), m_buffer_sp->GetByteSize(), err); + process.ReadMemory(pc, buffer, sizeof(buffer), err); if (err.Success()) { - DataExtractor extractor(m_buffer_sp, - m_process.GetByteOrder(), - m_process.GetAddressByteSize()); + DataExtractor extractor(buffer, sizeof(buffer), + process.GetByteOrder(), + process.GetAddressByteSize()); if (addr_valid) - m_disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false); + disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false); else - m_disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false); + disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false); - InstructionList &instruction_list = m_disassembler->GetInstructionList(); + InstructionList &instruction_list = disassembler->GetInstructionList(); const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize(); if (instruction_list.GetSize()) @@ -215,7 +217,10 @@ } } - if (m_abi && m_intptr_type.GetOpaqueQualType()) + const ABI *abi = process.GetABI().get(); + TypeFromUser intptr_type = GetIntPointerType(); + + if (abi && intptr_type.IsValid()) { ValueList value_list; const int num_args = 1; @@ -224,11 +229,11 @@ { Value value; value.SetValueType (Value::eValueTypeScalar); - value.SetContext (Value::eContextTypeClangType, m_intptr_type.GetOpaqueQualType()); + value.SetContext (Value::eContextTypeClangType, intptr_type.GetOpaqueQualType()); value_list.PushValue (value); } - if (m_abi->GetArgumentValues (m_thread, value_list)) + if (abi->GetArgumentValues (m_thread, value_list)) { for (int arg_index = 0; arg_index < num_args; ++arg_index) { From johnny.chen at apple.com Fri Aug 12 17:52:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 22:52:11 -0000 Subject: [Lldb-commits] [lldb] r137528 - /lldb/trunk/scripts/Python/interface/SBAddress.i Message-ID: <20110812225211.6B95B2A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 17:52:11 2011 New Revision: 137528 URL: http://llvm.org/viewvc/llvm-project?rev=137528&view=rev Log: Update the SBAddress.i Python interface file to the latest SBAddress.h, and add some docstrings. Modified: lldb/trunk/scripts/Python/interface/SBAddress.i Modified: lldb/trunk/scripts/Python/interface/SBAddress.i URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=137528&r1=137527&r2=137528&view=diff ============================================================================== --- lldb/trunk/scripts/Python/interface/SBAddress.i (original) +++ lldb/trunk/scripts/Python/interface/SBAddress.i Fri Aug 12 17:52:11 2011 @@ -82,8 +82,48 @@ SectionType GetSectionType (); + %feature("docstring", " + //------------------------------------------------------------------ + /// GetSymbolContext() and the following can lookup symbol information for a given address. + /// An address might refer to code or data from an existing module, or it + /// might refer to something on the stack or heap. The following functions + /// will only return valid values if the address has been resolved to a code + /// or data address using 'void SBAddress::SetLoadAddress(...)' or + /// 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'. + //------------------------------------------------------------------ + ") GetSymbolContext; + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope); + + %feature("docstring", " + //------------------------------------------------------------------ + /// GetModule() and the following grab individual objects for a given address and + /// are less efficient if you want more than one symbol related objects. + /// Use one of the following when you want multiple debug symbol related + /// objects for an address: + /// lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); + /// lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); + /// One or more bits from the SymbolContextItem enumerations can be logically + /// OR'ed together to more efficiently retrieve multiple symbol objects. + //------------------------------------------------------------------ + ") GetModule; lldb::SBModule GetModule (); + + lldb::SBCompileUnit + GetCompileUnit (); + + lldb::SBFunction + GetFunction (); + + lldb::SBBlock + GetBlock (); + + lldb::SBSymbol + GetSymbol (); + + lldb::SBLineEntry + GetLineEntry (); }; } // namespace lldb From gclayton at apple.com Fri Aug 12 18:32:17 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 23:32:17 -0000 Subject: [Lldb-commits] [lldb] r137533 - /lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h Message-ID: <20110812233217.CC3B82A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 18:32:17 2011 New Revision: 137533 URL: http://llvm.org/viewvc/llvm-project?rev=137533&view=rev Log: Removed an initialization that wasn't needed. Modified: lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h Modified: lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h?rev=137533&r1=137532&r2=137533&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h (original) +++ lldb/trunk/include/lldb/Expression/ProcessDataAllocator.h Fri Aug 12 18:32:17 2011 @@ -46,8 +46,6 @@ if (m_allocation) m_process.DeallocateMemory(m_allocation); - m_allocation = 0; - m_allocation = m_process.AllocateMemory(m_stream_string.GetSize(), lldb::ePermissionsReadable | lldb::ePermissionsWritable, err); if (!err.Success()) From gclayton at apple.com Fri Aug 12 18:32:52 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Aug 2011 23:32:52 -0000 Subject: [Lldb-commits] [lldb] r137534 - /lldb/trunk/source/Core/ArchSpec.cpp Message-ID: <20110812233252.C9ECD2A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 18:32:52 2011 New Revision: 137534 URL: http://llvm.org/viewvc/llvm-project?rev=137534&view=rev Log: Fixed an incorrect static analyzer fix. Modified: lldb/trunk/source/Core/ArchSpec.cpp Modified: lldb/trunk/source/Core/ArchSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=137534&r1=137533&r2=137534&view=diff ============================================================================== --- lldb/trunk/source/Core/ArchSpec.cpp (original) +++ lldb/trunk/source/Core/ArchSpec.cpp Fri Aug 12 18:32:52 2011 @@ -457,7 +457,7 @@ bool ArchSpec::SetTriple (const char *triple_cstr, Platform *platform) { - if (triple_cstr && !triple_cstr[0]) + if (triple_cstr && triple_cstr[0]) { llvm::StringRef triple_stref (triple_cstr); if (triple_stref.startswith (LLDB_ARCH_DEFAULT)) From jingham at apple.com Fri Aug 12 18:34:31 2011 From: jingham at apple.com (Jim Ingham) Date: Fri, 12 Aug 2011 23:34:31 -0000 Subject: [Lldb-commits] [lldb] r137536 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Core/ValueObject.h include/lldb/Core/ValueObjectRegister.h include/lldb/Interpreter/CommandInterpreter.h source/API/SBDebugger.cpp source/API/SBError.cpp source/API/SBValue.cpp source/Breakpoint/BreakpointSite.cpp source/Core/ValueObject.cpp source/Core/ValueObjectChild.cpp source/Core/ValueObjectRegister.cpp source/Interpreter/CommandInterpreter.cpp source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110812233432.1B6952A6C12C@llvm.org> Author: jingham Date: Fri Aug 12 18:34:31 2011 New Revision: 137536 URL: http://llvm.org/viewvc/llvm-project?rev=137536&view=rev Log: Make ValueObject::SetValueFromCString work correctly. Also change the SourceInitFile to look for .lldb- and source that preferentially if it exists. Also made the breakpoint site report its address as well as its breakpoint number when it gets hit and can't find any the associated locations (usually because the breakpoint got disabled or deleted programmatically between the time it was hit and reported.) Changed ThreadPlanCallFunction to initialize the ivar m_func in the initializers of the constructor, rather than waiting to initialize till later on in the function. Fixed a bug where if you make an SBError and the ask it Success, it returns false. Fixed ValueObject::ResolveValue so that it resolves a temporary value, rather than overwriting the one in the value object. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectRegister.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBError.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/Breakpoint/BreakpointSite.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Aug 12 18:34:31 2011 @@ -55,6 +55,9 @@ SkipLLDBInitFiles (bool b); void + SkipAppInitFiles (bool b); + + void SetInputFileHandle (FILE *f, bool transfer_ownership); void Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Aug 12 18:34:31 2011 @@ -343,6 +343,9 @@ return m_update_point.GetExecutionContextScope(); } + void + SetNeedsUpdate (); + virtual ~ValueObject(); //------------------------------------------------------------------ @@ -543,9 +546,6 @@ DataExtractor & GetDataExtractor (); - bool - Write (); - lldb::ValueObjectSP GetSP () { Modified: lldb/trunk/include/lldb/Core/ValueObjectRegister.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectRegister.h?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectRegister.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectRegister.h Fri Aug 12 18:34:31 2011 @@ -156,6 +156,9 @@ virtual uint32_t CalculateNumChildren(); + + virtual bool + SetValueFromCString (const char *value_str); protected: virtual bool Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Fri Aug 12 18:34:31 2011 @@ -346,6 +346,12 @@ m_skip_lldbinit_files = skip_lldbinit_files; } + void + SkipAppInitFiles (bool skip_app_init_files) + { + m_skip_app_init_files = m_skip_lldbinit_files; + } + bool GetSynchronous (); @@ -433,6 +439,7 @@ ExecutionContext m_exe_ctx; // The current execution context to use when handling commands bool m_synchronous_execution; bool m_skip_lldbinit_files; + bool m_skip_app_init_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=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 12 18:34:31 2011 @@ -149,6 +149,13 @@ m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b); } +void +SBDebugger::SkipAppInitFiles (bool b) +{ + if (m_opaque_sp) + m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles (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/API/SBError.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/API/SBError.cpp (original) +++ lldb/trunk/source/API/SBError.cpp Fri Aug 12 18:34:31 2011 @@ -86,7 +86,7 @@ SBError::Success () const { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - bool ret_value = false; + bool ret_value = true; if (m_opaque_ap.get()) ret_value = m_opaque_ap->Success(); Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri Aug 12 18:34:31 2011 @@ -629,6 +629,7 @@ int64_t SBValue::GetValueAsSigned(SBError& error, int64_t fail_value) { + error.Clear(); if (m_opaque_sp) { if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) @@ -650,6 +651,7 @@ uint64_t SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value) { + error.Clear(); if (m_opaque_sp) { if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) Modified: lldb/trunk/source/Breakpoint/BreakpointSite.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSite.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointSite.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointSite.cpp Fri Aug 12 18:34:31 2011 @@ -95,7 +95,7 @@ BreakpointSite::GetDescription (Stream *s, lldb::DescriptionLevel level) { if (level != lldb::eDescriptionLevelBrief) - s->Printf ("breakpoint site: %d ", GetID()); + s->Printf ("breakpoint site: %d at 0x%8.8llx", GetID(), GetLoadAddress()); m_owners.GetDescription (s, level); } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Aug 12 18:34:31 2011 @@ -252,6 +252,15 @@ } } +void +ValueObject::SetNeedsUpdate () +{ + m_update_point.SetNeedsUpdate(); + // We have to clear the value string here so ConstResult children will notice if their values are + // changed by hand (i.e. with SetValueAsCString). + m_value_str.clear(); +} + DataExtractor & ValueObject::GetDataExtractor () { @@ -338,7 +347,8 @@ ExecutionContextScope *exe_scope = GetExecutionContextScope(); if (exe_scope) exe_scope->CalculateExecutionContext(exe_ctx); - scalar = m_value.ResolveValue(&exe_ctx, GetClangAST ()); + Value tmp_value(m_value); + scalar = tmp_value.ResolveValue(&exe_ctx, GetClangAST ()); return scalar.IsValid(); } else @@ -1220,104 +1230,83 @@ uint32_t count = 0; lldb::Encoding encoding = ClangASTType::GetEncoding (GetClangType(), count); - char *end = NULL; const size_t byte_size = GetByteSize(); - switch (encoding) - { - case eEncodingInvalid: - return false; - case eEncodingUint: - if (byte_size > sizeof(unsigned long long)) - { - return false; - } - else + Value::ValueType value_type = m_value.GetValueType(); + + if (value_type == Value::eValueTypeScalar) + { + // If the value is already a scalar, then let the scalar change itself: + m_value.GetScalar().SetValueFromCString (value_str, encoding, byte_size); + } + else if (byte_size <= Scalar::GetMaxByteSize()) + { + // If the value fits in a scalar, then make a new scalar and again let the + // scalar code do the conversion, then figure out where to put the new value. + Scalar new_scalar; + Error error; + error = new_scalar.SetValueFromCString (value_str, encoding, byte_size); + if (error.Success()) { - unsigned long long ull_val = strtoull(value_str, &end, 0); - if (end && *end != '\0') - return false; - Value::ValueType value_type = m_value.GetValueType(); switch (value_type) { - case Value::eValueTypeLoadAddress: - case Value::eValueTypeHostAddress: - // The value in these cases lives in the data. So update the data: - - break; - case Value::eValueTypeScalar: - m_value.GetScalar() = ull_val; + case Value::eValueTypeLoadAddress: + { + // If it is a load address, then the scalar value is the storage location + // of the data, and we have to shove this value down to that load location. + ProcessSP process_sp = GetUpdatePoint().GetProcessSP(); + if (process_sp) + { + lldb::addr_t target_addr = m_value.GetScalar().GetRawBits64(LLDB_INVALID_ADDRESS); + size_t bytes_written = process_sp->WriteScalarToMemory (target_addr, + new_scalar, + byte_size, + error); + if (!error.Success() || bytes_written != byte_size) + return false; + } + } break; - case Value::eValueTypeFileAddress: - // Try to convert the file address to a load address and then write the new value there. + case Value::eValueTypeHostAddress: + { + // If it is a host address, then we stuff the scalar as a DataBuffer into the Value's data. + DataExtractor new_data; + new_data.SetByteOrder (m_data.GetByteOrder()); + + DataBufferSP buffer_sp (new DataBufferHeap(byte_size, 0)); + m_data.SetData(buffer_sp, 0); + bool success = new_scalar.GetData(new_data); + if (success) + { + new_data.CopyByteOrderedData(0, + byte_size, + const_cast(m_data.GetDataStart()), + byte_size, + m_data.GetByteOrder()); + } + m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); + + } break; + case Value::eValueTypeFileAddress: + case Value::eValueTypeScalar: + break; } - // Limit the bytes in our m_data appropriately. - m_value.GetScalar().GetData (m_data, byte_size); - } - break; - - case eEncodingSint: - if (byte_size > sizeof(long long)) - { - return false; } else { - long long sll_val = strtoll(value_str, &end, 0); - if (end && *end != '\0') - return false; - m_value.GetScalar() = sll_val; - // Limit the bytes in our m_data appropriately. - m_value.GetScalar().GetData (m_data, byte_size); - } - break; - - case eEncodingIEEE754: - { - const off_t byte_offset = GetByteOffset(); - uint8_t *dst = const_cast(m_data.PeekData(byte_offset, byte_size)); - if (dst != NULL) - { - // We are decoding a float into host byte order below, so make - // sure m_data knows what it contains. - m_data.SetByteOrder(lldb::endian::InlHostByteOrder()); - const size_t converted_byte_size = ClangASTContext::ConvertStringToFloatValue ( - GetClangAST(), - GetClangType(), - value_str, - dst, - byte_size); - - if (converted_byte_size == byte_size) - { - } - } + return false; } - break; - - case eEncodingVector: - return false; - - default: + } + else + { + // We don't support setting things bigger than a scalar at present. return false; } - - // If we have made it here the value is in m_data and we should write it - // out to the target - return Write (); -} - -bool -ValueObject::Write () -{ - // Clear the update ID so the next time we try and read the value - // we try and read it again. - m_update_point.SetNeedsUpdate(); - - // TODO: when Value has a method to write a value back, call it from here. - return false; - + + // If we have reached this point, then we have successfully changed the value. + SetNeedsUpdate(); + return true; } lldb::LanguageType Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Fri Aug 12 18:34:31 2011 @@ -150,7 +150,7 @@ else { // Set this object's scalar value to the address of its - // value be adding its byte offset to the parent address + // value by adding its byte offset to the parent address m_value.GetScalar() += GetByteOffset(); } } Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Fri Aug 12 18:34:31 2011 @@ -385,4 +385,22 @@ return false; } +bool +ValueObjectRegister::SetValueFromCString (const char *value_str) +{ + // The new value will be in the m_data. Copy that into our register value. + Error error = m_reg_value.SetValueFromCString (&m_reg_info, value_str); + if (error.Success()) + { + if (m_reg_ctx_sp->WriteRegister (&m_reg_info, m_reg_value)) + { + SetNeedsUpdate(); + return true; + } + else + return false; + } + else + return false; +} Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Aug 12 18:34:31 2011 @@ -68,6 +68,7 @@ m_debugger (debugger), m_synchronous_execution (synchronous_execution), m_skip_lldbinit_files (false), + m_skip_app_init_files (false), m_script_interpreter_ap (), m_comment_char ('#'), m_repeat_char ('!'), @@ -1762,11 +1763,37 @@ CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result) { // Don't parse any .lldbinit files if we were asked not to - if (m_skip_lldbinit_files) + if (m_skip_lldbinit_files && m_skip_app_init_files) return; const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit"; - FileSpec init_file (init_file_path, true); + + std::string app_specific_init; + + if (!m_skip_app_init_files) + { + FileSpec host_spec = Host::GetProgramFileSpec(); + const char *host_name = host_spec.GetFilename().AsCString(); + + if (host_name != NULL && strcmp (host_name, "lldb") != 0) + { + app_specific_init += init_file_path; + app_specific_init += "-"; + app_specific_init += host_name; + } + } + + FileSpec init_file; + if (!app_specific_init.empty()) + { + init_file.SetFile (app_specific_init.c_str(), true); + } + + if (!m_skip_lldbinit_files && !init_file.Exists()) + { + init_file.SetFile (init_file_path, true); + } + // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting // of the commands back to any appropriate listener (see CommandObjectSource::Execute for more details). Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=137536&r1=137535&r2=137536&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Fri Aug 12 18:34:31 2011 @@ -45,6 +45,7 @@ ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), + m_function_addr (function), m_function_sp (NULL), m_process (thread.GetProcess()), m_thread (thread), @@ -108,7 +109,6 @@ // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding... thread.SetStopInfoToNothing(); - m_function_addr = function; addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (this_arg && cmd_arg) @@ -161,6 +161,7 @@ ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), + m_function_addr (function), m_function_sp(NULL), m_process (thread.GetProcess()), m_thread (thread), @@ -224,7 +225,6 @@ // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding... thread.SetStopInfoToNothing(); - m_function_addr = function; addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (!abi->PrepareTrivialCall (thread, From johnny.chen at apple.com Fri Aug 12 18:55:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Aug 2011 23:55:07 -0000 Subject: [Lldb-commits] [lldb] r137540 - /lldb/trunk/test/dotest.py Message-ID: <20110812235507.8D1652A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 18:55:07 2011 New Revision: 137540 URL: http://llvm.org/viewvc/llvm-project?rev=137540&view=rev Log: Fix a test driver bug where multiple filter specs (through the -f TestClassName.test_method_name command line option) belonging to the same Test*.py file are ignored, except for the first one. 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=137540&r1=137539&r2=137540&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Aug 12 18:55:07 2011 @@ -717,21 +717,20 @@ filtered = False break - # If we reach here, we have a good filterspec. Add it. + # If filtered, we have a good filterspec. Add it. if filtered: - break + #print "adding filter spec %s to module %s" % (filterspec, module) + suite.addTests( + unittest2.defaultTestLoader.loadTestsFromName(filterspec, module)) + continue # Forgo this module if the (base, filterspec) combo is invalid # and no '-g' option is specified if filters and fs4all and not filtered: continue - # Add either the filtered test case or the entire test class. - if filterspec and filtered: - #print "adding filter spec %s to module %s" % (filterspec, module) - suite.addTests( - unittest2.defaultTestLoader.loadTestsFromName(filterspec, module)) - else: + # Add either the filtered test case(s) (which is done before) or the entire test class. + if not filterspec or not filtered: # 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. From jingham at apple.com Fri Aug 12 19:22:20 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 13 Aug 2011 00:22:20 -0000 Subject: [Lldb-commits] [lldb] r137541 - in /lldb/trunk: include/lldb/API/SBDebugger.h source/API/SBDebugger.cpp tools/driver/Driver.cpp Message-ID: <20110813002220.3731E2A6C12C@llvm.org> Author: jingham Date: Fri Aug 12 19:22:20 2011 New Revision: 137541 URL: http://llvm.org/viewvc/llvm-project?rev=137541&view=rev Log: Add a version of SBDebugger::Create which allows us to specify whether to source in the init files or not. Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/source/API/SBDebugger.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=137541&r1=137540&r2=137541&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Aug 12 19:22:20 2011 @@ -25,9 +25,13 @@ static void Terminate(); + // Deprecated, use the one that takes a source_init_files bool. static lldb::SBDebugger Create(); + static lldb::SBDebugger + Create(bool source_init_files); + static void Destroy (lldb::SBDebugger &debugger); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=137541&r1=137540&r2=137541&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 12 19:22:20 2011 @@ -71,6 +71,12 @@ SBDebugger SBDebugger::Create() { + return SBDebugger::Create(true); +} + +SBDebugger +SBDebugger::Create(bool source_init_files) +{ LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBDebugger debugger; @@ -83,6 +89,19 @@ log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData()); } + SBCommandInterpreter interp = debugger.GetCommandInterpreter(); + if (source_init_files) + { + interp.get()->SkipLLDBInitFiles(false); + interp.get()->SkipAppInitFiles (false); + SBCommandReturnObject result; + interp.SourceInitFileInHomeDirectory(result); + } + else + { + interp.get()->SkipLLDBInitFiles(true); + interp.get()->SkipAppInitFiles (true); + } return debugger; } Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=137541&r1=137540&r2=137541&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Fri Aug 12 19:22:20 2011 @@ -83,7 +83,7 @@ Driver::Driver () : SBBroadcaster ("Driver"), - m_debugger (SBDebugger::Create()), + m_debugger (SBDebugger::Create(false)), m_editline_pty (), m_editline_slave_fh (NULL), m_editline_reader (), @@ -478,6 +478,15 @@ } } + // This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't + // know at that point whether we should read in init files yet. So we don't read them in in the + // Driver constructor, then set the flags back to "read them in" here, and then if we see the + // "-n" flag, we'll turn it off again. Finally we have to read them in by hand later in the + // main loop. + + m_debugger.SkipLLDBInitFiles (false); + m_debugger.SkipAppInitFiles (false); + // Prepare for & make calls to getopt_long. #if __GLIBC__ optind = 0; @@ -542,6 +551,7 @@ case 'n': m_debugger.SkipLLDBInitFiles (true); + m_debugger.SkipAppInitFiles (true); break; case 'f': From johnny.chen at apple.com Fri Aug 12 19:27:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 13 Aug 2011 00:27:46 -0000 Subject: [Lldb-commits] [lldb] r137542 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20110813002746.3CC762A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 19:27:46 2011 New Revision: 137542 URL: http://llvm.org/viewvc/llvm-project?rev=137542&view=rev Log: Modify the skipUnless() logic to work for OSX Lion. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=137542&r1=137541&r2=137542&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Fri Aug 12 19:27:46 2011 @@ -16,7 +16,7 @@ self.line = line_number('main.c', '// Set break point at this line.') # rdar://problem/8972204 AddressByteSize of 32-bit process should be 4, got 8 instead. - @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4]=='i386', + @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4] in ['i386', 'x86_64'], "requires Darwin & i386") def test_process_launch_for_universal(self): """Test process launch of a universal binary.""" From jingham at apple.com Fri Aug 12 19:45:24 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 13 Aug 2011 00:45:24 -0000 Subject: [Lldb-commits] [lldb] r137543 - in /lldb/trunk/test/python_api/value/change_values: ./ Makefile TestValueAPI.py main.c Message-ID: <20110813004524.121BB2A6C12C@llvm.org> Author: jingham Date: Fri Aug 12 19:45:23 2011 New Revision: 137543 URL: http://llvm.org/viewvc/llvm-project?rev=137543&view=rev Log: Test case for changing ValueObjects with SBValue::SetValueFromCString. Added: lldb/trunk/test/python_api/value/change_values/ lldb/trunk/test/python_api/value/change_values/Makefile lldb/trunk/test/python_api/value/change_values/TestValueAPI.py lldb/trunk/test/python_api/value/change_values/main.c Added: lldb/trunk/test/python_api/value/change_values/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/Makefile?rev=137543&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/change_values/Makefile (added) +++ lldb/trunk/test/python_api/value/change_values/Makefile Fri Aug 12 19:45:23 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/value/change_values/TestValueAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/TestValueAPI.py?rev=137543&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/change_values/TestValueAPI.py (added) +++ lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Fri Aug 12 19:45:23 2011 @@ -0,0 +1,147 @@ +""" +Test some SBValue APIs. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class ChangeValueAPITestCase(TestBase): + + mydir = os.path.join("python_api", "value", "change_values") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_change_value_with_dsym(self): + """Exercise the SBValue::SetValueFromCString API.""" + d = {'EXE': self.exe_name} + self.buildDsym(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.change_value_api(self.exe_name) + + @python_api_test + def test_change_value_with_dwarf(self): + """Exercise the SBValue::SetValueFromCString API.""" + d = {'EXE': self.exe_name} + self.buildDwarf(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.change_value_api(self.exe_name) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # We'll use the test method name as the exe_name. + self.exe_name = self.testMethodName + # Find the line number to of function 'c'. + self.line = line_number('main.c', '// Stop here and set values') + self.end_line = line_number ('main.c', '// Set a breakpoint here at the end') + + def change_value_api(self, exe_name): + """Exercise some SBValue APIs.""" + exe = os.path.join(os.getcwd(), exe_name) + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Create the breakpoint inside function 'main'. + breakpoint = target.BreakpointCreateByLocation('main.c', self.line) + self.assertTrue(breakpoint, VALID_BREAKPOINT) + + # Create the breakpoint inside function 'main'. + end_breakpoint = target.BreakpointCreateByLocation('main.c', self.end_line) + self.assertTrue(end_breakpoint, VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Get Frame #0. + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") + frame0 = thread.GetFrameAtIndex(0) + self.assertTrue (frame0.IsValid(), "Got a valid frame.") + + # Get the val variable and change it: + error = lldb.SBError() + + val_value = frame0.FindVariable ("val") + self.assertTrue (val_value.IsValid(), "Got the SBValue for val") + actual_value = val_value.GetValueAsSigned (error, 0); + self.assertTrue (error.Success(), "Got a value from val") + self.assertTrue (actual_value == 100, "Got the right value from val") + + result = val_value.SetValueFromCString ("12345") + self.assertTrue (result, "Setting val returned True.") + actual_value = val_value.GetValueAsSigned (error, 0); + self.assertTrue (error.Success(), "Got a changed value from val") + self.assertTrue (actual_value == 12345, "Got the right changed value from val") + + # Now check that we can set a structure element: + + mine_value = frame0.FindVariable ("mine") + self.assertTrue (mine_value.IsValid(), "Got the SBValue for mine") + + mine_second_value = mine_value.GetChildMemberWithName ("second_val") + self.assertTrue (mine_second_value.IsValid(), "Got second_val from mine") + actual_value = mine_second_value.GetValueAsUnsigned (error, 0) + self.assertTrue (error.Success(), "Got an unsigned value for second_val") + self.assertTrue (actual_value == 5555) + + result = mine_second_value.SetValueFromCString ("98765") + self.assertTrue (result, "Success setting mine.second_value.") + actual_value = mine_second_value.GetValueAsSigned (error, 0); + self.assertTrue (error.Success(), "Got a changed value from mine.second_val") + self.assertTrue (actual_value == 98765, "Got the right changed value from mine.second_val") + + # Next do the same thing with the pointer version. + ptr_value = frame0.FindVariable ("ptr") + self.assertTrue (ptr_value.IsValid(), "Got the SBValue for ptr") + + ptr_second_value = ptr_value.GetChildMemberWithName ("second_val") + self.assertTrue (ptr_second_value.IsValid(), "Got second_val from ptr") + actual_value = ptr_second_value.GetValueAsUnsigned (error, 0) + self.assertTrue (error.Success(), "Got an unsigned value for ptr->second_val") + self.assertTrue (actual_value == 6666) + + result = ptr_second_value.SetValueFromCString ("98765") + self.assertTrue (result, "Success setting ptr->second_value.") + actual_value = ptr_second_value.GetValueAsSigned (error, 0); + self.assertTrue (error.Success(), "Got a changed value from ptr->second_val") + self.assertTrue (actual_value == 98765, "Got the right changed value from ptr->second_val") + + # Now step, grab the stdout and make sure we changed the real values as well... + thread.StepOver() + expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666" + stdout = process.GetSTDOUT(1000) + print stdout + self.assertTrue (expected_value in stdout, "STDOUT showed changed values.") + + # Finally, change the stack pointer to 0, and we should not make it to our end breakpoint. + frame0 = thread.GetFrameAtIndex(0) + self.assertTrue (frame0.IsValid(), "Second time: got a valid frame.") + sp_value = frame0.FindValue ("sp", lldb.eValueTypeRegister); + self.assertTrue (sp_value.IsValid(), "Got a stack pointer value") + result = sp_value.SetValueFromCString("1") + self.assertTrue (result, "Setting sp returned true.") + # GetValueAsUnsigned doesn't work for register value objects yet. + # actual_value = sp_value.GetValueAsUnsigned (error, 0) + # self.assertTrue (error.Success(), "Got a changed value for sp") + # self.assertTrue (actual_value == 1, "Got the right changed value for sp.") + + process.Continue() + + self.assertTrue(process.GetState() == lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread == None, "We should not have managed to hit our second breakpoint with sp == 1") + + process.Kill() + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/value/change_values/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/main.c?rev=137543&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/change_values/main.c (added) +++ lldb/trunk/test/python_api/value/change_values/main.c Fri Aug 12 19:45:23 2011 @@ -0,0 +1,29 @@ +#include +#include +#include + +struct foo +{ + uint8_t first_val; + uint32_t second_val; + uint64_t third_val; +}; + +int main () +{ + int val = 100; + struct foo mine = {55, 5555, 55555555}; + struct foo *ptr = (struct foo *) malloc (sizeof (struct foo)); + ptr->first_val = 66; + ptr->second_val = 6666; + ptr->third_val = 66666666; + + // Stop here and set values + printf ("Val - %d Mine - %d, %d, %llu. Ptr - %d, %d, %llu\n", + val, + mine.first_val, mine.second_val, mine.third_val, + ptr->first_val, ptr->second_val, ptr->third_val); + + printf ("This is just another call which we won't make it over %d.", val); + return 0; // Set a breakpoint here at the end +} From johnny.chen at apple.com Fri Aug 12 19:55:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 13 Aug 2011 00:55:56 -0000 Subject: [Lldb-commits] [lldb] r137544 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20110813005556.D86E32A6C12C@llvm.org> Author: johnny Date: Fri Aug 12 19:55:56 2011 New Revision: 137544 URL: http://llvm.org/viewvc/llvm-project?rev=137544&view=rev Log: Add a simple test case to exercise the SBDebugger.CreateTargetWithFileAndTargetTriple() API. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=137544&r1=137543&r2=137544&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Fri Aug 12 19:55:56 2011 @@ -15,6 +15,25 @@ # Find the line number to break inside main(). self.line = line_number('main.c', '// Set break point at this line.') + @python_api_test + @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4] in ['i386', 'x86_64'], + "requires Darwin & i386") + def test_sbdebugger_create_target_with_file_and_target_triple(self): + """Test the SBDebugger.CreateTargetWithFileAndTargetTriple() API.""" + # Invoke the default build rule. + self.buildDefault() + + # Note that "testit" is a universal binary. + exe = os.path.join(os.getcwd(), "testit") + + # Create a target by the debugger. + target = self.dbg.CreateTargetWithFileAndTargetTriple(exe, "i386-apple-darwin") + self.assertTrue(target, VALID_TARGET) + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + # rdar://problem/8972204 AddressByteSize of 32-bit process should be 4, got 8 instead. @unittest2.skipUnless(sys.platform.startswith("darwin") and os.uname()[4] in ['i386', 'x86_64'], "requires Darwin & i386") From jingham at apple.com Fri Aug 12 19:56:10 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 13 Aug 2011 00:56:10 -0000 Subject: [Lldb-commits] [lldb] r137545 - in /lldb/trunk/source: API/SBDebugger.cpp Target/Process.cpp Message-ID: <20110813005610.BC5392A6C12C@llvm.org> Author: jingham Date: Fri Aug 12 19:56:10 2011 New Revision: 137545 URL: http://llvm.org/viewvc/llvm-project?rev=137545&view=rev Log: Remember to restore the frame in the exe_ctx passed in to RunThreadPlan. Also, default "source_init_file" to False in the version of SBDebugger::Create so that we don't pick up the init file in Python. Modified: lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=137545&r1=137544&r2=137545&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 12 19:56:10 2011 @@ -71,7 +71,7 @@ SBDebugger SBDebugger::Create() { - return SBDebugger::Create(true); + return SBDebugger::Create(false); } SBDebugger Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=137545&r1=137544&r2=137545&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Aug 12 19:56:10 2011 @@ -3359,20 +3359,21 @@ return eExecutionSetupError; } - // Save this value for restoration of the execution context after we run + // Save the thread & frame from the exe_ctx for restoration after we run const uint32_t thread_idx_id = exe_ctx.thread->GetIndexID(); + StackID ctx_frame_id = exe_ctx.thread->GetSelectedFrame()->GetStackID(); // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, // so we should arrange to reset them as well. lldb::ThreadSP selected_thread_sp = exe_ctx.process->GetThreadList().GetSelectedThread(); - lldb::StackFrameSP selected_frame_sp; - uint32_t selected_tid; + uint32_t selected_tid; + StackID selected_stack_id; if (selected_thread_sp != NULL) { selected_tid = selected_thread_sp->GetIndexID(); - selected_frame_sp = selected_thread_sp->GetSelectedFrame(); + selected_stack_id = selected_thread_sp->GetSelectedFrame()->GetStackID(); } else { @@ -3866,20 +3867,25 @@ } // Thread we ran the function in may have gone away because we ran the target - // Check that it's still there. + // Check that it's still there, and if it is put it back in the context. Also restore the + // frame in the context if it is still present. exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(thread_idx_id, true).get(); if (exe_ctx.thread) - exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); + { + exe_ctx.frame = exe_ctx.thread->GetFrameWithStackID (ctx_frame_id).get(); + } // Also restore the current process'es selected frame & thread, since this function calling may // be done behind the user's back. if (selected_tid != LLDB_INVALID_THREAD_ID) { - if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid)) + if (exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID (selected_tid) && selected_stack_id.IsValid()) { // We were able to restore the selected thread, now restore the frame: - exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(selected_frame_sp.get()); + StackFrameSP old_frame_sp = exe_ctx.process->GetThreadList().GetSelectedThread()->GetFrameWithStackID(selected_stack_id); + if (old_frame_sp) + exe_ctx.process->GetThreadList().GetSelectedThread()->SetSelectedFrame(old_frame_sp.get()); } } From gclayton at apple.com Fri Aug 12 20:48:45 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 13 Aug 2011 01:48:45 -0000 Subject: [Lldb-commits] [lldb] r137547 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist source/Core/Debugger.cpp tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110813014845.B87932A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 20:48:45 2011 New Revision: 137547 URL: http://llvm.org/viewvc/llvm-project?rev=137547&view=rev Log: Bumped Xcode project versions for lldb-72 and debugserver-143. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/source/Core/Debugger.cpp 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=137547&r1=137546&r2=137547&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Aug 12 20:48:45 2011 @@ -3423,10 +3423,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 71; + DYLIB_CURRENT_VERSION = 72; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3475,11 +3475,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 71; + DYLIB_CURRENT_VERSION = 72; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3526,8 +3526,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; - DYLIB_CURRENT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; + DYLIB_CURRENT_VERSION = 72; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3565,9 +3565,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 71; + DYLIB_CURRENT_VERSION = 72; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3605,9 +3605,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 71; + DYLIB_CURRENT_VERSION = 72; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3675,7 +3675,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3706,11 +3706,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 71; + DYLIB_CURRENT_VERSION = 72; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3835,7 +3835,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3867,7 +3867,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 71; + CURRENT_PROJECT_VERSION = 72; 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=137547&r1=137546&r2=137547&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Aug 12 20:48:45 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 71 + 72 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=137547&r1=137546&r2=137547&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Aug 12 20:48:45 2011 @@ -260,6 +260,7 @@ process_sp->Destroy(); } DisconnectInput(); + printf("\n\n\nDebugger::~Debugger\n\n\n"); } 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=137547&r1=137546&r2=137547&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Aug 12 20:48:45 2011 @@ -473,7 +473,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; "GCC_VERSION[sdk=iphoneos*][arch=*]" = 4.2; "GCC_VERSION[sdk=macosx*][arch=*]" = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -533,7 +533,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -573,7 +573,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -613,7 +613,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 142; + CURRENT_PROJECT_VERSION = 143; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Fri Aug 12 20:49:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 13 Aug 2011 01:49:08 -0000 Subject: [Lldb-commits] [lldb] r137548 - /lldb/tags/lldb-72/ Message-ID: <20110813014908.DD2482A6C12C@llvm.org> Author: gclayton Date: Fri Aug 12 20:49:08 2011 New Revision: 137548 URL: http://llvm.org/viewvc/llvm-project?rev=137548&view=rev Log: lldb-72 Added: lldb/tags/lldb-72/ - copied from r137547, lldb/trunk/ From jingham at apple.com Sun Aug 14 20:32:22 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 15 Aug 2011 01:32:22 -0000 Subject: [Lldb-commits] [lldb] r137600 - in /lldb/trunk: include/lldb/Target/ObjCLanguageRuntime.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Symbol/Symtab.cpp source/Target/ObjCLanguageRuntime.cpp Message-ID: <20110815013222.E983B2A6C12C@llvm.org> Author: jingham Date: Sun Aug 14 20:32:22 2011 New Revision: 137600 URL: http://llvm.org/viewvc/llvm-project?rev=137600&view=rev Log: Factor out the code that parses ObjC Method names into a static method in ObjCLanguageRuntime. Add the category-free name of symbols to the Symtab name-to-index list. Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Symbol/Symtab.cpp lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Modified: lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h?rev=137600&r1=137599&r2=137600&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h (original) +++ lldb/trunk/include/lldb/Target/ObjCLanguageRuntime.h Sun Aug 14 20:32:22 2011 @@ -93,6 +93,12 @@ virtual size_t GetByteOffsetForIvar (ClangASTType &parent_qual_type, const char *ivar_name); + // If the passed in "name" is an ObjC method, return true. Also, fill in any of the + // sub-parts that are passed in non-NULL. The base_name means the name stripped of + // category attributes. + static bool + ParseMethodName (const char *name, ConstString *class_name, ConstString *method_name, ConstString *base_name); + protected: //------------------------------------------------------------------ // Classes that inherit from ObjCLanguageRuntime can see and modify these Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=137600&r1=137599&r2=137600&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Sun Aug 14 20:32:22 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/ObjCLanguageRuntime.h" #include "DWARFDebugAbbrev.h" #include "DWARFDebugAranges.h" @@ -791,51 +792,22 @@ { if (name) { - if ((name[0] == '-' || name[0] == '+') && name[1] == '[') + ConstString objc_class_name; + ConstString objc_method_name; + ConstString objc_base_name; + if (ObjCLanguageRuntime::ParseMethodName (name, + &objc_class_name, + &objc_method_name, + &objc_base_name)) { - int name_len = strlen (name); - // Objective C methods must have at least: - // "-[" or "+[" prefix - // One character for a class name - // One character for the space between the class name - // One character for the method name - // "]" suffix - if (name_len >= 6 && name[name_len - 1] == ']') + objc_class_selectors.Insert(objc_class_name, die_info); + + func_selectors.Insert (objc_method_name, die_info); + + if (!objc_base_name.IsEmpty()) { - const char *method_name = strchr (name, ' '); - if (method_name) - { - ConstString class_name (name + 2, method_name - name - 2); - - // Keep a map of the objective C class name to all selector - // DIEs - objc_class_selectors.Insert(class_name, die_info); - - // Skip the space - ++method_name; - // Extract the objective C basename and add it to the - // accelerator tables - size_t method_name_len = name_len - (method_name - name) - 1; - func_selectors.Insert (ConstString (method_name, method_name_len), die_info); - - // Also see if this is a "category" on our class. If so strip off the category name, - // and add the class name without it to the basename table. - - const char *first_paren = (char *) memchr (name, '(', method_name - name); - if (first_paren) - { - const char *second_paren = (char *) memchr (first_paren, ')', method_name - first_paren); - if (second_paren) - { - std::string buffer (name, first_paren - name); - buffer.append (second_paren + 1); - ConstString uncategoried_name (buffer.c_str()); - func_basenames.Insert (uncategoried_name, die_info); - func_fullnames.Insert (uncategoried_name, die_info); - - } - } - } + func_basenames.Insert (objc_base_name, die_info); + func_fullnames.Insert (objc_base_name, die_info); } } // If we have a mangled name, then the DW_AT_name attribute @@ -853,7 +825,8 @@ { if (specification_die_offset != DW_INVALID_OFFSET) { - const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL); + const DWARFDebugInfoEntry *specification_die + = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL); if (specification_die) { parent = specification_die->GetParent(); Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=137600&r1=137599&r2=137600&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Sun Aug 14 20:32:22 2011 @@ -14,6 +14,7 @@ #include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symtab.h" +#include "lldb/Target/ObjCLanguageRuntime.h" using namespace lldb; using namespace lldb_private; @@ -308,6 +309,20 @@ entry.cstring = mangled.GetDemangledName().GetCString(); if (entry.cstring && entry.cstring[0]) m_name_to_index.Append (entry); + + // If the demangled name turns out to be an ObjC name, and + // is a category name, add the version without categories to the index too. + ConstString objc_base_name; + if (ObjCLanguageRuntime::ParseMethodName (entry.cstring, + NULL, + NULL, + &objc_base_name) + && !objc_base_name.IsEmpty()) + { + entry.cstring = objc_base_name.GetCString(); + m_name_to_index.Append (entry); + } + } m_name_to_index.Sort(); } Modified: lldb/trunk/source/Target/ObjCLanguageRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCLanguageRuntime.cpp?rev=137600&r1=137599&r2=137600&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCLanguageRuntime.cpp (original) +++ lldb/trunk/source/Target/ObjCLanguageRuntime.cpp Sun Aug 14 20:32:22 2011 @@ -100,3 +100,66 @@ return LLDB_INVALID_IVAR_OFFSET; } + +bool +ObjCLanguageRuntime::ParseMethodName (const char *name, + ConstString *class_name, + ConstString *method_name, + ConstString *base_name) +{ + if (class_name) { class_name->Clear(); } + if (method_name) { method_name->Clear(); } + if (base_name) { base_name->Clear(); } + + if (name && (name[0] == '-' || name[0] == '+') && name[1] == '[') + { + int name_len = strlen (name); + // Objective C methods must have at least: + // "-[" or "+[" prefix + // One character for a class name + // One character for the space between the class name + // One character for the method name + // "]" suffix + if (name_len >= 6 && name[name_len - 1] == ']') + { + const char *method_name_ptr; + method_name_ptr = strchr (name, ' '); + if (method_name_ptr) + { + if (class_name) + class_name->SetCStringWithLength (name + 2, method_name_ptr - name - 2); + + // Skip the space + ++method_name_ptr; + // Extract the objective C basename and add it to the + // accelerator tables + size_t method_name_len = name_len - (method_name_ptr - name) - 1; + if (method_name) + method_name->SetCStringWithLength (method_name_ptr, method_name_len); + + // Also see if this is a "category" on our class. If so strip off the category name, + // and add the class name without it to the basename table. + + if (base_name) + { + const char *first_paren = (char *) memchr (name, '(', method_name_ptr - name); + if (first_paren) + { + const char *second_paren = (char *) memchr (first_paren, ')', method_name_ptr - first_paren); + if (second_paren) + { + std::string buffer (name, first_paren - name); + buffer.append (second_paren + 1); + base_name->SetCString (buffer.c_str()); + + } + } + } + } + return true; + } + return false; + } + else + return false; +} From gclayton at apple.com Sun Aug 14 21:24:40 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Aug 2011 02:24:40 -0000 Subject: [Lldb-commits] [lldb] r137602 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20110815022440.9E8442A6C12C@llvm.org> Author: gclayton Date: Sun Aug 14 21:24:40 2011 New Revision: 137602 URL: http://llvm.org/viewvc/llvm-project?rev=137602&view=rev Log: Added the ability to use llvm::APInt class to view any integers that are larger than a 8 bytes. We can now display signed decimal, unsigned decimal, octal, and binary (we could already view hex before this fix). Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=137602&r1=137601&r2=137602&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Sun Aug 14 21:24:40 2011 @@ -13,6 +13,7 @@ #include #include +#include "llvm/ADT/APInt.h" #include "llvm/Support/MathExtras.h" #include "lldb/Core/DataExtractor.h" @@ -1306,6 +1307,76 @@ return bytes_consumed; } +static uint32_t +DumpAPInt (Stream *s, const DataExtractor &data, uint32_t offset, uint32_t byte_size, bool is_signed, unsigned radix) +{ + llvm::SmallVector uint64_array; + uint32_t bytes_left = byte_size; + uint64_t u64; + const lldb::ByteOrder byte_order = data.GetByteOrder(); + if (byte_order == lldb::eByteOrderLittle) + { + while (bytes_left > 0) + { + if (bytes_left >= 8) + { + u64 = data.GetU64(&offset); + bytes_left -= 8; + } + else + { + u64 = data.GetMaxU64(&offset, bytes_left); + bytes_left = 0; + } + uint64_array.push_back(u64); + } + } + else if (byte_order == lldb::eByteOrderBig) + { + uint32_t be_offset = offset + byte_size; + uint32_t temp_offset; + while (bytes_left > 0) + { + if (bytes_left >= 8) + { + be_offset -= 8; + temp_offset = be_offset; + u64 = data.GetU64(&temp_offset); + bytes_left -= 8; + } + else + { + be_offset -= bytes_left; + temp_offset = be_offset; + u64 = data.GetMaxU64(&temp_offset, bytes_left); + bytes_left = 0; + } + uint64_array.push_back(u64); + } + } + else + return offset; + + llvm::APInt apint (byte_size * 8, + uint64_array.size(), + uint64_array.data()); + + std::string apint_str(apint.toString(radix, is_signed)); + switch (radix) + { + case 2: + s->Write ("0b", 2); + break; + case 8: + s->Write ("0", 1); + break; + case 10: + break; + } + s->Write(apint_str.c_str(), apint_str.size()); + return offset; +} + uint32_t DataExtractor::Dump ( @@ -1370,6 +1441,7 @@ break; case eFormatBinary: + if (item_byte_size <= 8) { uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset); // Avoid std::bitset<64>::to_string() since it is missing in @@ -1384,6 +1456,12 @@ else if (item_byte_size > 0 && item_byte_size <= 8) s->Printf("0b%s", binary_value.c_str() + 64 - item_byte_size * 8); } + else + { + const bool is_signed = false; + const unsigned radix = 2; + offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix); + } break; case eFormatBytes: @@ -1445,16 +1523,34 @@ case eFormatDecimal: if (item_byte_size <= 8) s->Printf ("%lld", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); + else + { + const bool is_signed = true; + const unsigned radix = 10; + offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix); + } break; case eFormatUnsigned: if (item_byte_size <= 8) s->Printf ("%llu", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); + else + { + const bool is_signed = false; + const unsigned radix = 10; + offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix); + } break; case eFormatOctal: if (item_byte_size <= 8) s->Printf ("0%llo", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); + else + { + const bool is_signed = false; + const unsigned radix = 8; + offset = DumpAPInt (s, *this, offset, item_byte_size, is_signed, radix); + } break; case eFormatOSType: From johnso87 at crhc.illinois.edu Sun Aug 14 23:20:33 2011 From: johnso87 at crhc.illinois.edu (Matt Johnson) Date: Sun, 14 Aug 2011 23:20:33 -0500 Subject: [Lldb-commits] [PATCH] Disambiguate APInt() call, fix build on GCC 4.5.2 Message-ID: <4E489E91.6050503@crhc.illinois.edu> Hi All, r137602 added a call to the (deprecated; see llvm/include/llvm/ADT/APInt.h) APInt constructor that takes a size and pointer for a word array. The reason this constructor is deprecated is that it is prone to ambiguity with another constructor that takes a single word and a bool that denotes the signedness of the value. The deprecated constructor has been supplanted by one that takes a single ArrayRef parameter that encapsulates the size and a pointer to the word array. The attached patch calls the other constructor instead, and avoids the following build-breaker on gcc 4.5.2: DataExtractor.cpp: In function ?uint32_t DumpAPInt(lldb_private::Stream*, const lldb_private::DataExtractor&, uint32_t, uint32_t, bool, unsigned int)?: DataExtractor.cpp:1362:55: error: call of overloaded ?APInt(uint32_t, llvm::SmallVectorTemplateCommon::size_type, uint64_t*)? is ambiguous /media/d2/llvm/include/llvm/ADT/APInt.h:250:3: note: candidates are: llvm::APInt::APInt(unsigned int, unsigned int, const uint64_t*) /media/d2/llvm/include/llvm/ADT/APInt.h:227:3: note: llvm::APInt::APInt(unsigned int, uint64_t, bool) You can also get around this error by casting the second argument to (unsigned), but I think this solution is cleaner. Best, Matt -------------- next part -------------- A non-text attachment was scrubbed... Name: apint_constructor.diff Type: text/x-diff Size: 739 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110814/be6118aa/attachment.bin