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