Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [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 | 969795f | 2011-09-21 01:17:13 | [diff] [blame] | 19 | #include "lldb/Breakpoint/BreakpointResolverFileRegex.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 20 | #include "lldb/Breakpoint/BreakpointResolverName.h" |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 21 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 22 | #include "lldb/Core/Event.h" |
| 23 | #include "lldb/Core/Log.h" |
Caroline Tice | 969ed3d1 | 2011-05-02 20:41:46 | [diff] [blame] | 24 | #include "lldb/Core/StreamAsynchronousIO.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 25 | #include "lldb/Core/StreamString.h" |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 26 | #include "lldb/Core/Timer.h" |
| 27 | #include "lldb/Core/ValueObject.h" |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 | [diff] [blame] | 28 | #include "lldb/Expression/ClangUserExpression.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 29 | #include "lldb/Host/Host.h" |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 30 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 31 | #include "lldb/Interpreter/CommandReturnObject.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 32 | #include "lldb/lldb-private-log.h" |
| 33 | #include "lldb/Symbol/ObjectFile.h" |
| 34 | #include "lldb/Target/Process.h" |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 35 | #include "lldb/Target/StackFrame.h" |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 36 | #include "lldb/Target/Thread.h" |
| 37 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 38 | |
| 39 | using namespace lldb; |
| 40 | using namespace lldb_private; |
| 41 | |
| 42 | //---------------------------------------------------------------------- |
| 43 | // Target constructor |
| 44 | //---------------------------------------------------------------------- |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 45 | Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp) : |
| 46 | Broadcaster ("lldb.target"), |
| 47 | ExecutionContextScope (), |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 | [diff] [blame] | 48 | TargetInstanceSettings (*GetSettingsController()), |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 | [diff] [blame] | 49 | m_debugger (debugger), |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 50 | m_platform_sp (platform_sp), |
Greg Clayton | af67cec | 2010-12-20 20:49:23 | [diff] [blame] | 51 | m_mutex (Mutex::eMutexTypeRecursive), |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 52 | m_arch (target_arch), |
| 53 | m_images (), |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 54 | m_section_load_list (), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 55 | m_breakpoint_list (false), |
| 56 | m_internal_breakpoint_list (true), |
Johnny Chen | 1d6bad0 | 2011-09-06 20:05:25 | [diff] [blame] | 57 | m_watchpoint_location_list (), |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 58 | m_process_sp (), |
| 59 | m_search_filter_sp (), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 60 | m_image_search_paths (ImageSearchPathsChanged, this), |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 61 | m_scratch_ast_context_ap (NULL), |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 62 | m_persistent_variables (), |
Jim Ingham | e37d605 | 2011-09-13 00:29:56 | [diff] [blame] | 63 | m_source_manager(*this), |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 64 | m_stop_hooks (), |
Jim Ingham | 6026ca3 | 2011-05-12 02:06:14 | [diff] [blame] | 65 | m_stop_hook_next_id (0), |
| 66 | m_suppress_stop_hooks (false) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 67 | { |
Greg Clayton | cfd1ace | 2010-10-31 03:01:06 | [diff] [blame] | 68 | SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed"); |
| 69 | SetEventName (eBroadcastBitModulesLoaded, "modules-loaded"); |
| 70 | SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded"); |
| 71 | |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 72 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 73 | if (log) |
| 74 | log->Printf ("%p Target::Target()", this); |
| 75 | } |
| 76 | |
| 77 | //---------------------------------------------------------------------- |
| 78 | // Destructor |
| 79 | //---------------------------------------------------------------------- |
| 80 | Target::~Target() |
| 81 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 82 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 83 | if (log) |
| 84 | log->Printf ("%p Target::~Target()", this); |
| 85 | DeleteCurrentProcess (); |
| 86 | } |
| 87 | |
| 88 | void |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame] | 89 | Target::Dump (Stream *s, lldb::DescriptionLevel description_level) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 90 | { |
Greg Clayton | 8941142 | 2010-10-08 00:21:05 | [diff] [blame] | 91 | // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame] | 92 | if (description_level != lldb::eDescriptionLevelBrief) |
| 93 | { |
| 94 | s->Indent(); |
| 95 | s->PutCString("Target\n"); |
| 96 | s->IndentMore(); |
Greg Clayton | 93aa84e | 2010-10-29 04:59:35 | [diff] [blame] | 97 | m_images.Dump(s); |
| 98 | m_breakpoint_list.Dump(s); |
| 99 | m_internal_breakpoint_list.Dump(s); |
| 100 | s->IndentLess(); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame] | 101 | } |
| 102 | else |
| 103 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 104 | Module *exe_module = GetExecutableModulePointer(); |
| 105 | if (exe_module) |
| 106 | s->PutCString (exe_module->GetFileSpec().GetFilename().GetCString()); |
Jim Ingham | 48028b6 | 2011-05-12 01:12:28 | [diff] [blame] | 107 | else |
| 108 | s->PutCString ("No executable module."); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 | [diff] [blame] | 109 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | void |
| 113 | Target::DeleteCurrentProcess () |
| 114 | { |
| 115 | if (m_process_sp.get()) |
| 116 | { |
Greg Clayton | 17f6920 | 2010-09-14 23:52:43 | [diff] [blame] | 117 | m_section_load_list.Clear(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 118 | if (m_process_sp->IsAlive()) |
| 119 | m_process_sp->Destroy(); |
Jim Ingham | d0a3e12b | 2011-02-16 17:54:55 | [diff] [blame] | 120 | |
| 121 | m_process_sp->Finalize(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 122 | |
| 123 | // Do any cleanup of the target we need to do between process instances. |
| 124 | // NB It is better to do this before destroying the process in case the |
| 125 | // clean up needs some help from the process. |
| 126 | m_breakpoint_list.ClearAllBreakpointSites(); |
| 127 | m_internal_breakpoint_list.ClearAllBreakpointSites(); |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 128 | // Disable watchpoint locations just on the debugger side. |
| 129 | DisableAllWatchpointLocations(false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 130 | m_process_sp.reset(); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | const lldb::ProcessSP & |
| 135 | Target::CreateProcess (Listener &listener, const char *plugin_name) |
| 136 | { |
| 137 | DeleteCurrentProcess (); |
| 138 | m_process_sp.reset(Process::FindPlugin(*this, plugin_name, listener)); |
| 139 | return m_process_sp; |
| 140 | } |
| 141 | |
| 142 | const lldb::ProcessSP & |
| 143 | Target::GetProcessSP () const |
| 144 | { |
| 145 | return m_process_sp; |
| 146 | } |
| 147 | |
| 148 | lldb::TargetSP |
| 149 | Target::GetSP() |
| 150 | { |
Greg Clayton | 4d122c4 | 2011-09-17 08:33:22 | [diff] [blame] | 151 | // This object contains an instrusive ref count base class so we can |
| 152 | // easily make a shared pointer to this object |
| 153 | return TargetSP(this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 154 | } |
| 155 | |
Greg Clayton | 3418c85 | 2011-08-10 02:10:13 | [diff] [blame] | 156 | void |
| 157 | Target::Destroy() |
| 158 | { |
| 159 | Mutex::Locker locker (m_mutex); |
| 160 | DeleteCurrentProcess (); |
| 161 | m_platform_sp.reset(); |
| 162 | m_arch.Clear(); |
| 163 | m_images.Clear(); |
| 164 | m_section_load_list.Clear(); |
| 165 | const bool notify = false; |
| 166 | m_breakpoint_list.RemoveAll(notify); |
| 167 | m_internal_breakpoint_list.RemoveAll(notify); |
| 168 | m_last_created_breakpoint.reset(); |
| 169 | m_search_filter_sp.reset(); |
| 170 | m_image_search_paths.Clear(notify); |
| 171 | m_scratch_ast_context_ap.reset(); |
| 172 | m_persistent_variables.Clear(); |
| 173 | m_stop_hooks.clear(); |
| 174 | m_stop_hook_next_id = 0; |
| 175 | m_suppress_stop_hooks = false; |
| 176 | } |
| 177 | |
| 178 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 179 | BreakpointList & |
| 180 | Target::GetBreakpointList(bool internal) |
| 181 | { |
| 182 | if (internal) |
| 183 | return m_internal_breakpoint_list; |
| 184 | else |
| 185 | return m_breakpoint_list; |
| 186 | } |
| 187 | |
| 188 | const BreakpointList & |
| 189 | Target::GetBreakpointList(bool internal) const |
| 190 | { |
| 191 | if (internal) |
| 192 | return m_internal_breakpoint_list; |
| 193 | else |
| 194 | return m_breakpoint_list; |
| 195 | } |
| 196 | |
| 197 | BreakpointSP |
| 198 | Target::GetBreakpointByID (break_id_t break_id) |
| 199 | { |
| 200 | BreakpointSP bp_sp; |
| 201 | |
| 202 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 203 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 204 | else |
| 205 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 206 | |
| 207 | return bp_sp; |
| 208 | } |
| 209 | |
| 210 | BreakpointSP |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 211 | Target::CreateSourceRegexBreakpoint (const FileSpecList *containingModules, |
| 212 | const FileSpecList *source_file_spec_list, |
Jim Ingham | 969795f | 2011-09-21 01:17:13 | [diff] [blame] | 213 | RegularExpression &source_regex, |
| 214 | bool internal) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 215 | { |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 216 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, source_file_spec_list)); |
| 217 | BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex (NULL, source_regex)); |
Jim Ingham | 969795f | 2011-09-21 01:17:13 | [diff] [blame] | 218 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | BreakpointSP |
| 223 | Target::CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal) |
| 224 | { |
| 225 | SearchFilterSP filter_sp(GetSearchFilterForModuleList (containingModules)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 226 | BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines)); |
| 227 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | BreakpointSP |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 232 | Target::CreateBreakpoint (lldb::addr_t addr, bool internal) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 233 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 234 | Address so_addr; |
| 235 | // Attempt to resolve our load address if possible, though it is ok if |
| 236 | // it doesn't resolve to section/offset. |
| 237 | |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 238 | // Try and resolve as a load address if possible |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 | [diff] [blame] | 239 | m_section_load_list.ResolveLoadAddress(addr, so_addr); |
Greg Clayton | 1b72fcb | 2010-08-24 00:45:41 | [diff] [blame] | 240 | if (!so_addr.IsValid()) |
| 241 | { |
| 242 | // The address didn't resolve, so just set this as an absolute address |
| 243 | so_addr.SetOffset (addr); |
| 244 | } |
| 245 | BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 246 | return bp_sp; |
| 247 | } |
| 248 | |
| 249 | BreakpointSP |
| 250 | Target::CreateBreakpoint (Address &addr, bool internal) |
| 251 | { |
| 252 | TargetSP target_sp = this->GetSP(); |
| 253 | SearchFilterSP filter_sp(new SearchFilter (target_sp)); |
| 254 | BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr)); |
| 255 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 256 | } |
| 257 | |
| 258 | BreakpointSP |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 259 | Target::CreateBreakpoint (const FileSpecList *containingModules, |
| 260 | const FileSpecList *containingSourceFiles, |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 261 | const char *func_name, |
| 262 | uint32_t func_name_type_mask, |
| 263 | bool internal, |
| 264 | LazyBool skip_prologue) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 265 | { |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 | [diff] [blame] | 266 | BreakpointSP bp_sp; |
| 267 | if (func_name) |
| 268 | { |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 269 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 270 | |
| 271 | BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, |
| 272 | func_name, |
| 273 | func_name_type_mask, |
| 274 | Breakpoint::Exact, |
| 275 | skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 | [diff] [blame] | 276 | bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 277 | } |
| 278 | return bp_sp; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | |
| 282 | SearchFilterSP |
| 283 | Target::GetSearchFilterForModule (const FileSpec *containingModule) |
| 284 | { |
| 285 | SearchFilterSP filter_sp; |
| 286 | lldb::TargetSP target_sp = this->GetSP(); |
| 287 | if (containingModule != NULL) |
| 288 | { |
| 289 | // TODO: We should look into sharing module based search filters |
| 290 | // across many breakpoints like we do for the simple target based one |
| 291 | filter_sp.reset (new SearchFilterByModule (target_sp, *containingModule)); |
| 292 | } |
| 293 | else |
| 294 | { |
| 295 | if (m_search_filter_sp.get() == NULL) |
| 296 | m_search_filter_sp.reset (new SearchFilter (target_sp)); |
| 297 | filter_sp = m_search_filter_sp; |
| 298 | } |
| 299 | return filter_sp; |
| 300 | } |
| 301 | |
Jim Ingham | 969795f | 2011-09-21 01:17:13 | [diff] [blame] | 302 | SearchFilterSP |
| 303 | Target::GetSearchFilterForModuleList (const FileSpecList *containingModules) |
| 304 | { |
| 305 | SearchFilterSP filter_sp; |
| 306 | lldb::TargetSP target_sp = this->GetSP(); |
| 307 | if (containingModules && containingModules->GetSize() != 0) |
| 308 | { |
| 309 | // TODO: We should look into sharing module based search filters |
| 310 | // across many breakpoints like we do for the simple target based one |
| 311 | filter_sp.reset (new SearchFilterByModuleList (target_sp, *containingModules)); |
| 312 | } |
| 313 | else |
| 314 | { |
| 315 | if (m_search_filter_sp.get() == NULL) |
| 316 | m_search_filter_sp.reset (new SearchFilter (target_sp)); |
| 317 | filter_sp = m_search_filter_sp; |
| 318 | } |
| 319 | return filter_sp; |
| 320 | } |
| 321 | |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 322 | SearchFilterSP |
| 323 | Target::GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles) |
| 324 | { |
| 325 | if (containingSourceFiles == NULL || containingSourceFiles->GetSize() == 0) |
| 326 | return GetSearchFilterForModuleList(containingModules); |
| 327 | |
| 328 | SearchFilterSP filter_sp; |
| 329 | lldb::TargetSP target_sp = this->GetSP(); |
| 330 | if (containingModules == NULL) |
| 331 | { |
| 332 | // We could make a special "CU List only SearchFilter". Better yet was if these could be composable, |
| 333 | // but that will take a little reworking. |
| 334 | |
| 335 | filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, FileSpecList(), *containingSourceFiles)); |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | filter_sp.reset (new SearchFilterByModuleListAndCU (target_sp, *containingModules, *containingSourceFiles)); |
| 340 | } |
| 341 | return filter_sp; |
| 342 | } |
| 343 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 344 | BreakpointSP |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 345 | Target::CreateFuncRegexBreakpoint (const FileSpecList *containingModules, |
| 346 | const FileSpecList *containingSourceFiles, |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 347 | RegularExpression &func_regex, |
| 348 | bool internal, |
| 349 | LazyBool skip_prologue) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 350 | { |
Jim Ingham | 87df91b | 2011-09-23 00:54:11 | [diff] [blame] | 351 | SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList (containingModules, containingSourceFiles)); |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 352 | BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, |
| 353 | func_regex, |
| 354 | skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 355 | |
| 356 | return CreateBreakpoint (filter_sp, resolver_sp, internal); |
| 357 | } |
| 358 | |
| 359 | BreakpointSP |
| 360 | Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal) |
| 361 | { |
| 362 | BreakpointSP bp_sp; |
| 363 | if (filter_sp && resolver_sp) |
| 364 | { |
| 365 | bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp)); |
| 366 | resolver_sp->SetBreakpoint (bp_sp.get()); |
| 367 | |
| 368 | if (internal) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 369 | m_internal_breakpoint_list.Add (bp_sp, false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 370 | else |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 371 | m_breakpoint_list.Add (bp_sp, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 372 | |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 373 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 374 | if (log) |
| 375 | { |
| 376 | StreamString s; |
| 377 | bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); |
| 378 | log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData()); |
| 379 | } |
| 380 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 381 | bp_sp->ResolveBreakpoint(); |
| 382 | } |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 383 | |
| 384 | if (!internal && bp_sp) |
| 385 | { |
| 386 | m_last_created_breakpoint = bp_sp; |
| 387 | } |
| 388 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 389 | return bp_sp; |
| 390 | } |
| 391 | |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 392 | bool |
| 393 | Target::ProcessIsValid() |
| 394 | { |
| 395 | return (m_process_sp && m_process_sp->IsAlive()); |
| 396 | } |
| 397 | |
Johnny Chen | ab9ee76 | 2011-09-14 00:26:03 | [diff] [blame] | 398 | // See also WatchpointLocation::SetWatchpointType(uint32_t type) and |
| 399 | // the OptionGroupWatchpoint::WatchType enum type. |
Johnny Chen | 887062a | 2011-09-12 23:38:44 | [diff] [blame] | 400 | WatchpointLocationSP |
| 401 | Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type) |
| 402 | { |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 403 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 404 | if (log) |
| 405 | log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n", |
| 406 | __FUNCTION__, addr, size, type); |
| 407 | |
Johnny Chen | 887062a | 2011-09-12 23:38:44 | [diff] [blame] | 408 | WatchpointLocationSP wp_loc_sp; |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 409 | if (!ProcessIsValid()) |
Johnny Chen | 2fd89a0 | 2011-09-13 18:30:59 | [diff] [blame] | 410 | return wp_loc_sp; |
Johnny Chen | 45e541f | 2011-09-14 22:20:15 | [diff] [blame] | 411 | if (addr == LLDB_INVALID_ADDRESS || size == 0) |
Johnny Chen | 887062a | 2011-09-12 23:38:44 | [diff] [blame] | 412 | return wp_loc_sp; |
Johnny Chen | 7313a64 | 2011-09-13 01:15:36 | [diff] [blame] | 413 | |
Johnny Chen | ab9ee76 | 2011-09-14 00:26:03 | [diff] [blame] | 414 | // Currently we only support one watchpoint location per address, with total |
| 415 | // number of watchpoint locations limited by the hardware which the inferior |
| 416 | // is running on. |
Johnny Chen | 3c53258 | 2011-09-13 23:29:31 | [diff] [blame] | 417 | WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr); |
| 418 | if (matched_sp) |
| 419 | { |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 420 | size_t old_size = matched_sp->GetByteSize(); |
Johnny Chen | 3c53258 | 2011-09-13 23:29:31 | [diff] [blame] | 421 | uint32_t old_type = |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 422 | (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) | |
| 423 | (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0); |
Johnny Chen | 45e541f | 2011-09-14 22:20:15 | [diff] [blame] | 424 | // Return the existing watchpoint location if both size and type match. |
| 425 | if (size == old_size && type == old_type) { |
| 426 | wp_loc_sp = matched_sp; |
| 427 | wp_loc_sp->SetEnabled(false); |
| 428 | } else { |
| 429 | // Nil the matched watchpoint location; we will be creating a new one. |
| 430 | m_process_sp->DisableWatchpoint(matched_sp.get()); |
| 431 | m_watchpoint_location_list.Remove(matched_sp->GetID()); |
| 432 | } |
Johnny Chen | 3c53258 | 2011-09-13 23:29:31 | [diff] [blame] | 433 | } |
| 434 | |
Johnny Chen | 45e541f | 2011-09-14 22:20:15 | [diff] [blame] | 435 | if (!wp_loc_sp) { |
| 436 | WatchpointLocation *new_loc = new WatchpointLocation(addr, size); |
| 437 | if (!new_loc) { |
| 438 | printf("WatchpointLocation ctor failed, out of memory?\n"); |
| 439 | return wp_loc_sp; |
| 440 | } |
| 441 | new_loc->SetWatchpointType(type); |
| 442 | wp_loc_sp.reset(new_loc); |
| 443 | m_watchpoint_location_list.Add(wp_loc_sp); |
| 444 | } |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 445 | |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 446 | Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); |
Johnny Chen | 0c40637 | 2011-09-14 20:23:45 | [diff] [blame] | 447 | if (log) |
| 448 | log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n", |
| 449 | __FUNCTION__, |
| 450 | rc.Success() ? "succeeded" : "failed", |
| 451 | wp_loc_sp->GetID()); |
| 452 | |
Johnny Chen | 45e541f | 2011-09-14 22:20:15 | [diff] [blame] | 453 | if (rc.Fail()) wp_loc_sp.reset(); |
Johnny Chen | 7313a64 | 2011-09-13 01:15:36 | [diff] [blame] | 454 | return wp_loc_sp; |
Johnny Chen | 887062a | 2011-09-12 23:38:44 | [diff] [blame] | 455 | } |
| 456 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 457 | void |
| 458 | Target::RemoveAllBreakpoints (bool internal_also) |
| 459 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 460 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 461 | if (log) |
| 462 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 463 | |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 464 | m_breakpoint_list.RemoveAll (true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 465 | if (internal_also) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 466 | m_internal_breakpoint_list.RemoveAll (false); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 467 | |
| 468 | m_last_created_breakpoint.reset(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | void |
| 472 | Target::DisableAllBreakpoints (bool internal_also) |
| 473 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 474 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 475 | if (log) |
| 476 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 477 | |
| 478 | m_breakpoint_list.SetEnabledAll (false); |
| 479 | if (internal_also) |
| 480 | m_internal_breakpoint_list.SetEnabledAll (false); |
| 481 | } |
| 482 | |
| 483 | void |
| 484 | Target::EnableAllBreakpoints (bool internal_also) |
| 485 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 486 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 487 | if (log) |
| 488 | log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); |
| 489 | |
| 490 | m_breakpoint_list.SetEnabledAll (true); |
| 491 | if (internal_also) |
| 492 | m_internal_breakpoint_list.SetEnabledAll (true); |
| 493 | } |
| 494 | |
| 495 | bool |
| 496 | Target::RemoveBreakpointByID (break_id_t break_id) |
| 497 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 498 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 499 | if (log) |
| 500 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 501 | |
| 502 | if (DisableBreakpointByID (break_id)) |
| 503 | { |
| 504 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 505 | m_internal_breakpoint_list.Remove(break_id, false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 506 | else |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 507 | { |
Greg Clayton | aa1c587 | 2011-01-24 23:35:47 | [diff] [blame] | 508 | if (m_last_created_breakpoint) |
| 509 | { |
| 510 | if (m_last_created_breakpoint->GetID() == break_id) |
| 511 | m_last_created_breakpoint.reset(); |
| 512 | } |
Greg Clayton | 9fed0d8 | 2010-07-23 23:33:17 | [diff] [blame] | 513 | m_breakpoint_list.Remove(break_id, true); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 | [diff] [blame] | 514 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 515 | return true; |
| 516 | } |
| 517 | return false; |
| 518 | } |
| 519 | |
| 520 | bool |
| 521 | Target::DisableBreakpointByID (break_id_t break_id) |
| 522 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 523 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 524 | if (log) |
| 525 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 526 | |
| 527 | BreakpointSP bp_sp; |
| 528 | |
| 529 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 530 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 531 | else |
| 532 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 533 | if (bp_sp) |
| 534 | { |
| 535 | bp_sp->SetEnabled (false); |
| 536 | return true; |
| 537 | } |
| 538 | return false; |
| 539 | } |
| 540 | |
| 541 | bool |
| 542 | Target::EnableBreakpointByID (break_id_t break_id) |
| 543 | { |
Greg Clayton | 2d4edfb | 2010-11-06 01:53:30 | [diff] [blame] | 544 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 545 | if (log) |
| 546 | log->Printf ("Target::%s (break_id = %i, internal = %s)\n", |
| 547 | __FUNCTION__, |
| 548 | break_id, |
| 549 | LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no"); |
| 550 | |
| 551 | BreakpointSP bp_sp; |
| 552 | |
| 553 | if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) |
| 554 | bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id); |
| 555 | else |
| 556 | bp_sp = m_breakpoint_list.FindBreakpointByID (break_id); |
| 557 | |
| 558 | if (bp_sp) |
| 559 | { |
| 560 | bp_sp->SetEnabled (true); |
| 561 | return true; |
| 562 | } |
| 563 | return false; |
| 564 | } |
| 565 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 566 | // The flag 'end_to_end', default to true, signifies that the operation is |
| 567 | // performed end to end, for both the debugger and the debuggee. |
| 568 | |
| 569 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list |
| 570 | // for end to end operations. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 571 | bool |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 572 | Target::RemoveAllWatchpointLocations (bool end_to_end) |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 573 | { |
| 574 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 575 | if (log) |
| 576 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 577 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 578 | if (!end_to_end) { |
| 579 | m_watchpoint_location_list.RemoveAll(); |
| 580 | return true; |
| 581 | } |
| 582 | |
| 583 | // Otherwise, it's an end to end operation. |
| 584 | |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 585 | if (!ProcessIsValid()) |
| 586 | return false; |
| 587 | |
| 588 | size_t num_watchpoints = m_watchpoint_location_list.GetSize(); |
| 589 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 590 | { |
| 591 | WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); |
| 592 | if (!wp_loc_sp) |
| 593 | return false; |
| 594 | |
| 595 | Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); |
| 596 | if (rc.Fail()) |
| 597 | return false; |
| 598 | } |
| 599 | m_watchpoint_location_list.RemoveAll (); |
| 600 | return true; // Success! |
| 601 | } |
| 602 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 603 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list |
| 604 | // for end to end operations. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 605 | bool |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 606 | Target::DisableAllWatchpointLocations (bool end_to_end) |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 607 | { |
| 608 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 609 | if (log) |
| 610 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 611 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 612 | if (!end_to_end) { |
| 613 | m_watchpoint_location_list.SetEnabledAll(false); |
| 614 | return true; |
| 615 | } |
| 616 | |
| 617 | // Otherwise, it's an end to end operation. |
| 618 | |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 619 | if (!ProcessIsValid()) |
| 620 | return false; |
| 621 | |
| 622 | size_t num_watchpoints = m_watchpoint_location_list.GetSize(); |
| 623 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 624 | { |
| 625 | WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); |
| 626 | if (!wp_loc_sp) |
| 627 | return false; |
| 628 | |
| 629 | Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); |
| 630 | if (rc.Fail()) |
| 631 | return false; |
| 632 | } |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 633 | return true; // Success! |
| 634 | } |
| 635 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 636 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list |
| 637 | // for end to end operations. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 638 | bool |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 639 | Target::EnableAllWatchpointLocations (bool end_to_end) |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 640 | { |
| 641 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 642 | if (log) |
| 643 | log->Printf ("Target::%s\n", __FUNCTION__); |
| 644 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 645 | if (!end_to_end) { |
| 646 | m_watchpoint_location_list.SetEnabledAll(true); |
| 647 | return true; |
| 648 | } |
| 649 | |
| 650 | // Otherwise, it's an end to end operation. |
| 651 | |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 652 | if (!ProcessIsValid()) |
| 653 | return false; |
| 654 | |
| 655 | size_t num_watchpoints = m_watchpoint_location_list.GetSize(); |
| 656 | for (size_t i = 0; i < num_watchpoints; ++i) |
| 657 | { |
| 658 | WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.GetByIndex(i); |
| 659 | if (!wp_loc_sp) |
| 660 | return false; |
| 661 | |
| 662 | Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); |
| 663 | if (rc.Fail()) |
| 664 | return false; |
| 665 | } |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 666 | return true; // Success! |
| 667 | } |
| 668 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 669 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 670 | bool |
| 671 | Target::DisableWatchpointLocationByID (lldb::watch_id_t watch_id) |
| 672 | { |
| 673 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 674 | if (log) |
| 675 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 676 | |
| 677 | if (!ProcessIsValid()) |
| 678 | return false; |
| 679 | |
| 680 | WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); |
| 681 | if (wp_loc_sp) |
| 682 | { |
| 683 | Error rc = m_process_sp->DisableWatchpoint(wp_loc_sp.get()); |
Johnny Chen | f04ee93 | 2011-09-22 18:04:58 | [diff] [blame] | 684 | if (rc.Success()) |
| 685 | return true; |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 686 | |
Johnny Chen | f04ee93 | 2011-09-22 18:04:58 | [diff] [blame] | 687 | // Else, fallthrough. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 688 | } |
| 689 | return false; |
| 690 | } |
| 691 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 692 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 693 | bool |
| 694 | Target::EnableWatchpointLocationByID (lldb::watch_id_t watch_id) |
| 695 | { |
| 696 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 697 | if (log) |
| 698 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 699 | |
| 700 | if (!ProcessIsValid()) |
| 701 | return false; |
| 702 | |
| 703 | WatchpointLocationSP wp_loc_sp = m_watchpoint_location_list.FindByID (watch_id); |
| 704 | if (wp_loc_sp) |
| 705 | { |
| 706 | Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get()); |
Johnny Chen | f04ee93 | 2011-09-22 18:04:58 | [diff] [blame] | 707 | if (rc.Success()) |
| 708 | return true; |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 709 | |
Johnny Chen | f04ee93 | 2011-09-22 18:04:58 | [diff] [blame] | 710 | // Else, fallthrough. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 711 | } |
| 712 | return false; |
| 713 | } |
| 714 | |
Johnny Chen | edf5037 | 2011-09-23 21:21:43 | [diff] [blame] | 715 | // Assumption: Caller holds the list mutex lock for m_watchpoint_location_list. |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 716 | bool |
| 717 | Target::RemoveWatchpointLocationByID (lldb::watch_id_t watch_id) |
| 718 | { |
| 719 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS)); |
| 720 | if (log) |
| 721 | log->Printf ("Target::%s (watch_id = %i)\n", __FUNCTION__, watch_id); |
| 722 | |
| 723 | if (DisableWatchpointLocationByID (watch_id)) |
| 724 | { |
| 725 | m_watchpoint_location_list.Remove(watch_id); |
| 726 | return true; |
| 727 | } |
| 728 | return false; |
| 729 | } |
| 730 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 731 | ModuleSP |
| 732 | Target::GetExecutableModule () |
| 733 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 734 | return m_images.GetModuleAtIndex(0); |
| 735 | } |
| 736 | |
| 737 | Module* |
| 738 | Target::GetExecutableModulePointer () |
| 739 | { |
| 740 | return m_images.GetModulePointerAtIndex(0); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 741 | } |
| 742 | |
| 743 | void |
| 744 | Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) |
| 745 | { |
| 746 | m_images.Clear(); |
| 747 | m_scratch_ast_context_ap.reset(); |
| 748 | |
| 749 | if (executable_sp.get()) |
| 750 | { |
| 751 | Timer scoped_timer (__PRETTY_FUNCTION__, |
| 752 | "Target::SetExecutableModule (executable = '%s/%s')", |
| 753 | executable_sp->GetFileSpec().GetDirectory().AsCString(), |
| 754 | executable_sp->GetFileSpec().GetFilename().AsCString()); |
| 755 | |
| 756 | m_images.Append(executable_sp); // The first image is our exectuable file |
| 757 | |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 758 | // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module. |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 759 | if (!m_arch.IsValid()) |
| 760 | m_arch = executable_sp->GetArchitecture(); |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 761 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 762 | FileSpecList dependent_files; |
Greg Clayton | e996fd3 | 2011-03-08 22:40:15 | [diff] [blame] | 763 | ObjectFile *executable_objfile = executable_sp->GetObjectFile(); |
Jim Ingham | b7f6b2f | 2011-09-08 22:13:49 | [diff] [blame] | 764 | // Let's find the file & line for main and set the default source file from there. |
| 765 | if (!m_source_manager.DefaultFileAndLineSet()) |
| 766 | { |
| 767 | SymbolContextList sc_list; |
| 768 | uint32_t num_matches; |
| 769 | ConstString main_name("main"); |
| 770 | bool symbols_okay = false; // Force it to be a debug symbol. |
| 771 | bool append = false; |
| 772 | num_matches = executable_sp->FindFunctions (main_name, eFunctionNameTypeBase, symbols_okay, append, sc_list); |
| 773 | for (uint32_t idx = 0; idx < num_matches; idx++) |
| 774 | { |
| 775 | SymbolContext sc; |
| 776 | sc_list.GetContextAtIndex(idx, sc); |
| 777 | if (sc.line_entry.file) |
| 778 | { |
| 779 | m_source_manager.SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line); |
| 780 | break; |
| 781 | } |
| 782 | } |
| 783 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 784 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 | [diff] [blame^] | 785 | if (executable_objfile && get_dependent_files) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 786 | { |
| 787 | executable_objfile->GetDependentModules(dependent_files); |
| 788 | for (uint32_t i=0; i<dependent_files.GetSize(); i++) |
| 789 | { |
Greg Clayton | ded470d | 2011-03-19 01:12:21 | [diff] [blame] | 790 | FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i)); |
| 791 | FileSpec platform_dependent_file_spec; |
| 792 | if (m_platform_sp) |
Greg Clayton | d314e81 | 2011-03-23 00:09:55 | [diff] [blame] | 793 | m_platform_sp->GetFile (dependent_file_spec, NULL, platform_dependent_file_spec); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 | [diff] [blame] | 794 | else |
| 795 | platform_dependent_file_spec = dependent_file_spec; |
| 796 | |
| 797 | ModuleSP image_module_sp(GetSharedModule (platform_dependent_file_spec, |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 798 | m_arch)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 799 | if (image_module_sp.get()) |
| 800 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 801 | ObjectFile *objfile = image_module_sp->GetObjectFile(); |
| 802 | if (objfile) |
| 803 | objfile->GetDependentModules(dependent_files); |
| 804 | } |
| 805 | } |
| 806 | } |
| 807 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 808 | } |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 809 | |
| 810 | UpdateInstanceName(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 814 | bool |
| 815 | Target::SetArchitecture (const ArchSpec &arch_spec) |
| 816 | { |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 817 | if (m_arch == arch_spec) |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 818 | { |
| 819 | // If we're setting the architecture to our current architecture, we |
| 820 | // don't need to do anything. |
| 821 | return true; |
| 822 | } |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 823 | else if (!m_arch.IsValid()) |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 824 | { |
| 825 | // If we haven't got a valid arch spec, then we just need to set it. |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 826 | m_arch = arch_spec; |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 827 | return true; |
| 828 | } |
| 829 | else |
| 830 | { |
| 831 | // If we have an executable file, try to reset the executable to the desired architecture |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 832 | m_arch = arch_spec; |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 833 | ModuleSP executable_sp = GetExecutableModule (); |
| 834 | m_images.Clear(); |
| 835 | m_scratch_ast_context_ap.reset(); |
Jim Ingham | 5aee162 | 2010-08-09 23:31:02 | [diff] [blame] | 836 | // Need to do something about unsetting breakpoints. |
| 837 | |
| 838 | if (executable_sp) |
| 839 | { |
| 840 | FileSpec exec_file_spec = executable_sp->GetFileSpec(); |
| 841 | Error error = ModuleList::GetSharedModule(exec_file_spec, |
| 842 | arch_spec, |
| 843 | NULL, |
| 844 | NULL, |
| 845 | 0, |
| 846 | executable_sp, |
| 847 | NULL, |
| 848 | NULL); |
| 849 | |
| 850 | if (!error.Fail() && executable_sp) |
| 851 | { |
| 852 | SetExecutableModule (executable_sp, true); |
| 853 | return true; |
| 854 | } |
| 855 | else |
| 856 | { |
| 857 | return false; |
| 858 | } |
| 859 | } |
| 860 | else |
| 861 | { |
| 862 | return false; |
| 863 | } |
| 864 | } |
| 865 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 866 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 867 | void |
| 868 | Target::ModuleAdded (ModuleSP &module_sp) |
| 869 | { |
| 870 | // A module is being added to this target for the first time |
| 871 | ModuleList module_list; |
| 872 | module_list.Append(module_sp); |
| 873 | ModulesDidLoad (module_list); |
| 874 | } |
| 875 | |
| 876 | void |
| 877 | Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp) |
| 878 | { |
Jim Ingham | e716ae0 | 2011-08-03 01:00:06 | [diff] [blame] | 879 | // A module is replacing an already added module |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 880 | ModuleList module_list; |
| 881 | module_list.Append (old_module_sp); |
| 882 | ModulesDidUnload (module_list); |
| 883 | module_list.Clear (); |
| 884 | module_list.Append (new_module_sp); |
| 885 | ModulesDidLoad (module_list); |
| 886 | } |
| 887 | |
| 888 | void |
| 889 | Target::ModulesDidLoad (ModuleList &module_list) |
| 890 | { |
| 891 | m_breakpoint_list.UpdateBreakpoints (module_list, true); |
| 892 | // TODO: make event data that packages up the module_list |
| 893 | BroadcastEvent (eBroadcastBitModulesLoaded, NULL); |
| 894 | } |
| 895 | |
| 896 | void |
| 897 | Target::ModulesDidUnload (ModuleList &module_list) |
| 898 | { |
| 899 | m_breakpoint_list.UpdateBreakpoints (module_list, false); |
Greg Clayton | a4d7830 | 2010-12-06 23:51:26 | [diff] [blame] | 900 | |
| 901 | // Remove the images from the target image list |
| 902 | m_images.Remove(module_list); |
| 903 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 904 | // TODO: make event data that packages up the module_list |
| 905 | BroadcastEvent (eBroadcastBitModulesUnloaded, NULL); |
| 906 | } |
| 907 | |
| 908 | size_t |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 909 | Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error) |
| 910 | { |
| 911 | const Section *section = addr.GetSection(); |
| 912 | if (section && section->GetModule()) |
| 913 | { |
| 914 | ObjectFile *objfile = section->GetModule()->GetObjectFile(); |
| 915 | if (objfile) |
| 916 | { |
| 917 | size_t bytes_read = section->ReadSectionDataFromObjectFile (objfile, |
| 918 | addr.GetOffset(), |
| 919 | dst, |
| 920 | dst_len); |
| 921 | if (bytes_read > 0) |
| 922 | return bytes_read; |
| 923 | else |
| 924 | error.SetErrorStringWithFormat("error reading data from section %s", section->GetName().GetCString()); |
| 925 | } |
| 926 | else |
| 927 | { |
| 928 | error.SetErrorString("address isn't from a object file"); |
| 929 | } |
| 930 | } |
| 931 | else |
| 932 | { |
| 933 | error.SetErrorString("address doesn't contain a section that points to a section in a object file"); |
| 934 | } |
| 935 | return 0; |
| 936 | } |
| 937 | |
| 938 | size_t |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 939 | Target::ReadMemory (const Address& addr, |
| 940 | bool prefer_file_cache, |
| 941 | void *dst, |
| 942 | size_t dst_len, |
| 943 | Error &error, |
| 944 | lldb::addr_t *load_addr_ptr) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 945 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 946 | error.Clear(); |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 947 | |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 948 | // if we end up reading this from process memory, we will fill this |
| 949 | // with the actual load address |
| 950 | if (load_addr_ptr) |
| 951 | *load_addr_ptr = LLDB_INVALID_ADDRESS; |
| 952 | |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 953 | size_t bytes_read = 0; |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 954 | |
| 955 | addr_t load_addr = LLDB_INVALID_ADDRESS; |
| 956 | addr_t file_addr = LLDB_INVALID_ADDRESS; |
Greg Clayton | 357132e | 2011-03-26 19:14:58 | [diff] [blame] | 957 | Address resolved_addr; |
| 958 | if (!addr.IsSectionOffset()) |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 959 | { |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 960 | if (m_section_load_list.IsEmpty()) |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 961 | { |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 962 | // No sections are loaded, so we must assume we are not running |
| 963 | // yet and anything we are given is a file address. |
| 964 | file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the file address |
| 965 | m_images.ResolveFileAddress (file_addr, resolved_addr); |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 966 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 967 | else |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 968 | { |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 969 | // We have at least one section loaded. This can be becuase |
| 970 | // we have manually loaded some sections with "target modules load ..." |
| 971 | // or because we have have a live process that has sections loaded |
| 972 | // through the dynamic loader |
| 973 | load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the load address |
| 974 | m_section_load_list.ResolveLoadAddress (load_addr, resolved_addr); |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 975 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 976 | } |
Greg Clayton | 357132e | 2011-03-26 19:14:58 | [diff] [blame] | 977 | if (!resolved_addr.IsValid()) |
| 978 | resolved_addr = addr; |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 979 | |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 980 | |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 981 | if (prefer_file_cache) |
| 982 | { |
| 983 | bytes_read = ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error); |
| 984 | if (bytes_read > 0) |
| 985 | return bytes_read; |
| 986 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 987 | |
Johnny Chen | 86364b4 | 2011-09-20 23:28:55 | [diff] [blame] | 988 | if (ProcessIsValid()) |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 989 | { |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 990 | if (load_addr == LLDB_INVALID_ADDRESS) |
| 991 | load_addr = resolved_addr.GetLoadAddress (this); |
| 992 | |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 993 | if (load_addr == LLDB_INVALID_ADDRESS) |
| 994 | { |
| 995 | if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec()) |
| 996 | error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n", |
| 997 | resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(), |
Jason Molenda | 7e589a6 | 2011-09-20 00:26:08 | [diff] [blame] | 998 | resolved_addr.GetFileAddress(), |
| 999 | resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString()); |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1000 | else |
| 1001 | error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress()); |
| 1002 | } |
| 1003 | else |
| 1004 | { |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 1005 | bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1006 | if (bytes_read != dst_len) |
| 1007 | { |
| 1008 | if (error.Success()) |
| 1009 | { |
| 1010 | if (bytes_read == 0) |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1011 | error.SetErrorStringWithFormat("Read memory from 0x%llx failed.\n", load_addr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1012 | else |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1013 | error.SetErrorStringWithFormat("Only %zu of %zu bytes were read from memory at 0x%llx.\n", bytes_read, dst_len, load_addr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1014 | } |
| 1015 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1016 | if (bytes_read) |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 1017 | { |
| 1018 | if (load_addr_ptr) |
| 1019 | *load_addr_ptr = load_addr; |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1020 | return bytes_read; |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 1021 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1022 | // If the address is not section offset we have an address that |
| 1023 | // doesn't resolve to any address in any currently loaded shared |
| 1024 | // libaries and we failed to read memory so there isn't anything |
| 1025 | // more we can do. If it is section offset, we might be able to |
| 1026 | // read cached memory from the object file. |
| 1027 | if (!resolved_addr.IsSectionOffset()) |
| 1028 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1029 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1030 | } |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1031 | |
Greg Clayton | c749eb8 | 2011-07-11 05:12:02 | [diff] [blame] | 1032 | if (!prefer_file_cache && resolved_addr.IsSectionOffset()) |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1033 | { |
Greg Clayton | db59823 | 2011-01-07 01:57:07 | [diff] [blame] | 1034 | // If we didn't already try and read from the object file cache, then |
| 1035 | // try it after failing to read from the process. |
| 1036 | return ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error); |
Greg Clayton | dda4f7b | 2010-06-30 23:03:03 | [diff] [blame] | 1037 | } |
| 1038 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1039 | } |
| 1040 | |
Greg Clayton | d16e1e5 | 2011-07-12 17:06:17 | [diff] [blame] | 1041 | size_t |
| 1042 | Target::ReadScalarIntegerFromMemory (const Address& addr, |
| 1043 | bool prefer_file_cache, |
| 1044 | uint32_t byte_size, |
| 1045 | bool is_signed, |
| 1046 | Scalar &scalar, |
| 1047 | Error &error) |
| 1048 | { |
| 1049 | uint64_t uval; |
| 1050 | |
| 1051 | if (byte_size <= sizeof(uval)) |
| 1052 | { |
| 1053 | size_t bytes_read = ReadMemory (addr, prefer_file_cache, &uval, byte_size, error); |
| 1054 | if (bytes_read == byte_size) |
| 1055 | { |
| 1056 | DataExtractor data (&uval, sizeof(uval), m_arch.GetByteOrder(), m_arch.GetAddressByteSize()); |
| 1057 | uint32_t offset = 0; |
| 1058 | if (byte_size <= 4) |
| 1059 | scalar = data.GetMaxU32 (&offset, byte_size); |
| 1060 | else |
| 1061 | scalar = data.GetMaxU64 (&offset, byte_size); |
| 1062 | |
| 1063 | if (is_signed) |
| 1064 | scalar.SignExtend(byte_size * 8); |
| 1065 | return bytes_read; |
| 1066 | } |
| 1067 | } |
| 1068 | else |
| 1069 | { |
| 1070 | error.SetErrorStringWithFormat ("byte size of %u is too large for integer scalar type", byte_size); |
| 1071 | } |
| 1072 | return 0; |
| 1073 | } |
| 1074 | |
| 1075 | uint64_t |
| 1076 | Target::ReadUnsignedIntegerFromMemory (const Address& addr, |
| 1077 | bool prefer_file_cache, |
| 1078 | size_t integer_byte_size, |
| 1079 | uint64_t fail_value, |
| 1080 | Error &error) |
| 1081 | { |
| 1082 | Scalar scalar; |
| 1083 | if (ReadScalarIntegerFromMemory (addr, |
| 1084 | prefer_file_cache, |
| 1085 | integer_byte_size, |
| 1086 | false, |
| 1087 | scalar, |
| 1088 | error)) |
| 1089 | return scalar.ULongLong(fail_value); |
| 1090 | return fail_value; |
| 1091 | } |
| 1092 | |
| 1093 | bool |
| 1094 | Target::ReadPointerFromMemory (const Address& addr, |
| 1095 | bool prefer_file_cache, |
| 1096 | Error &error, |
| 1097 | Address &pointer_addr) |
| 1098 | { |
| 1099 | Scalar scalar; |
| 1100 | if (ReadScalarIntegerFromMemory (addr, |
| 1101 | prefer_file_cache, |
| 1102 | m_arch.GetAddressByteSize(), |
| 1103 | false, |
| 1104 | scalar, |
| 1105 | error)) |
| 1106 | { |
| 1107 | addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS); |
| 1108 | if (pointer_vm_addr != LLDB_INVALID_ADDRESS) |
| 1109 | { |
| 1110 | if (m_section_load_list.IsEmpty()) |
| 1111 | { |
| 1112 | // No sections are loaded, so we must assume we are not running |
| 1113 | // yet and anything we are given is a file address. |
| 1114 | m_images.ResolveFileAddress (pointer_vm_addr, pointer_addr); |
| 1115 | } |
| 1116 | else |
| 1117 | { |
| 1118 | // We have at least one section loaded. This can be becuase |
| 1119 | // we have manually loaded some sections with "target modules load ..." |
| 1120 | // or because we have have a live process that has sections loaded |
| 1121 | // through the dynamic loader |
| 1122 | m_section_load_list.ResolveLoadAddress (pointer_vm_addr, pointer_addr); |
| 1123 | } |
| 1124 | // We weren't able to resolve the pointer value, so just return |
| 1125 | // an address with no section |
| 1126 | if (!pointer_addr.IsValid()) |
| 1127 | pointer_addr.SetOffset (pointer_vm_addr); |
| 1128 | return true; |
| 1129 | |
| 1130 | } |
| 1131 | } |
| 1132 | return false; |
| 1133 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1134 | |
| 1135 | ModuleSP |
| 1136 | Target::GetSharedModule |
| 1137 | ( |
| 1138 | const FileSpec& file_spec, |
| 1139 | const ArchSpec& arch, |
Greg Clayton | 6083026 | 2011-02-04 18:53:10 | [diff] [blame] | 1140 | const lldb_private::UUID *uuid_ptr, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1141 | const ConstString *object_name, |
| 1142 | off_t object_offset, |
| 1143 | Error *error_ptr |
| 1144 | ) |
| 1145 | { |
| 1146 | // Don't pass in the UUID so we can tell if we have a stale value in our list |
| 1147 | ModuleSP old_module_sp; // This will get filled in if we have a new version of the library |
| 1148 | bool did_create_module = false; |
| 1149 | ModuleSP module_sp; |
| 1150 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1151 | Error error; |
| 1152 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1153 | // If there are image search path entries, try to use them first to acquire a suitable image. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1154 | if (m_image_search_paths.GetSize()) |
| 1155 | { |
| 1156 | FileSpec transformed_spec; |
| 1157 | if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory())) |
| 1158 | { |
| 1159 | transformed_spec.GetFilename() = file_spec.GetFilename(); |
| 1160 | error = ModuleList::GetSharedModule (transformed_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module); |
| 1161 | } |
| 1162 | } |
| 1163 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1164 | // The platform is responsible for finding and caching an appropriate |
| 1165 | // module in the shared module cache. |
| 1166 | if (m_platform_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1167 | { |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1168 | FileSpec platform_file_spec; |
| 1169 | error = m_platform_sp->GetSharedModule (file_spec, |
| 1170 | arch, |
| 1171 | uuid_ptr, |
| 1172 | object_name, |
| 1173 | object_offset, |
| 1174 | module_sp, |
| 1175 | &old_module_sp, |
| 1176 | &did_create_module); |
| 1177 | } |
| 1178 | else |
| 1179 | { |
| 1180 | error.SetErrorString("no platform is currently set"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1181 | } |
| 1182 | |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1183 | // If a module hasn't been found yet, use the unmodified path. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1184 | if (module_sp) |
| 1185 | { |
| 1186 | m_images.Append (module_sp); |
| 1187 | if (did_create_module) |
| 1188 | { |
| 1189 | if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32) |
| 1190 | ModuleUpdated(old_module_sp, module_sp); |
| 1191 | else |
| 1192 | ModuleAdded(module_sp); |
| 1193 | } |
| 1194 | } |
| 1195 | if (error_ptr) |
| 1196 | *error_ptr = error; |
| 1197 | return module_sp; |
| 1198 | } |
| 1199 | |
| 1200 | |
| 1201 | Target * |
| 1202 | Target::CalculateTarget () |
| 1203 | { |
| 1204 | return this; |
| 1205 | } |
| 1206 | |
| 1207 | Process * |
| 1208 | Target::CalculateProcess () |
| 1209 | { |
| 1210 | return NULL; |
| 1211 | } |
| 1212 | |
| 1213 | Thread * |
| 1214 | Target::CalculateThread () |
| 1215 | { |
| 1216 | return NULL; |
| 1217 | } |
| 1218 | |
| 1219 | StackFrame * |
| 1220 | Target::CalculateStackFrame () |
| 1221 | { |
| 1222 | return NULL; |
| 1223 | } |
| 1224 | |
| 1225 | void |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 | [diff] [blame] | 1226 | Target::CalculateExecutionContext (ExecutionContext &exe_ctx) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1227 | { |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 | [diff] [blame] | 1228 | exe_ctx.Clear(); |
| 1229 | exe_ctx.SetTargetPtr(this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | PathMappingList & |
| 1233 | Target::GetImageSearchPathList () |
| 1234 | { |
| 1235 | return m_image_search_paths; |
| 1236 | } |
| 1237 | |
| 1238 | void |
| 1239 | Target::ImageSearchPathsChanged |
| 1240 | ( |
| 1241 | const PathMappingList &path_list, |
| 1242 | void *baton |
| 1243 | ) |
| 1244 | { |
| 1245 | Target *target = (Target *)baton; |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 1246 | ModuleSP exe_module_sp (target->GetExecutableModule()); |
| 1247 | if (exe_module_sp) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1248 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 1249 | target->m_images.Clear(); |
| 1250 | target->SetExecutableModule (exe_module_sp, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | ClangASTContext * |
| 1255 | Target::GetScratchClangASTContext() |
| 1256 | { |
Greg Clayton | 73da244 | 2011-08-03 01:23:55 | [diff] [blame] | 1257 | // Now see if we know the target triple, and if so, create our scratch AST context: |
| 1258 | if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid()) |
| 1259 | m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str())); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1260 | return m_scratch_ast_context_ap.get(); |
| 1261 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1262 | |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1263 | void |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 | [diff] [blame] | 1264 | Target::SettingsInitialize () |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1265 | { |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1266 | UserSettingsControllerSP &usc = GetSettingsController(); |
| 1267 | usc.reset (new SettingsController); |
| 1268 | UserSettingsController::InitializeSettingsController (usc, |
| 1269 | SettingsController::global_settings_table, |
| 1270 | SettingsController::instance_settings_table); |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 | [diff] [blame] | 1271 | |
| 1272 | // Now call SettingsInitialize() on each 'child' setting of Target |
| 1273 | Process::SettingsInitialize (); |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1274 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1275 | |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1276 | void |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 | [diff] [blame] | 1277 | Target::SettingsTerminate () |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1278 | { |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 | [diff] [blame] | 1279 | |
| 1280 | // Must call SettingsTerminate() on each settings 'child' of Target, before terminating Target's Settings. |
| 1281 | |
| 1282 | Process::SettingsTerminate (); |
| 1283 | |
| 1284 | // Now terminate Target Settings. |
| 1285 | |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1286 | UserSettingsControllerSP &usc = GetSettingsController(); |
| 1287 | UserSettingsController::FinalizeSettingsController (usc); |
| 1288 | usc.reset(); |
| 1289 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1290 | |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 | [diff] [blame] | 1291 | UserSettingsControllerSP & |
| 1292 | Target::GetSettingsController () |
| 1293 | { |
| 1294 | static UserSettingsControllerSP g_settings_controller; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1295 | return g_settings_controller; |
| 1296 | } |
| 1297 | |
| 1298 | ArchSpec |
| 1299 | Target::GetDefaultArchitecture () |
| 1300 | { |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 | [diff] [blame] | 1301 | lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController()); |
| 1302 | |
| 1303 | if (settings_controller_sp) |
| 1304 | return static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture (); |
| 1305 | return ArchSpec(); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1306 | } |
| 1307 | |
| 1308 | void |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 | [diff] [blame] | 1309 | Target::SetDefaultArchitecture (const ArchSpec& arch) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1310 | { |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 | [diff] [blame] | 1311 | lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController()); |
| 1312 | |
| 1313 | if (settings_controller_sp) |
| 1314 | static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture () = arch; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1315 | } |
| 1316 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 | [diff] [blame] | 1317 | Target * |
| 1318 | Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr) |
| 1319 | { |
| 1320 | // The target can either exist in the "process" of ExecutionContext, or in |
| 1321 | // the "target_sp" member of SymbolContext. This accessor helper function |
| 1322 | // will get the target from one of these locations. |
| 1323 | |
| 1324 | Target *target = NULL; |
| 1325 | if (sc_ptr != NULL) |
| 1326 | target = sc_ptr->target_sp.get(); |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 | [diff] [blame] | 1327 | if (target == NULL && exe_ctx_ptr) |
| 1328 | target = exe_ctx_ptr->GetTargetPtr(); |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 | [diff] [blame] | 1329 | return target; |
| 1330 | } |
| 1331 | |
| 1332 | |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 1333 | void |
| 1334 | Target::UpdateInstanceName () |
| 1335 | { |
| 1336 | StreamString sstr; |
| 1337 | |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 1338 | Module *exe_module = GetExecutableModulePointer(); |
| 1339 | if (exe_module) |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 1340 | { |
Greg Clayton | 307de25 | 2010-10-27 02:06:37 | [diff] [blame] | 1341 | sstr.Printf ("%s_%s", |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 | [diff] [blame] | 1342 | exe_module->GetFileSpec().GetFilename().AsCString(), |
| 1343 | exe_module->GetArchitecture().GetArchitectureName()); |
| 1344 | GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 1345 | } |
| 1346 | } |
| 1347 | |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 1348 | const char * |
| 1349 | Target::GetExpressionPrefixContentsAsCString () |
| 1350 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 1351 | if (m_expr_prefix_contents_sp) |
| 1352 | return (const char *)m_expr_prefix_contents_sp->GetBytes(); |
| 1353 | return NULL; |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 1354 | } |
| 1355 | |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1356 | ExecutionResults |
| 1357 | Target::EvaluateExpression |
| 1358 | ( |
| 1359 | const char *expr_cstr, |
| 1360 | StackFrame *frame, |
Sean Callanan | 3bfdaa2 | 2011-09-15 02:13:07 | [diff] [blame] | 1361 | lldb_private::ExecutionPolicy execution_policy, |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1362 | bool unwind_on_error, |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 | [diff] [blame] | 1363 | bool keep_in_memory, |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 1364 | lldb::DynamicValueType use_dynamic, |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1365 | lldb::ValueObjectSP &result_valobj_sp |
| 1366 | ) |
| 1367 | { |
| 1368 | ExecutionResults execution_results = eExecutionSetupError; |
| 1369 | |
| 1370 | result_valobj_sp.reset(); |
Jim Ingham | 6026ca3 | 2011-05-12 02:06:14 | [diff] [blame] | 1371 | |
| 1372 | // We shouldn't run stop hooks in expressions. |
| 1373 | // Be sure to reset this if you return anywhere within this function. |
| 1374 | bool old_suppress_value = m_suppress_stop_hooks; |
| 1375 | m_suppress_stop_hooks = true; |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1376 | |
| 1377 | ExecutionContext exe_ctx; |
| 1378 | if (frame) |
| 1379 | { |
| 1380 | frame->CalculateExecutionContext(exe_ctx); |
Greg Clayton | 54979cd | 2010-12-15 05:08:08 | [diff] [blame] | 1381 | Error error; |
Greg Clayton | 6d5e68e | 2011-01-20 19:27:18 | [diff] [blame] | 1382 | const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | |
Enrico Granata | 27b625e | 2011-08-09 01:04:56 | [diff] [blame] | 1383 | StackFrame::eExpressionPathOptionsNoFragileObjcIvar | |
| 1384 | StackFrame::eExpressionPathOptionsNoSyntheticChildren; |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 1385 | lldb::VariableSP var_sp; |
| 1386 | result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, |
| 1387 | use_dynamic, |
| 1388 | expr_path_options, |
| 1389 | var_sp, |
| 1390 | error); |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1391 | } |
| 1392 | else if (m_process_sp) |
| 1393 | { |
| 1394 | m_process_sp->CalculateExecutionContext(exe_ctx); |
| 1395 | } |
| 1396 | else |
| 1397 | { |
| 1398 | CalculateExecutionContext(exe_ctx); |
| 1399 | } |
| 1400 | |
| 1401 | if (result_valobj_sp) |
| 1402 | { |
| 1403 | execution_results = eExecutionCompleted; |
| 1404 | // We got a result from the frame variable expression path above... |
| 1405 | ConstString persistent_variable_name (m_persistent_variables.GetNextPersistentVariableName()); |
| 1406 | |
| 1407 | lldb::ValueObjectSP const_valobj_sp; |
| 1408 | |
| 1409 | // Check in case our value is already a constant value |
| 1410 | if (result_valobj_sp->GetIsConstant()) |
| 1411 | { |
| 1412 | const_valobj_sp = result_valobj_sp; |
| 1413 | const_valobj_sp->SetName (persistent_variable_name); |
| 1414 | } |
| 1415 | else |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1416 | { |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 1417 | if (use_dynamic != lldb::eNoDynamicValues) |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1418 | { |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 1419 | ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(use_dynamic); |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1420 | if (dynamic_sp) |
| 1421 | result_valobj_sp = dynamic_sp; |
| 1422 | } |
| 1423 | |
Jim Ingham | 6035b67 | 2011-03-31 00:19:25 | [diff] [blame] | 1424 | const_valobj_sp = result_valobj_sp->CreateConstantValue (persistent_variable_name); |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1425 | } |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1426 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 | [diff] [blame] | 1427 | lldb::ValueObjectSP live_valobj_sp = result_valobj_sp; |
| 1428 | |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1429 | result_valobj_sp = const_valobj_sp; |
| 1430 | |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 | [diff] [blame] | 1431 | ClangExpressionVariableSP clang_expr_variable_sp(m_persistent_variables.CreatePersistentVariable(result_valobj_sp)); |
| 1432 | assert (clang_expr_variable_sp.get()); |
| 1433 | |
| 1434 | // Set flags and live data as appropriate |
| 1435 | |
| 1436 | const Value &result_value = live_valobj_sp->GetValue(); |
| 1437 | |
| 1438 | switch (result_value.GetValueType()) |
| 1439 | { |
| 1440 | case Value::eValueTypeHostAddress: |
| 1441 | case Value::eValueTypeFileAddress: |
| 1442 | // we don't do anything with these for now |
| 1443 | break; |
| 1444 | case Value::eValueTypeScalar: |
| 1445 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated; |
| 1446 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation; |
| 1447 | break; |
| 1448 | case Value::eValueTypeLoadAddress: |
| 1449 | clang_expr_variable_sp->m_live_sp = live_valobj_sp; |
| 1450 | clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference; |
| 1451 | break; |
| 1452 | } |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1453 | } |
| 1454 | else |
| 1455 | { |
| 1456 | // Make sure we aren't just trying to see the value of a persistent |
| 1457 | // variable (something like "$0") |
Greg Clayton | 3e06bd9 | 2011-01-09 21:07:35 | [diff] [blame] | 1458 | lldb::ClangExpressionVariableSP persistent_var_sp; |
| 1459 | // Only check for persistent variables the expression starts with a '$' |
| 1460 | if (expr_cstr[0] == '$') |
| 1461 | persistent_var_sp = m_persistent_variables.GetVariable (expr_cstr); |
| 1462 | |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1463 | if (persistent_var_sp) |
| 1464 | { |
| 1465 | result_valobj_sp = persistent_var_sp->GetValueObject (); |
| 1466 | execution_results = eExecutionCompleted; |
| 1467 | } |
| 1468 | else |
| 1469 | { |
| 1470 | const char *prefix = GetExpressionPrefixContentsAsCString(); |
Sean Callanan | 3bfdaa2 | 2011-09-15 02:13:07 | [diff] [blame] | 1471 | |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1472 | execution_results = ClangUserExpression::Evaluate (exe_ctx, |
Sean Callanan | 3bfdaa2 | 2011-09-15 02:13:07 | [diff] [blame] | 1473 | execution_policy, |
Sean Callanan | 92adcac | 2011-01-13 08:53:35 | [diff] [blame] | 1474 | unwind_on_error, |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1475 | expr_cstr, |
| 1476 | prefix, |
| 1477 | result_valobj_sp); |
| 1478 | } |
| 1479 | } |
Jim Ingham | 6026ca3 | 2011-05-12 02:06:14 | [diff] [blame] | 1480 | |
| 1481 | m_suppress_stop_hooks = old_suppress_value; |
| 1482 | |
Greg Clayton | 8b2fe6d | 2010-12-14 02:59:59 | [diff] [blame] | 1483 | return execution_results; |
| 1484 | } |
| 1485 | |
Greg Clayton | f3ef3d2 | 2011-05-22 22:46:53 | [diff] [blame] | 1486 | lldb::addr_t |
| 1487 | Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const |
| 1488 | { |
| 1489 | addr_t code_addr = load_addr; |
| 1490 | switch (m_arch.GetMachine()) |
| 1491 | { |
| 1492 | case llvm::Triple::arm: |
| 1493 | case llvm::Triple::thumb: |
| 1494 | switch (addr_class) |
| 1495 | { |
| 1496 | case eAddressClassData: |
| 1497 | case eAddressClassDebug: |
| 1498 | return LLDB_INVALID_ADDRESS; |
| 1499 | |
| 1500 | case eAddressClassUnknown: |
| 1501 | case eAddressClassInvalid: |
| 1502 | case eAddressClassCode: |
| 1503 | case eAddressClassCodeAlternateISA: |
| 1504 | case eAddressClassRuntime: |
| 1505 | // Check if bit zero it no set? |
| 1506 | if ((code_addr & 1ull) == 0) |
| 1507 | { |
| 1508 | // Bit zero isn't set, check if the address is a multiple of 2? |
| 1509 | if (code_addr & 2ull) |
| 1510 | { |
| 1511 | // The address is a multiple of 2 so it must be thumb, set bit zero |
| 1512 | code_addr |= 1ull; |
| 1513 | } |
| 1514 | else if (addr_class == eAddressClassCodeAlternateISA) |
| 1515 | { |
| 1516 | // We checked the address and the address claims to be the alternate ISA |
| 1517 | // which means thumb, so set bit zero. |
| 1518 | code_addr |= 1ull; |
| 1519 | } |
| 1520 | } |
| 1521 | break; |
| 1522 | } |
| 1523 | break; |
| 1524 | |
| 1525 | default: |
| 1526 | break; |
| 1527 | } |
| 1528 | return code_addr; |
| 1529 | } |
| 1530 | |
| 1531 | lldb::addr_t |
| 1532 | Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const |
| 1533 | { |
| 1534 | addr_t opcode_addr = load_addr; |
| 1535 | switch (m_arch.GetMachine()) |
| 1536 | { |
| 1537 | case llvm::Triple::arm: |
| 1538 | case llvm::Triple::thumb: |
| 1539 | switch (addr_class) |
| 1540 | { |
| 1541 | case eAddressClassData: |
| 1542 | case eAddressClassDebug: |
| 1543 | return LLDB_INVALID_ADDRESS; |
| 1544 | |
| 1545 | case eAddressClassInvalid: |
| 1546 | case eAddressClassUnknown: |
| 1547 | case eAddressClassCode: |
| 1548 | case eAddressClassCodeAlternateISA: |
| 1549 | case eAddressClassRuntime: |
| 1550 | opcode_addr &= ~(1ull); |
| 1551 | break; |
| 1552 | } |
| 1553 | break; |
| 1554 | |
| 1555 | default: |
| 1556 | break; |
| 1557 | } |
| 1558 | return opcode_addr; |
| 1559 | } |
| 1560 | |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1561 | lldb::user_id_t |
| 1562 | Target::AddStopHook (Target::StopHookSP &new_hook_sp) |
| 1563 | { |
| 1564 | lldb::user_id_t new_uid = ++m_stop_hook_next_id; |
| 1565 | new_hook_sp.reset (new StopHook(GetSP(), new_uid)); |
| 1566 | m_stop_hooks[new_uid] = new_hook_sp; |
| 1567 | return new_uid; |
| 1568 | } |
| 1569 | |
| 1570 | bool |
| 1571 | Target::RemoveStopHookByID (lldb::user_id_t user_id) |
| 1572 | { |
| 1573 | size_t num_removed; |
| 1574 | num_removed = m_stop_hooks.erase (user_id); |
| 1575 | if (num_removed == 0) |
| 1576 | return false; |
| 1577 | else |
| 1578 | return true; |
| 1579 | } |
| 1580 | |
| 1581 | void |
| 1582 | Target::RemoveAllStopHooks () |
| 1583 | { |
| 1584 | m_stop_hooks.clear(); |
| 1585 | } |
| 1586 | |
| 1587 | Target::StopHookSP |
| 1588 | Target::GetStopHookByID (lldb::user_id_t user_id) |
| 1589 | { |
| 1590 | StopHookSP found_hook; |
| 1591 | |
| 1592 | StopHookCollection::iterator specified_hook_iter; |
| 1593 | specified_hook_iter = m_stop_hooks.find (user_id); |
| 1594 | if (specified_hook_iter != m_stop_hooks.end()) |
| 1595 | found_hook = (*specified_hook_iter).second; |
| 1596 | return found_hook; |
| 1597 | } |
| 1598 | |
| 1599 | bool |
| 1600 | Target::SetStopHookActiveStateByID (lldb::user_id_t user_id, bool active_state) |
| 1601 | { |
| 1602 | StopHookCollection::iterator specified_hook_iter; |
| 1603 | specified_hook_iter = m_stop_hooks.find (user_id); |
| 1604 | if (specified_hook_iter == m_stop_hooks.end()) |
| 1605 | return false; |
| 1606 | |
| 1607 | (*specified_hook_iter).second->SetIsActive (active_state); |
| 1608 | return true; |
| 1609 | } |
| 1610 | |
| 1611 | void |
| 1612 | Target::SetAllStopHooksActiveState (bool active_state) |
| 1613 | { |
| 1614 | StopHookCollection::iterator pos, end = m_stop_hooks.end(); |
| 1615 | for (pos = m_stop_hooks.begin(); pos != end; pos++) |
| 1616 | { |
| 1617 | (*pos).second->SetIsActive (active_state); |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | void |
| 1622 | Target::RunStopHooks () |
| 1623 | { |
Jim Ingham | 6026ca3 | 2011-05-12 02:06:14 | [diff] [blame] | 1624 | if (m_suppress_stop_hooks) |
| 1625 | return; |
| 1626 | |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1627 | if (!m_process_sp) |
| 1628 | return; |
| 1629 | |
| 1630 | if (m_stop_hooks.empty()) |
| 1631 | return; |
| 1632 | |
| 1633 | StopHookCollection::iterator pos, end = m_stop_hooks.end(); |
| 1634 | |
| 1635 | // If there aren't any active stop hooks, don't bother either: |
| 1636 | bool any_active_hooks = false; |
| 1637 | for (pos = m_stop_hooks.begin(); pos != end; pos++) |
| 1638 | { |
| 1639 | if ((*pos).second->IsActive()) |
| 1640 | { |
| 1641 | any_active_hooks = true; |
| 1642 | break; |
| 1643 | } |
| 1644 | } |
| 1645 | if (!any_active_hooks) |
| 1646 | return; |
| 1647 | |
| 1648 | CommandReturnObject result; |
| 1649 | |
| 1650 | std::vector<ExecutionContext> exc_ctx_with_reasons; |
| 1651 | std::vector<SymbolContext> sym_ctx_with_reasons; |
| 1652 | |
| 1653 | ThreadList &cur_threadlist = m_process_sp->GetThreadList(); |
| 1654 | size_t num_threads = cur_threadlist.GetSize(); |
| 1655 | for (size_t i = 0; i < num_threads; i++) |
| 1656 | { |
| 1657 | lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex (i); |
| 1658 | if (cur_thread_sp->ThreadStoppedForAReason()) |
| 1659 | { |
| 1660 | lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0); |
| 1661 | exc_ctx_with_reasons.push_back(ExecutionContext(m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get())); |
| 1662 | sym_ctx_with_reasons.push_back(cur_frame_sp->GetSymbolContext(eSymbolContextEverything)); |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | // If no threads stopped for a reason, don't run the stop-hooks. |
| 1667 | size_t num_exe_ctx = exc_ctx_with_reasons.size(); |
| 1668 | if (num_exe_ctx == 0) |
| 1669 | return; |
| 1670 | |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 | [diff] [blame] | 1671 | result.SetImmediateOutputStream (m_debugger.GetAsyncOutputStream()); |
| 1672 | result.SetImmediateErrorStream (m_debugger.GetAsyncErrorStream()); |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1673 | |
| 1674 | bool keep_going = true; |
| 1675 | bool hooks_ran = false; |
Jim Ingham | 381e25b | 2011-03-22 01:47:27 | [diff] [blame] | 1676 | bool print_hook_header; |
| 1677 | bool print_thread_header; |
| 1678 | |
| 1679 | if (num_exe_ctx == 1) |
| 1680 | print_thread_header = false; |
| 1681 | else |
| 1682 | print_thread_header = true; |
| 1683 | |
| 1684 | if (m_stop_hooks.size() == 1) |
| 1685 | print_hook_header = false; |
| 1686 | else |
| 1687 | print_hook_header = true; |
| 1688 | |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1689 | for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) |
| 1690 | { |
| 1691 | // result.Clear(); |
| 1692 | StopHookSP cur_hook_sp = (*pos).second; |
| 1693 | if (!cur_hook_sp->IsActive()) |
| 1694 | continue; |
| 1695 | |
| 1696 | bool any_thread_matched = false; |
| 1697 | for (size_t i = 0; keep_going && i < num_exe_ctx; i++) |
| 1698 | { |
| 1699 | if ((cur_hook_sp->GetSpecifier () == NULL |
| 1700 | || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i])) |
| 1701 | && (cur_hook_sp->GetThreadSpecifier() == NULL |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 | [diff] [blame] | 1702 | || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].GetThreadPtr()))) |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1703 | { |
| 1704 | if (!hooks_ran) |
| 1705 | { |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1706 | hooks_ran = true; |
| 1707 | } |
Jim Ingham | 381e25b | 2011-03-22 01:47:27 | [diff] [blame] | 1708 | if (print_hook_header && !any_thread_matched) |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1709 | { |
| 1710 | result.AppendMessageWithFormat("\n- Hook %d\n", cur_hook_sp->GetID()); |
| 1711 | any_thread_matched = true; |
| 1712 | } |
| 1713 | |
Jim Ingham | 381e25b | 2011-03-22 01:47:27 | [diff] [blame] | 1714 | if (print_thread_header) |
Greg Clayton | c14ee32 | 2011-09-22 04:58:26 | [diff] [blame] | 1715 | result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].GetThreadPtr()->GetIndexID()); |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1716 | |
| 1717 | bool stop_on_continue = true; |
| 1718 | bool stop_on_error = true; |
| 1719 | bool echo_commands = false; |
| 1720 | bool print_results = true; |
| 1721 | GetDebugger().GetCommandInterpreter().HandleCommands (cur_hook_sp->GetCommands(), |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1722 | &exc_ctx_with_reasons[i], |
| 1723 | stop_on_continue, |
| 1724 | stop_on_error, |
| 1725 | echo_commands, |
| 1726 | print_results, |
| 1727 | result); |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1728 | |
| 1729 | // If the command started the target going again, we should bag out of |
| 1730 | // running the stop hooks. |
Greg Clayton | 32e0a75 | 2011-03-30 18:16:51 | [diff] [blame] | 1731 | if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) || |
| 1732 | (result.GetStatus() == eReturnStatusSuccessContinuingResult)) |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1733 | { |
| 1734 | result.AppendMessageWithFormat ("Aborting stop hooks, hook %d set the program running.", cur_hook_sp->GetID()); |
| 1735 | keep_going = false; |
| 1736 | } |
| 1737 | } |
| 1738 | } |
| 1739 | } |
Jason Molenda | 879cf77 | 2011-09-23 00:42:55 | [diff] [blame] | 1740 | |
Caroline Tice | 969ed3d1 | 2011-05-02 20:41:46 | [diff] [blame] | 1741 | result.GetImmediateOutputStream()->Flush(); |
| 1742 | result.GetImmediateErrorStream()->Flush(); |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1743 | } |
| 1744 | |
Greg Clayton | 7b24238 | 2011-07-08 00:48:09 | [diff] [blame] | 1745 | bool |
| 1746 | Target::LoadModuleWithSlide (Module *module, lldb::addr_t slide) |
| 1747 | { |
| 1748 | bool changed = false; |
| 1749 | if (module) |
| 1750 | { |
| 1751 | ObjectFile *object_file = module->GetObjectFile(); |
| 1752 | if (object_file) |
| 1753 | { |
| 1754 | SectionList *section_list = object_file->GetSectionList (); |
| 1755 | if (section_list) |
| 1756 | { |
| 1757 | // All sections listed in the dyld image info structure will all |
| 1758 | // either be fixed up already, or they will all be off by a single |
| 1759 | // slide amount that is determined by finding the first segment |
| 1760 | // that is at file offset zero which also has bytes (a file size |
| 1761 | // that is greater than zero) in the object file. |
| 1762 | |
| 1763 | // Determine the slide amount (if any) |
| 1764 | const size_t num_sections = section_list->GetSize(); |
| 1765 | size_t sect_idx = 0; |
| 1766 | for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) |
| 1767 | { |
| 1768 | // Iterate through the object file sections to find the |
| 1769 | // first section that starts of file offset zero and that |
| 1770 | // has bytes in the file... |
| 1771 | Section *section = section_list->GetSectionAtIndex (sect_idx).get(); |
| 1772 | if (section) |
| 1773 | { |
| 1774 | if (m_section_load_list.SetSectionLoadAddress (section, section->GetFileAddress() + slide)) |
| 1775 | changed = true; |
| 1776 | } |
| 1777 | } |
| 1778 | } |
| 1779 | } |
| 1780 | } |
| 1781 | return changed; |
| 1782 | } |
| 1783 | |
| 1784 | |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1785 | //-------------------------------------------------------------- |
| 1786 | // class Target::StopHook |
| 1787 | //-------------------------------------------------------------- |
| 1788 | |
| 1789 | |
| 1790 | Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) : |
| 1791 | UserID (uid), |
| 1792 | m_target_sp (target_sp), |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1793 | m_commands (), |
| 1794 | m_specifier_sp (), |
Stephen Wilson | 71c21d1 | 2011-04-11 19:41:40 | [diff] [blame] | 1795 | m_thread_spec_ap(NULL), |
| 1796 | m_active (true) |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1797 | { |
| 1798 | } |
| 1799 | |
| 1800 | Target::StopHook::StopHook (const StopHook &rhs) : |
| 1801 | UserID (rhs.GetID()), |
| 1802 | m_target_sp (rhs.m_target_sp), |
| 1803 | m_commands (rhs.m_commands), |
| 1804 | m_specifier_sp (rhs.m_specifier_sp), |
Stephen Wilson | 71c21d1 | 2011-04-11 19:41:40 | [diff] [blame] | 1805 | m_thread_spec_ap (NULL), |
| 1806 | m_active (rhs.m_active) |
Jim Ingham | 9575d84 | 2011-03-11 03:53:59 | [diff] [blame] | 1807 | { |
| 1808 | if (rhs.m_thread_spec_ap.get() != NULL) |
| 1809 | m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); |
| 1810 | } |
| 1811 | |
| 1812 | |
| 1813 | Target::StopHook::~StopHook () |
| 1814 | { |
| 1815 | } |
| 1816 | |
| 1817 | void |
| 1818 | Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier) |
| 1819 | { |
| 1820 | m_thread_spec_ap.reset (specifier); |
| 1821 | } |
| 1822 | |
| 1823 | |
| 1824 | void |
| 1825 | Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const |
| 1826 | { |
| 1827 | int indent_level = s->GetIndentLevel(); |
| 1828 | |
| 1829 | s->SetIndentLevel(indent_level + 2); |
| 1830 | |
| 1831 | s->Printf ("Hook: %d\n", GetID()); |
| 1832 | if (m_active) |
| 1833 | s->Indent ("State: enabled\n"); |
| 1834 | else |
| 1835 | s->Indent ("State: disabled\n"); |
| 1836 | |
| 1837 | if (m_specifier_sp) |
| 1838 | { |
| 1839 | s->Indent(); |
| 1840 | s->PutCString ("Specifier:\n"); |
| 1841 | s->SetIndentLevel (indent_level + 4); |
| 1842 | m_specifier_sp->GetDescription (s, level); |
| 1843 | s->SetIndentLevel (indent_level + 2); |
| 1844 | } |
| 1845 | |
| 1846 | if (m_thread_spec_ap.get() != NULL) |
| 1847 | { |
| 1848 | StreamString tmp; |
| 1849 | s->Indent("Thread:\n"); |
| 1850 | m_thread_spec_ap->GetDescription (&tmp, level); |
| 1851 | s->SetIndentLevel (indent_level + 4); |
| 1852 | s->Indent (tmp.GetData()); |
| 1853 | s->PutCString ("\n"); |
| 1854 | s->SetIndentLevel (indent_level + 2); |
| 1855 | } |
| 1856 | |
| 1857 | s->Indent ("Commands: \n"); |
| 1858 | s->SetIndentLevel (indent_level + 4); |
| 1859 | uint32_t num_commands = m_commands.GetSize(); |
| 1860 | for (uint32_t i = 0; i < num_commands; i++) |
| 1861 | { |
| 1862 | s->Indent(m_commands.GetStringAtIndex(i)); |
| 1863 | s->PutCString ("\n"); |
| 1864 | } |
| 1865 | s->SetIndentLevel (indent_level); |
| 1866 | } |
| 1867 | |
| 1868 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1869 | //-------------------------------------------------------------- |
| 1870 | // class Target::SettingsController |
| 1871 | //-------------------------------------------------------------- |
| 1872 | |
| 1873 | Target::SettingsController::SettingsController () : |
| 1874 | UserSettingsController ("target", Debugger::GetSettingsController()), |
| 1875 | m_default_architecture () |
| 1876 | { |
| 1877 | m_default_settings.reset (new TargetInstanceSettings (*this, false, |
| 1878 | InstanceSettings::GetDefaultName().AsCString())); |
| 1879 | } |
| 1880 | |
| 1881 | Target::SettingsController::~SettingsController () |
| 1882 | { |
| 1883 | } |
| 1884 | |
| 1885 | lldb::InstanceSettingsSP |
| 1886 | Target::SettingsController::CreateInstanceSettings (const char *instance_name) |
| 1887 | { |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 | [diff] [blame] | 1888 | TargetInstanceSettings *new_settings = new TargetInstanceSettings (*GetSettingsController(), |
| 1889 | false, |
| 1890 | instance_name); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1891 | lldb::InstanceSettingsSP new_settings_sp (new_settings); |
| 1892 | return new_settings_sp; |
| 1893 | } |
| 1894 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1895 | |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1896 | #define TSC_DEFAULT_ARCH "default-arch" |
| 1897 | #define TSC_EXPR_PREFIX "expr-prefix" |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1898 | #define TSC_PREFER_DYNAMIC "prefer-dynamic-value" |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 1899 | #define TSC_SKIP_PROLOGUE "skip-prologue" |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 1900 | #define TSC_SOURCE_MAP "source-map" |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 1901 | #define TSC_MAX_CHILDREN "max-children-count" |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 1902 | #define TSC_MAX_STRLENSUMMARY "max-string-summary-length" |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1903 | |
| 1904 | |
| 1905 | static const ConstString & |
| 1906 | GetSettingNameForDefaultArch () |
| 1907 | { |
| 1908 | static ConstString g_const_string (TSC_DEFAULT_ARCH); |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1909 | return g_const_string; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1910 | } |
| 1911 | |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1912 | static const ConstString & |
| 1913 | GetSettingNameForExpressionPrefix () |
| 1914 | { |
| 1915 | static ConstString g_const_string (TSC_EXPR_PREFIX); |
| 1916 | return g_const_string; |
| 1917 | } |
| 1918 | |
| 1919 | static const ConstString & |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 1920 | GetSettingNameForPreferDynamicValue () |
| 1921 | { |
| 1922 | static ConstString g_const_string (TSC_PREFER_DYNAMIC); |
| 1923 | return g_const_string; |
| 1924 | } |
| 1925 | |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 1926 | static const ConstString & |
| 1927 | GetSettingNameForSourcePathMap () |
| 1928 | { |
| 1929 | static ConstString g_const_string (TSC_SOURCE_MAP); |
| 1930 | return g_const_string; |
| 1931 | } |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1932 | |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 1933 | static const ConstString & |
| 1934 | GetSettingNameForSkipPrologue () |
| 1935 | { |
| 1936 | static ConstString g_const_string (TSC_SKIP_PROLOGUE); |
| 1937 | return g_const_string; |
| 1938 | } |
| 1939 | |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 1940 | static const ConstString & |
| 1941 | GetSettingNameForMaxChildren () |
| 1942 | { |
| 1943 | static ConstString g_const_string (TSC_MAX_CHILDREN); |
| 1944 | return g_const_string; |
| 1945 | } |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 1946 | |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 1947 | static const ConstString & |
| 1948 | GetSettingNameForMaxStringSummaryLength () |
| 1949 | { |
| 1950 | static ConstString g_const_string (TSC_MAX_STRLENSUMMARY); |
| 1951 | return g_const_string; |
| 1952 | } |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 1953 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1954 | bool |
| 1955 | Target::SettingsController::SetGlobalVariable (const ConstString &var_name, |
| 1956 | const char *index_value, |
| 1957 | const char *value, |
| 1958 | const SettingEntry &entry, |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 | [diff] [blame] | 1959 | const VarSetOperationType op, |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1960 | Error&err) |
| 1961 | { |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1962 | if (var_name == GetSettingNameForDefaultArch()) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1963 | { |
Greg Clayton | eb0103f | 2011-04-07 22:46:35 | [diff] [blame] | 1964 | m_default_architecture.SetTriple (value, NULL); |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 | [diff] [blame] | 1965 | if (!m_default_architecture.IsValid()) |
| 1966 | err.SetErrorStringWithFormat ("'%s' is not a valid architecture or triple.", value); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1967 | } |
| 1968 | return true; |
| 1969 | } |
| 1970 | |
| 1971 | |
| 1972 | bool |
| 1973 | Target::SettingsController::GetGlobalVariable (const ConstString &var_name, |
| 1974 | StringList &value, |
| 1975 | Error &err) |
| 1976 | { |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 1977 | if (var_name == GetSettingNameForDefaultArch()) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1978 | { |
Greg Clayton | 307de25 | 2010-10-27 02:06:37 | [diff] [blame] | 1979 | // If the arch is invalid (the default), don't show a string for it |
| 1980 | if (m_default_architecture.IsValid()) |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 | [diff] [blame] | 1981 | value.AppendString (m_default_architecture.GetArchitectureName()); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 1982 | return true; |
| 1983 | } |
| 1984 | else |
| 1985 | err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 1986 | |
| 1987 | return false; |
| 1988 | } |
| 1989 | |
| 1990 | //-------------------------------------------------------------- |
| 1991 | // class TargetInstanceSettings |
| 1992 | //-------------------------------------------------------------- |
| 1993 | |
Greg Clayton | 85851dd | 2010-12-04 00:10:17 | [diff] [blame] | 1994 | TargetInstanceSettings::TargetInstanceSettings |
| 1995 | ( |
| 1996 | UserSettingsController &owner, |
| 1997 | bool live_instance, |
| 1998 | const char *name |
| 1999 | ) : |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 2000 | InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2001 | m_expr_prefix_file (), |
| 2002 | m_expr_prefix_contents_sp (), |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 2003 | m_prefer_dynamic_value (2), |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2004 | m_skip_prologue (true, true), |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 2005 | m_source_map (NULL, NULL), |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2006 | m_max_children_display(256), |
| 2007 | m_max_strlen_length(1024) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2008 | { |
| 2009 | // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called |
| 2010 | // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers. |
| 2011 | // For this reason it has to be called here, rather than in the initializer or in the parent constructor. |
| 2012 | // This is true for CreateInstanceName() too. |
| 2013 | |
| 2014 | if (GetInstanceName () == InstanceSettings::InvalidName()) |
| 2015 | { |
| 2016 | ChangeInstanceName (std::string (CreateInstanceName().AsCString())); |
| 2017 | m_owner.RegisterInstanceSettings (this); |
| 2018 | } |
| 2019 | |
| 2020 | if (live_instance) |
| 2021 | { |
| 2022 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 2023 | CopyInstanceSettings (pending_settings,false); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2024 | } |
| 2025 | } |
| 2026 | |
| 2027 | TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) : |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2028 | InstanceSettings (*Target::GetSettingsController(), CreateInstanceName().AsCString()), |
| 2029 | m_expr_prefix_file (rhs.m_expr_prefix_file), |
| 2030 | m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp), |
| 2031 | m_prefer_dynamic_value (rhs.m_prefer_dynamic_value), |
| 2032 | m_skip_prologue (rhs.m_skip_prologue), |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 2033 | m_source_map (rhs.m_source_map), |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2034 | m_max_children_display(rhs.m_max_children_display), |
| 2035 | m_max_strlen_length(rhs.m_max_strlen_length) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2036 | { |
| 2037 | if (m_instance_name != InstanceSettings::GetDefaultName()) |
| 2038 | { |
| 2039 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 2040 | CopyInstanceSettings (pending_settings,false); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | TargetInstanceSettings::~TargetInstanceSettings () |
| 2045 | { |
| 2046 | } |
| 2047 | |
| 2048 | TargetInstanceSettings& |
| 2049 | TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs) |
| 2050 | { |
| 2051 | if (this != &rhs) |
| 2052 | { |
| 2053 | } |
| 2054 | |
| 2055 | return *this; |
| 2056 | } |
| 2057 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2058 | void |
| 2059 | TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, |
| 2060 | const char *index_value, |
| 2061 | const char *value, |
| 2062 | const ConstString &instance_name, |
| 2063 | const SettingEntry &entry, |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 | [diff] [blame] | 2064 | VarSetOperationType op, |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2065 | Error &err, |
| 2066 | bool pending) |
| 2067 | { |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 2068 | if (var_name == GetSettingNameForExpressionPrefix ()) |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2069 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2070 | err = UserSettingsController::UpdateFileSpecOptionValue (value, op, m_expr_prefix_file); |
| 2071 | if (err.Success()) |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2072 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2073 | switch (op) |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2074 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2075 | default: |
| 2076 | break; |
| 2077 | case eVarSetOperationAssign: |
| 2078 | case eVarSetOperationAppend: |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2079 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2080 | if (!m_expr_prefix_file.GetCurrentValue().Exists()) |
| 2081 | { |
| 2082 | err.SetErrorToGenericError (); |
| 2083 | err.SetErrorStringWithFormat ("%s does not exist.\n", value); |
| 2084 | return; |
| 2085 | } |
| 2086 | |
| 2087 | m_expr_prefix_contents_sp = m_expr_prefix_file.GetCurrentValue().ReadFileContents(); |
| 2088 | |
| 2089 | if (!m_expr_prefix_contents_sp && m_expr_prefix_contents_sp->GetByteSize() == 0) |
| 2090 | { |
| 2091 | err.SetErrorStringWithFormat ("Couldn't read data from '%s'\n", value); |
| 2092 | m_expr_prefix_contents_sp.reset(); |
| 2093 | } |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2094 | } |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2095 | break; |
| 2096 | case eVarSetOperationClear: |
| 2097 | m_expr_prefix_contents_sp.reset(); |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2098 | } |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2099 | } |
| 2100 | } |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 2101 | else if (var_name == GetSettingNameForPreferDynamicValue()) |
| 2102 | { |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 2103 | int new_value; |
| 2104 | UserSettingsController::UpdateEnumVariable (g_dynamic_value_types, &new_value, value, err); |
| 2105 | if (err.Success()) |
| 2106 | m_prefer_dynamic_value = new_value; |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 2107 | } |
| 2108 | else if (var_name == GetSettingNameForSkipPrologue()) |
| 2109 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2110 | err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_skip_prologue); |
| 2111 | } |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 2112 | else if (var_name == GetSettingNameForMaxChildren()) |
| 2113 | { |
| 2114 | bool ok; |
| 2115 | uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok); |
| 2116 | if (ok) |
| 2117 | m_max_children_display = new_value; |
| 2118 | } |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2119 | else if (var_name == GetSettingNameForMaxStringSummaryLength()) |
| 2120 | { |
| 2121 | bool ok; |
| 2122 | uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok); |
| 2123 | if (ok) |
| 2124 | m_max_strlen_length = new_value; |
| 2125 | } |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2126 | else if (var_name == GetSettingNameForSourcePathMap ()) |
| 2127 | { |
| 2128 | switch (op) |
| 2129 | { |
| 2130 | case eVarSetOperationReplace: |
| 2131 | case eVarSetOperationInsertBefore: |
| 2132 | case eVarSetOperationInsertAfter: |
| 2133 | case eVarSetOperationRemove: |
| 2134 | default: |
| 2135 | break; |
| 2136 | case eVarSetOperationAssign: |
| 2137 | m_source_map.Clear(true); |
| 2138 | // Fall through to append.... |
| 2139 | case eVarSetOperationAppend: |
| 2140 | { |
| 2141 | Args args(value); |
| 2142 | const uint32_t argc = args.GetArgumentCount(); |
| 2143 | if (argc & 1 || argc == 0) |
| 2144 | { |
| 2145 | err.SetErrorStringWithFormat ("an even number of paths must be supplied to to the source-map setting: %u arguments given", argc); |
| 2146 | } |
| 2147 | else |
| 2148 | { |
| 2149 | char resolved_new_path[PATH_MAX]; |
| 2150 | FileSpec file_spec; |
| 2151 | const char *old_path; |
| 2152 | for (uint32_t idx = 0; (old_path = args.GetArgumentAtIndex(idx)) != NULL; idx += 2) |
| 2153 | { |
| 2154 | const char *new_path = args.GetArgumentAtIndex(idx+1); |
| 2155 | assert (new_path); // We have an even number of paths, this shouldn't happen! |
| 2156 | |
| 2157 | file_spec.SetFile(new_path, true); |
| 2158 | if (file_spec.Exists()) |
| 2159 | { |
| 2160 | if (file_spec.GetPath (resolved_new_path, sizeof(resolved_new_path)) >= sizeof(resolved_new_path)) |
| 2161 | { |
| 2162 | err.SetErrorStringWithFormat("new path '%s' is too long", new_path); |
| 2163 | return; |
| 2164 | } |
| 2165 | } |
| 2166 | else |
| 2167 | { |
| 2168 | err.SetErrorStringWithFormat("new path '%s' doesn't exist", new_path); |
| 2169 | return; |
| 2170 | } |
| 2171 | m_source_map.Append(ConstString (old_path), ConstString (resolved_new_path), true); |
| 2172 | } |
| 2173 | } |
| 2174 | } |
| 2175 | break; |
| 2176 | |
| 2177 | case eVarSetOperationClear: |
| 2178 | m_source_map.Clear(true); |
| 2179 | break; |
| 2180 | } |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 2181 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | void |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 2185 | TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2186 | { |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2187 | TargetInstanceSettings *new_settings_ptr = static_cast <TargetInstanceSettings *> (new_settings.get()); |
| 2188 | |
| 2189 | if (!new_settings_ptr) |
| 2190 | return; |
| 2191 | |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2192 | m_expr_prefix_file = new_settings_ptr->m_expr_prefix_file; |
| 2193 | m_expr_prefix_contents_sp = new_settings_ptr->m_expr_prefix_contents_sp; |
| 2194 | m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value; |
| 2195 | m_skip_prologue = new_settings_ptr->m_skip_prologue; |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 2196 | m_max_children_display = new_settings_ptr->m_max_children_display; |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2197 | m_max_strlen_length = new_settings_ptr->m_max_strlen_length; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2198 | } |
| 2199 | |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 | [diff] [blame] | 2200 | bool |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2201 | TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, |
| 2202 | const ConstString &var_name, |
| 2203 | StringList &value, |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 | [diff] [blame] | 2204 | Error *err) |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2205 | { |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 2206 | if (var_name == GetSettingNameForExpressionPrefix ()) |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2207 | { |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2208 | char path[PATH_MAX]; |
| 2209 | const size_t path_len = m_expr_prefix_file.GetCurrentValue().GetPath (path, sizeof(path)); |
| 2210 | if (path_len > 0) |
| 2211 | value.AppendString (path, path_len); |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2212 | } |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 2213 | else if (var_name == GetSettingNameForPreferDynamicValue()) |
| 2214 | { |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 2215 | value.AppendString (g_dynamic_value_types[m_prefer_dynamic_value].string_value); |
Jim Ingham | 78a685a | 2011-04-16 00:01:13 | [diff] [blame] | 2216 | } |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 | [diff] [blame] | 2217 | else if (var_name == GetSettingNameForSkipPrologue()) |
| 2218 | { |
| 2219 | if (m_skip_prologue) |
| 2220 | value.AppendString ("true"); |
| 2221 | else |
| 2222 | value.AppendString ("false"); |
| 2223 | } |
Greg Clayton | 7e14f91 | 2011-04-23 02:04:55 | [diff] [blame] | 2224 | else if (var_name == GetSettingNameForSourcePathMap ()) |
| 2225 | { |
| 2226 | } |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 | [diff] [blame] | 2227 | else if (var_name == GetSettingNameForMaxChildren()) |
| 2228 | { |
| 2229 | StreamString count_str; |
| 2230 | count_str.Printf ("%d", m_max_children_display); |
| 2231 | value.AppendString (count_str.GetData()); |
| 2232 | } |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2233 | else if (var_name == GetSettingNameForMaxStringSummaryLength()) |
| 2234 | { |
| 2235 | StreamString count_str; |
| 2236 | count_str.Printf ("%d", m_max_strlen_length); |
| 2237 | value.AppendString (count_str.GetData()); |
| 2238 | } |
Sean Callanan | 322f529 | 2010-10-29 00:29:03 | [diff] [blame] | 2239 | else |
| 2240 | { |
| 2241 | if (err) |
| 2242 | err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 2243 | return false; |
| 2244 | } |
| 2245 | |
| 2246 | return true; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2247 | } |
| 2248 | |
| 2249 | const ConstString |
| 2250 | TargetInstanceSettings::CreateInstanceName () |
| 2251 | { |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2252 | StreamString sstr; |
Caroline Tice | 1559a46 | 2010-09-27 00:30:10 | [diff] [blame] | 2253 | static int instance_count = 1; |
| 2254 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2255 | sstr.Printf ("target_%d", instance_count); |
| 2256 | ++instance_count; |
| 2257 | |
| 2258 | const ConstString ret_val (sstr.GetData()); |
| 2259 | return ret_val; |
| 2260 | } |
| 2261 | |
| 2262 | //-------------------------------------------------- |
| 2263 | // Target::SettingsController Variable Tables |
| 2264 | //-------------------------------------------------- |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 2265 | OptionEnumValueElement |
| 2266 | TargetInstanceSettings::g_dynamic_value_types[] = |
| 2267 | { |
Greg Clayton | 5d2fbfe | 2011-05-30 00:39:48 | [diff] [blame] | 2268 | { eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"}, |
| 2269 | { eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."}, |
| 2270 | { eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."}, |
Jim Ingham | 2837b76 | 2011-05-04 03:43:18 | [diff] [blame] | 2271 | { 0, NULL, NULL } |
| 2272 | }; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2273 | |
| 2274 | SettingEntry |
| 2275 | Target::SettingsController::global_settings_table[] = |
| 2276 | { |
Greg Clayton | bfe5f3b | 2011-02-18 01:44:25 | [diff] [blame] | 2277 | // var-name var-type default enum init'd hidden help-text |
| 2278 | // ================= ================== =========== ==== ====== ====== ========================================================================= |
| 2279 | { TSC_DEFAULT_ARCH , eSetVarTypeString , NULL , NULL, false, false, "Default architecture to choose, when there's a choice." }, |
| 2280 | { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } |
| 2281 | }; |
| 2282 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2283 | SettingEntry |
| 2284 | Target::SettingsController::instance_settings_table[] = |
| 2285 | { |
Enrico Granata | 9128ee2f | 2011-09-06 19:20:51 | [diff] [blame] | 2286 | // var-name var-type default enum init'd hidden help-text |
| 2287 | // ================= ================== =============== ======================= ====== ====== ========================================================================= |
| 2288 | { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." }, |
| 2289 | { TSC_PREFER_DYNAMIC , eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." }, |
| 2290 | { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." }, |
| 2291 | { TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." }, |
| 2292 | { TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." }, |
| 2293 | { TSC_MAX_STRLENSUMMARY , eSetVarTypeInt , "1024" , NULL, true, false, "Maximum number of characters to show when using %s in summary strings." }, |
| 2294 | { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 | [diff] [blame] | 2295 | }; |