Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- Target.cpp ----------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "lldb/Target/Target.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Breakpoint/BreakpointResolver.h" |
| 17 | #include "lldb/Breakpoint/BreakpointResolverAddress.h" |
| 18 | #include "lldb/Breakpoint/BreakpointResolverFileLine.h" |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 19 | #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Breakpoint/BreakpointResolverName.h" |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 21 | #include "lldb/Breakpoint/Watchpoint.h" |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 22 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Core/Event.h" |
| 24 | #include "lldb/Core/Log.h" |
Caroline Tice | 4a34808 | 2011-05-02 20:41:46 +0000 | [diff] [blame] | 25 | #include "lldb/Core/StreamAsynchronousIO.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 26 | #include "lldb/Core/StreamString.h" |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 27 | #include "lldb/Core/Timer.h" |
| 28 | #include "lldb/Core/ValueObject.h" |
Sean Callanan | dcf03f8 | 2011-11-15 22:27:19 +0000 | [diff] [blame] | 29 | #include "lldb/Expression/ClangASTSource.h" |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 30 | #include "lldb/Expression/ClangUserExpression.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | #include "lldb/Host/Host.h" |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 32 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 33 | #include "lldb/Interpreter/CommandReturnObject.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 34 | #include "lldb/lldb-private-log.h" |
| 35 | #include "lldb/Symbol/ObjectFile.h" |
| 36 | #include "lldb/Target/Process.h" |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 37 | #include "lldb/Target/StackFrame.h" |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 38 | #include "lldb/Target/Thread.h" |
| 39 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 40 | |
| 41 | using namespace lldb; |
| 42 | using namespace lldb_private; |
| 43 | |
| 44 | //---------------------------------------------------------------------- |
| 45 | // Target constructor |
| 46 | //---------------------------------------------------------------------- |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 47 | Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp) : |
| 48 | Broadcaster ("lldb.target"), |
| 49 | ExecutionContextScope (), |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 50 | TargetInstanceSettings (GetSettingsController()), |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 51 | m_debugger (debugger), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 52 | m_platform_sp (platform_sp), |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 53 | m_mutex (Mutex::eMutexTypeRecursive), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 54 | m_arch (target_arch), |
| 55 | m_images (), |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 56 | m_section_load_list (), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | m_breakpoint_list (false), |
| 58 | m_internal_breakpoint_list (true), |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 59 | m_watchpoint_list (), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 60 | m_process_sp (), |
| 61 | m_search_filter_sp (), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | m_image_search_paths (ImageSearchPathsChanged, this), |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 63 | m_scratch_ast_context_ap (NULL), |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 64 | m_scratch_ast_source_ap (NULL), |
| 65 | m_ast_importer_ap (NULL), |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 66 | m_persistent_variables (), |
Jim Ingham | cc63746 | 2011-09-13 00:29:56 +0000 | [diff] [blame] | 67 | m_source_manager(*this), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 68 | m_stop_hooks (), |
Jim Ingham | 3613ae1 | 2011-05-12 02:06:14 +0000 | [diff] [blame] | 69 | m_stop_hook_next_id (0), |
| 70 | m_suppress_stop_hooks (false) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 71 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 72 | SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed"); |
| 73 | SetEventName (eBroadcastBitModulesLoaded, "modules-loaded"); |
| 74 | SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded"); |
| 75 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 76 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | if (log) |
| 78 | log->Printf ("%p Target::Target()", this); |
| 79 | } |
| 80 | |
| 81 | //---------------------------------------------------------------------- |
| 82 | // Destructor |
| 83 | //---------------------------------------------------------------------- |
| 84 | Target::~Target() |
| 85 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 86 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 87 | if (log) |
| 88 | log->Printf ("%p Target::~Target()", this); |
| 89 | DeleteCurrentProcess (); |
| 90 | } |
| 91 | |
| 92 | void |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 93 | Target::Dump (Stream *s, lldb::DescriptionLevel description_level) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 94 | { |
Greg Clayton | 3fed8b9 | 2010-10-08 00:21:05 +0000 | [diff] [blame] | 95 | // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 96 | if (description_level != lldb::eDescriptionLevelBrief) |
| 97 | { |
| 98 | s->Indent(); |
| 99 | s->PutCString("Target\n"); |
| 100 | s->IndentMore(); |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 101 | m_images.Dump(s); |
| 102 | m_breakpoint_list.Dump(s); |
| 103 | m_internal_breakpoint_list.Dump(s); |
| 104 | s->IndentLess(); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 105 | } |
| 106 | else |
| 107 | { |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 108 | Module *exe_module = GetExecutableModulePointer(); |
| 109 | if (exe_module) |
| 110 | s->PutCString (exe_module->GetFileSpec().GetFilename().GetCString()); |
Jim Ingham | 53fe9cc | 2011-05-12 01:12:28 +0000 | [diff] [blame] | 111 | else |
| 112 | s->PutCString ("No executable module."); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 113 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | void |
| 117 | Target::DeleteCurrentProcess () |
| 118 | { |
| 119 | if (m_process_sp.get()) |
| 120 | { |
Greg Clayton | 49480b1 | 2010-09-14 23:52:43 +0000 | [diff] [blame] | 121 | m_section_load_list.Clear(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 122 | if (m_process_sp->IsAlive()) |
| 123 | m_process_sp->Destroy(); |
Jim Ingham | 88fa7bd | 2011-02-16 17:54:55 +0000 | [diff] [blame] | 124 | |
| 125 | m_process_sp->Finalize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 126 | |
| 127 | // Do any cleanup of the target we need to do between process instances. |
| 128 | // NB It is better to do this before destroying the process in case the |
| 129 | // clean up needs some help from the process. |
| 130 | m_breakpoint_list.ClearAllBreakpointSites(); |
| 131 | m_internal_breakpoint_list.ClearAllBreakpointSites(); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 132 | // Disable watchpoints just on the debugger side. |
| 133 | DisableAllWatchpoints(false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 134 | m_process_sp.reset(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | const lldb::ProcessSP & |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 139 | Target::CreateProcess (Listener &listener, const char *plugin_name, const FileSpec *crash_file) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 140 | { |
| 141 | DeleteCurrentProcess (); |
Greg Clayton | 46c9a35 | 2012-02-09 06:16:32 +0000 | [diff] [blame] | 142 | m_process_sp = Process::FindPlugin(*this, plugin_name, listener, crash_file); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 143 | return m_process_sp; |
| 144 | } |
| 145 | |
| 146 | const lldb::ProcessSP & |
| 147 | Target::GetProcessSP () const |
| 148 | { |
| 149 | return m_process_sp; |
| 150 | } |
| 151 | |
Greg Clayton | 153ccd7 | 2011-08-10 02:10:13 +0000 | [diff] [blame] | 152 | void |
| 153 | Target::Destroy() |
| 154 | { |
| 155 | Mutex::Locker locker (m_mutex); |
| 156 | DeleteCurrentProcess (); |
| 157 | m_platform_sp.reset(); |
| 158 | m_arch.Clear(); |
| 159 | m_images.Clear(); |
| 160 | m_section_load_list.Clear(); |
| 161 | const bool notify = false; |
| 162 | m_breakpoint_list.RemoveAll(notify); |
| 163 | m_internal_breakpoint_list.RemoveAll(notify); |
| 164 | m_last_created_breakpoint.reset(); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 165 | m_last_created_watchpoint.reset(); |
Greg Clayton | 153ccd7 | 2011-08-10 02:10:13 +0000 | [diff] [blame] | 166 | m_search_filter_sp.reset(); |
| 167 | m_image_search_paths.Clear(notify); |
| 168 | m_scratch_ast_context_ap.reset(); |
Sean Callanan | dcf03f8 | 2011-11-15 22:27:19 +0000 | [diff] [blame] | 169 | m_scratch_ast_source_ap.reset(); |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 170 | m_ast_importer_ap.reset(); |
Greg Clayton | 153ccd7 | 2011-08-10 02:10:13 +0000 | [diff] [blame] | 171 | m_persistent_variables.Clear(); |
| 172 | m_stop_hooks.clear(); |
| 173 | m_stop_hook_next_id = 0; |
| 174 | m_suppress_stop_hooks = false; |
| 175 | } |
| 176 | |
| 177 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 178 | BreakpointList & |
| 179 | Target::GetBreakpointList(bool internal) |
| 180 | { |
| 181 | if (internal) |
| 182 | return m_internal_breakpoint_list; |
| 183 | else |
| 184 | return m_breakpoint_list; |
| 185 | } |
| 186 | |
| 187 | const BreakpointList & |
| 188 | Target::GetBreakpointList(bool internal) const |
| 189 | { |
| 190 | if (internal) |
| 191 | return m_internal_breakpoint_list; |
| 192 | else |
| 193 | return m_breakpoint_list; |
| 194 | } |
| 195 | |
| 196 | BreakpointSP |
| 197 | Target::GetBreakpointByID (break_id_t break_id) |
| 198 | { |
| 199 | BreakpointSP bp_sp; |
| 200 | |
| 201 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 202 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 203 | else |
| 204 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 205 | |
| 206 | return bp_sp; |
| 207 | } |
| 208 | |
| 209 | BreakpointSP |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 210 | Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules, |
| 211 | const FileSpecList *source_file_spec_list, |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 212 | RegularExpression &source_regex, |
| 213 | bool internal) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 214 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 215 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list)); |
| 216 | BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex)); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 217 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | BreakpointSP |
| 222 | Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal) |
| 223 | { |
| 224 | SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 225 | BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines)); |
| 226 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | BreakpointSP |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 231 | Target::CreateBreakpoint (lldb::addr_t addr, bool internal) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 232 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 233 | Address so_addr; |
| 234 | // Attempt to resolve our load address if possible, though it is ok if |
| 235 | // it doesn't resolve to section/offset. |
| 236 | |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 237 | // Try and resolve as a load address if possible |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 238 | m_section_load_list.ResolveLoadAddress(addr, so_addr); |
Greg Clayton | 33ed170 | 2010-08-24 00:45:41 +0000 | [diff] [blame] | 239 | if (!so_addr.IsValid()) |
| 240 | { |
| 241 | // The address didn't resolve, so just set this as an absolute address |
| 242 | so_addr.SetOffset (addr); |
| 243 | } |
| 244 | BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 245 | return bp_sp; |
| 246 | } |
| 247 | |
| 248 | BreakpointSP |
| 249 | Target::CreateBreakpoint (Address &addr, bool internal) |
| 250 | { |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 251 | SearchFilterSP filter_sp(new SearchFilterForNonModuleSpecificSearches (shared_from_this())); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 252 | BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr)); |
| 253 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 254 | } |
| 255 | |
| 256 | BreakpointSP |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 257 | Target::CreateBreakpoint (const FileSpecList *containingModules, |
| 258 | const FileSpecList *containingSourceFiles, |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 259 | const char *func_name, |
| 260 | uint32_t func_name_type_mask, |
| 261 | bool internal, |
| 262 | LazyBool skip_prologue) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 263 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 264 | BreakpointSP bp_sp; |
| 265 | if (func_name) |
| 266 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 267 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 268 | |
| 269 | BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, |
| 270 | func_name, |
| 271 | func_name_type_mask, |
| 272 | Breakpoint::Exact, |
| 273 | skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 274 | bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 275 | } |
| 276 | return bp_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | |
| 280 | SearchFilterSP |
| 281 | Target::GetSearchFilterForModule (const FileSpec *containingModule) |
| 282 | { |
| 283 | SearchFilterSP filter_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 284 | if (containingModule != NULL) |
| 285 | { |
| 286 | // TODO: We should look into sharing module based search filters |
| 287 | // across many breakpoints like we do for the simple target based one |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 288 | filter_sp.reset (new SearchFilterByModule (shared_from_this(), *containingModule)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 289 | } |
| 290 | else |
| 291 | { |
| 292 | if (m_search_filter_sp.get() == NULL) |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 293 | m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (shared_from_this())); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 294 | filter_sp = m_search_filter_sp; |
| 295 | } |
| 296 | return filter_sp; |
| 297 | } |
| 298 | |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 299 | SearchFilterSP |
| 300 | Target::GetSearchFilterForModuleList (const FileSpecList *containingModules) |
| 301 | { |
| 302 | SearchFilterSP filter_sp; |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 303 | if (containingModules && containingModules->GetSize() != 0) |
| 304 | { |
| 305 | // TODO: We should look into sharing module based search filters |
| 306 | // across many breakpoints like we do for the simple target based one |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 307 | filter_sp.reset (new SearchFilterByModuleList (shared_from_this(), *containingModules)); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 308 | } |
| 309 | else |
| 310 | { |
| 311 | if (m_search_filter_sp.get() == NULL) |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 312 | m_search_filter_sp.reset (new SearchFilterForNonModuleSpecificSearches (shared_from_this())); |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 313 | filter_sp = m_search_filter_sp; |
| 314 | } |
| 315 | return filter_sp; |
| 316 | } |
| 317 | |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 318 | SearchFilterSP |
| 319 | Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles) |
| 320 | { |
| 321 | if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0) |
| 322 | return GetSearchFilterForModuleList(containingModules); |
| 323 | |
| 324 | SearchFilterSP filter_sp; |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 325 | if (containingModules == NULL) |
| 326 | { |
| 327 | // We could make a special "CU List only SearchFilter". Better yet was if these could be composable, |
| 328 | // but that will take a little reworking. |
| 329 | |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 330 | filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), FileSpecList(), *containingSourceFiles)); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 331 | } |
| 332 | else |
| 333 | { |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 334 | filter_sp.reset (new SearchFilterByModuleListAndCU (shared_from_this(), *containingModules, *containingSourceFiles)); |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 335 | } |
| 336 | return filter_sp; |
| 337 | } |
| 338 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 339 | BreakpointSP |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 340 | Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, |
| 341 | const FileSpecList *containingSourceFiles, |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 342 | RegularExpression &func_regex, |
| 343 | bool internal, |
| 344 | LazyBool skip_prologue) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 345 | { |
Jim Ingham | d6d4797 | 2011-09-23 00:54:11 +0000 | [diff] [blame] | 346 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 347 | BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, |
| 348 | func_regex, |
| 349 | skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 350 | |
| 351 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 352 | } |
| 353 | |
| 354 | BreakpointSP |
| 355 | Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal) |
| 356 | { |
| 357 | BreakpointSP bp_sp; |
| 358 | if (filter_sp && resolver_sp) |
| 359 | { |
| 360 | bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp)); |
| 361 | resolver_sp->SetBreakpoint (bp_sp.get()); |
| 362 | |
| 363 | if (internal) |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 364 | m_internal_breakpoint_list.Add (bp_sp, false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 365 | else |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 366 | m_breakpoint_list.Add (bp_sp, true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 367 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 368 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 369 | if (log) |
| 370 | { |
| 371 | StreamString s; |
| 372 | bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); |
| 373 | log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData()); |
| 374 | } |
| 375 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 376 | bp_sp->ResolveBreakpoint(); |
| 377 | } |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 378 | |
| 379 | if (!internal && bp_sp) |
| 380 | { |
| 381 | m_last_created_breakpoint = bp_sp; |
| 382 | } |
| 383 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 384 | return bp_sp; |
| 385 | } |
| 386 | |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 387 | bool |
| 388 | Target::ProcessIsValid() |
| 389 | { |
| 390 | return (m_process_sp && m_process_sp->IsAlive()); |
| 391 | } |
| 392 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 393 | // See also Watchpoint::SetWatchpointType(uint32_t type) and |
Johnny Chen | 87ff53b | 2011-09-14 00:26:03 +0000 | [diff] [blame] | 394 | // the OptionGroupWatchpoint::WatchType enum type. |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 395 | WatchpointSP |
| 396 | Target::CreateWatchpoint(lldb::addr_t addr, size_t size, uint32_t type) |
Johnny Chen | 34bbf85 | 2011-09-12 23:38:44 +0000 | [diff] [blame] | 397 | { |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 398 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 399 | if (log) |
| 400 | log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n", |
| 401 | __FUNCTION__, addr, size, type); |
| 402 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 403 | WatchpointSP wp_sp; |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 404 | if (!ProcessIsValid()) |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 405 | return wp_sp; |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 406 | if (addr == LLDB_INVALID_ADDRESS || size == 0) |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 407 | return wp_sp; |
Johnny Chen | 9bf1199 | 2011-09-13 01:15:36 +0000 | [diff] [blame] | 408 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 409 | // Currently we only support one watchpoint per address, with total number |
| 410 | // of watchpoints limited by the hardware which the inferior is running on. |
| 411 | WatchpointSP matched_sp = m_watchpoint_list.FindByAddress(addr); |
Johnny Chen | 69b6ec8 | 2011-09-13 23:29:31 +0000 | [diff] [blame] | 412 | if (matched_sp) |
| 413 | { |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 414 | size_t old_size = matched_sp->GetByteSize(); |
Johnny Chen | 69b6ec8 | 2011-09-13 23:29:31 +0000 | [diff] [blame] | 415 | uint32_t old_type = |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 416 | (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) | |
| 417 | (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 418 | // Return the existing watchpoint if both size and type match. |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 419 | if (size == old_size && type == old_type) { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 420 | wp_sp = matched_sp; |
| 421 | wp_sp->SetEnabled(false); |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 422 | } else { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 423 | // Nil the matched watchpoint; we will be creating a new one. |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 424 | m_process_sp->DisableWatchpoint(matched_sp.get()); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 425 | m_watchpoint_list.Remove(matched_sp->GetID()); |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 426 | } |
Johnny Chen | 69b6ec8 | 2011-09-13 23:29:31 +0000 | [diff] [blame] | 427 | } |
| 428 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 429 | if (!wp_sp) { |
| 430 | Watchpoint *new_wp = new Watchpoint(addr, size); |
| 431 | if (!new_wp) { |
| 432 | printf("Watchpoint ctor failed, out of memory?\n"); |
| 433 | return wp_sp; |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 434 | } |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 435 | new_wp->SetWatchpointType(type); |
| 436 | new_wp->SetTarget(this); |
| 437 | wp_sp.reset(new_wp); |
| 438 | m_watchpoint_list.Add(wp_sp); |
Johnny Chen | 22a56cc | 2011-09-14 22:20:15 +0000 | [diff] [blame] | 439 | } |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 440 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 441 | Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 442 | if (log) |
| 443 | log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n", |
| 444 | __FUNCTION__, |
| 445 | rc.Success() ? "succeeded" : "failed", |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 446 | wp_sp->GetID()); |
Johnny Chen | 5b2fc57 | 2011-09-14 20:23:45 +0000 | [diff] [blame] | 447 | |
Johnny Chen | 5eb54bb | 2011-09-27 20:29:45 +0000 | [diff] [blame] | 448 | if (rc.Fail()) |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 449 | wp_sp.reset(); |
Johnny Chen | 5eb54bb | 2011-09-27 20:29:45 +0000 | [diff] [blame] | 450 | else |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 451 | m_last_created_watchpoint = wp_sp; |
| 452 | return wp_sp; |
Johnny Chen | 34bbf85 | 2011-09-12 23:38:44 +0000 | [diff] [blame] | 453 | } |
| 454 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 455 | void |
| 456 | Target::RemoveAllBreakpoints (bool internal_also) |
| 457 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 458 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 459 | if (log) |
| 460 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 461 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 462 | m_breakpoint_list.RemoveAll (true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 463 | if (internal_also) |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 464 | m_internal_breakpoint_list.RemoveAll (false); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 465 | |
| 466 | m_last_created_breakpoint.reset(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | void |
| 470 | Target::DisableAllBreakpoints (bool internal_also) |
| 471 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 472 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 473 | if (log) |
| 474 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 475 | |
| 476 | m_breakpoint_list.SetEnabledAll (false); |
| 477 | if (internal_also) |
| 478 | m_internal_breakpoint_list.SetEnabledAll (false); |
| 479 | } |
| 480 | |
| 481 | void |
| 482 | Target::EnableAllBreakpoints (bool internal_also) |
| 483 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 484 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 485 | if (log) |
| 486 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 487 | |
| 488 | m_breakpoint_list.SetEnabledAll (true); |
| 489 | if (internal_also) |
| 490 | m_internal_breakpoint_list.SetEnabledAll (true); |
| 491 | } |
| 492 | |
| 493 | bool |
| 494 | Target::RemoveBreakpointByID (break_id_t break_id) |
| 495 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 496 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 497 | if (log) |
| 498 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 499 | |
| 500 | if (DisableBreakpointByID (break_id)) |
| 501 | { |
| 502 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 503 | m_internal_breakpoint_list.Remove(break_id, false); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 504 | else |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 505 | { |
Greg Clayton | 22c9e0d | 2011-01-24 23:35:47 +0000 | [diff] [blame] | 506 | if (m_last_created_breakpoint) |
| 507 | { |
| 508 | if (m_last_created_breakpoint->GetID() == break_id) |
| 509 | m_last_created_breakpoint.reset(); |
| 510 | } |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 511 | m_breakpoint_list.Remove(break_id, true); |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 512 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 513 | return true; |
| 514 | } |
| 515 | return false; |
| 516 | } |
| 517 | |
| 518 | bool |
| 519 | Target::DisableBreakpointByID (break_id_t break_id) |
| 520 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 521 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 522 | if (log) |
| 523 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 524 | |
| 525 | BreakpointSP bp_sp; |
| 526 | |
| 527 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 528 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 529 | else |
| 530 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 531 | if (bp_sp) |
| 532 | { |
| 533 | bp_sp->SetEnabled (false); |
| 534 | return true; |
| 535 | } |
| 536 | return false; |
| 537 | } |
| 538 | |
| 539 | bool |
| 540 | Target::EnableBreakpointByID (break_id_t break_id) |
| 541 | { |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 542 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 543 | if (log) |
| 544 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", |
| 545 | __FUNCTION__, |
| 546 | break_id, |
| 547 | LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 548 | |
| 549 | BreakpointSP bp_sp; |
| 550 | |
| 551 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 552 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 553 | else |
| 554 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 555 | |
| 556 | if (bp_sp) |
| 557 | { |
| 558 | bp_sp->SetEnabled (true); |
| 559 | return true; |
| 560 | } |
| 561 | return false; |
| 562 | } |
| 563 | |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 564 | // The flag 'end_to_end', default to true, signifies that the operation is |
| 565 | // performed end to end, for both the debugger and the debuggee. |
| 566 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 567 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end |
| 568 | // to end operations. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 569 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 570 | Target::RemoveAllWatchpoints (bool end_to_end) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 571 | { |
| 572 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 573 | if (log) |
| 574 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 575 | |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 576 | if (!end_to_end) { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 577 | m_watchpoint_list.RemoveAll(); |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 578 | return true; |
| 579 | } |
| 580 | |
| 581 | // Otherwise, it's an end to end operation. |
| 582 | |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 583 | if (!ProcessIsValid()) |
| 584 | return false; |
| 585 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 586 | size_t num_watchpoints = m_watchpoint_list.GetSize(); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 587 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 588 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 589 | WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); |
| 590 | if (!wp_sp) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 591 | return false; |
| 592 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 593 | Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 594 | if (rc.Fail()) |
| 595 | return false; |
| 596 | } |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 597 | m_watchpoint_list.RemoveAll (); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 598 | return true; // Success! |
| 599 | } |
| 600 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 601 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to |
| 602 | // end operations. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 603 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 604 | Target::DisableAllWatchpoints (bool end_to_end) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 605 | { |
| 606 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 607 | if (log) |
| 608 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 609 | |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 610 | if (!end_to_end) { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 611 | m_watchpoint_list.SetEnabledAll(false); |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 612 | return true; |
| 613 | } |
| 614 | |
| 615 | // Otherwise, it's an end to end operation. |
| 616 | |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 617 | if (!ProcessIsValid()) |
| 618 | return false; |
| 619 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 620 | size_t num_watchpoints = m_watchpoint_list.GetSize(); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 621 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 622 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 623 | WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); |
| 624 | if (!wp_sp) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 625 | return false; |
| 626 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 627 | Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 628 | if (rc.Fail()) |
| 629 | return false; |
| 630 | } |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 631 | return true; // Success! |
| 632 | } |
| 633 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 634 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list for end to |
| 635 | // end operations. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 636 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 637 | Target::EnableAllWatchpoints (bool end_to_end) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 638 | { |
| 639 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 640 | if (log) |
| 641 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 642 | |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 643 | if (!end_to_end) { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 644 | m_watchpoint_list.SetEnabledAll(true); |
Johnny Chen | c86582f | 2011-09-23 21:21:43 +0000 | [diff] [blame] | 645 | return true; |
| 646 | } |
| 647 | |
| 648 | // Otherwise, it's an end to end operation. |
| 649 | |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 650 | if (!ProcessIsValid()) |
| 651 | return false; |
| 652 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 653 | size_t num_watchpoints = m_watchpoint_list.GetSize(); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 654 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 655 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 656 | WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); |
| 657 | if (!wp_sp) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 658 | return false; |
| 659 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 660 | Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 661 | if (rc.Fail()) |
| 662 | return false; |
| 663 | } |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 664 | return true; // Success! |
| 665 | } |
| 666 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 667 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 668 | // during these operations. |
| 669 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 670 | Target::IgnoreAllWatchpoints (uint32_t ignore_count) |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 671 | { |
| 672 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 673 | if (log) |
| 674 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 675 | |
| 676 | if (!ProcessIsValid()) |
| 677 | return false; |
| 678 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 679 | size_t num_watchpoints = m_watchpoint_list.GetSize(); |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 680 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 681 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 682 | WatchpointSP wp_sp = m_watchpoint_list.GetByIndex(i); |
| 683 | if (!wp_sp) |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 684 | return false; |
| 685 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 686 | wp_sp->SetIgnoreCount(ignore_count); |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 687 | } |
| 688 | return true; // Success! |
| 689 | } |
| 690 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 691 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 692 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 693 | Target::DisableWatchpointByID (lldb::watch_id_t watch_id) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 694 | { |
| 695 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 696 | if (log) |
| 697 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 698 | |
| 699 | if (!ProcessIsValid()) |
| 700 | return false; |
| 701 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 702 | WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); |
| 703 | if (wp_sp) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 704 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 705 | Error rc = m_process_sp->DisableWatchpoint(wp_sp.get()); |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 706 | if (rc.Success()) |
| 707 | return true; |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 708 | |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 709 | // Else, fallthrough. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 710 | } |
| 711 | return false; |
| 712 | } |
| 713 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 714 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 715 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 716 | Target::EnableWatchpointByID (lldb::watch_id_t watch_id) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 717 | { |
| 718 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 719 | if (log) |
| 720 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 721 | |
| 722 | if (!ProcessIsValid()) |
| 723 | return false; |
| 724 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 725 | WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); |
| 726 | if (wp_sp) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 727 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 728 | Error rc = m_process_sp->EnableWatchpoint(wp_sp.get()); |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 729 | if (rc.Success()) |
| 730 | return true; |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 731 | |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 732 | // Else, fallthrough. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 733 | } |
| 734 | return false; |
| 735 | } |
| 736 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 737 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list. |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 738 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 739 | Target::RemoveWatchpointByID (lldb::watch_id_t watch_id) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 740 | { |
| 741 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 742 | if (log) |
| 743 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 744 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 745 | if (DisableWatchpointByID (watch_id)) |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 746 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 747 | m_watchpoint_list.Remove(watch_id); |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 748 | return true; |
| 749 | } |
| 750 | return false; |
| 751 | } |
| 752 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 753 | // Assumption: Caller holds the list mutex lock for m_watchpoint_list. |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 754 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 755 | Target::IgnoreWatchpointByID (lldb::watch_id_t watch_id, uint32_t ignore_count) |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 756 | { |
| 757 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 758 | if (log) |
| 759 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 760 | |
| 761 | if (!ProcessIsValid()) |
| 762 | return false; |
| 763 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 764 | WatchpointSP wp_sp = m_watchpoint_list.FindByID (watch_id); |
| 765 | if (wp_sp) |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 766 | { |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 767 | wp_sp->SetIgnoreCount(ignore_count); |
Johnny Chen | e14cf4e | 2011-10-05 21:35:46 +0000 | [diff] [blame] | 768 | return true; |
| 769 | } |
| 770 | return false; |
| 771 | } |
| 772 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 773 | ModuleSP |
| 774 | Target::GetExecutableModule () |
| 775 | { |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 776 | return m_images.GetModuleAtIndex(0); |
| 777 | } |
| 778 | |
| 779 | Module* |
| 780 | Target::GetExecutableModulePointer () |
| 781 | { |
| 782 | return m_images.GetModulePointerAtIndex(0); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | void |
| 786 | Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) |
| 787 | { |
| 788 | m_images.Clear(); |
| 789 | m_scratch_ast_context_ap.reset(); |
Sean Callanan | dcf03f8 | 2011-11-15 22:27:19 +0000 | [diff] [blame] | 790 | m_scratch_ast_source_ap.reset(); |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 791 | m_ast_importer_ap.reset(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 792 | |
| 793 | if (executable_sp.get()) |
| 794 | { |
| 795 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 796 | "Target::SetExecutableModule (executable = '%s/%s')", |
| 797 | executable_sp->GetFileSpec().GetDirectory().AsCString(), |
| 798 | executable_sp->GetFileSpec().GetFilename().AsCString()); |
| 799 | |
| 800 | m_images.Append(executable_sp); // The first image is our exectuable file |
| 801 | |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 802 | // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module. |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 803 | if (!m_arch.IsValid()) |
| 804 | m_arch = executable_sp->GetArchitecture(); |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 805 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 806 | FileSpecList dependent_files; |
Greg Clayton | e4b9c1f | 2011-03-08 22:40:15 +0000 | [diff] [blame] | 807 | ObjectFile *executable_objfile = executable_sp->GetObjectFile(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 808 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 809 | if (executable_objfile && get_dependent_files) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 810 | { |
| 811 | executable_objfile->GetDependentModules(dependent_files); |
| 812 | for (uint32_t i=0; i<dependent_files.GetSize(); i++) |
| 813 | { |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 814 | FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i)); |
| 815 | FileSpec platform_dependent_file_spec; |
| 816 | if (m_platform_sp) |
Greg Clayton | cb8977d | 2011-03-23 00:09:55 +0000 | [diff] [blame] | 817 | m_platform_sp->GetFile (dependent_file_spec, NULL, platform_dependent_file_spec); |
Greg Clayton | b1888f2 | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 818 | else |
| 819 | platform_dependent_file_spec = dependent_file_spec; |
| 820 | |
| 821 | ModuleSP image_module_sp(GetSharedModule (platform_dependent_file_spec, |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 822 | m_arch)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 823 | if (image_module_sp.get()) |
| 824 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 825 | ObjectFile *objfile = image_module_sp->GetObjectFile(); |
| 826 | if (objfile) |
| 827 | objfile->GetDependentModules(dependent_files); |
| 828 | } |
| 829 | } |
| 830 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 831 | } |
Caroline Tice | 1ebef44 | 2010-09-27 00:30:10 +0000 | [diff] [blame] | 832 | |
| 833 | UpdateInstanceName(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 837 | bool |
| 838 | Target::SetArchitecture (const ArchSpec &arch_spec) |
| 839 | { |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 840 | if (m_arch == arch_spec) |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 841 | { |
| 842 | // If we're setting the architecture to our current architecture, we |
| 843 | // don't need to do anything. |
| 844 | return true; |
| 845 | } |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 846 | else if (!m_arch.IsValid()) |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 847 | { |
| 848 | // If we haven't got a valid arch spec, then we just need to set it. |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 849 | m_arch = arch_spec; |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 850 | return true; |
| 851 | } |
| 852 | else |
| 853 | { |
| 854 | // If we have an executable file, try to reset the executable to the desired architecture |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 855 | m_arch = arch_spec; |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 856 | ModuleSP executable_sp = GetExecutableModule (); |
| 857 | m_images.Clear(); |
| 858 | m_scratch_ast_context_ap.reset(); |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 859 | m_scratch_ast_source_ap.reset(); |
| 860 | m_ast_importer_ap.reset(); |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 861 | // Need to do something about unsetting breakpoints. |
| 862 | |
| 863 | if (executable_sp) |
| 864 | { |
| 865 | FileSpec exec_file_spec = executable_sp->GetFileSpec(); |
| 866 | Error error = ModuleList::GetSharedModule(exec_file_spec, |
| 867 | arch_spec, |
| 868 | NULL, |
| 869 | NULL, |
| 870 | 0, |
| 871 | executable_sp, |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 872 | &GetExecutableSearchPaths(), |
Jim Ingham | 7508e73 | 2010-08-09 23:31:02 +0000 | [diff] [blame] | 873 | NULL, |
| 874 | NULL); |
| 875 | |
| 876 | if (!error.Fail() && executable_sp) |
| 877 | { |
| 878 | SetExecutableModule (executable_sp, true); |
| 879 | return true; |
| 880 | } |
| 881 | else |
| 882 | { |
| 883 | return false; |
| 884 | } |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | return false; |
| 889 | } |
| 890 | } |
| 891 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 892 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 893 | void |
| 894 | Target::ModuleAdded (ModuleSP &module_sp) |
| 895 | { |
| 896 | // A module is being added to this target for the first time |
| 897 | ModuleList module_list; |
| 898 | module_list.Append(module_sp); |
| 899 | ModulesDidLoad (module_list); |
| 900 | } |
| 901 | |
| 902 | void |
| 903 | Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp) |
| 904 | { |
Jim Ingham | 3b8a605 | 2011-08-03 01:00:06 +0000 | [diff] [blame] | 905 | // A module is replacing an already added module |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 906 | ModuleList module_list; |
| 907 | module_list.Append (old_module_sp); |
| 908 | ModulesDidUnload (module_list); |
| 909 | module_list.Clear (); |
| 910 | module_list.Append (new_module_sp); |
| 911 | ModulesDidLoad (module_list); |
| 912 | } |
| 913 | |
| 914 | void |
| 915 | Target::ModulesDidLoad (ModuleList &module_list) |
| 916 | { |
| 917 | m_breakpoint_list.UpdateBreakpoints (module_list, true); |
| 918 | // TODO: make event data that packages up the module_list |
| 919 | BroadcastEvent (eBroadcastBitModulesLoaded, NULL); |
| 920 | } |
| 921 | |
| 922 | void |
| 923 | Target::ModulesDidUnload (ModuleList &module_list) |
| 924 | { |
| 925 | m_breakpoint_list.UpdateBreakpoints (module_list, false); |
Greg Clayton | 7b9fcc0 | 2010-12-06 23:51:26 +0000 | [diff] [blame] | 926 | |
| 927 | // Remove the images from the target image list |
| 928 | m_images.Remove(module_list); |
| 929 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 930 | // TODO: make event data that packages up the module_list |
| 931 | BroadcastEvent (eBroadcastBitModulesUnloaded, NULL); |
| 932 | } |
| 933 | |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 934 | |
Daniel Dunbar | 705a098 | 2011-10-31 22:50:37 +0000 | [diff] [blame] | 935 | bool |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 936 | Target::ModuleIsExcludedForNonModuleSpecificSearches (const FileSpec &module_spec) |
| 937 | { |
| 938 | |
| 939 | if (!m_breakpoints_use_platform_avoid) |
| 940 | return false; |
| 941 | else |
| 942 | { |
| 943 | ModuleList matchingModules; |
| 944 | const ArchSpec *arch_ptr = NULL; |
| 945 | const lldb_private::UUID *uuid_ptr= NULL; |
| 946 | const ConstString *object_name = NULL; |
| 947 | size_t num_modules = GetImages().FindModules(&module_spec, arch_ptr, uuid_ptr, object_name, matchingModules); |
| 948 | |
| 949 | // If there is more than one module for this file spec, only return true if ALL the modules are on the |
| 950 | // black list. |
| 951 | if (num_modules > 0) |
| 952 | { |
| 953 | for (int i = 0; i < num_modules; i++) |
| 954 | { |
| 955 | if (!ModuleIsExcludedForNonModuleSpecificSearches (matchingModules.GetModuleAtIndex(i))) |
| 956 | return false; |
| 957 | } |
| 958 | return true; |
| 959 | } |
| 960 | else |
| 961 | return false; |
| 962 | } |
| 963 | } |
| 964 | |
Daniel Dunbar | 705a098 | 2011-10-31 22:50:37 +0000 | [diff] [blame] | 965 | bool |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 966 | Target::ModuleIsExcludedForNonModuleSpecificSearches (const lldb::ModuleSP &module_sp) |
| 967 | { |
| 968 | if (!m_breakpoints_use_platform_avoid) |
| 969 | return false; |
| 970 | else if (GetPlatform()) |
| 971 | { |
| 972 | return GetPlatform()->ModuleIsExcludedForNonModuleSpecificSearches (*this, module_sp); |
| 973 | } |
| 974 | else |
| 975 | return false; |
| 976 | } |
| 977 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 978 | size_t |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 979 | Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error) |
| 980 | { |
| 981 | const Section *section = addr.GetSection(); |
| 982 | if (section && section->GetModule()) |
| 983 | { |
| 984 | ObjectFile *objfile = section->GetModule()->GetObjectFile(); |
| 985 | if (objfile) |
| 986 | { |
Greg Clayton | b5a8f14 | 2012-02-05 02:38:54 +0000 | [diff] [blame] | 987 | size_t bytes_read = objfile->ReadSectionData (section, |
| 988 | addr.GetOffset(), |
| 989 | dst, |
| 990 | dst_len); |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 991 | if (bytes_read > 0) |
| 992 | return bytes_read; |
| 993 | else |
| 994 | error.SetErrorStringWithFormat("error reading data from section %s", section->GetName().GetCString()); |
| 995 | } |
| 996 | else |
| 997 | { |
| 998 | error.SetErrorString("address isn't from a object file"); |
| 999 | } |
| 1000 | } |
| 1001 | else |
| 1002 | { |
| 1003 | error.SetErrorString("address doesn't contain a section that points to a section in a object file"); |
| 1004 | } |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | size_t |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1009 | Target::ReadMemory (const Address& addr, |
| 1010 | bool prefer_file_cache, |
| 1011 | void *dst, |
| 1012 | size_t dst_len, |
| 1013 | Error &error, |
| 1014 | lldb::addr_t *load_addr_ptr) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1015 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1016 | error.Clear(); |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 1017 | |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1018 | // if we end up reading this from process memory, we will fill this |
| 1019 | // with the actual load address |
| 1020 | if (load_addr_ptr) |
| 1021 | *load_addr_ptr = LLDB_INVALID_ADDRESS; |
| 1022 | |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 1023 | size_t bytes_read = 0; |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1024 | |
| 1025 | addr_t load_addr = LLDB_INVALID_ADDRESS; |
| 1026 | addr_t file_addr = LLDB_INVALID_ADDRESS; |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1027 | Address resolved_addr; |
| 1028 | if (!addr.IsSectionOffset()) |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1029 | { |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 1030 | if (m_section_load_list.IsEmpty()) |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1031 | { |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 1032 | // No sections are loaded, so we must assume we are not running |
| 1033 | // yet and anything we are given is a file address. |
| 1034 | file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the file address |
| 1035 | m_images.ResolveFileAddress (file_addr, resolved_addr); |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1036 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1037 | else |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1038 | { |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 1039 | // We have at least one section loaded. This can be becuase |
| 1040 | // we have manually loaded some sections with "target modules load ..." |
| 1041 | // or because we have have a live process that has sections loaded |
| 1042 | // through the dynamic loader |
| 1043 | load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the load address |
| 1044 | m_section_load_list.ResolveLoadAddress (load_addr, resolved_addr); |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1045 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1046 | } |
Greg Clayton | 889fbd0 | 2011-03-26 19:14:58 +0000 | [diff] [blame] | 1047 | if (!resolved_addr.IsValid()) |
| 1048 | resolved_addr = addr; |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1049 | |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1050 | |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 1051 | if (prefer_file_cache) |
| 1052 | { |
| 1053 | bytes_read = ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error); |
| 1054 | if (bytes_read > 0) |
| 1055 | return bytes_read; |
| 1056 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1057 | |
Johnny Chen | da5a802 | 2011-09-20 23:28:55 +0000 | [diff] [blame] | 1058 | if (ProcessIsValid()) |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1059 | { |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1060 | if (load_addr == LLDB_INVALID_ADDRESS) |
| 1061 | load_addr = resolved_addr.GetLoadAddress (this); |
| 1062 | |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1063 | if (load_addr == LLDB_INVALID_ADDRESS) |
| 1064 | { |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 1065 | Module *addr_module = resolved_addr.GetModulePtr(); |
| 1066 | if (addr_module && addr_module->GetFileSpec()) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1067 | error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded", |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 1068 | addr_module->GetFileSpec().GetFilename().AsCString(), |
Jason Molenda | 95b7b43 | 2011-09-20 00:26:08 +0000 | [diff] [blame] | 1069 | resolved_addr.GetFileAddress(), |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 1070 | addr_module->GetFileSpec().GetFilename().AsCString()); |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1071 | else |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1072 | error.SetErrorStringWithFormat("0x%llx can't be resolved", resolved_addr.GetFileAddress()); |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1073 | } |
| 1074 | else |
| 1075 | { |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 1076 | bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1077 | if (bytes_read != dst_len) |
| 1078 | { |
| 1079 | if (error.Success()) |
| 1080 | { |
| 1081 | if (bytes_read == 0) |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1082 | error.SetErrorStringWithFormat("read memory from 0x%llx failed", load_addr); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1083 | else |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 1084 | error.SetErrorStringWithFormat("only %zu of %zu bytes were read from memory at 0x%llx", bytes_read, dst_len, load_addr); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1085 | } |
| 1086 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1087 | if (bytes_read) |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1088 | { |
| 1089 | if (load_addr_ptr) |
| 1090 | *load_addr_ptr = load_addr; |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1091 | return bytes_read; |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1092 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1093 | // If the address is not section offset we have an address that |
| 1094 | // doesn't resolve to any address in any currently loaded shared |
| 1095 | // libaries and we failed to read memory so there isn't anything |
| 1096 | // more we can do. If it is section offset, we might be able to |
| 1097 | // read cached memory from the object file. |
| 1098 | if (!resolved_addr.IsSectionOffset()) |
| 1099 | return 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1100 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1101 | } |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1102 | |
Greg Clayton | 9b82f86 | 2011-07-11 05:12:02 +0000 | [diff] [blame] | 1103 | if (!prefer_file_cache && resolved_addr.IsSectionOffset()) |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1104 | { |
Greg Clayton | 26100dc | 2011-01-07 01:57:07 +0000 | [diff] [blame] | 1105 | // If we didn't already try and read from the object file cache, then |
| 1106 | // try it after failing to read from the process. |
| 1107 | return ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error); |
Greg Clayton | 7043635 | 2010-06-30 23:03:03 +0000 | [diff] [blame] | 1108 | } |
| 1109 | return 0; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1110 | } |
| 1111 | |
Greg Clayton | 7dd98df | 2011-07-12 17:06:17 +0000 | [diff] [blame] | 1112 | size_t |
| 1113 | Target::ReadScalarIntegerFromMemory (const Address& addr, |
| 1114 | bool prefer_file_cache, |
| 1115 | uint32_t byte_size, |
| 1116 | bool is_signed, |
| 1117 | Scalar &scalar, |
| 1118 | Error &error) |
| 1119 | { |
| 1120 | uint64_t uval; |
| 1121 | |
| 1122 | if (byte_size <= sizeof(uval)) |
| 1123 | { |
| 1124 | size_t bytes_read = ReadMemory (addr, prefer_file_cache, &uval, byte_size, error); |
| 1125 | if (bytes_read == byte_size) |
| 1126 | { |
| 1127 | DataExtractor data (&uval, sizeof(uval), m_arch.GetByteOrder(), m_arch.GetAddressByteSize()); |
| 1128 | uint32_t offset = 0; |
| 1129 | if (byte_size <= 4) |
| 1130 | scalar = data.GetMaxU32 (&offset, byte_size); |
| 1131 | else |
| 1132 | scalar = data.GetMaxU64 (&offset, byte_size); |
| 1133 | |
| 1134 | if (is_signed) |
| 1135 | scalar.SignExtend(byte_size * 8); |
| 1136 | return bytes_read; |
| 1137 | } |
| 1138 | } |
| 1139 | else |
| 1140 | { |
| 1141 | error.SetErrorStringWithFormat ("byte size of %u is too large for integer scalar type", byte_size); |
| 1142 | } |
| 1143 | return 0; |
| 1144 | } |
| 1145 | |
| 1146 | uint64_t |
| 1147 | Target::ReadUnsignedIntegerFromMemory (const Address& addr, |
| 1148 | bool prefer_file_cache, |
| 1149 | size_t integer_byte_size, |
| 1150 | uint64_t fail_value, |
| 1151 | Error &error) |
| 1152 | { |
| 1153 | Scalar scalar; |
| 1154 | if (ReadScalarIntegerFromMemory (addr, |
| 1155 | prefer_file_cache, |
| 1156 | integer_byte_size, |
| 1157 | false, |
| 1158 | scalar, |
| 1159 | error)) |
| 1160 | return scalar.ULongLong(fail_value); |
| 1161 | return fail_value; |
| 1162 | } |
| 1163 | |
| 1164 | bool |
| 1165 | Target::ReadPointerFromMemory (const Address& addr, |
| 1166 | bool prefer_file_cache, |
| 1167 | Error &error, |
| 1168 | Address &pointer_addr) |
| 1169 | { |
| 1170 | Scalar scalar; |
| 1171 | if (ReadScalarIntegerFromMemory (addr, |
| 1172 | prefer_file_cache, |
| 1173 | m_arch.GetAddressByteSize(), |
| 1174 | false, |
| 1175 | scalar, |
| 1176 | error)) |
| 1177 | { |
| 1178 | addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS); |
| 1179 | if (pointer_vm_addr != LLDB_INVALID_ADDRESS) |
| 1180 | { |
| 1181 | if (m_section_load_list.IsEmpty()) |
| 1182 | { |
| 1183 | // No sections are loaded, so we must assume we are not running |
| 1184 | // yet and anything we are given is a file address. |
| 1185 | m_images.ResolveFileAddress (pointer_vm_addr, pointer_addr); |
| 1186 | } |
| 1187 | else |
| 1188 | { |
| 1189 | // We have at least one section loaded. This can be becuase |
| 1190 | // we have manually loaded some sections with "target modules load ..." |
| 1191 | // or because we have have a live process that has sections loaded |
| 1192 | // through the dynamic loader |
| 1193 | m_section_load_list.ResolveLoadAddress (pointer_vm_addr, pointer_addr); |
| 1194 | } |
| 1195 | // We weren't able to resolve the pointer value, so just return |
| 1196 | // an address with no section |
| 1197 | if (!pointer_addr.IsValid()) |
| 1198 | pointer_addr.SetOffset (pointer_vm_addr); |
| 1199 | return true; |
| 1200 | |
| 1201 | } |
| 1202 | } |
| 1203 | return false; |
| 1204 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1205 | |
| 1206 | ModuleSP |
| 1207 | Target::GetSharedModule |
| 1208 | ( |
| 1209 | const FileSpec& file_spec, |
| 1210 | const ArchSpec& arch, |
Greg Clayton | 0467c78 | 2011-02-04 18:53:10 +0000 | [diff] [blame] | 1211 | const lldb_private::UUID *uuid_ptr, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1212 | const ConstString *object_name, |
| 1213 | off_t object_offset, |
| 1214 | Error *error_ptr |
| 1215 | ) |
| 1216 | { |
| 1217 | // Don't pass in the UUID so we can tell if we have a stale value in our list |
| 1218 | ModuleSP old_module_sp; // This will get filled in if we have a new version of the library |
| 1219 | bool did_create_module = false; |
| 1220 | ModuleSP module_sp; |
| 1221 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1222 | Error error; |
| 1223 | |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1224 | // If there are image search path entries, try to use them first to acquire a suitable image. |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1225 | if (m_image_search_paths.GetSize()) |
| 1226 | { |
| 1227 | FileSpec transformed_spec; |
| 1228 | if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory())) |
| 1229 | { |
| 1230 | transformed_spec.GetFilename() = file_spec.GetFilename(); |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 1231 | error = ModuleList::GetSharedModule (transformed_spec, |
| 1232 | arch, |
| 1233 | uuid_ptr, |
| 1234 | object_name, |
| 1235 | object_offset, |
| 1236 | module_sp, |
| 1237 | &GetExecutableSearchPaths(), |
| 1238 | &old_module_sp, |
| 1239 | &did_create_module); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1240 | } |
| 1241 | } |
| 1242 | |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1243 | // The platform is responsible for finding and caching an appropriate |
| 1244 | // module in the shared module cache. |
| 1245 | if (m_platform_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1246 | { |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1247 | FileSpec platform_file_spec; |
| 1248 | error = m_platform_sp->GetSharedModule (file_spec, |
| 1249 | arch, |
| 1250 | uuid_ptr, |
| 1251 | object_name, |
| 1252 | object_offset, |
| 1253 | module_sp, |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 1254 | &GetExecutableSearchPaths(), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1255 | &old_module_sp, |
| 1256 | &did_create_module); |
| 1257 | } |
| 1258 | else |
| 1259 | { |
| 1260 | error.SetErrorString("no platform is currently set"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1261 | } |
| 1262 | |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1263 | // If a module hasn't been found yet, use the unmodified path. |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1264 | if (module_sp) |
| 1265 | { |
| 1266 | m_images.Append (module_sp); |
| 1267 | if (did_create_module) |
| 1268 | { |
| 1269 | if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32) |
| 1270 | ModuleUpdated(old_module_sp, module_sp); |
| 1271 | else |
| 1272 | ModuleAdded(module_sp); |
| 1273 | } |
| 1274 | } |
| 1275 | if (error_ptr) |
| 1276 | *error_ptr = error; |
| 1277 | return module_sp; |
| 1278 | } |
| 1279 | |
| 1280 | |
| 1281 | Target * |
| 1282 | Target::CalculateTarget () |
| 1283 | { |
| 1284 | return this; |
| 1285 | } |
| 1286 | |
| 1287 | Process * |
| 1288 | Target::CalculateProcess () |
| 1289 | { |
| 1290 | return NULL; |
| 1291 | } |
| 1292 | |
| 1293 | Thread * |
| 1294 | Target::CalculateThread () |
| 1295 | { |
| 1296 | return NULL; |
| 1297 | } |
| 1298 | |
| 1299 | StackFrame * |
| 1300 | Target::CalculateStackFrame () |
| 1301 | { |
| 1302 | return NULL; |
| 1303 | } |
| 1304 | |
| 1305 | void |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1306 | Target::CalculateExecutionContext (ExecutionContext &exe_ctx) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1307 | { |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 1308 | exe_ctx.Clear(); |
| 1309 | exe_ctx.SetTargetPtr(this); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | PathMappingList & |
| 1313 | Target::GetImageSearchPathList () |
| 1314 | { |
| 1315 | return m_image_search_paths; |
| 1316 | } |
| 1317 | |
| 1318 | void |
| 1319 | Target::ImageSearchPathsChanged |
| 1320 | ( |
| 1321 | const PathMappingList &path_list, |
| 1322 | void *baton |
| 1323 | ) |
| 1324 | { |
| 1325 | Target *target = (Target *)baton; |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1326 | ModuleSP exe_module_sp (target->GetExecutableModule()); |
| 1327 | if (exe_module_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1328 | { |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1329 | target->m_images.Clear(); |
| 1330 | target->SetExecutableModule (exe_module_sp, true); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | ClangASTContext * |
Johnny Chen | fa21ffd | 2011-11-30 23:18:53 +0000 | [diff] [blame] | 1335 | Target::GetScratchClangASTContext(bool create_on_demand) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1336 | { |
Greg Clayton | 34ce4ea | 2011-08-03 01:23:55 +0000 | [diff] [blame] | 1337 | // Now see if we know the target triple, and if so, create our scratch AST context: |
Johnny Chen | fa21ffd | 2011-11-30 23:18:53 +0000 | [diff] [blame] | 1338 | if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid() && create_on_demand) |
Sean Callanan | dcf03f8 | 2011-11-15 22:27:19 +0000 | [diff] [blame] | 1339 | { |
Greg Clayton | 34ce4ea | 2011-08-03 01:23:55 +0000 | [diff] [blame] | 1340 | m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str())); |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 1341 | m_scratch_ast_source_ap.reset (new ClangASTSource(shared_from_this())); |
Sean Callanan | dcf03f8 | 2011-11-15 22:27:19 +0000 | [diff] [blame] | 1342 | m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext()); |
| 1343 | llvm::OwningPtr<clang::ExternalASTSource> proxy_ast_source(m_scratch_ast_source_ap->CreateProxy()); |
| 1344 | m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source); |
| 1345 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1346 | return m_scratch_ast_context_ap.get(); |
| 1347 | } |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1348 | |
Sean Callanan | 4938bd6 | 2011-11-16 18:20:47 +0000 | [diff] [blame] | 1349 | ClangASTImporter * |
| 1350 | Target::GetClangASTImporter() |
| 1351 | { |
| 1352 | ClangASTImporter *ast_importer = m_ast_importer_ap.get(); |
| 1353 | |
| 1354 | if (!ast_importer) |
| 1355 | { |
| 1356 | ast_importer = new ClangASTImporter(); |
| 1357 | m_ast_importer_ap.reset(ast_importer); |
| 1358 | } |
| 1359 | |
| 1360 | return ast_importer; |
| 1361 | } |
| 1362 | |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1363 | void |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 1364 | Target::SettingsInitialize () |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1365 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1366 | UserSettingsController::InitializeSettingsController (GetSettingsController(), |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1367 | SettingsController::global_settings_table, |
| 1368 | SettingsController::instance_settings_table); |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 1369 | |
| 1370 | // Now call SettingsInitialize() on each 'child' setting of Target |
| 1371 | Process::SettingsInitialize (); |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1372 | } |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1373 | |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1374 | void |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 1375 | Target::SettingsTerminate () |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1376 | { |
Caroline Tice | 2a45681 | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 1377 | |
| 1378 | // Must call SettingsTerminate() on each settings 'child' of Target, before terminating Target's Settings. |
| 1379 | |
| 1380 | Process::SettingsTerminate (); |
| 1381 | |
| 1382 | // Now terminate Target Settings. |
| 1383 | |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1384 | UserSettingsControllerSP &usc = GetSettingsController(); |
| 1385 | UserSettingsController::FinalizeSettingsController (usc); |
| 1386 | usc.reset(); |
| 1387 | } |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1388 | |
Greg Clayton | 990de7b | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 1389 | UserSettingsControllerSP & |
| 1390 | Target::GetSettingsController () |
| 1391 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1392 | static UserSettingsControllerSP g_settings_controller_sp; |
| 1393 | if (!g_settings_controller_sp) |
| 1394 | { |
| 1395 | g_settings_controller_sp.reset (new Target::SettingsController); |
| 1396 | // The first shared pointer to Target::SettingsController in |
| 1397 | // g_settings_controller_sp must be fully created above so that |
| 1398 | // the TargetInstanceSettings can use a weak_ptr to refer back |
| 1399 | // to the master setttings controller |
| 1400 | InstanceSettingsSP default_instance_settings_sp (new TargetInstanceSettings (g_settings_controller_sp, |
| 1401 | false, |
| 1402 | InstanceSettings::GetDefaultName().AsCString())); |
| 1403 | g_settings_controller_sp->SetDefaultInstanceSettings (default_instance_settings_sp); |
| 1404 | } |
| 1405 | return g_settings_controller_sp; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1406 | } |
| 1407 | |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 1408 | FileSpecList |
| 1409 | Target::GetDefaultExecutableSearchPaths () |
| 1410 | { |
| 1411 | lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController()); |
| 1412 | if (settings_controller_sp) |
| 1413 | { |
| 1414 | lldb::InstanceSettingsSP instance_settings_sp (settings_controller_sp->GetDefaultInstanceSettings ()); |
| 1415 | if (instance_settings_sp) |
| 1416 | return static_cast<TargetInstanceSettings *>(instance_settings_sp.get())->GetExecutableSearchPaths (); |
| 1417 | } |
| 1418 | return FileSpecList(); |
| 1419 | } |
| 1420 | |
| 1421 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1422 | ArchSpec |
| 1423 | Target::GetDefaultArchitecture () |
| 1424 | { |
Greg Clayton | 940b103 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 1425 | lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController()); |
| 1426 | |
| 1427 | if (settings_controller_sp) |
| 1428 | return static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture (); |
| 1429 | return ArchSpec(); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | void |
Greg Clayton | 940b103 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 1433 | Target::SetDefaultArchitecture (const ArchSpec& arch) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1434 | { |
Greg Clayton | 940b103 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 1435 | lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController()); |
| 1436 | |
| 1437 | if (settings_controller_sp) |
| 1438 | static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture () = arch; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 1439 | } |
| 1440 | |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1441 | Target * |
| 1442 | Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr) |
| 1443 | { |
| 1444 | // The target can either exist in the "process" of ExecutionContext, or in |
| 1445 | // the "target_sp" member of SymbolContext. This accessor helper function |
| 1446 | // will get the target from one of these locations. |
| 1447 | |
| 1448 | Target *target = NULL; |
| 1449 | if (sc_ptr != NULL) |
| 1450 | target = sc_ptr->target_sp.get(); |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 1451 | if (target == NULL && exe_ctx_ptr) |
| 1452 | target = exe_ctx_ptr->GetTargetPtr(); |
Greg Clayton | a830adb | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1453 | return target; |
| 1454 | } |
| 1455 | |
| 1456 | |
Caroline Tice | 1ebef44 | 2010-09-27 00:30:10 +0000 | [diff] [blame] | 1457 | void |
| 1458 | Target::UpdateInstanceName () |
| 1459 | { |
| 1460 | StreamString sstr; |
| 1461 | |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1462 | Module *exe_module = GetExecutableModulePointer(); |
| 1463 | if (exe_module) |
Caroline Tice | 1ebef44 | 2010-09-27 00:30:10 +0000 | [diff] [blame] | 1464 | { |
Greg Clayton | bf6e210 | 2010-10-27 02:06:37 +0000 | [diff] [blame] | 1465 | sstr.Printf ("%s_%s", |
Greg Clayton | 5beb99d | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1466 | exe_module->GetFileSpec().GetFilename().AsCString(), |
| 1467 | exe_module->GetArchitecture().GetArchitectureName()); |
| 1468 | GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); |
Caroline Tice | 1ebef44 | 2010-09-27 00:30:10 +0000 | [diff] [blame] | 1469 | } |
| 1470 | } |
| 1471 | |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 1472 | const char * |
| 1473 | Target::GetExpressionPrefixContentsAsCString () |
| 1474 | { |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 1475 | if (!m_expr_prefix_contents.empty()) |
| 1476 | return m_expr_prefix_contents.c_str(); |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 1477 | return NULL; |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 1478 | } |
| 1479 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1480 | ExecutionResults |
| 1481 | Target::EvaluateExpression |
| 1482 | ( |
| 1483 | const char *expr_cstr, |
| 1484 | StackFrame *frame, |
Sean Callanan | 47dc457 | 2011-09-15 02:13:07 +0000 | [diff] [blame] | 1485 | lldb_private::ExecutionPolicy execution_policy, |
Sean Callanan | daa6efe | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 1486 | bool coerce_to_id, |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1487 | bool unwind_on_error, |
Sean Callanan | 6a92553 | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 1488 | bool keep_in_memory, |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1489 | lldb::DynamicValueType use_dynamic, |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1490 | lldb::ValueObjectSP &result_valobj_sp |
| 1491 | ) |
| 1492 | { |
| 1493 | ExecutionResults execution_results = eExecutionSetupError; |
| 1494 | |
| 1495 | result_valobj_sp.reset(); |
Greg Clayton | 37bb8dd | 2011-12-08 02:13:16 +0000 | [diff] [blame] | 1496 | |
| 1497 | if (expr_cstr == NULL || expr_cstr[0] == '\0') |
| 1498 | return execution_results; |
| 1499 | |
Jim Ingham | 3613ae1 | 2011-05-12 02:06:14 +0000 | [diff] [blame] | 1500 | // We shouldn't run stop hooks in expressions. |
| 1501 | // Be sure to reset this if you return anywhere within this function. |
| 1502 | bool old_suppress_value = m_suppress_stop_hooks; |
| 1503 | m_suppress_stop_hooks = true; |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1504 | |
| 1505 | ExecutionContext exe_ctx; |
Greg Clayton | 37bb8dd | 2011-12-08 02:13:16 +0000 | [diff] [blame] | 1506 | |
| 1507 | const size_t expr_cstr_len = ::strlen (expr_cstr); |
| 1508 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1509 | if (frame) |
| 1510 | { |
| 1511 | frame->CalculateExecutionContext(exe_ctx); |
Greg Clayton | c3b61d2 | 2010-12-15 05:08:08 +0000 | [diff] [blame] | 1512 | Error error; |
Greg Clayton | c67efa4 | 2011-01-20 19:27:18 +0000 | [diff] [blame] | 1513 | const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | |
Enrico Granata | f669850 | 2011-08-09 01:04:56 +0000 | [diff] [blame] | 1514 | StackFrame::eExpressionPathOptionsNoFragileObjcIvar | |
| 1515 | StackFrame::eExpressionPathOptionsNoSyntheticChildren; |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1516 | lldb::VariableSP var_sp; |
Greg Clayton | 37bb8dd | 2011-12-08 02:13:16 +0000 | [diff] [blame] | 1517 | |
| 1518 | // Make sure we don't have any things that we know a variable expression |
| 1519 | // won't be able to deal with before calling into it |
| 1520 | if (::strcspn (expr_cstr, "()+*&|!~<=/^%,?") == expr_cstr_len) |
| 1521 | { |
| 1522 | result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, |
| 1523 | use_dynamic, |
| 1524 | expr_path_options, |
| 1525 | var_sp, |
| 1526 | error); |
| 1527 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1528 | } |
| 1529 | else if (m_process_sp) |
| 1530 | { |
| 1531 | m_process_sp->CalculateExecutionContext(exe_ctx); |
| 1532 | } |
| 1533 | else |
| 1534 | { |
| 1535 | CalculateExecutionContext(exe_ctx); |
| 1536 | } |
| 1537 | |
| 1538 | if (result_valobj_sp) |
| 1539 | { |
| 1540 | execution_results = eExecutionCompleted; |
| 1541 | // We got a result from the frame variable expression path above... |
| 1542 | ConstString persistent_variable_name (m_persistent_variables.GetNextPersistentVariableName()); |
| 1543 | |
| 1544 | lldb::ValueObjectSP const_valobj_sp; |
| 1545 | |
| 1546 | // Check in case our value is already a constant value |
| 1547 | if (result_valobj_sp->GetIsConstant()) |
| 1548 | { |
| 1549 | const_valobj_sp = result_valobj_sp; |
| 1550 | const_valobj_sp->SetName (persistent_variable_name); |
| 1551 | } |
| 1552 | else |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1553 | { |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1554 | if (use_dynamic != lldb::eNoDynamicValues) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1555 | { |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1556 | ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(use_dynamic); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1557 | if (dynamic_sp) |
| 1558 | result_valobj_sp = dynamic_sp; |
| 1559 | } |
| 1560 | |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 1561 | const_valobj_sp = result_valobj_sp->CreateConstantValue (persistent_variable_name); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1562 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1563 | |
Sean Callanan | 6a92553 | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 1564 | lldb::ValueObjectSP live_valobj_sp = result_valobj_sp; |
| 1565 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1566 | result_valobj_sp = const_valobj_sp; |
| 1567 | |
Sean Callanan | 6a92553 | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 1568 | ClangExpressionVariableSP clang_expr_variable_sp(m_persistent_variables.CreatePersistentVariable(result_valobj_sp)); |
| 1569 | assert (clang_expr_variable_sp.get()); |
| 1570 | |
| 1571 | // Set flags and live data as appropriate |
| 1572 | |
| 1573 | const Value &result_value = live_valobj_sp->GetValue(); |
| 1574 | |
| 1575 | switch (result_value.GetValueType()) |
| 1576 | { |
| 1577 | case Value::eValueTypeHostAddress: |
| 1578 | case Value::eValueTypeFileAddress: |
| 1579 | // we don't do anything with these for now |
| 1580 | break; |
| 1581 | case Value::eValueTypeScalar: |
| 1582 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated; |
| 1583 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation; |
| 1584 | break; |
| 1585 | case Value::eValueTypeLoadAddress: |
| 1586 | clang_expr_variable_sp->m_live_sp = live_valobj_sp; |
| 1587 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference; |
| 1588 | break; |
| 1589 | } |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1590 | } |
| 1591 | else |
| 1592 | { |
| 1593 | // Make sure we aren't just trying to see the value of a persistent |
| 1594 | // variable (something like "$0") |
Greg Clayton | a875b64 | 2011-01-09 21:07:35 +0000 | [diff] [blame] | 1595 | lldb::ClangExpressionVariableSP persistent_var_sp; |
| 1596 | // Only check for persistent variables the expression starts with a '$' |
| 1597 | if (expr_cstr[0] == '$') |
| 1598 | persistent_var_sp = m_persistent_variables.GetVariable (expr_cstr); |
| 1599 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1600 | if (persistent_var_sp) |
| 1601 | { |
| 1602 | result_valobj_sp = persistent_var_sp->GetValueObject (); |
| 1603 | execution_results = eExecutionCompleted; |
| 1604 | } |
| 1605 | else |
| 1606 | { |
| 1607 | const char *prefix = GetExpressionPrefixContentsAsCString(); |
Sean Callanan | 47dc457 | 2011-09-15 02:13:07 +0000 | [diff] [blame] | 1608 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1609 | execution_results = ClangUserExpression::Evaluate (exe_ctx, |
Sean Callanan | 47dc457 | 2011-09-15 02:13:07 +0000 | [diff] [blame] | 1610 | execution_policy, |
Sean Callanan | 5b658cc | 2011-11-07 23:35:40 +0000 | [diff] [blame] | 1611 | lldb::eLanguageTypeUnknown, |
Sean Callanan | daa6efe | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 1612 | coerce_to_id ? ClangUserExpression::eResultTypeId : ClangUserExpression::eResultTypeAny, |
Sean Callanan | 6a92553 | 2011-01-13 08:53:35 +0000 | [diff] [blame] | 1613 | unwind_on_error, |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1614 | expr_cstr, |
| 1615 | prefix, |
| 1616 | result_valobj_sp); |
| 1617 | } |
| 1618 | } |
Jim Ingham | 3613ae1 | 2011-05-12 02:06:14 +0000 | [diff] [blame] | 1619 | |
| 1620 | m_suppress_stop_hooks = old_suppress_value; |
| 1621 | |
Greg Clayton | 427f290 | 2010-12-14 02:59:59 +0000 | [diff] [blame] | 1622 | return execution_results; |
| 1623 | } |
| 1624 | |
Greg Clayton | c0fa533 | 2011-05-22 22:46:53 +0000 | [diff] [blame] | 1625 | lldb::addr_t |
| 1626 | Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const |
| 1627 | { |
| 1628 | addr_t code_addr = load_addr; |
| 1629 | switch (m_arch.GetMachine()) |
| 1630 | { |
| 1631 | case llvm::Triple::arm: |
| 1632 | case llvm::Triple::thumb: |
| 1633 | switch (addr_class) |
| 1634 | { |
| 1635 | case eAddressClassData: |
| 1636 | case eAddressClassDebug: |
| 1637 | return LLDB_INVALID_ADDRESS; |
| 1638 | |
| 1639 | case eAddressClassUnknown: |
| 1640 | case eAddressClassInvalid: |
| 1641 | case eAddressClassCode: |
| 1642 | case eAddressClassCodeAlternateISA: |
| 1643 | case eAddressClassRuntime: |
| 1644 | // Check if bit zero it no set? |
| 1645 | if ((code_addr & 1ull) == 0) |
| 1646 | { |
| 1647 | // Bit zero isn't set, check if the address is a multiple of 2? |
| 1648 | if (code_addr & 2ull) |
| 1649 | { |
| 1650 | // The address is a multiple of 2 so it must be thumb, set bit zero |
| 1651 | code_addr |= 1ull; |
| 1652 | } |
| 1653 | else if (addr_class == eAddressClassCodeAlternateISA) |
| 1654 | { |
| 1655 | // We checked the address and the address claims to be the alternate ISA |
| 1656 | // which means thumb, so set bit zero. |
| 1657 | code_addr |= 1ull; |
| 1658 | } |
| 1659 | } |
| 1660 | break; |
| 1661 | } |
| 1662 | break; |
| 1663 | |
| 1664 | default: |
| 1665 | break; |
| 1666 | } |
| 1667 | return code_addr; |
| 1668 | } |
| 1669 | |
| 1670 | lldb::addr_t |
| 1671 | Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const |
| 1672 | { |
| 1673 | addr_t opcode_addr = load_addr; |
| 1674 | switch (m_arch.GetMachine()) |
| 1675 | { |
| 1676 | case llvm::Triple::arm: |
| 1677 | case llvm::Triple::thumb: |
| 1678 | switch (addr_class) |
| 1679 | { |
| 1680 | case eAddressClassData: |
| 1681 | case eAddressClassDebug: |
| 1682 | return LLDB_INVALID_ADDRESS; |
| 1683 | |
| 1684 | case eAddressClassInvalid: |
| 1685 | case eAddressClassUnknown: |
| 1686 | case eAddressClassCode: |
| 1687 | case eAddressClassCodeAlternateISA: |
| 1688 | case eAddressClassRuntime: |
| 1689 | opcode_addr &= ~(1ull); |
| 1690 | break; |
| 1691 | } |
| 1692 | break; |
| 1693 | |
| 1694 | default: |
| 1695 | break; |
| 1696 | } |
| 1697 | return opcode_addr; |
| 1698 | } |
| 1699 | |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1700 | lldb::user_id_t |
| 1701 | Target::AddStopHook (Target::StopHookSP &new_hook_sp) |
| 1702 | { |
| 1703 | lldb::user_id_t new_uid = ++m_stop_hook_next_id; |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 1704 | new_hook_sp.reset (new StopHook(shared_from_this(), new_uid)); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1705 | m_stop_hooks[new_uid] = new_hook_sp; |
| 1706 | return new_uid; |
| 1707 | } |
| 1708 | |
| 1709 | bool |
| 1710 | Target::RemoveStopHookByID (lldb::user_id_t user_id) |
| 1711 | { |
| 1712 | size_t num_removed; |
| 1713 | num_removed = m_stop_hooks.erase (user_id); |
| 1714 | if (num_removed == 0) |
| 1715 | return false; |
| 1716 | else |
| 1717 | return true; |
| 1718 | } |
| 1719 | |
| 1720 | void |
| 1721 | Target::RemoveAllStopHooks () |
| 1722 | { |
| 1723 | m_stop_hooks.clear(); |
| 1724 | } |
| 1725 | |
| 1726 | Target::StopHookSP |
| 1727 | Target::GetStopHookByID (lldb::user_id_t user_id) |
| 1728 | { |
| 1729 | StopHookSP found_hook; |
| 1730 | |
| 1731 | StopHookCollection::iterator specified_hook_iter; |
| 1732 | specified_hook_iter = m_stop_hooks.find (user_id); |
| 1733 | if (specified_hook_iter != m_stop_hooks.end()) |
| 1734 | found_hook = (*specified_hook_iter).second; |
| 1735 | return found_hook; |
| 1736 | } |
| 1737 | |
| 1738 | bool |
| 1739 | Target::SetStopHookActiveStateByID (lldb::user_id_t user_id, bool active_state) |
| 1740 | { |
| 1741 | StopHookCollection::iterator specified_hook_iter; |
| 1742 | specified_hook_iter = m_stop_hooks.find (user_id); |
| 1743 | if (specified_hook_iter == m_stop_hooks.end()) |
| 1744 | return false; |
| 1745 | |
| 1746 | (*specified_hook_iter).second->SetIsActive (active_state); |
| 1747 | return true; |
| 1748 | } |
| 1749 | |
| 1750 | void |
| 1751 | Target::SetAllStopHooksActiveState (bool active_state) |
| 1752 | { |
| 1753 | StopHookCollection::iterator pos, end = m_stop_hooks.end(); |
| 1754 | for (pos = m_stop_hooks.begin(); pos != end; pos++) |
| 1755 | { |
| 1756 | (*pos).second->SetIsActive (active_state); |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | void |
| 1761 | Target::RunStopHooks () |
| 1762 | { |
Jim Ingham | 3613ae1 | 2011-05-12 02:06:14 +0000 | [diff] [blame] | 1763 | if (m_suppress_stop_hooks) |
| 1764 | return; |
| 1765 | |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1766 | if (!m_process_sp) |
| 1767 | return; |
| 1768 | |
| 1769 | if (m_stop_hooks.empty()) |
| 1770 | return; |
| 1771 | |
| 1772 | StopHookCollection::iterator pos, end = m_stop_hooks.end(); |
| 1773 | |
| 1774 | // If there aren't any active stop hooks, don't bother either: |
| 1775 | bool any_active_hooks = false; |
| 1776 | for (pos = m_stop_hooks.begin(); pos != end; pos++) |
| 1777 | { |
| 1778 | if ((*pos).second->IsActive()) |
| 1779 | { |
| 1780 | any_active_hooks = true; |
| 1781 | break; |
| 1782 | } |
| 1783 | } |
| 1784 | if (!any_active_hooks) |
| 1785 | return; |
| 1786 | |
| 1787 | CommandReturnObject result; |
| 1788 | |
| 1789 | std::vector<ExecutionContext> exc_ctx_with_reasons; |
| 1790 | std::vector<SymbolContext> sym_ctx_with_reasons; |
| 1791 | |
| 1792 | ThreadList &cur_threadlist = m_process_sp->GetThreadList(); |
| 1793 | size_t num_threads = cur_threadlist.GetSize(); |
| 1794 | for (size_t i = 0; i < num_threads; i++) |
| 1795 | { |
| 1796 | lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex (i); |
| 1797 | if (cur_thread_sp->ThreadStoppedForAReason()) |
| 1798 | { |
| 1799 | lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0); |
| 1800 | exc_ctx_with_reasons.push_back(ExecutionContext(m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get())); |
| 1801 | sym_ctx_with_reasons.push_back(cur_frame_sp->GetSymbolContext(eSymbolContextEverything)); |
| 1802 | } |
| 1803 | } |
| 1804 | |
| 1805 | // If no threads stopped for a reason, don't run the stop-hooks. |
| 1806 | size_t num_exe_ctx = exc_ctx_with_reasons.size(); |
| 1807 | if (num_exe_ctx == 0) |
| 1808 | return; |
| 1809 | |
Jim Ingham | e5ed8e9 | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 1810 | result.SetImmediateOutputStream (m_debugger.GetAsyncOutputStream()); |
| 1811 | result.SetImmediateErrorStream (m_debugger.GetAsyncErrorStream()); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1812 | |
| 1813 | bool keep_going = true; |
| 1814 | bool hooks_ran = false; |
Jim Ingham | c54840c | 2011-03-22 01:47:27 +0000 | [diff] [blame] | 1815 | bool print_hook_header; |
| 1816 | bool print_thread_header; |
| 1817 | |
| 1818 | if (num_exe_ctx == 1) |
| 1819 | print_thread_header = false; |
| 1820 | else |
| 1821 | print_thread_header = true; |
| 1822 | |
| 1823 | if (m_stop_hooks.size() == 1) |
| 1824 | print_hook_header = false; |
| 1825 | else |
| 1826 | print_hook_header = true; |
| 1827 | |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1828 | for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) |
| 1829 | { |
| 1830 | // result.Clear(); |
| 1831 | StopHookSP cur_hook_sp = (*pos).second; |
| 1832 | if (!cur_hook_sp->IsActive()) |
| 1833 | continue; |
| 1834 | |
| 1835 | bool any_thread_matched = false; |
| 1836 | for (size_t i = 0; keep_going && i < num_exe_ctx; i++) |
| 1837 | { |
| 1838 | if ((cur_hook_sp->GetSpecifier () == NULL |
| 1839 | || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i])) |
| 1840 | && (cur_hook_sp->GetThreadSpecifier() == NULL |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 1841 | || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadPtr()))) |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1842 | { |
| 1843 | if (!hooks_ran) |
| 1844 | { |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1845 | hooks_ran = true; |
| 1846 | } |
Jim Ingham | c54840c | 2011-03-22 01:47:27 +0000 | [diff] [blame] | 1847 | if (print_hook_header && !any_thread_matched) |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1848 | { |
Johnny Chen | 4d96a74 | 2011-10-24 23:01:06 +0000 | [diff] [blame] | 1849 | const char *cmd = (cur_hook_sp->GetCommands().GetSize() == 1 ? |
| 1850 | cur_hook_sp->GetCommands().GetStringAtIndex(0) : |
| 1851 | NULL); |
| 1852 | if (cmd) |
| 1853 | result.AppendMessageWithFormat("\n- Hook %llu (%s)\n", cur_hook_sp->GetID(), cmd); |
| 1854 | else |
| 1855 | result.AppendMessageWithFormat("\n- Hook %llu\n", cur_hook_sp->GetID()); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1856 | any_thread_matched = true; |
| 1857 | } |
| 1858 | |
Jim Ingham | c54840c | 2011-03-22 01:47:27 +0000 | [diff] [blame] | 1859 | if (print_thread_header) |
Greg Clayton | 567e7f3 | 2011-09-22 04:58:26 +0000 | [diff] [blame] | 1860 | result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID()); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1861 | |
| 1862 | bool stop_on_continue = true; |
| 1863 | bool stop_on_error = true; |
| 1864 | bool echo_commands = false; |
| 1865 | bool print_results = true; |
| 1866 | GetDebugger().GetCommandInterpreter().HandleCommands (cur_hook_sp->GetCommands(), |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1867 | &exc_ctx_with_reasons[i], |
| 1868 | stop_on_continue, |
| 1869 | stop_on_error, |
| 1870 | echo_commands, |
| 1871 | print_results, |
| 1872 | result); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1873 | |
| 1874 | // If the command started the target going again, we should bag out of |
| 1875 | // running the stop hooks. |
Greg Clayton | 24bc5d9 | 2011-03-30 18:16:51 +0000 | [diff] [blame] | 1876 | if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) || |
| 1877 | (result.GetStatus() == eReturnStatusSuccessContinuingResult)) |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1878 | { |
Greg Clayton | 444e35b | 2011-10-19 18:09:39 +0000 | [diff] [blame] | 1879 | result.AppendMessageWithFormat ("Aborting stop hooks, hook %llu set the program running.", cur_hook_sp->GetID()); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1880 | keep_going = false; |
| 1881 | } |
| 1882 | } |
| 1883 | } |
| 1884 | } |
Jason Molenda | 850ac6e | 2011-09-23 00:42:55 +0000 | [diff] [blame] | 1885 | |
Caroline Tice | 4a34808 | 2011-05-02 20:41:46 +0000 | [diff] [blame] | 1886 | result.GetImmediateOutputStream()->Flush(); |
| 1887 | result.GetImmediateErrorStream()->Flush(); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1888 | } |
| 1889 | |
Greg Clayton | bbea133 | 2011-07-08 00:48:09 +0000 | [diff] [blame] | 1890 | bool |
| 1891 | Target::LoadModuleWithSlide (Module *module, lldb::addr_t slide) |
| 1892 | { |
| 1893 | bool changed = false; |
| 1894 | if (module) |
| 1895 | { |
| 1896 | ObjectFile *object_file = module->GetObjectFile(); |
| 1897 | if (object_file) |
| 1898 | { |
| 1899 | SectionList *section_list = object_file->GetSectionList (); |
| 1900 | if (section_list) |
| 1901 | { |
| 1902 | // All sections listed in the dyld image info structure will all |
| 1903 | // either be fixed up already, or they will all be off by a single |
| 1904 | // slide amount that is determined by finding the first segment |
| 1905 | // that is at file offset zero which also has bytes (a file size |
| 1906 | // that is greater than zero) in the object file. |
| 1907 | |
| 1908 | // Determine the slide amount (if any) |
| 1909 | const size_t num_sections = section_list->GetSize(); |
| 1910 | size_t sect_idx = 0; |
| 1911 | for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) |
| 1912 | { |
| 1913 | // Iterate through the object file sections to find the |
| 1914 | // first section that starts of file offset zero and that |
| 1915 | // has bytes in the file... |
| 1916 | Section *section = section_list->GetSectionAtIndex (sect_idx).get(); |
| 1917 | if (section) |
| 1918 | { |
| 1919 | if (m_section_load_list.SetSectionLoadAddress (section, section->GetFileAddress() + slide)) |
| 1920 | changed = true; |
| 1921 | } |
| 1922 | } |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | return changed; |
| 1927 | } |
| 1928 | |
| 1929 | |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1930 | //-------------------------------------------------------------- |
| 1931 | // class Target::StopHook |
| 1932 | //-------------------------------------------------------------- |
| 1933 | |
| 1934 | |
| 1935 | Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) : |
| 1936 | UserID (uid), |
| 1937 | m_target_sp (target_sp), |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1938 | m_commands (), |
| 1939 | m_specifier_sp (), |
Stephen Wilson | dbeb3e1 | 2011-04-11 19:41:40 +0000 | [diff] [blame] | 1940 | m_thread_spec_ap(NULL), |
| 1941 | m_active (true) |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1942 | { |
| 1943 | } |
| 1944 | |
| 1945 | Target::StopHook::StopHook (const StopHook &rhs) : |
| 1946 | UserID (rhs.GetID()), |
| 1947 | m_target_sp (rhs.m_target_sp), |
| 1948 | m_commands (rhs.m_commands), |
| 1949 | m_specifier_sp (rhs.m_specifier_sp), |
Stephen Wilson | dbeb3e1 | 2011-04-11 19:41:40 +0000 | [diff] [blame] | 1950 | m_thread_spec_ap (NULL), |
| 1951 | m_active (rhs.m_active) |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1952 | { |
| 1953 | if (rhs.m_thread_spec_ap.get() != NULL) |
| 1954 | m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); |
| 1955 | } |
| 1956 | |
| 1957 | |
| 1958 | Target::StopHook::~StopHook () |
| 1959 | { |
| 1960 | } |
| 1961 | |
| 1962 | void |
| 1963 | Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier) |
| 1964 | { |
| 1965 | m_thread_spec_ap.reset (specifier); |
| 1966 | } |
| 1967 | |
| 1968 | |
| 1969 | void |
| 1970 | Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const |
| 1971 | { |
| 1972 | int indent_level = s->GetIndentLevel(); |
| 1973 | |
| 1974 | s->SetIndentLevel(indent_level + 2); |
| 1975 | |
Greg Clayton | 444e35b | 2011-10-19 18:09:39 +0000 | [diff] [blame] | 1976 | s->Printf ("Hook: %llu\n", GetID()); |
Jim Ingham | d60d94a | 2011-03-11 03:53:59 +0000 | [diff] [blame] | 1977 | if (m_active) |
| 1978 | s->Indent ("State: enabled\n"); |
| 1979 | else |
| 1980 | s->Indent ("State: disabled\n"); |
| 1981 | |
| 1982 | if (m_specifier_sp) |
| 1983 | { |
| 1984 | s->Indent(); |
| 1985 | s->PutCString ("Specifier:\n"); |
| 1986 | s->SetIndentLevel (indent_level + 4); |
| 1987 | m_specifier_sp->GetDescription (s, level); |
| 1988 | s->SetIndentLevel (indent_level + 2); |
| 1989 | } |
| 1990 | |
| 1991 | if (m_thread_spec_ap.get() != NULL) |
| 1992 | { |
| 1993 | StreamString tmp; |
| 1994 | s->Indent("Thread:\n"); |
| 1995 | m_thread_spec_ap->GetDescription (&tmp, level); |
| 1996 | s->SetIndentLevel (indent_level + 4); |
| 1997 | s->Indent (tmp.GetData()); |
| 1998 | s->PutCString ("\n"); |
| 1999 | s->SetIndentLevel (indent_level + 2); |
| 2000 | } |
| 2001 | |
| 2002 | s->Indent ("Commands: \n"); |
| 2003 | s->SetIndentLevel (indent_level + 4); |
| 2004 | uint32_t num_commands = m_commands.GetSize(); |
| 2005 | for (uint32_t i = 0; i < num_commands; i++) |
| 2006 | { |
| 2007 | s->Indent(m_commands.GetStringAtIndex(i)); |
| 2008 | s->PutCString ("\n"); |
| 2009 | } |
| 2010 | s->SetIndentLevel (indent_level); |
| 2011 | } |
| 2012 | |
| 2013 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2014 | //-------------------------------------------------------------- |
| 2015 | // class Target::SettingsController |
| 2016 | //-------------------------------------------------------------- |
| 2017 | |
| 2018 | Target::SettingsController::SettingsController () : |
| 2019 | UserSettingsController ("target", Debugger::GetSettingsController()), |
| 2020 | m_default_architecture () |
| 2021 | { |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | Target::SettingsController::~SettingsController () |
| 2025 | { |
| 2026 | } |
| 2027 | |
| 2028 | lldb::InstanceSettingsSP |
| 2029 | Target::SettingsController::CreateInstanceSettings (const char *instance_name) |
| 2030 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2031 | lldb::InstanceSettingsSP new_settings_sp (new TargetInstanceSettings (GetSettingsController(), |
| 2032 | false, |
| 2033 | instance_name)); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2034 | return new_settings_sp; |
| 2035 | } |
| 2036 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2037 | |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2038 | #define TSC_DEFAULT_ARCH "default-arch" |
| 2039 | #define TSC_EXPR_PREFIX "expr-prefix" |
| 2040 | #define TSC_PREFER_DYNAMIC "prefer-dynamic-value" |
| 2041 | #define TSC_SKIP_PROLOGUE "skip-prologue" |
| 2042 | #define TSC_SOURCE_MAP "source-map" |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2043 | #define TSC_EXE_SEARCH_PATHS "exec-search-paths" |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2044 | #define TSC_MAX_CHILDREN "max-children-count" |
| 2045 | #define TSC_MAX_STRLENSUMMARY "max-string-summary-length" |
| 2046 | #define TSC_PLATFORM_AVOID "breakpoints-use-platform-avoid-list" |
| 2047 | #define TSC_RUN_ARGS "run-args" |
| 2048 | #define TSC_ENV_VARS "env-vars" |
| 2049 | #define TSC_INHERIT_ENV "inherit-env" |
| 2050 | #define TSC_STDIN_PATH "input-path" |
| 2051 | #define TSC_STDOUT_PATH "output-path" |
| 2052 | #define TSC_STDERR_PATH "error-path" |
| 2053 | #define TSC_DISABLE_ASLR "disable-aslr" |
| 2054 | #define TSC_DISABLE_STDIO "disable-stdio" |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2055 | |
| 2056 | |
| 2057 | static const ConstString & |
| 2058 | GetSettingNameForDefaultArch () |
| 2059 | { |
| 2060 | static ConstString g_const_string (TSC_DEFAULT_ARCH); |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2061 | return g_const_string; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2062 | } |
| 2063 | |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2064 | static const ConstString & |
| 2065 | GetSettingNameForExpressionPrefix () |
| 2066 | { |
| 2067 | static ConstString g_const_string (TSC_EXPR_PREFIX); |
| 2068 | return g_const_string; |
| 2069 | } |
| 2070 | |
| 2071 | static const ConstString & |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 2072 | GetSettingNameForPreferDynamicValue () |
| 2073 | { |
| 2074 | static ConstString g_const_string (TSC_PREFER_DYNAMIC); |
| 2075 | return g_const_string; |
| 2076 | } |
| 2077 | |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2078 | static const ConstString & |
| 2079 | GetSettingNameForSourcePathMap () |
| 2080 | { |
| 2081 | static ConstString g_const_string (TSC_SOURCE_MAP); |
| 2082 | return g_const_string; |
| 2083 | } |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2084 | |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2085 | static const ConstString & |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2086 | GetSettingNameForExecutableSearchPaths () |
| 2087 | { |
| 2088 | static ConstString g_const_string (TSC_EXE_SEARCH_PATHS); |
| 2089 | return g_const_string; |
| 2090 | } |
| 2091 | |
| 2092 | static const ConstString & |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2093 | GetSettingNameForSkipPrologue () |
| 2094 | { |
| 2095 | static ConstString g_const_string (TSC_SKIP_PROLOGUE); |
| 2096 | return g_const_string; |
| 2097 | } |
| 2098 | |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 2099 | static const ConstString & |
| 2100 | GetSettingNameForMaxChildren () |
| 2101 | { |
| 2102 | static ConstString g_const_string (TSC_MAX_CHILDREN); |
| 2103 | return g_const_string; |
| 2104 | } |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2105 | |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2106 | static const ConstString & |
| 2107 | GetSettingNameForMaxStringSummaryLength () |
| 2108 | { |
| 2109 | static ConstString g_const_string (TSC_MAX_STRLENSUMMARY); |
| 2110 | return g_const_string; |
| 2111 | } |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2112 | |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2113 | static const ConstString & |
| 2114 | GetSettingNameForPlatformAvoid () |
| 2115 | { |
| 2116 | static ConstString g_const_string (TSC_PLATFORM_AVOID); |
| 2117 | return g_const_string; |
| 2118 | } |
| 2119 | |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2120 | const ConstString & |
| 2121 | GetSettingNameForRunArgs () |
| 2122 | { |
| 2123 | static ConstString g_const_string (TSC_RUN_ARGS); |
| 2124 | return g_const_string; |
| 2125 | } |
| 2126 | |
| 2127 | const ConstString & |
| 2128 | GetSettingNameForEnvVars () |
| 2129 | { |
| 2130 | static ConstString g_const_string (TSC_ENV_VARS); |
| 2131 | return g_const_string; |
| 2132 | } |
| 2133 | |
| 2134 | const ConstString & |
| 2135 | GetSettingNameForInheritHostEnv () |
| 2136 | { |
| 2137 | static ConstString g_const_string (TSC_INHERIT_ENV); |
| 2138 | return g_const_string; |
| 2139 | } |
| 2140 | |
| 2141 | const ConstString & |
| 2142 | GetSettingNameForInputPath () |
| 2143 | { |
| 2144 | static ConstString g_const_string (TSC_STDIN_PATH); |
| 2145 | return g_const_string; |
| 2146 | } |
| 2147 | |
| 2148 | const ConstString & |
| 2149 | GetSettingNameForOutputPath () |
| 2150 | { |
| 2151 | static ConstString g_const_string (TSC_STDOUT_PATH); |
| 2152 | return g_const_string; |
| 2153 | } |
| 2154 | |
| 2155 | const ConstString & |
| 2156 | GetSettingNameForErrorPath () |
| 2157 | { |
| 2158 | static ConstString g_const_string (TSC_STDERR_PATH); |
| 2159 | return g_const_string; |
| 2160 | } |
| 2161 | |
| 2162 | const ConstString & |
| 2163 | GetSettingNameForDisableASLR () |
| 2164 | { |
| 2165 | static ConstString g_const_string (TSC_DISABLE_ASLR); |
| 2166 | return g_const_string; |
| 2167 | } |
| 2168 | |
| 2169 | const ConstString & |
| 2170 | GetSettingNameForDisableSTDIO () |
| 2171 | { |
| 2172 | static ConstString g_const_string (TSC_DISABLE_STDIO); |
| 2173 | return g_const_string; |
| 2174 | } |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2175 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2176 | bool |
| 2177 | Target::SettingsController::SetGlobalVariable (const ConstString &var_name, |
| 2178 | const char *index_value, |
| 2179 | const char *value, |
| 2180 | const SettingEntry &entry, |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 2181 | const VarSetOperationType op, |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2182 | Error&err) |
| 2183 | { |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2184 | if (var_name == GetSettingNameForDefaultArch()) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2185 | { |
Greg Clayton | f15996e | 2011-04-07 22:46:35 +0000 | [diff] [blame] | 2186 | m_default_architecture.SetTriple (value, NULL); |
Greg Clayton | 940b103 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 2187 | if (!m_default_architecture.IsValid()) |
| 2188 | err.SetErrorStringWithFormat ("'%s' is not a valid architecture or triple.", value); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2189 | } |
| 2190 | return true; |
| 2191 | } |
| 2192 | |
| 2193 | |
| 2194 | bool |
| 2195 | Target::SettingsController::GetGlobalVariable (const ConstString &var_name, |
| 2196 | StringList &value, |
| 2197 | Error &err) |
| 2198 | { |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2199 | if (var_name == GetSettingNameForDefaultArch()) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2200 | { |
Greg Clayton | bf6e210 | 2010-10-27 02:06:37 +0000 | [diff] [blame] | 2201 | // If the arch is invalid (the default), don't show a string for it |
| 2202 | if (m_default_architecture.IsValid()) |
Greg Clayton | 940b103 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 2203 | value.AppendString (m_default_architecture.GetArchitectureName()); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2204 | return true; |
| 2205 | } |
| 2206 | else |
| 2207 | err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 2208 | |
| 2209 | return false; |
| 2210 | } |
| 2211 | |
| 2212 | //-------------------------------------------------------------- |
| 2213 | // class TargetInstanceSettings |
| 2214 | //-------------------------------------------------------------- |
| 2215 | |
Greg Clayton | 638351a | 2010-12-04 00:10:17 +0000 | [diff] [blame] | 2216 | TargetInstanceSettings::TargetInstanceSettings |
| 2217 | ( |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2218 | const lldb::UserSettingsControllerSP &owner_sp, |
Greg Clayton | 638351a | 2010-12-04 00:10:17 +0000 | [diff] [blame] | 2219 | bool live_instance, |
| 2220 | const char *name |
| 2221 | ) : |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2222 | InstanceSettings (owner_sp, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2223 | m_expr_prefix_file (), |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 2224 | m_expr_prefix_contents (), |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 2225 | m_prefer_dynamic_value (2), |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2226 | m_skip_prologue (true, true), |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 2227 | m_source_map (NULL, NULL), |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2228 | m_exe_search_paths (), |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2229 | m_max_children_display(256), |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2230 | m_max_strlen_length(1024), |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2231 | m_breakpoints_use_platform_avoid (true, true), |
| 2232 | m_run_args (), |
| 2233 | m_env_vars (), |
| 2234 | m_input_path (), |
| 2235 | m_output_path (), |
| 2236 | m_error_path (), |
| 2237 | m_disable_aslr (true), |
| 2238 | m_disable_stdio (false), |
| 2239 | m_inherit_host_env (true), |
| 2240 | m_got_host_env (false) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2241 | { |
| 2242 | // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called |
| 2243 | // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. |
| 2244 | // For this reason it has to be called here, rather than in the initializer or in the parent constructor. |
| 2245 | // This is true for CreateInstanceName() too. |
| 2246 | |
| 2247 | if (GetInstanceName () == InstanceSettings::InvalidName()) |
| 2248 | { |
| 2249 | ChangeInstanceName (std::string (CreateInstanceName().AsCString())); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2250 | owner_sp->RegisterInstanceSettings (this); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2251 | } |
| 2252 | |
| 2253 | if (live_instance) |
| 2254 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2255 | const lldb::InstanceSettingsSP &pending_settings = owner_sp->FindPendingSettings (m_instance_name); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2256 | CopyInstanceSettings (pending_settings,false); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2257 | } |
| 2258 | } |
| 2259 | |
| 2260 | TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) : |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2261 | InstanceSettings (Target::GetSettingsController(), CreateInstanceName().AsCString()), |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2262 | m_expr_prefix_file (rhs.m_expr_prefix_file), |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 2263 | m_expr_prefix_contents (rhs.m_expr_prefix_contents), |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2264 | m_prefer_dynamic_value (rhs.m_prefer_dynamic_value), |
| 2265 | m_skip_prologue (rhs.m_skip_prologue), |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 2266 | m_source_map (rhs.m_source_map), |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2267 | m_exe_search_paths (rhs.m_exe_search_paths), |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2268 | m_max_children_display (rhs.m_max_children_display), |
| 2269 | m_max_strlen_length (rhs.m_max_strlen_length), |
| 2270 | m_breakpoints_use_platform_avoid (rhs.m_breakpoints_use_platform_avoid), |
| 2271 | m_run_args (rhs.m_run_args), |
| 2272 | m_env_vars (rhs.m_env_vars), |
| 2273 | m_input_path (rhs.m_input_path), |
| 2274 | m_output_path (rhs.m_output_path), |
| 2275 | m_error_path (rhs.m_error_path), |
| 2276 | m_disable_aslr (rhs.m_disable_aslr), |
| 2277 | m_disable_stdio (rhs.m_disable_stdio), |
| 2278 | m_inherit_host_env (rhs.m_inherit_host_env) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2279 | { |
| 2280 | if (m_instance_name != InstanceSettings::GetDefaultName()) |
| 2281 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 2282 | UserSettingsControllerSP owner_sp (m_owner_wp.lock()); |
| 2283 | if (owner_sp) |
| 2284 | CopyInstanceSettings (owner_sp->FindPendingSettings (m_instance_name),false); |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2285 | } |
| 2286 | } |
| 2287 | |
| 2288 | TargetInstanceSettings::~TargetInstanceSettings () |
| 2289 | { |
| 2290 | } |
| 2291 | |
| 2292 | TargetInstanceSettings& |
| 2293 | TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs) |
| 2294 | { |
| 2295 | if (this != &rhs) |
| 2296 | { |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2297 | m_expr_prefix_file = rhs.m_expr_prefix_file; |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 2298 | m_expr_prefix_contents = rhs.m_expr_prefix_contents; |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2299 | m_prefer_dynamic_value = rhs.m_prefer_dynamic_value; |
| 2300 | m_skip_prologue = rhs.m_skip_prologue; |
| 2301 | m_source_map = rhs.m_source_map; |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2302 | m_exe_search_paths = rhs.m_exe_search_paths; |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2303 | m_max_children_display = rhs.m_max_children_display; |
| 2304 | m_max_strlen_length = rhs.m_max_strlen_length; |
| 2305 | m_breakpoints_use_platform_avoid = rhs.m_breakpoints_use_platform_avoid; |
| 2306 | m_run_args = rhs.m_run_args; |
| 2307 | m_env_vars = rhs.m_env_vars; |
| 2308 | m_input_path = rhs.m_input_path; |
| 2309 | m_output_path = rhs.m_output_path; |
| 2310 | m_error_path = rhs.m_error_path; |
| 2311 | m_disable_aslr = rhs.m_disable_aslr; |
| 2312 | m_disable_stdio = rhs.m_disable_stdio; |
| 2313 | m_inherit_host_env = rhs.m_inherit_host_env; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2314 | } |
| 2315 | |
| 2316 | return *this; |
| 2317 | } |
| 2318 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2319 | void |
| 2320 | TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, |
| 2321 | const char *index_value, |
| 2322 | const char *value, |
| 2323 | const ConstString &instance_name, |
| 2324 | const SettingEntry &entry, |
Greg Clayton | b344843 | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 2325 | VarSetOperationType op, |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2326 | Error &err, |
| 2327 | bool pending) |
| 2328 | { |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2329 | if (var_name == GetSettingNameForExpressionPrefix ()) |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2330 | { |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2331 | err = UserSettingsController::UpdateFileSpecOptionValue (value, op, m_expr_prefix_file); |
| 2332 | if (err.Success()) |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2333 | { |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2334 | switch (op) |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2335 | { |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2336 | default: |
| 2337 | break; |
| 2338 | case eVarSetOperationAssign: |
| 2339 | case eVarSetOperationAppend: |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2340 | { |
Greg Clayton | 4b23ab3 | 2012-01-06 02:01:06 +0000 | [diff] [blame] | 2341 | m_expr_prefix_contents.clear(); |
| 2342 | |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2343 | if (!m_expr_prefix_file.GetCurrentValue().Exists()) |
| 2344 | { |
| 2345 | err.SetErrorToGenericError (); |
Greg Clayton | 9c23673 | 2011-10-26 00:56:27 +0000 | [diff] [blame] | 2346 | err.SetErrorStringWithFormat ("%s does not exist", value); |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2347 | return; |
| 2348 | } |
| 2349 | |
Greg Clayton | 4b23ab3 | 2012-01-06 02:01:06 +0000 | [diff] [blame] | 2350 | DataBufferSP file_data_sp (m_expr_prefix_file.GetCurrentValue().ReadFileContents(0, SIZE_MAX, &err)); |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 2351 | |
Greg Clayton | 4b23ab3 | 2012-01-06 02:01:06 +0000 | [diff] [blame] | 2352 | if (err.Success()) |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2353 | { |
Greg Clayton | 4b23ab3 | 2012-01-06 02:01:06 +0000 | [diff] [blame] | 2354 | if (file_data_sp && file_data_sp->GetByteSize() > 0) |
| 2355 | { |
| 2356 | m_expr_prefix_contents.assign((const char*)file_data_sp->GetBytes(), file_data_sp->GetByteSize()); |
| 2357 | } |
| 2358 | else |
| 2359 | { |
| 2360 | err.SetErrorStringWithFormat ("couldn't read data from '%s'", value); |
| 2361 | } |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2362 | } |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2363 | } |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2364 | break; |
| 2365 | case eVarSetOperationClear: |
Sean Callanan | e0b7f94 | 2011-11-16 01:54:57 +0000 | [diff] [blame] | 2366 | m_expr_prefix_contents.clear(); |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2367 | } |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2368 | } |
| 2369 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 2370 | else if (var_name == GetSettingNameForPreferDynamicValue()) |
| 2371 | { |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 2372 | int new_value; |
| 2373 | UserSettingsController::UpdateEnumVariable (g_dynamic_value_types, &new_value, value, err); |
| 2374 | if (err.Success()) |
| 2375 | m_prefer_dynamic_value = new_value; |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2376 | } |
| 2377 | else if (var_name == GetSettingNameForSkipPrologue()) |
| 2378 | { |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2379 | err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_skip_prologue); |
| 2380 | } |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 2381 | else if (var_name == GetSettingNameForMaxChildren()) |
| 2382 | { |
| 2383 | bool ok; |
| 2384 | uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok); |
| 2385 | if (ok) |
| 2386 | m_max_children_display = new_value; |
| 2387 | } |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2388 | else if (var_name == GetSettingNameForMaxStringSummaryLength()) |
| 2389 | { |
| 2390 | bool ok; |
| 2391 | uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok); |
| 2392 | if (ok) |
| 2393 | m_max_strlen_length = new_value; |
| 2394 | } |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2395 | else if (var_name == GetSettingNameForExecutableSearchPaths()) |
| 2396 | { |
| 2397 | switch (op) |
| 2398 | { |
| 2399 | case eVarSetOperationReplace: |
| 2400 | case eVarSetOperationInsertBefore: |
| 2401 | case eVarSetOperationInsertAfter: |
| 2402 | case eVarSetOperationRemove: |
| 2403 | default: |
| 2404 | break; |
| 2405 | case eVarSetOperationAssign: |
| 2406 | m_exe_search_paths.Clear(); |
| 2407 | // Fall through to append.... |
| 2408 | case eVarSetOperationAppend: |
| 2409 | { |
| 2410 | Args args(value); |
| 2411 | const uint32_t argc = args.GetArgumentCount(); |
| 2412 | if (argc > 0) |
| 2413 | { |
| 2414 | const char *exe_search_path_dir; |
| 2415 | for (uint32_t idx = 0; (exe_search_path_dir = args.GetArgumentAtIndex(idx)) != NULL; ++idx) |
| 2416 | { |
| 2417 | FileSpec file_spec; |
| 2418 | file_spec.GetDirectory().SetCString(exe_search_path_dir); |
| 2419 | FileSpec::FileType file_type = file_spec.GetFileType(); |
| 2420 | if (file_type == FileSpec::eFileTypeDirectory || file_type == FileSpec::eFileTypeInvalid) |
| 2421 | { |
| 2422 | m_exe_search_paths.Append(file_spec); |
| 2423 | } |
| 2424 | else |
| 2425 | { |
| 2426 | err.SetErrorStringWithFormat("executable search path '%s' exists, but it does not resolve to a directory", exe_search_path_dir); |
| 2427 | } |
| 2428 | } |
| 2429 | } |
| 2430 | } |
| 2431 | break; |
| 2432 | |
| 2433 | case eVarSetOperationClear: |
| 2434 | m_exe_search_paths.Clear(); |
| 2435 | break; |
| 2436 | } |
| 2437 | } |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2438 | else if (var_name == GetSettingNameForSourcePathMap ()) |
| 2439 | { |
| 2440 | switch (op) |
| 2441 | { |
| 2442 | case eVarSetOperationReplace: |
| 2443 | case eVarSetOperationInsertBefore: |
| 2444 | case eVarSetOperationInsertAfter: |
| 2445 | case eVarSetOperationRemove: |
| 2446 | default: |
| 2447 | break; |
| 2448 | case eVarSetOperationAssign: |
| 2449 | m_source_map.Clear(true); |
| 2450 | // Fall through to append.... |
| 2451 | case eVarSetOperationAppend: |
| 2452 | { |
| 2453 | Args args(value); |
| 2454 | const uint32_t argc = args.GetArgumentCount(); |
| 2455 | if (argc & 1 || argc == 0) |
| 2456 | { |
| 2457 | err.SetErrorStringWithFormat ("an even number of paths must be supplied to to the source-map setting: %u arguments given", argc); |
| 2458 | } |
| 2459 | else |
| 2460 | { |
| 2461 | char resolved_new_path[PATH_MAX]; |
| 2462 | FileSpec file_spec; |
| 2463 | const char *old_path; |
| 2464 | for (uint32_t idx = 0; (old_path = args.GetArgumentAtIndex(idx)) != NULL; idx += 2) |
| 2465 | { |
| 2466 | const char *new_path = args.GetArgumentAtIndex(idx+1); |
| 2467 | assert (new_path); // We have an even number of paths, this shouldn't happen! |
| 2468 | |
| 2469 | file_spec.SetFile(new_path, true); |
| 2470 | if (file_spec.Exists()) |
| 2471 | { |
| 2472 | if (file_spec.GetPath (resolved_new_path, sizeof(resolved_new_path)) >= sizeof(resolved_new_path)) |
| 2473 | { |
| 2474 | err.SetErrorStringWithFormat("new path '%s' is too long", new_path); |
| 2475 | return; |
| 2476 | } |
| 2477 | } |
| 2478 | else |
| 2479 | { |
| 2480 | err.SetErrorStringWithFormat("new path '%s' doesn't exist", new_path); |
| 2481 | return; |
| 2482 | } |
| 2483 | m_source_map.Append(ConstString (old_path), ConstString (resolved_new_path), true); |
| 2484 | } |
| 2485 | } |
| 2486 | } |
| 2487 | break; |
| 2488 | |
| 2489 | case eVarSetOperationClear: |
| 2490 | m_source_map.Clear(true); |
| 2491 | break; |
| 2492 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 2493 | } |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2494 | else if (var_name == GetSettingNameForPlatformAvoid ()) |
| 2495 | { |
| 2496 | err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_breakpoints_use_platform_avoid); |
| 2497 | } |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2498 | else if (var_name == GetSettingNameForRunArgs()) |
| 2499 | { |
| 2500 | UserSettingsController::UpdateStringArrayVariable (op, index_value, m_run_args, value, err); |
| 2501 | } |
| 2502 | else if (var_name == GetSettingNameForEnvVars()) |
| 2503 | { |
| 2504 | // This is nice for local debugging, but it is isn't correct for |
| 2505 | // remote debugging. We need to stop process.env-vars from being |
| 2506 | // populated with the host environment and add this as a launch option |
| 2507 | // and get the correct environment from the Target's platform. |
| 2508 | // GetHostEnvironmentIfNeeded (); |
| 2509 | UserSettingsController::UpdateDictionaryVariable (op, index_value, m_env_vars, value, err); |
| 2510 | } |
| 2511 | else if (var_name == GetSettingNameForInputPath()) |
| 2512 | { |
| 2513 | UserSettingsController::UpdateStringVariable (op, m_input_path, value, err); |
| 2514 | } |
| 2515 | else if (var_name == GetSettingNameForOutputPath()) |
| 2516 | { |
| 2517 | UserSettingsController::UpdateStringVariable (op, m_output_path, value, err); |
| 2518 | } |
| 2519 | else if (var_name == GetSettingNameForErrorPath()) |
| 2520 | { |
| 2521 | UserSettingsController::UpdateStringVariable (op, m_error_path, value, err); |
| 2522 | } |
| 2523 | else if (var_name == GetSettingNameForDisableASLR()) |
| 2524 | { |
| 2525 | UserSettingsController::UpdateBooleanVariable (op, m_disable_aslr, value, true, err); |
| 2526 | } |
| 2527 | else if (var_name == GetSettingNameForDisableSTDIO ()) |
| 2528 | { |
| 2529 | UserSettingsController::UpdateBooleanVariable (op, m_disable_stdio, value, false, err); |
| 2530 | } |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2531 | } |
| 2532 | |
| 2533 | void |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2534 | TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2535 | { |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2536 | TargetInstanceSettings *new_settings_ptr = static_cast <TargetInstanceSettings *> (new_settings.get()); |
| 2537 | |
| 2538 | if (!new_settings_ptr) |
| 2539 | return; |
| 2540 | |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2541 | *this = *new_settings_ptr; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2542 | } |
| 2543 | |
Caroline Tice | bcb5b45 | 2010-09-20 21:37:42 +0000 | [diff] [blame] | 2544 | bool |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2545 | TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, |
| 2546 | const ConstString &var_name, |
| 2547 | StringList &value, |
Caroline Tice | bcb5b45 | 2010-09-20 21:37:42 +0000 | [diff] [blame] | 2548 | Error *err) |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2549 | { |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2550 | if (var_name == GetSettingNameForExpressionPrefix ()) |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2551 | { |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2552 | char path[PATH_MAX]; |
| 2553 | const size_t path_len = m_expr_prefix_file.GetCurrentValue().GetPath (path, sizeof(path)); |
| 2554 | if (path_len > 0) |
| 2555 | value.AppendString (path, path_len); |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2556 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 2557 | else if (var_name == GetSettingNameForPreferDynamicValue()) |
| 2558 | { |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 2559 | value.AppendString (g_dynamic_value_types[m_prefer_dynamic_value].string_value); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 2560 | } |
Greg Clayton | 17cd995 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2561 | else if (var_name == GetSettingNameForSkipPrologue()) |
| 2562 | { |
| 2563 | if (m_skip_prologue) |
| 2564 | value.AppendString ("true"); |
| 2565 | else |
| 2566 | value.AppendString ("false"); |
| 2567 | } |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2568 | else if (var_name == GetSettingNameForExecutableSearchPaths()) |
| 2569 | { |
| 2570 | if (m_exe_search_paths.GetSize()) |
| 2571 | { |
| 2572 | for (size_t i = 0, n = m_exe_search_paths.GetSize(); i < n; ++i) |
| 2573 | { |
| 2574 | value.AppendString(m_exe_search_paths.GetFileSpecAtIndex (i).GetDirectory().AsCString()); |
| 2575 | } |
| 2576 | } |
| 2577 | } |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2578 | else if (var_name == GetSettingNameForSourcePathMap ()) |
| 2579 | { |
Johnny Chen | 931449e | 2011-12-12 21:59:28 +0000 | [diff] [blame] | 2580 | if (m_source_map.GetSize()) |
| 2581 | { |
| 2582 | size_t i; |
| 2583 | for (i = 0; i < m_source_map.GetSize(); ++i) { |
| 2584 | StreamString sstr; |
| 2585 | m_source_map.Dump(&sstr, i); |
| 2586 | value.AppendString(sstr.GetData()); |
| 2587 | } |
| 2588 | } |
Greg Clayton | ff44ab4 | 2011-04-23 02:04:55 +0000 | [diff] [blame] | 2589 | } |
Enrico Granata | 018921d | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 2590 | else if (var_name == GetSettingNameForMaxChildren()) |
| 2591 | { |
| 2592 | StreamString count_str; |
| 2593 | count_str.Printf ("%d", m_max_children_display); |
| 2594 | value.AppendString (count_str.GetData()); |
| 2595 | } |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2596 | else if (var_name == GetSettingNameForMaxStringSummaryLength()) |
| 2597 | { |
| 2598 | StreamString count_str; |
| 2599 | count_str.Printf ("%d", m_max_strlen_length); |
| 2600 | value.AppendString (count_str.GetData()); |
| 2601 | } |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2602 | else if (var_name == GetSettingNameForPlatformAvoid()) |
| 2603 | { |
| 2604 | if (m_breakpoints_use_platform_avoid) |
| 2605 | value.AppendString ("true"); |
| 2606 | else |
| 2607 | value.AppendString ("false"); |
| 2608 | } |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2609 | else if (var_name == GetSettingNameForRunArgs()) |
| 2610 | { |
| 2611 | if (m_run_args.GetArgumentCount() > 0) |
| 2612 | { |
| 2613 | for (int i = 0; i < m_run_args.GetArgumentCount(); ++i) |
| 2614 | value.AppendString (m_run_args.GetArgumentAtIndex (i)); |
| 2615 | } |
| 2616 | } |
| 2617 | else if (var_name == GetSettingNameForEnvVars()) |
| 2618 | { |
| 2619 | GetHostEnvironmentIfNeeded (); |
| 2620 | |
| 2621 | if (m_env_vars.size() > 0) |
| 2622 | { |
| 2623 | std::map<std::string, std::string>::iterator pos; |
| 2624 | for (pos = m_env_vars.begin(); pos != m_env_vars.end(); ++pos) |
| 2625 | { |
| 2626 | StreamString value_str; |
| 2627 | value_str.Printf ("%s=%s", pos->first.c_str(), pos->second.c_str()); |
| 2628 | value.AppendString (value_str.GetData()); |
| 2629 | } |
| 2630 | } |
| 2631 | } |
| 2632 | else if (var_name == GetSettingNameForInputPath()) |
| 2633 | { |
| 2634 | value.AppendString (m_input_path.c_str()); |
| 2635 | } |
| 2636 | else if (var_name == GetSettingNameForOutputPath()) |
| 2637 | { |
| 2638 | value.AppendString (m_output_path.c_str()); |
| 2639 | } |
| 2640 | else if (var_name == GetSettingNameForErrorPath()) |
| 2641 | { |
| 2642 | value.AppendString (m_error_path.c_str()); |
| 2643 | } |
| 2644 | else if (var_name == GetSettingNameForInheritHostEnv()) |
| 2645 | { |
| 2646 | if (m_inherit_host_env) |
| 2647 | value.AppendString ("true"); |
| 2648 | else |
| 2649 | value.AppendString ("false"); |
| 2650 | } |
| 2651 | else if (var_name == GetSettingNameForDisableASLR()) |
| 2652 | { |
| 2653 | if (m_disable_aslr) |
| 2654 | value.AppendString ("true"); |
| 2655 | else |
| 2656 | value.AppendString ("false"); |
| 2657 | } |
| 2658 | else if (var_name == GetSettingNameForDisableSTDIO()) |
| 2659 | { |
| 2660 | if (m_disable_stdio) |
| 2661 | value.AppendString ("true"); |
| 2662 | else |
| 2663 | value.AppendString ("false"); |
| 2664 | } |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2665 | else |
| 2666 | { |
| 2667 | if (err) |
| 2668 | err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 2669 | return false; |
| 2670 | } |
Sean Callanan | 77e9394 | 2010-10-29 00:29:03 +0000 | [diff] [blame] | 2671 | return true; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2672 | } |
| 2673 | |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2674 | void |
| 2675 | Target::TargetInstanceSettings::GetHostEnvironmentIfNeeded () |
| 2676 | { |
| 2677 | if (m_inherit_host_env && !m_got_host_env) |
| 2678 | { |
| 2679 | m_got_host_env = true; |
| 2680 | StringList host_env; |
| 2681 | const size_t host_env_count = Host::GetEnvironment (host_env); |
| 2682 | for (size_t idx=0; idx<host_env_count; idx++) |
| 2683 | { |
| 2684 | const char *env_entry = host_env.GetStringAtIndex (idx); |
| 2685 | if (env_entry) |
| 2686 | { |
| 2687 | const char *equal_pos = ::strchr(env_entry, '='); |
| 2688 | if (equal_pos) |
| 2689 | { |
| 2690 | std::string key (env_entry, equal_pos - env_entry); |
| 2691 | std::string value (equal_pos + 1); |
| 2692 | if (m_env_vars.find (key) == m_env_vars.end()) |
| 2693 | m_env_vars[key] = value; |
| 2694 | } |
| 2695 | } |
| 2696 | } |
| 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | |
| 2701 | size_t |
| 2702 | Target::TargetInstanceSettings::GetEnvironmentAsArgs (Args &env) |
| 2703 | { |
| 2704 | GetHostEnvironmentIfNeeded (); |
| 2705 | |
| 2706 | dictionary::const_iterator pos, end = m_env_vars.end(); |
| 2707 | for (pos = m_env_vars.begin(); pos != end; ++pos) |
| 2708 | { |
| 2709 | std::string env_var_equal_value (pos->first); |
| 2710 | env_var_equal_value.append(1, '='); |
| 2711 | env_var_equal_value.append (pos->second); |
| 2712 | env.AppendArgument (env_var_equal_value.c_str()); |
| 2713 | } |
| 2714 | return env.GetArgumentCount(); |
| 2715 | } |
| 2716 | |
| 2717 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2718 | const ConstString |
| 2719 | TargetInstanceSettings::CreateInstanceName () |
| 2720 | { |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2721 | StreamString sstr; |
Caroline Tice | 1ebef44 | 2010-09-27 00:30:10 +0000 | [diff] [blame] | 2722 | static int instance_count = 1; |
| 2723 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2724 | sstr.Printf ("target_%d", instance_count); |
| 2725 | ++instance_count; |
| 2726 | |
| 2727 | const ConstString ret_val (sstr.GetData()); |
| 2728 | return ret_val; |
| 2729 | } |
| 2730 | |
| 2731 | //-------------------------------------------------- |
| 2732 | // Target::SettingsController Variable Tables |
| 2733 | //-------------------------------------------------- |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 2734 | OptionEnumValueElement |
| 2735 | TargetInstanceSettings::g_dynamic_value_types[] = |
| 2736 | { |
Greg Clayton | 577fbc3 | 2011-05-30 00:39:48 +0000 | [diff] [blame] | 2737 | { eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, |
| 2738 | { eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."}, |
| 2739 | { eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."}, |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 2740 | { 0, NULL, NULL } |
| 2741 | }; |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2742 | |
| 2743 | SettingEntry |
| 2744 | Target::SettingsController::global_settings_table[] = |
| 2745 | { |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 2746 | // var-name var-type default enum init'd hidden help-text |
| 2747 | // ================= ================== =========== ==== ====== ====== ========================================================================= |
| 2748 | { TSC_DEFAULT_ARCH , eSetVarTypeString , NULL , NULL, false, false, "Default architecture to choose, when there's a choice." }, |
| 2749 | { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } |
| 2750 | }; |
| 2751 | |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2752 | SettingEntry |
| 2753 | Target::SettingsController::instance_settings_table[] = |
| 2754 | { |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2755 | // var-name var-type default enum init'd hidden help-text |
| 2756 | // ================= ================== =============== ======================= ====== ====== ========================================================================= |
| 2757 | { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, |
| 2758 | { TSC_PREFER_DYNAMIC , eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, |
| 2759 | { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, |
| 2760 | { TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, |
Greg Clayton | 9ce9538 | 2012-02-13 23:10:39 +0000 | [diff] [blame^] | 2761 | { TSC_EXE_SEARCH_PATHS , eSetVarTypeArray , NULL , NULL, false, false, "Executable search paths to use when locating executable files whose paths don't match the local file system." }, |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2762 | { TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." }, |
| 2763 | { TSC_MAX_STRLENSUMMARY , eSetVarTypeInt , "1024" , NULL, true, false, "Maximum number of characters to show when using %s in summary strings." }, |
Jim Ingham | 7089d8a | 2011-10-28 23:14:11 +0000 | [diff] [blame] | 2764 | { TSC_PLATFORM_AVOID , eSetVarTypeBoolean, "true" , NULL, false, false, "Consult the platform module avoid list when setting non-module specific breakpoints." }, |
Greg Clayton | abb3302 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 2765 | { TSC_RUN_ARGS , eSetVarTypeArray , NULL , NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." }, |
| 2766 | { TSC_ENV_VARS , eSetVarTypeDictionary, NULL , NULL, false, false, "A list of all the environment variables to be passed to the executable's environment, and their values." }, |
| 2767 | { TSC_INHERIT_ENV , eSetVarTypeBoolean, "true" , NULL, false, false, "Inherit the environment from the process that is running LLDB." }, |
| 2768 | { TSC_STDIN_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for reading its standard input." }, |
| 2769 | { TSC_STDOUT_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for writing its standard output." }, |
| 2770 | { TSC_STDERR_PATH , eSetVarTypeString , NULL , NULL, false, false, "The file/path to be used by the executable program for writing its standard error." }, |
| 2771 | // { "plugin", eSetVarTypeEnum, NULL, NULL, false, false, "The plugin to be used to run the process." }, |
| 2772 | { TSC_DISABLE_ASLR , eSetVarTypeBoolean, "true" , NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, |
| 2773 | { TSC_DISABLE_STDIO , eSetVarTypeBoolean, "false" , NULL, false, false, "Disable stdin/stdout for process (e.g. for a GUI application)" }, |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 2774 | { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } |
Caroline Tice | 5bc8c97 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2775 | }; |