blob: 080a54e4d146b872c53343eeb0d9d5c14572e9fc [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:241//===-- 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 Clayton8b2fe6d2010-12-14 02:59:5920#include "lldb/Core/Debugger.h"
Chris Lattner30fdc8d2010-06-08 16:52:2421#include "lldb/Core/Event.h"
22#include "lldb/Core/Log.h"
Caroline Tice969ed3d12011-05-02 20:41:4623#include "lldb/Core/StreamAsynchronousIO.h"
Chris Lattner30fdc8d2010-06-08 16:52:2424#include "lldb/Core/StreamString.h"
Greg Clayton8b2fe6d2010-12-14 02:59:5925#include "lldb/Core/Timer.h"
26#include "lldb/Core/ValueObject.h"
Greg Claytoneb0103f2011-04-07 22:46:3527#include "lldb/Expression/ClangUserExpression.h"
Chris Lattner30fdc8d2010-06-08 16:52:2428#include "lldb/Host/Host.h"
Jim Ingham9575d842011-03-11 03:53:5929#include "lldb/Interpreter/CommandInterpreter.h"
30#include "lldb/Interpreter/CommandReturnObject.h"
Chris Lattner30fdc8d2010-06-08 16:52:2431#include "lldb/lldb-private-log.h"
32#include "lldb/Symbol/ObjectFile.h"
33#include "lldb/Target/Process.h"
Greg Clayton8b2fe6d2010-12-14 02:59:5934#include "lldb/Target/StackFrame.h"
Jim Ingham9575d842011-03-11 03:53:5935#include "lldb/Target/Thread.h"
36#include "lldb/Target/ThreadSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:2437
38using namespace lldb;
39using namespace lldb_private;
40
41//----------------------------------------------------------------------
42// Target constructor
43//----------------------------------------------------------------------
Greg Clayton32e0a752011-03-30 18:16:5144Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp) :
45 Broadcaster ("lldb.target"),
46 ExecutionContextScope (),
Greg Claytondbe54502010-11-19 03:46:0147 TargetInstanceSettings (*GetSettingsController()),
Greg Clayton66111032010-06-23 01:19:2948 m_debugger (debugger),
Greg Clayton32e0a752011-03-30 18:16:5149 m_platform_sp (platform_sp),
Greg Claytonaf67cec2010-12-20 20:49:2350 m_mutex (Mutex::eMutexTypeRecursive),
Greg Clayton32e0a752011-03-30 18:16:5151 m_arch (target_arch),
52 m_images (),
Greg Claytonf5e56de2010-09-14 23:36:4053 m_section_load_list (),
Chris Lattner30fdc8d2010-06-08 16:52:2454 m_breakpoint_list (false),
55 m_internal_breakpoint_list (true),
Greg Clayton32e0a752011-03-30 18:16:5156 m_process_sp (),
57 m_search_filter_sp (),
Chris Lattner30fdc8d2010-06-08 16:52:2458 m_image_search_paths (ImageSearchPathsChanged, this),
Greg Clayton8b2fe6d2010-12-14 02:59:5959 m_scratch_ast_context_ap (NULL),
Jim Ingham9575d842011-03-11 03:53:5960 m_persistent_variables (),
Greg Clayton32e0a752011-03-30 18:16:5161 m_stop_hooks (),
62 m_stop_hook_next_id (0)
Chris Lattner30fdc8d2010-06-08 16:52:2463{
Greg Claytoncfd1ace2010-10-31 03:01:0664 SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed");
65 SetEventName (eBroadcastBitModulesLoaded, "modules-loaded");
66 SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded");
67
Greg Clayton2d4edfb2010-11-06 01:53:3068 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Chris Lattner30fdc8d2010-06-08 16:52:2469 if (log)
70 log->Printf ("%p Target::Target()", this);
71}
72
73//----------------------------------------------------------------------
74// Destructor
75//----------------------------------------------------------------------
76Target::~Target()
77{
Greg Clayton2d4edfb2010-11-06 01:53:3078 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Chris Lattner30fdc8d2010-06-08 16:52:2479 if (log)
80 log->Printf ("%p Target::~Target()", this);
81 DeleteCurrentProcess ();
82}
83
84void
Caroline Ticeceb6b132010-10-26 03:11:1385Target::Dump (Stream *s, lldb::DescriptionLevel description_level)
Chris Lattner30fdc8d2010-06-08 16:52:2486{
Greg Clayton89411422010-10-08 00:21:0587// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
Caroline Ticeceb6b132010-10-26 03:11:1388 if (description_level != lldb::eDescriptionLevelBrief)
89 {
90 s->Indent();
91 s->PutCString("Target\n");
92 s->IndentMore();
Greg Clayton93aa84e2010-10-29 04:59:3593 m_images.Dump(s);
94 m_breakpoint_list.Dump(s);
95 m_internal_breakpoint_list.Dump(s);
96 s->IndentLess();
Caroline Ticeceb6b132010-10-26 03:11:1397 }
98 else
99 {
Greg Clayton48381312010-10-30 04:51:46100 s->PutCString (GetExecutableModule()->GetFileSpec().GetFilename().GetCString());
Caroline Ticeceb6b132010-10-26 03:11:13101 }
Chris Lattner30fdc8d2010-06-08 16:52:24102}
103
104void
105Target::DeleteCurrentProcess ()
106{
107 if (m_process_sp.get())
108 {
Greg Clayton17f69202010-09-14 23:52:43109 m_section_load_list.Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24110 if (m_process_sp->IsAlive())
111 m_process_sp->Destroy();
Jim Inghamd0a3e12b2011-02-16 17:54:55112
113 m_process_sp->Finalize();
Chris Lattner30fdc8d2010-06-08 16:52:24114
115 // Do any cleanup of the target we need to do between process instances.
116 // NB It is better to do this before destroying the process in case the
117 // clean up needs some help from the process.
118 m_breakpoint_list.ClearAllBreakpointSites();
119 m_internal_breakpoint_list.ClearAllBreakpointSites();
120 m_process_sp.reset();
121 }
122}
123
124const lldb::ProcessSP &
125Target::CreateProcess (Listener &listener, const char *plugin_name)
126{
127 DeleteCurrentProcess ();
128 m_process_sp.reset(Process::FindPlugin(*this, plugin_name, listener));
129 return m_process_sp;
130}
131
132const lldb::ProcessSP &
133Target::GetProcessSP () const
134{
135 return m_process_sp;
136}
137
138lldb::TargetSP
139Target::GetSP()
140{
Greg Clayton66111032010-06-23 01:19:29141 return m_debugger.GetTargetList().GetTargetSP(this);
Chris Lattner30fdc8d2010-06-08 16:52:24142}
143
144BreakpointList &
145Target::GetBreakpointList(bool internal)
146{
147 if (internal)
148 return m_internal_breakpoint_list;
149 else
150 return m_breakpoint_list;
151}
152
153const BreakpointList &
154Target::GetBreakpointList(bool internal) const
155{
156 if (internal)
157 return m_internal_breakpoint_list;
158 else
159 return m_breakpoint_list;
160}
161
162BreakpointSP
163Target::GetBreakpointByID (break_id_t break_id)
164{
165 BreakpointSP bp_sp;
166
167 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
168 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
169 else
170 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
171
172 return bp_sp;
173}
174
175BreakpointSP
176Target::CreateBreakpoint (const FileSpec *containingModule, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal)
177{
178 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
179 BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines));
180 return CreateBreakpoint (filter_sp, resolver_sp, internal);
181}
182
183
184BreakpointSP
Greg Clayton1b72fcb2010-08-24 00:45:41185Target::CreateBreakpoint (lldb::addr_t addr, bool internal)
Chris Lattner30fdc8d2010-06-08 16:52:24186{
Chris Lattner30fdc8d2010-06-08 16:52:24187 Address so_addr;
188 // Attempt to resolve our load address if possible, though it is ok if
189 // it doesn't resolve to section/offset.
190
Greg Clayton1b72fcb2010-08-24 00:45:41191 // Try and resolve as a load address if possible
Greg Claytonf5e56de2010-09-14 23:36:40192 m_section_load_list.ResolveLoadAddress(addr, so_addr);
Greg Clayton1b72fcb2010-08-24 00:45:41193 if (!so_addr.IsValid())
194 {
195 // The address didn't resolve, so just set this as an absolute address
196 so_addr.SetOffset (addr);
197 }
198 BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal));
Chris Lattner30fdc8d2010-06-08 16:52:24199 return bp_sp;
200}
201
202BreakpointSP
203Target::CreateBreakpoint (Address &addr, bool internal)
204{
205 TargetSP target_sp = this->GetSP();
206 SearchFilterSP filter_sp(new SearchFilter (target_sp));
207 BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
208 return CreateBreakpoint (filter_sp, resolver_sp, internal);
209}
210
211BreakpointSP
Greg Clayton0c5cd902010-06-28 21:30:43212Target::CreateBreakpoint (FileSpec *containingModule, const char *func_name, uint32_t func_name_type_mask, bool internal)
Chris Lattner30fdc8d2010-06-08 16:52:24213{
Greg Clayton0c5cd902010-06-28 21:30:43214 BreakpointSP bp_sp;
215 if (func_name)
216 {
217 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
218 BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL, func_name, func_name_type_mask, Breakpoint::Exact));
219 bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal);
220 }
221 return bp_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24222}
223
224
225SearchFilterSP
226Target::GetSearchFilterForModule (const FileSpec *containingModule)
227{
228 SearchFilterSP filter_sp;
229 lldb::TargetSP target_sp = this->GetSP();
230 if (containingModule != NULL)
231 {
232 // TODO: We should look into sharing module based search filters
233 // across many breakpoints like we do for the simple target based one
234 filter_sp.reset (new SearchFilterByModule (target_sp, *containingModule));
235 }
236 else
237 {
238 if (m_search_filter_sp.get() == NULL)
239 m_search_filter_sp.reset (new SearchFilter (target_sp));
240 filter_sp = m_search_filter_sp;
241 }
242 return filter_sp;
243}
244
245BreakpointSP
246Target::CreateBreakpoint (FileSpec *containingModule, RegularExpression &func_regex, bool internal)
247{
248 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
249 BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL, func_regex));
250
251 return CreateBreakpoint (filter_sp, resolver_sp, internal);
252}
253
254BreakpointSP
255Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal)
256{
257 BreakpointSP bp_sp;
258 if (filter_sp && resolver_sp)
259 {
260 bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp));
261 resolver_sp->SetBreakpoint (bp_sp.get());
262
263 if (internal)
Greg Clayton9fed0d82010-07-23 23:33:17264 m_internal_breakpoint_list.Add (bp_sp, false);
Chris Lattner30fdc8d2010-06-08 16:52:24265 else
Greg Clayton9fed0d82010-07-23 23:33:17266 m_breakpoint_list.Add (bp_sp, true);
Chris Lattner30fdc8d2010-06-08 16:52:24267
Greg Clayton2d4edfb2010-11-06 01:53:30268 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24269 if (log)
270 {
271 StreamString s;
272 bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
273 log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData());
274 }
275
Chris Lattner30fdc8d2010-06-08 16:52:24276 bp_sp->ResolveBreakpoint();
277 }
Jim Ingham36f3b362010-10-14 23:45:03278
279 if (!internal && bp_sp)
280 {
281 m_last_created_breakpoint = bp_sp;
282 }
283
Chris Lattner30fdc8d2010-06-08 16:52:24284 return bp_sp;
285}
286
287void
288Target::RemoveAllBreakpoints (bool internal_also)
289{
Greg Clayton2d4edfb2010-11-06 01:53:30290 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24291 if (log)
292 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
293
Greg Clayton9fed0d82010-07-23 23:33:17294 m_breakpoint_list.RemoveAll (true);
Chris Lattner30fdc8d2010-06-08 16:52:24295 if (internal_also)
Greg Clayton9fed0d82010-07-23 23:33:17296 m_internal_breakpoint_list.RemoveAll (false);
Jim Ingham36f3b362010-10-14 23:45:03297
298 m_last_created_breakpoint.reset();
Chris Lattner30fdc8d2010-06-08 16:52:24299}
300
301void
302Target::DisableAllBreakpoints (bool internal_also)
303{
Greg Clayton2d4edfb2010-11-06 01:53:30304 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24305 if (log)
306 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
307
308 m_breakpoint_list.SetEnabledAll (false);
309 if (internal_also)
310 m_internal_breakpoint_list.SetEnabledAll (false);
311}
312
313void
314Target::EnableAllBreakpoints (bool internal_also)
315{
Greg Clayton2d4edfb2010-11-06 01:53:30316 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24317 if (log)
318 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
319
320 m_breakpoint_list.SetEnabledAll (true);
321 if (internal_also)
322 m_internal_breakpoint_list.SetEnabledAll (true);
323}
324
325bool
326Target::RemoveBreakpointByID (break_id_t break_id)
327{
Greg Clayton2d4edfb2010-11-06 01:53:30328 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24329 if (log)
330 log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
331
332 if (DisableBreakpointByID (break_id))
333 {
334 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
Greg Clayton9fed0d82010-07-23 23:33:17335 m_internal_breakpoint_list.Remove(break_id, false);
Chris Lattner30fdc8d2010-06-08 16:52:24336 else
Jim Ingham36f3b362010-10-14 23:45:03337 {
Greg Claytonaa1c5872011-01-24 23:35:47338 if (m_last_created_breakpoint)
339 {
340 if (m_last_created_breakpoint->GetID() == break_id)
341 m_last_created_breakpoint.reset();
342 }
Greg Clayton9fed0d82010-07-23 23:33:17343 m_breakpoint_list.Remove(break_id, true);
Jim Ingham36f3b362010-10-14 23:45:03344 }
Chris Lattner30fdc8d2010-06-08 16:52:24345 return true;
346 }
347 return false;
348}
349
350bool
351Target::DisableBreakpointByID (break_id_t break_id)
352{
Greg Clayton2d4edfb2010-11-06 01:53:30353 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24354 if (log)
355 log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
356
357 BreakpointSP bp_sp;
358
359 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
360 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
361 else
362 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
363 if (bp_sp)
364 {
365 bp_sp->SetEnabled (false);
366 return true;
367 }
368 return false;
369}
370
371bool
372Target::EnableBreakpointByID (break_id_t break_id)
373{
Greg Clayton2d4edfb2010-11-06 01:53:30374 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner30fdc8d2010-06-08 16:52:24375 if (log)
376 log->Printf ("Target::%s (break_id = %i, internal = %s)\n",
377 __FUNCTION__,
378 break_id,
379 LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
380
381 BreakpointSP bp_sp;
382
383 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
384 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
385 else
386 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
387
388 if (bp_sp)
389 {
390 bp_sp->SetEnabled (true);
391 return true;
392 }
393 return false;
394}
395
396ModuleSP
397Target::GetExecutableModule ()
398{
399 ModuleSP executable_sp;
400 if (m_images.GetSize() > 0)
401 executable_sp = m_images.GetModuleAtIndex(0);
402 return executable_sp;
403}
404
405void
406Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
407{
408 m_images.Clear();
409 m_scratch_ast_context_ap.reset();
410
411 if (executable_sp.get())
412 {
413 Timer scoped_timer (__PRETTY_FUNCTION__,
414 "Target::SetExecutableModule (executable = '%s/%s')",
415 executable_sp->GetFileSpec().GetDirectory().AsCString(),
416 executable_sp->GetFileSpec().GetFilename().AsCString());
417
418 m_images.Append(executable_sp); // The first image is our exectuable file
419
Jim Ingham5aee1622010-08-09 23:31:02420 // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module.
Greg Clayton32e0a752011-03-30 18:16:51421 if (!m_arch.IsValid())
422 m_arch = executable_sp->GetArchitecture();
Jim Ingham5aee1622010-08-09 23:31:02423
Chris Lattner30fdc8d2010-06-08 16:52:24424 FileSpecList dependent_files;
Greg Claytone996fd32011-03-08 22:40:15425 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
Chris Lattner30fdc8d2010-06-08 16:52:24426
427 if (executable_objfile)
428 {
429 executable_objfile->GetDependentModules(dependent_files);
430 for (uint32_t i=0; i<dependent_files.GetSize(); i++)
431 {
Greg Claytonded470d2011-03-19 01:12:21432 FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
433 FileSpec platform_dependent_file_spec;
434 if (m_platform_sp)
Greg Claytond314e812011-03-23 00:09:55435 m_platform_sp->GetFile (dependent_file_spec, NULL, platform_dependent_file_spec);
Greg Claytonded470d2011-03-19 01:12:21436 else
437 platform_dependent_file_spec = dependent_file_spec;
438
439 ModuleSP image_module_sp(GetSharedModule (platform_dependent_file_spec,
Greg Clayton32e0a752011-03-30 18:16:51440 m_arch));
Chris Lattner30fdc8d2010-06-08 16:52:24441 if (image_module_sp.get())
442 {
443 //image_module_sp->Dump(&s);// REMOVE THIS, DEBUG ONLY
444 ObjectFile *objfile = image_module_sp->GetObjectFile();
445 if (objfile)
446 objfile->GetDependentModules(dependent_files);
447 }
448 }
449 }
450
451 // Now see if we know the target triple, and if so, create our scratch AST context:
Greg Clayton32e0a752011-03-30 18:16:51452 if (m_arch.IsValid())
Chris Lattner30fdc8d2010-06-08 16:52:24453 {
Greg Clayton32e0a752011-03-30 18:16:51454 m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str()));
Chris Lattner30fdc8d2010-06-08 16:52:24455 }
456 }
Caroline Tice1559a462010-09-27 00:30:10457
458 UpdateInstanceName();
Chris Lattner30fdc8d2010-06-08 16:52:24459}
460
461
Jim Ingham5aee1622010-08-09 23:31:02462bool
463Target::SetArchitecture (const ArchSpec &arch_spec)
464{
Greg Clayton32e0a752011-03-30 18:16:51465 if (m_arch == arch_spec)
Jim Ingham5aee1622010-08-09 23:31:02466 {
467 // If we're setting the architecture to our current architecture, we
468 // don't need to do anything.
469 return true;
470 }
Greg Clayton32e0a752011-03-30 18:16:51471 else if (!m_arch.IsValid())
Jim Ingham5aee1622010-08-09 23:31:02472 {
473 // If we haven't got a valid arch spec, then we just need to set it.
Greg Clayton32e0a752011-03-30 18:16:51474 m_arch = arch_spec;
Jim Ingham5aee1622010-08-09 23:31:02475 return true;
476 }
477 else
478 {
479 // If we have an executable file, try to reset the executable to the desired architecture
Greg Clayton32e0a752011-03-30 18:16:51480 m_arch = arch_spec;
Jim Ingham5aee1622010-08-09 23:31:02481 ModuleSP executable_sp = GetExecutableModule ();
482 m_images.Clear();
483 m_scratch_ast_context_ap.reset();
Jim Ingham5aee1622010-08-09 23:31:02484 // Need to do something about unsetting breakpoints.
485
486 if (executable_sp)
487 {
488 FileSpec exec_file_spec = executable_sp->GetFileSpec();
489 Error error = ModuleList::GetSharedModule(exec_file_spec,
490 arch_spec,
491 NULL,
492 NULL,
493 0,
494 executable_sp,
495 NULL,
496 NULL);
497
498 if (!error.Fail() && executable_sp)
499 {
500 SetExecutableModule (executable_sp, true);
501 return true;
502 }
503 else
504 {
505 return false;
506 }
507 }
508 else
509 {
510 return false;
511 }
512 }
513}
Chris Lattner30fdc8d2010-06-08 16:52:24514
Chris Lattner30fdc8d2010-06-08 16:52:24515void
516Target::ModuleAdded (ModuleSP &module_sp)
517{
518 // A module is being added to this target for the first time
519 ModuleList module_list;
520 module_list.Append(module_sp);
521 ModulesDidLoad (module_list);
522}
523
524void
525Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp)
526{
527 // A module is being added to this target for the first time
528 ModuleList module_list;
529 module_list.Append (old_module_sp);
530 ModulesDidUnload (module_list);
531 module_list.Clear ();
532 module_list.Append (new_module_sp);
533 ModulesDidLoad (module_list);
534}
535
536void
537Target::ModulesDidLoad (ModuleList &module_list)
538{
539 m_breakpoint_list.UpdateBreakpoints (module_list, true);
540 // TODO: make event data that packages up the module_list
541 BroadcastEvent (eBroadcastBitModulesLoaded, NULL);
542}
543
544void
545Target::ModulesDidUnload (ModuleList &module_list)
546{
547 m_breakpoint_list.UpdateBreakpoints (module_list, false);
Greg Claytona4d78302010-12-06 23:51:26548
549 // Remove the images from the target image list
550 m_images.Remove(module_list);
551
Chris Lattner30fdc8d2010-06-08 16:52:24552 // TODO: make event data that packages up the module_list
553 BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
554}
555
556size_t
Greg Claytondb598232011-01-07 01:57:07557Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error)
558{
559 const Section *section = addr.GetSection();
560 if (section && section->GetModule())
561 {
562 ObjectFile *objfile = section->GetModule()->GetObjectFile();
563 if (objfile)
564 {
565 size_t bytes_read = section->ReadSectionDataFromObjectFile (objfile,
566 addr.GetOffset(),
567 dst,
568 dst_len);
569 if (bytes_read > 0)
570 return bytes_read;
571 else
572 error.SetErrorStringWithFormat("error reading data from section %s", section->GetName().GetCString());
573 }
574 else
575 {
576 error.SetErrorString("address isn't from a object file");
577 }
578 }
579 else
580 {
581 error.SetErrorString("address doesn't contain a section that points to a section in a object file");
582 }
583 return 0;
584}
585
586size_t
587Target::ReadMemory (const Address& addr, bool prefer_file_cache, void *dst, size_t dst_len, Error &error)
Chris Lattner30fdc8d2010-06-08 16:52:24588{
Chris Lattner30fdc8d2010-06-08 16:52:24589 error.Clear();
Greg Claytondb598232011-01-07 01:57:07590
Greg Claytondda4f7b2010-06-30 23:03:03591 bool process_is_valid = m_process_sp && m_process_sp->IsAlive();
592
Greg Claytondb598232011-01-07 01:57:07593 size_t bytes_read = 0;
Greg Clayton357132e2011-03-26 19:14:58594 Address resolved_addr;
595 if (!addr.IsSectionOffset())
Greg Claytondda4f7b2010-06-30 23:03:03596 {
597 if (process_is_valid)
Greg Claytonf5e56de2010-09-14 23:36:40598 m_section_load_list.ResolveLoadAddress (addr.GetOffset(), resolved_addr);
Greg Claytondda4f7b2010-06-30 23:03:03599 else
Greg Claytondda4f7b2010-06-30 23:03:03600 m_images.ResolveFileAddress(addr.GetOffset(), resolved_addr);
Greg Claytondda4f7b2010-06-30 23:03:03601 }
Greg Clayton357132e2011-03-26 19:14:58602 if (!resolved_addr.IsValid())
603 resolved_addr = addr;
Greg Claytondda4f7b2010-06-30 23:03:03604
Greg Claytondb598232011-01-07 01:57:07605 if (prefer_file_cache)
606 {
607 bytes_read = ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
608 if (bytes_read > 0)
609 return bytes_read;
610 }
Greg Claytondda4f7b2010-06-30 23:03:03611
612 if (process_is_valid)
613 {
Greg Claytonf5e56de2010-09-14 23:36:40614 lldb::addr_t load_addr = resolved_addr.GetLoadAddress (this);
Greg Claytondda4f7b2010-06-30 23:03:03615 if (load_addr == LLDB_INVALID_ADDRESS)
616 {
617 if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec())
618 error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n",
619 resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(),
620 resolved_addr.GetFileAddress());
621 else
622 error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress());
623 }
624 else
625 {
Greg Claytondb598232011-01-07 01:57:07626 bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
Chris Lattner30fdc8d2010-06-08 16:52:24627 if (bytes_read != dst_len)
628 {
629 if (error.Success())
630 {
631 if (bytes_read == 0)
Greg Claytondda4f7b2010-06-30 23:03:03632 error.SetErrorStringWithFormat("Read memory from 0x%llx failed.\n", load_addr);
Chris Lattner30fdc8d2010-06-08 16:52:24633 else
Greg Claytondda4f7b2010-06-30 23:03:03634 error.SetErrorStringWithFormat("Only %zu of %zu bytes were read from memory at 0x%llx.\n", bytes_read, dst_len, load_addr);
Chris Lattner30fdc8d2010-06-08 16:52:24635 }
636 }
Greg Claytondda4f7b2010-06-30 23:03:03637 if (bytes_read)
638 return bytes_read;
639 // If the address is not section offset we have an address that
640 // doesn't resolve to any address in any currently loaded shared
641 // libaries and we failed to read memory so there isn't anything
642 // more we can do. If it is section offset, we might be able to
643 // read cached memory from the object file.
644 if (!resolved_addr.IsSectionOffset())
645 return 0;
Chris Lattner30fdc8d2010-06-08 16:52:24646 }
Chris Lattner30fdc8d2010-06-08 16:52:24647 }
Greg Claytondda4f7b2010-06-30 23:03:03648
Greg Claytondb598232011-01-07 01:57:07649 if (!prefer_file_cache)
Greg Claytondda4f7b2010-06-30 23:03:03650 {
Greg Claytondb598232011-01-07 01:57:07651 // If we didn't already try and read from the object file cache, then
652 // try it after failing to read from the process.
653 return ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
Greg Claytondda4f7b2010-06-30 23:03:03654 }
655 return 0;
Chris Lattner30fdc8d2010-06-08 16:52:24656}
657
658
659ModuleSP
660Target::GetSharedModule
661(
662 const FileSpec& file_spec,
663 const ArchSpec& arch,
Greg Clayton60830262011-02-04 18:53:10664 const lldb_private::UUID *uuid_ptr,
Chris Lattner30fdc8d2010-06-08 16:52:24665 const ConstString *object_name,
666 off_t object_offset,
667 Error *error_ptr
668)
669{
670 // Don't pass in the UUID so we can tell if we have a stale value in our list
671 ModuleSP old_module_sp; // This will get filled in if we have a new version of the library
672 bool did_create_module = false;
673 ModuleSP module_sp;
674
Chris Lattner30fdc8d2010-06-08 16:52:24675 Error error;
676
Greg Clayton32e0a752011-03-30 18:16:51677 // If there are image search path entries, try to use them first to acquire a suitable image.
Chris Lattner30fdc8d2010-06-08 16:52:24678 if (m_image_search_paths.GetSize())
679 {
680 FileSpec transformed_spec;
681 if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory()))
682 {
683 transformed_spec.GetFilename() = file_spec.GetFilename();
684 error = ModuleList::GetSharedModule (transformed_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module);
685 }
686 }
687
Greg Clayton32e0a752011-03-30 18:16:51688 // The platform is responsible for finding and caching an appropriate
689 // module in the shared module cache.
690 if (m_platform_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24691 {
Greg Clayton32e0a752011-03-30 18:16:51692 FileSpec platform_file_spec;
693 error = m_platform_sp->GetSharedModule (file_spec,
694 arch,
695 uuid_ptr,
696 object_name,
697 object_offset,
698 module_sp,
699 &old_module_sp,
700 &did_create_module);
701 }
702 else
703 {
704 error.SetErrorString("no platform is currently set");
Chris Lattner30fdc8d2010-06-08 16:52:24705 }
706
Greg Clayton32e0a752011-03-30 18:16:51707 // If a module hasn't been found yet, use the unmodified path.
Chris Lattner30fdc8d2010-06-08 16:52:24708 if (module_sp)
709 {
710 m_images.Append (module_sp);
711 if (did_create_module)
712 {
713 if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32)
714 ModuleUpdated(old_module_sp, module_sp);
715 else
716 ModuleAdded(module_sp);
717 }
718 }
719 if (error_ptr)
720 *error_ptr = error;
721 return module_sp;
722}
723
724
725Target *
726Target::CalculateTarget ()
727{
728 return this;
729}
730
731Process *
732Target::CalculateProcess ()
733{
734 return NULL;
735}
736
737Thread *
738Target::CalculateThread ()
739{
740 return NULL;
741}
742
743StackFrame *
744Target::CalculateStackFrame ()
745{
746 return NULL;
747}
748
749void
Greg Clayton0603aa92010-10-04 01:05:56750Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner30fdc8d2010-06-08 16:52:24751{
752 exe_ctx.target = this;
753 exe_ctx.process = NULL; // Do NOT fill in process...
754 exe_ctx.thread = NULL;
755 exe_ctx.frame = NULL;
756}
757
758PathMappingList &
759Target::GetImageSearchPathList ()
760{
761 return m_image_search_paths;
762}
763
764void
765Target::ImageSearchPathsChanged
766(
767 const PathMappingList &path_list,
768 void *baton
769)
770{
771 Target *target = (Target *)baton;
772 if (target->m_images.GetSize() > 1)
773 {
774 ModuleSP exe_module_sp (target->GetExecutableModule());
775 if (exe_module_sp)
776 {
777 target->m_images.Clear();
778 target->SetExecutableModule (exe_module_sp, true);
779 }
780 }
781}
782
783ClangASTContext *
784Target::GetScratchClangASTContext()
785{
786 return m_scratch_ast_context_ap.get();
787}
Caroline Ticedaccaa92010-09-20 20:44:43788
Greg Clayton99d0faf2010-11-18 23:32:35789void
Caroline Tice20bd37f2011-03-10 22:14:10790Target::SettingsInitialize ()
Caroline Ticedaccaa92010-09-20 20:44:43791{
Greg Clayton99d0faf2010-11-18 23:32:35792 UserSettingsControllerSP &usc = GetSettingsController();
793 usc.reset (new SettingsController);
794 UserSettingsController::InitializeSettingsController (usc,
795 SettingsController::global_settings_table,
796 SettingsController::instance_settings_table);
Caroline Tice20bd37f2011-03-10 22:14:10797
798 // Now call SettingsInitialize() on each 'child' setting of Target
799 Process::SettingsInitialize ();
Greg Clayton99d0faf2010-11-18 23:32:35800}
Caroline Ticedaccaa92010-09-20 20:44:43801
Greg Clayton99d0faf2010-11-18 23:32:35802void
Caroline Tice20bd37f2011-03-10 22:14:10803Target::SettingsTerminate ()
Greg Clayton99d0faf2010-11-18 23:32:35804{
Caroline Tice20bd37f2011-03-10 22:14:10805
806 // Must call SettingsTerminate() on each settings 'child' of Target, before terminating Target's Settings.
807
808 Process::SettingsTerminate ();
809
810 // Now terminate Target Settings.
811
Greg Clayton99d0faf2010-11-18 23:32:35812 UserSettingsControllerSP &usc = GetSettingsController();
813 UserSettingsController::FinalizeSettingsController (usc);
814 usc.reset();
815}
Caroline Ticedaccaa92010-09-20 20:44:43816
Greg Clayton99d0faf2010-11-18 23:32:35817UserSettingsControllerSP &
818Target::GetSettingsController ()
819{
820 static UserSettingsControllerSP g_settings_controller;
Caroline Ticedaccaa92010-09-20 20:44:43821 return g_settings_controller;
822}
823
824ArchSpec
825Target::GetDefaultArchitecture ()
826{
Greg Clayton64195a22011-02-23 00:35:02827 lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
828
829 if (settings_controller_sp)
830 return static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture ();
831 return ArchSpec();
Caroline Ticedaccaa92010-09-20 20:44:43832}
833
834void
Greg Clayton64195a22011-02-23 00:35:02835Target::SetDefaultArchitecture (const ArchSpec& arch)
Caroline Ticedaccaa92010-09-20 20:44:43836{
Greg Clayton64195a22011-02-23 00:35:02837 lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
838
839 if (settings_controller_sp)
840 static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture () = arch;
Caroline Ticedaccaa92010-09-20 20:44:43841}
842
Greg Clayton0603aa92010-10-04 01:05:56843Target *
844Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
845{
846 // The target can either exist in the "process" of ExecutionContext, or in
847 // the "target_sp" member of SymbolContext. This accessor helper function
848 // will get the target from one of these locations.
849
850 Target *target = NULL;
851 if (sc_ptr != NULL)
852 target = sc_ptr->target_sp.get();
853 if (target == NULL)
854 {
855 if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL)
856 target = &exe_ctx_ptr->process->GetTarget();
857 }
858 return target;
859}
860
861
Caroline Tice1559a462010-09-27 00:30:10862void
863Target::UpdateInstanceName ()
864{
865 StreamString sstr;
866
867 ModuleSP module_sp = GetExecutableModule();
868 if (module_sp)
869 {
Greg Clayton307de252010-10-27 02:06:37870 sstr.Printf ("%s_%s",
871 module_sp->GetFileSpec().GetFilename().AsCString(),
Greg Clayton64195a22011-02-23 00:35:02872 module_sp->GetArchitecture().GetArchitectureName());
Greg Claytondbe54502010-11-19 03:46:01873 GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(),
874 sstr.GetData());
Caroline Tice1559a462010-09-27 00:30:10875 }
876}
877
Sean Callanan322f5292010-10-29 00:29:03878const char *
879Target::GetExpressionPrefixContentsAsCString ()
880{
Greg Clayton7e14f912011-04-23 02:04:55881 if (m_expr_prefix_contents_sp)
882 return (const char *)m_expr_prefix_contents_sp->GetBytes();
883 return NULL;
Sean Callanan322f5292010-10-29 00:29:03884}
885
Greg Clayton8b2fe6d2010-12-14 02:59:59886ExecutionResults
887Target::EvaluateExpression
888(
889 const char *expr_cstr,
890 StackFrame *frame,
891 bool unwind_on_error,
Sean Callanan92adcac2011-01-13 08:53:35892 bool keep_in_memory,
Jim Ingham2837b762011-05-04 03:43:18893 lldb::DynamicValueType use_dynamic,
Greg Clayton8b2fe6d2010-12-14 02:59:59894 lldb::ValueObjectSP &result_valobj_sp
895)
896{
897 ExecutionResults execution_results = eExecutionSetupError;
898
899 result_valobj_sp.reset();
900
901 ExecutionContext exe_ctx;
902 if (frame)
903 {
904 frame->CalculateExecutionContext(exe_ctx);
Greg Clayton54979cd2010-12-15 05:08:08905 Error error;
Greg Clayton6d5e68e2011-01-20 19:27:18906 const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember |
907 StackFrame::eExpressionPathOptionsNoFragileObjcIvar;
Jim Ingham2837b762011-05-04 03:43:18908 lldb::VariableSP var_sp;
909 result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr,
910 use_dynamic,
911 expr_path_options,
912 var_sp,
913 error);
Greg Clayton8b2fe6d2010-12-14 02:59:59914 }
915 else if (m_process_sp)
916 {
917 m_process_sp->CalculateExecutionContext(exe_ctx);
918 }
919 else
920 {
921 CalculateExecutionContext(exe_ctx);
922 }
923
924 if (result_valobj_sp)
925 {
926 execution_results = eExecutionCompleted;
927 // We got a result from the frame variable expression path above...
928 ConstString persistent_variable_name (m_persistent_variables.GetNextPersistentVariableName());
929
930 lldb::ValueObjectSP const_valobj_sp;
931
932 // Check in case our value is already a constant value
933 if (result_valobj_sp->GetIsConstant())
934 {
935 const_valobj_sp = result_valobj_sp;
936 const_valobj_sp->SetName (persistent_variable_name);
937 }
938 else
Jim Ingham78a685a2011-04-16 00:01:13939 {
Jim Ingham2837b762011-05-04 03:43:18940 if (use_dynamic != lldb::eNoDynamicValues)
Jim Ingham78a685a2011-04-16 00:01:13941 {
Jim Ingham2837b762011-05-04 03:43:18942 ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(use_dynamic);
Jim Ingham78a685a2011-04-16 00:01:13943 if (dynamic_sp)
944 result_valobj_sp = dynamic_sp;
945 }
946
Jim Ingham6035b672011-03-31 00:19:25947 const_valobj_sp = result_valobj_sp->CreateConstantValue (persistent_variable_name);
Jim Ingham78a685a2011-04-16 00:01:13948 }
Greg Clayton8b2fe6d2010-12-14 02:59:59949
Sean Callanan92adcac2011-01-13 08:53:35950 lldb::ValueObjectSP live_valobj_sp = result_valobj_sp;
951
Greg Clayton8b2fe6d2010-12-14 02:59:59952 result_valobj_sp = const_valobj_sp;
953
Sean Callanan92adcac2011-01-13 08:53:35954 ClangExpressionVariableSP clang_expr_variable_sp(m_persistent_variables.CreatePersistentVariable(result_valobj_sp));
955 assert (clang_expr_variable_sp.get());
956
957 // Set flags and live data as appropriate
958
959 const Value &result_value = live_valobj_sp->GetValue();
960
961 switch (result_value.GetValueType())
962 {
963 case Value::eValueTypeHostAddress:
964 case Value::eValueTypeFileAddress:
965 // we don't do anything with these for now
966 break;
967 case Value::eValueTypeScalar:
968 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
969 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
970 break;
971 case Value::eValueTypeLoadAddress:
972 clang_expr_variable_sp->m_live_sp = live_valobj_sp;
973 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
974 break;
975 }
Greg Clayton8b2fe6d2010-12-14 02:59:59976 }
977 else
978 {
979 // Make sure we aren't just trying to see the value of a persistent
980 // variable (something like "$0")
Greg Clayton3e06bd92011-01-09 21:07:35981 lldb::ClangExpressionVariableSP persistent_var_sp;
982 // Only check for persistent variables the expression starts with a '$'
983 if (expr_cstr[0] == '$')
984 persistent_var_sp = m_persistent_variables.GetVariable (expr_cstr);
985
Greg Clayton8b2fe6d2010-12-14 02:59:59986 if (persistent_var_sp)
987 {
988 result_valobj_sp = persistent_var_sp->GetValueObject ();
989 execution_results = eExecutionCompleted;
990 }
991 else
992 {
993 const char *prefix = GetExpressionPrefixContentsAsCString();
994
995 execution_results = ClangUserExpression::Evaluate (exe_ctx,
Sean Callanan92adcac2011-01-13 08:53:35996 unwind_on_error,
Greg Clayton8b2fe6d2010-12-14 02:59:59997 expr_cstr,
998 prefix,
999 result_valobj_sp);
1000 }
1001 }
1002 return execution_results;
1003}
1004
Jim Ingham9575d842011-03-11 03:53:591005lldb::user_id_t
1006Target::AddStopHook (Target::StopHookSP &new_hook_sp)
1007{
1008 lldb::user_id_t new_uid = ++m_stop_hook_next_id;
1009 new_hook_sp.reset (new StopHook(GetSP(), new_uid));
1010 m_stop_hooks[new_uid] = new_hook_sp;
1011 return new_uid;
1012}
1013
1014bool
1015Target::RemoveStopHookByID (lldb::user_id_t user_id)
1016{
1017 size_t num_removed;
1018 num_removed = m_stop_hooks.erase (user_id);
1019 if (num_removed == 0)
1020 return false;
1021 else
1022 return true;
1023}
1024
1025void
1026Target::RemoveAllStopHooks ()
1027{
1028 m_stop_hooks.clear();
1029}
1030
1031Target::StopHookSP
1032Target::GetStopHookByID (lldb::user_id_t user_id)
1033{
1034 StopHookSP found_hook;
1035
1036 StopHookCollection::iterator specified_hook_iter;
1037 specified_hook_iter = m_stop_hooks.find (user_id);
1038 if (specified_hook_iter != m_stop_hooks.end())
1039 found_hook = (*specified_hook_iter).second;
1040 return found_hook;
1041}
1042
1043bool
1044Target::SetStopHookActiveStateByID (lldb::user_id_t user_id, bool active_state)
1045{
1046 StopHookCollection::iterator specified_hook_iter;
1047 specified_hook_iter = m_stop_hooks.find (user_id);
1048 if (specified_hook_iter == m_stop_hooks.end())
1049 return false;
1050
1051 (*specified_hook_iter).second->SetIsActive (active_state);
1052 return true;
1053}
1054
1055void
1056Target::SetAllStopHooksActiveState (bool active_state)
1057{
1058 StopHookCollection::iterator pos, end = m_stop_hooks.end();
1059 for (pos = m_stop_hooks.begin(); pos != end; pos++)
1060 {
1061 (*pos).second->SetIsActive (active_state);
1062 }
1063}
1064
1065void
1066Target::RunStopHooks ()
1067{
1068 if (!m_process_sp)
1069 return;
1070
1071 if (m_stop_hooks.empty())
1072 return;
1073
1074 StopHookCollection::iterator pos, end = m_stop_hooks.end();
1075
1076 // If there aren't any active stop hooks, don't bother either:
1077 bool any_active_hooks = false;
1078 for (pos = m_stop_hooks.begin(); pos != end; pos++)
1079 {
1080 if ((*pos).second->IsActive())
1081 {
1082 any_active_hooks = true;
1083 break;
1084 }
1085 }
1086 if (!any_active_hooks)
1087 return;
1088
1089 CommandReturnObject result;
1090
1091 std::vector<ExecutionContext> exc_ctx_with_reasons;
1092 std::vector<SymbolContext> sym_ctx_with_reasons;
1093
1094 ThreadList &cur_threadlist = m_process_sp->GetThreadList();
1095 size_t num_threads = cur_threadlist.GetSize();
1096 for (size_t i = 0; i < num_threads; i++)
1097 {
1098 lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex (i);
1099 if (cur_thread_sp->ThreadStoppedForAReason())
1100 {
1101 lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
1102 exc_ctx_with_reasons.push_back(ExecutionContext(m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get()));
1103 sym_ctx_with_reasons.push_back(cur_frame_sp->GetSymbolContext(eSymbolContextEverything));
1104 }
1105 }
1106
1107 // If no threads stopped for a reason, don't run the stop-hooks.
1108 size_t num_exe_ctx = exc_ctx_with_reasons.size();
1109 if (num_exe_ctx == 0)
1110 return;
1111
Caroline Tice969ed3d12011-05-02 20:41:461112 StreamSP output_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(),
1113 CommandInterpreter::eBroadcastBitAsynchronousOutputData));
1114 StreamSP error_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(),
1115 CommandInterpreter::eBroadcastBitAsynchronousErrorData));
1116 result.SetImmediateOutputStream (output_stream);
1117 result.SetImmediateErrorStream (error_stream);
Jim Ingham9575d842011-03-11 03:53:591118
1119 bool keep_going = true;
1120 bool hooks_ran = false;
Jim Ingham381e25b2011-03-22 01:47:271121 bool print_hook_header;
1122 bool print_thread_header;
1123
1124 if (num_exe_ctx == 1)
1125 print_thread_header = false;
1126 else
1127 print_thread_header = true;
1128
1129 if (m_stop_hooks.size() == 1)
1130 print_hook_header = false;
1131 else
1132 print_hook_header = true;
1133
Jim Ingham9575d842011-03-11 03:53:591134 for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++)
1135 {
1136 // result.Clear();
1137 StopHookSP cur_hook_sp = (*pos).second;
1138 if (!cur_hook_sp->IsActive())
1139 continue;
1140
1141 bool any_thread_matched = false;
1142 for (size_t i = 0; keep_going && i < num_exe_ctx; i++)
1143 {
1144 if ((cur_hook_sp->GetSpecifier () == NULL
1145 || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
1146 && (cur_hook_sp->GetThreadSpecifier() == NULL
1147 || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].thread)))
1148 {
1149 if (!hooks_ran)
1150 {
Jim Ingham381e25b2011-03-22 01:47:271151 result.AppendMessage("\n** Stop Hooks **");
Jim Ingham9575d842011-03-11 03:53:591152 hooks_ran = true;
1153 }
Jim Ingham381e25b2011-03-22 01:47:271154 if (print_hook_header && !any_thread_matched)
Jim Ingham9575d842011-03-11 03:53:591155 {
1156 result.AppendMessageWithFormat("\n- Hook %d\n", cur_hook_sp->GetID());
1157 any_thread_matched = true;
1158 }
1159
Jim Ingham381e25b2011-03-22 01:47:271160 if (print_thread_header)
1161 result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID());
Jim Ingham9575d842011-03-11 03:53:591162
1163 bool stop_on_continue = true;
1164 bool stop_on_error = true;
1165 bool echo_commands = false;
1166 bool print_results = true;
1167 GetDebugger().GetCommandInterpreter().HandleCommands (cur_hook_sp->GetCommands(),
Greg Clayton32e0a752011-03-30 18:16:511168 &exc_ctx_with_reasons[i],
1169 stop_on_continue,
1170 stop_on_error,
1171 echo_commands,
1172 print_results,
1173 result);
Jim Ingham9575d842011-03-11 03:53:591174
1175 // If the command started the target going again, we should bag out of
1176 // running the stop hooks.
Greg Clayton32e0a752011-03-30 18:16:511177 if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
1178 (result.GetStatus() == eReturnStatusSuccessContinuingResult))
Jim Ingham9575d842011-03-11 03:53:591179 {
1180 result.AppendMessageWithFormat ("Aborting stop hooks, hook %d set the program running.", cur_hook_sp->GetID());
1181 keep_going = false;
1182 }
1183 }
1184 }
1185 }
1186 if (hooks_ran)
1187 result.AppendMessage ("\n** End Stop Hooks **\n");
Caroline Tice969ed3d12011-05-02 20:41:461188
1189 result.GetImmediateOutputStream()->Flush();
1190 result.GetImmediateErrorStream()->Flush();
Jim Ingham9575d842011-03-11 03:53:591191}
1192
1193//--------------------------------------------------------------
1194// class Target::StopHook
1195//--------------------------------------------------------------
1196
1197
1198Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) :
1199 UserID (uid),
1200 m_target_sp (target_sp),
Jim Ingham9575d842011-03-11 03:53:591201 m_commands (),
1202 m_specifier_sp (),
Stephen Wilson71c21d12011-04-11 19:41:401203 m_thread_spec_ap(NULL),
1204 m_active (true)
Jim Ingham9575d842011-03-11 03:53:591205{
1206}
1207
1208Target::StopHook::StopHook (const StopHook &rhs) :
1209 UserID (rhs.GetID()),
1210 m_target_sp (rhs.m_target_sp),
1211 m_commands (rhs.m_commands),
1212 m_specifier_sp (rhs.m_specifier_sp),
Stephen Wilson71c21d12011-04-11 19:41:401213 m_thread_spec_ap (NULL),
1214 m_active (rhs.m_active)
Jim Ingham9575d842011-03-11 03:53:591215{
1216 if (rhs.m_thread_spec_ap.get() != NULL)
1217 m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
1218}
1219
1220
1221Target::StopHook::~StopHook ()
1222{
1223}
1224
1225void
1226Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier)
1227{
1228 m_thread_spec_ap.reset (specifier);
1229}
1230
1231
1232void
1233Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
1234{
1235 int indent_level = s->GetIndentLevel();
1236
1237 s->SetIndentLevel(indent_level + 2);
1238
1239 s->Printf ("Hook: %d\n", GetID());
1240 if (m_active)
1241 s->Indent ("State: enabled\n");
1242 else
1243 s->Indent ("State: disabled\n");
1244
1245 if (m_specifier_sp)
1246 {
1247 s->Indent();
1248 s->PutCString ("Specifier:\n");
1249 s->SetIndentLevel (indent_level + 4);
1250 m_specifier_sp->GetDescription (s, level);
1251 s->SetIndentLevel (indent_level + 2);
1252 }
1253
1254 if (m_thread_spec_ap.get() != NULL)
1255 {
1256 StreamString tmp;
1257 s->Indent("Thread:\n");
1258 m_thread_spec_ap->GetDescription (&tmp, level);
1259 s->SetIndentLevel (indent_level + 4);
1260 s->Indent (tmp.GetData());
1261 s->PutCString ("\n");
1262 s->SetIndentLevel (indent_level + 2);
1263 }
1264
1265 s->Indent ("Commands: \n");
1266 s->SetIndentLevel (indent_level + 4);
1267 uint32_t num_commands = m_commands.GetSize();
1268 for (uint32_t i = 0; i < num_commands; i++)
1269 {
1270 s->Indent(m_commands.GetStringAtIndex(i));
1271 s->PutCString ("\n");
1272 }
1273 s->SetIndentLevel (indent_level);
1274}
1275
1276
Caroline Ticedaccaa92010-09-20 20:44:431277//--------------------------------------------------------------
1278// class Target::SettingsController
1279//--------------------------------------------------------------
1280
1281Target::SettingsController::SettingsController () :
1282 UserSettingsController ("target", Debugger::GetSettingsController()),
1283 m_default_architecture ()
1284{
1285 m_default_settings.reset (new TargetInstanceSettings (*this, false,
1286 InstanceSettings::GetDefaultName().AsCString()));
1287}
1288
1289Target::SettingsController::~SettingsController ()
1290{
1291}
1292
1293lldb::InstanceSettingsSP
1294Target::SettingsController::CreateInstanceSettings (const char *instance_name)
1295{
Greg Claytondbe54502010-11-19 03:46:011296 TargetInstanceSettings *new_settings = new TargetInstanceSettings (*GetSettingsController(),
1297 false,
1298 instance_name);
Caroline Ticedaccaa92010-09-20 20:44:431299 lldb::InstanceSettingsSP new_settings_sp (new_settings);
1300 return new_settings_sp;
1301}
1302
Caroline Ticedaccaa92010-09-20 20:44:431303
Jim Ingham78a685a2011-04-16 00:01:131304#define TSC_DEFAULT_ARCH "default-arch"
1305#define TSC_EXPR_PREFIX "expr-prefix"
Jim Ingham78a685a2011-04-16 00:01:131306#define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
Greg Clayton385aa282011-04-22 03:55:061307#define TSC_SKIP_PROLOGUE "skip-prologue"
Greg Clayton7e14f912011-04-23 02:04:551308#define TSC_SOURCE_MAP "source-map"
Greg Claytonbfe5f3b2011-02-18 01:44:251309
1310
1311static const ConstString &
1312GetSettingNameForDefaultArch ()
1313{
1314 static ConstString g_const_string (TSC_DEFAULT_ARCH);
Greg Claytonbfe5f3b2011-02-18 01:44:251315 return g_const_string;
Caroline Ticedaccaa92010-09-20 20:44:431316}
1317
Greg Claytonbfe5f3b2011-02-18 01:44:251318static const ConstString &
1319GetSettingNameForExpressionPrefix ()
1320{
1321 static ConstString g_const_string (TSC_EXPR_PREFIX);
1322 return g_const_string;
1323}
1324
1325static const ConstString &
Jim Ingham78a685a2011-04-16 00:01:131326GetSettingNameForPreferDynamicValue ()
1327{
1328 static ConstString g_const_string (TSC_PREFER_DYNAMIC);
1329 return g_const_string;
1330}
1331
Greg Clayton7e14f912011-04-23 02:04:551332static const ConstString &
1333GetSettingNameForSourcePathMap ()
1334{
1335 static ConstString g_const_string (TSC_SOURCE_MAP);
1336 return g_const_string;
1337}
Greg Claytonbfe5f3b2011-02-18 01:44:251338
Greg Clayton385aa282011-04-22 03:55:061339static const ConstString &
1340GetSettingNameForSkipPrologue ()
1341{
1342 static ConstString g_const_string (TSC_SKIP_PROLOGUE);
1343 return g_const_string;
1344}
1345
1346
1347
Caroline Ticedaccaa92010-09-20 20:44:431348bool
1349Target::SettingsController::SetGlobalVariable (const ConstString &var_name,
1350 const char *index_value,
1351 const char *value,
1352 const SettingEntry &entry,
Greg Claytone0d378b2011-03-24 21:19:541353 const VarSetOperationType op,
Caroline Ticedaccaa92010-09-20 20:44:431354 Error&err)
1355{
Greg Claytonbfe5f3b2011-02-18 01:44:251356 if (var_name == GetSettingNameForDefaultArch())
Caroline Ticedaccaa92010-09-20 20:44:431357 {
Greg Claytoneb0103f2011-04-07 22:46:351358 m_default_architecture.SetTriple (value, NULL);
Greg Clayton64195a22011-02-23 00:35:021359 if (!m_default_architecture.IsValid())
1360 err.SetErrorStringWithFormat ("'%s' is not a valid architecture or triple.", value);
Caroline Ticedaccaa92010-09-20 20:44:431361 }
1362 return true;
1363}
1364
1365
1366bool
1367Target::SettingsController::GetGlobalVariable (const ConstString &var_name,
1368 StringList &value,
1369 Error &err)
1370{
Greg Claytonbfe5f3b2011-02-18 01:44:251371 if (var_name == GetSettingNameForDefaultArch())
Caroline Ticedaccaa92010-09-20 20:44:431372 {
Greg Clayton307de252010-10-27 02:06:371373 // If the arch is invalid (the default), don't show a string for it
1374 if (m_default_architecture.IsValid())
Greg Clayton64195a22011-02-23 00:35:021375 value.AppendString (m_default_architecture.GetArchitectureName());
Caroline Ticedaccaa92010-09-20 20:44:431376 return true;
1377 }
1378 else
1379 err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
1380
1381 return false;
1382}
1383
1384//--------------------------------------------------------------
1385// class TargetInstanceSettings
1386//--------------------------------------------------------------
1387
Greg Clayton85851dd2010-12-04 00:10:171388TargetInstanceSettings::TargetInstanceSettings
1389(
1390 UserSettingsController &owner,
1391 bool live_instance,
1392 const char *name
1393) :
Greg Claytonbfe5f3b2011-02-18 01:44:251394 InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
Greg Clayton7e14f912011-04-23 02:04:551395 m_expr_prefix_file (),
1396 m_expr_prefix_contents_sp (),
Jim Ingham2837b762011-05-04 03:43:181397 m_prefer_dynamic_value (2),
Greg Clayton7e14f912011-04-23 02:04:551398 m_skip_prologue (true, true),
1399 m_source_map (NULL, NULL)
Caroline Ticedaccaa92010-09-20 20:44:431400{
1401 // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
1402 // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers.
1403 // For this reason it has to be called here, rather than in the initializer or in the parent constructor.
1404 // This is true for CreateInstanceName() too.
1405
1406 if (GetInstanceName () == InstanceSettings::InvalidName())
1407 {
1408 ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
1409 m_owner.RegisterInstanceSettings (this);
1410 }
1411
1412 if (live_instance)
1413 {
1414 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1415 CopyInstanceSettings (pending_settings,false);
Caroline Ticedaccaa92010-09-20 20:44:431416 }
1417}
1418
1419TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) :
Greg Clayton7e14f912011-04-23 02:04:551420 InstanceSettings (*Target::GetSettingsController(), CreateInstanceName().AsCString()),
1421 m_expr_prefix_file (rhs.m_expr_prefix_file),
1422 m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp),
1423 m_prefer_dynamic_value (rhs.m_prefer_dynamic_value),
1424 m_skip_prologue (rhs.m_skip_prologue),
1425 m_source_map (rhs.m_source_map)
Caroline Ticedaccaa92010-09-20 20:44:431426{
1427 if (m_instance_name != InstanceSettings::GetDefaultName())
1428 {
1429 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1430 CopyInstanceSettings (pending_settings,false);
Caroline Ticedaccaa92010-09-20 20:44:431431 }
1432}
1433
1434TargetInstanceSettings::~TargetInstanceSettings ()
1435{
1436}
1437
1438TargetInstanceSettings&
1439TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs)
1440{
1441 if (this != &rhs)
1442 {
1443 }
1444
1445 return *this;
1446}
1447
Caroline Ticedaccaa92010-09-20 20:44:431448void
1449TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
1450 const char *index_value,
1451 const char *value,
1452 const ConstString &instance_name,
1453 const SettingEntry &entry,
Greg Claytone0d378b2011-03-24 21:19:541454 VarSetOperationType op,
Caroline Ticedaccaa92010-09-20 20:44:431455 Error &err,
1456 bool pending)
1457{
Greg Claytonbfe5f3b2011-02-18 01:44:251458 if (var_name == GetSettingNameForExpressionPrefix ())
Sean Callanan322f5292010-10-29 00:29:031459 {
Greg Clayton7e14f912011-04-23 02:04:551460 err = UserSettingsController::UpdateFileSpecOptionValue (value, op, m_expr_prefix_file);
1461 if (err.Success())
Sean Callanan322f5292010-10-29 00:29:031462 {
Greg Clayton7e14f912011-04-23 02:04:551463 switch (op)
Sean Callanan322f5292010-10-29 00:29:031464 {
Greg Clayton7e14f912011-04-23 02:04:551465 default:
1466 break;
1467 case eVarSetOperationAssign:
1468 case eVarSetOperationAppend:
Sean Callanan322f5292010-10-29 00:29:031469 {
Greg Clayton7e14f912011-04-23 02:04:551470 if (!m_expr_prefix_file.GetCurrentValue().Exists())
1471 {
1472 err.SetErrorToGenericError ();
1473 err.SetErrorStringWithFormat ("%s does not exist.\n", value);
1474 return;
1475 }
1476
1477 m_expr_prefix_contents_sp = m_expr_prefix_file.GetCurrentValue().ReadFileContents();
1478
1479 if (!m_expr_prefix_contents_sp && m_expr_prefix_contents_sp->GetByteSize() == 0)
1480 {
1481 err.SetErrorStringWithFormat ("Couldn't read data from '%s'\n", value);
1482 m_expr_prefix_contents_sp.reset();
1483 }
Sean Callanan322f5292010-10-29 00:29:031484 }
Greg Clayton7e14f912011-04-23 02:04:551485 break;
1486 case eVarSetOperationClear:
1487 m_expr_prefix_contents_sp.reset();
Sean Callanan322f5292010-10-29 00:29:031488 }
Sean Callanan322f5292010-10-29 00:29:031489 }
1490 }
Jim Ingham78a685a2011-04-16 00:01:131491 else if (var_name == GetSettingNameForPreferDynamicValue())
1492 {
Jim Ingham2837b762011-05-04 03:43:181493 int new_value;
1494 UserSettingsController::UpdateEnumVariable (g_dynamic_value_types, &new_value, value, err);
1495 if (err.Success())
1496 m_prefer_dynamic_value = new_value;
Greg Clayton385aa282011-04-22 03:55:061497 }
1498 else if (var_name == GetSettingNameForSkipPrologue())
1499 {
Greg Clayton7e14f912011-04-23 02:04:551500 err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_skip_prologue);
1501 }
1502 else if (var_name == GetSettingNameForSourcePathMap ())
1503 {
1504 switch (op)
1505 {
1506 case eVarSetOperationReplace:
1507 case eVarSetOperationInsertBefore:
1508 case eVarSetOperationInsertAfter:
1509 case eVarSetOperationRemove:
1510 default:
1511 break;
1512 case eVarSetOperationAssign:
1513 m_source_map.Clear(true);
1514 // Fall through to append....
1515 case eVarSetOperationAppend:
1516 {
1517 Args args(value);
1518 const uint32_t argc = args.GetArgumentCount();
1519 if (argc & 1 || argc == 0)
1520 {
1521 err.SetErrorStringWithFormat ("an even number of paths must be supplied to to the source-map setting: %u arguments given", argc);
1522 }
1523 else
1524 {
1525 char resolved_new_path[PATH_MAX];
1526 FileSpec file_spec;
1527 const char *old_path;
1528 for (uint32_t idx = 0; (old_path = args.GetArgumentAtIndex(idx)) != NULL; idx += 2)
1529 {
1530 const char *new_path = args.GetArgumentAtIndex(idx+1);
1531 assert (new_path); // We have an even number of paths, this shouldn't happen!
1532
1533 file_spec.SetFile(new_path, true);
1534 if (file_spec.Exists())
1535 {
1536 if (file_spec.GetPath (resolved_new_path, sizeof(resolved_new_path)) >= sizeof(resolved_new_path))
1537 {
1538 err.SetErrorStringWithFormat("new path '%s' is too long", new_path);
1539 return;
1540 }
1541 }
1542 else
1543 {
1544 err.SetErrorStringWithFormat("new path '%s' doesn't exist", new_path);
1545 return;
1546 }
1547 m_source_map.Append(ConstString (old_path), ConstString (resolved_new_path), true);
1548 }
1549 }
1550 }
1551 break;
1552
1553 case eVarSetOperationClear:
1554 m_source_map.Clear(true);
1555 break;
1556 }
Jim Ingham78a685a2011-04-16 00:01:131557 }
Caroline Ticedaccaa92010-09-20 20:44:431558}
1559
1560void
Greg Claytonbfe5f3b2011-02-18 01:44:251561TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending)
Caroline Ticedaccaa92010-09-20 20:44:431562{
Sean Callanan322f5292010-10-29 00:29:031563 TargetInstanceSettings *new_settings_ptr = static_cast <TargetInstanceSettings *> (new_settings.get());
1564
1565 if (!new_settings_ptr)
1566 return;
1567
Greg Clayton7e14f912011-04-23 02:04:551568 m_expr_prefix_file = new_settings_ptr->m_expr_prefix_file;
1569 m_expr_prefix_contents_sp = new_settings_ptr->m_expr_prefix_contents_sp;
1570 m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value;
1571 m_skip_prologue = new_settings_ptr->m_skip_prologue;
Caroline Ticedaccaa92010-09-20 20:44:431572}
1573
Caroline Tice12cecd72010-09-20 21:37:421574bool
Caroline Ticedaccaa92010-09-20 20:44:431575TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
1576 const ConstString &var_name,
1577 StringList &value,
Caroline Tice12cecd72010-09-20 21:37:421578 Error *err)
Caroline Ticedaccaa92010-09-20 20:44:431579{
Greg Claytonbfe5f3b2011-02-18 01:44:251580 if (var_name == GetSettingNameForExpressionPrefix ())
Sean Callanan322f5292010-10-29 00:29:031581 {
Greg Clayton7e14f912011-04-23 02:04:551582 char path[PATH_MAX];
1583 const size_t path_len = m_expr_prefix_file.GetCurrentValue().GetPath (path, sizeof(path));
1584 if (path_len > 0)
1585 value.AppendString (path, path_len);
Sean Callanan322f5292010-10-29 00:29:031586 }
Jim Ingham78a685a2011-04-16 00:01:131587 else if (var_name == GetSettingNameForPreferDynamicValue())
1588 {
Jim Ingham2837b762011-05-04 03:43:181589 value.AppendString (g_dynamic_value_types[m_prefer_dynamic_value].string_value);
Jim Ingham78a685a2011-04-16 00:01:131590 }
Greg Clayton385aa282011-04-22 03:55:061591 else if (var_name == GetSettingNameForSkipPrologue())
1592 {
1593 if (m_skip_prologue)
1594 value.AppendString ("true");
1595 else
1596 value.AppendString ("false");
1597 }
Greg Clayton7e14f912011-04-23 02:04:551598 else if (var_name == GetSettingNameForSourcePathMap ())
1599 {
1600 }
Sean Callanan322f5292010-10-29 00:29:031601 else
1602 {
1603 if (err)
1604 err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
1605 return false;
1606 }
1607
1608 return true;
Caroline Ticedaccaa92010-09-20 20:44:431609}
1610
1611const ConstString
1612TargetInstanceSettings::CreateInstanceName ()
1613{
Caroline Ticedaccaa92010-09-20 20:44:431614 StreamString sstr;
Caroline Tice1559a462010-09-27 00:30:101615 static int instance_count = 1;
1616
Caroline Ticedaccaa92010-09-20 20:44:431617 sstr.Printf ("target_%d", instance_count);
1618 ++instance_count;
1619
1620 const ConstString ret_val (sstr.GetData());
1621 return ret_val;
1622}
1623
1624//--------------------------------------------------
1625// Target::SettingsController Variable Tables
1626//--------------------------------------------------
Jim Ingham2837b762011-05-04 03:43:181627OptionEnumValueElement
1628TargetInstanceSettings::g_dynamic_value_types[] =
1629{
1630{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"},
1631{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."},
1632{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."},
1633{ 0, NULL, NULL }
1634};
Caroline Ticedaccaa92010-09-20 20:44:431635
1636SettingEntry
1637Target::SettingsController::global_settings_table[] =
1638{
Greg Claytonbfe5f3b2011-02-18 01:44:251639 // var-name var-type default enum init'd hidden help-text
1640 // ================= ================== =========== ==== ====== ====== =========================================================================
1641 { TSC_DEFAULT_ARCH , eSetVarTypeString , NULL , NULL, false, false, "Default architecture to choose, when there's a choice." },
1642 { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
1643};
1644
Caroline Ticedaccaa92010-09-20 20:44:431645SettingEntry
1646Target::SettingsController::instance_settings_table[] =
1647{
Jim Ingham2837b762011-05-04 03:43:181648 // var-name var-type default enum init'd hidden help-text
1649 // ================= ================== =============== ======================= ====== ====== =========================================================================
1650 { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." },
1651 { TSC_PREFER_DYNAMIC, eSetVarTypeEnum , "no-run-target", g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." },
1652 { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean ,"true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." },
1653 { TSC_SOURCE_MAP , eSetVarTypeArray ,NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." },
1654 { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
Caroline Ticedaccaa92010-09-20 20:44:431655};