blob: 607bb90b4cccbbbf80e1a33b9ea88513561cf278 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 Clayton427f2902010-12-14 02:59:59 +000020#include "lldb/Core/Debugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Core/Event.h"
22#include "lldb/Core/Log.h"
Caroline Tice4a348082011-05-02 20:41:46 +000023#include "lldb/Core/StreamAsynchronousIO.h"
Chris Lattner24943d22010-06-08 16:52:24 +000024#include "lldb/Core/StreamString.h"
Greg Clayton427f2902010-12-14 02:59:59 +000025#include "lldb/Core/Timer.h"
26#include "lldb/Core/ValueObject.h"
Greg Claytonf15996e2011-04-07 22:46:35 +000027#include "lldb/Expression/ClangUserExpression.h"
Chris Lattner24943d22010-06-08 16:52:24 +000028#include "lldb/Host/Host.h"
Jim Inghamd60d94a2011-03-11 03:53:59 +000029#include "lldb/Interpreter/CommandInterpreter.h"
30#include "lldb/Interpreter/CommandReturnObject.h"
Chris Lattner24943d22010-06-08 16:52:24 +000031#include "lldb/lldb-private-log.h"
32#include "lldb/Symbol/ObjectFile.h"
33#include "lldb/Target/Process.h"
Greg Clayton427f2902010-12-14 02:59:59 +000034#include "lldb/Target/StackFrame.h"
Jim Inghamd60d94a2011-03-11 03:53:59 +000035#include "lldb/Target/Thread.h"
36#include "lldb/Target/ThreadSpec.h"
Chris Lattner24943d22010-06-08 16:52:24 +000037
38using namespace lldb;
39using namespace lldb_private;
40
41//----------------------------------------------------------------------
42// Target constructor
43//----------------------------------------------------------------------
Greg Clayton24bc5d92011-03-30 18:16:51 +000044Target::Target(Debugger &debugger, const ArchSpec &target_arch, const lldb::PlatformSP &platform_sp) :
45 Broadcaster ("lldb.target"),
46 ExecutionContextScope (),
Greg Claytonc0c1b0c2010-11-19 03:46:01 +000047 TargetInstanceSettings (*GetSettingsController()),
Greg Clayton63094e02010-06-23 01:19:29 +000048 m_debugger (debugger),
Greg Clayton24bc5d92011-03-30 18:16:51 +000049 m_platform_sp (platform_sp),
Greg Claytonbdcda462010-12-20 20:49:23 +000050 m_mutex (Mutex::eMutexTypeRecursive),
Greg Clayton24bc5d92011-03-30 18:16:51 +000051 m_arch (target_arch),
52 m_images (),
Greg Claytoneea26402010-09-14 23:36:40 +000053 m_section_load_list (),
Chris Lattner24943d22010-06-08 16:52:24 +000054 m_breakpoint_list (false),
55 m_internal_breakpoint_list (true),
Johnny Chen9a3c2a52011-09-06 20:05:25 +000056 m_watchpoint_location_list (),
Greg Clayton24bc5d92011-03-30 18:16:51 +000057 m_process_sp (),
58 m_search_filter_sp (),
Chris Lattner24943d22010-06-08 16:52:24 +000059 m_image_search_paths (ImageSearchPathsChanged, this),
Greg Clayton427f2902010-12-14 02:59:59 +000060 m_scratch_ast_context_ap (NULL),
Jim Inghamd60d94a2011-03-11 03:53:59 +000061 m_persistent_variables (),
Jim Inghamcc637462011-09-13 00:29:56 +000062 m_source_manager(*this),
Greg Clayton24bc5d92011-03-30 18:16:51 +000063 m_stop_hooks (),
Jim Ingham3613ae12011-05-12 02:06:14 +000064 m_stop_hook_next_id (0),
65 m_suppress_stop_hooks (false)
Chris Lattner24943d22010-06-08 16:52:24 +000066{
Greg Clayton49ce6822010-10-31 03:01:06 +000067 SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed");
68 SetEventName (eBroadcastBitModulesLoaded, "modules-loaded");
69 SetEventName (eBroadcastBitModulesUnloaded, "modules-unloaded");
70
Greg Claytone005f2c2010-11-06 01:53:30 +000071 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Chris Lattner24943d22010-06-08 16:52:24 +000072 if (log)
73 log->Printf ("%p Target::Target()", this);
74}
75
76//----------------------------------------------------------------------
77// Destructor
78//----------------------------------------------------------------------
79Target::~Target()
80{
Greg Claytone005f2c2010-11-06 01:53:30 +000081 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
Chris Lattner24943d22010-06-08 16:52:24 +000082 if (log)
83 log->Printf ("%p Target::~Target()", this);
84 DeleteCurrentProcess ();
85}
86
87void
Caroline Tice7826c882010-10-26 03:11:13 +000088Target::Dump (Stream *s, lldb::DescriptionLevel description_level)
Chris Lattner24943d22010-06-08 16:52:24 +000089{
Greg Clayton3fed8b92010-10-08 00:21:05 +000090// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
Caroline Tice7826c882010-10-26 03:11:13 +000091 if (description_level != lldb::eDescriptionLevelBrief)
92 {
93 s->Indent();
94 s->PutCString("Target\n");
95 s->IndentMore();
Greg Clayton3f5ee7f2010-10-29 04:59:35 +000096 m_images.Dump(s);
97 m_breakpoint_list.Dump(s);
98 m_internal_breakpoint_list.Dump(s);
99 s->IndentLess();
Caroline Tice7826c882010-10-26 03:11:13 +0000100 }
101 else
102 {
Greg Clayton5beb99d2011-08-11 02:48:45 +0000103 Module *exe_module = GetExecutableModulePointer();
104 if (exe_module)
105 s->PutCString (exe_module->GetFileSpec().GetFilename().GetCString());
Jim Ingham53fe9cc2011-05-12 01:12:28 +0000106 else
107 s->PutCString ("No executable module.");
Caroline Tice7826c882010-10-26 03:11:13 +0000108 }
Chris Lattner24943d22010-06-08 16:52:24 +0000109}
110
111void
112Target::DeleteCurrentProcess ()
113{
114 if (m_process_sp.get())
115 {
Greg Clayton49480b12010-09-14 23:52:43 +0000116 m_section_load_list.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000117 if (m_process_sp->IsAlive())
118 m_process_sp->Destroy();
Jim Ingham88fa7bd2011-02-16 17:54:55 +0000119
120 m_process_sp->Finalize();
Chris Lattner24943d22010-06-08 16:52:24 +0000121
122 // Do any cleanup of the target we need to do between process instances.
123 // NB It is better to do this before destroying the process in case the
124 // clean up needs some help from the process.
125 m_breakpoint_list.ClearAllBreakpointSites();
126 m_internal_breakpoint_list.ClearAllBreakpointSites();
127 m_process_sp.reset();
128 }
129}
130
131const lldb::ProcessSP &
132Target::CreateProcess (Listener &listener, const char *plugin_name)
133{
134 DeleteCurrentProcess ();
135 m_process_sp.reset(Process::FindPlugin(*this, plugin_name, listener));
136 return m_process_sp;
137}
138
139const lldb::ProcessSP &
140Target::GetProcessSP () const
141{
142 return m_process_sp;
143}
144
145lldb::TargetSP
146Target::GetSP()
147{
Greg Clayton63094e02010-06-23 01:19:29 +0000148 return m_debugger.GetTargetList().GetTargetSP(this);
Chris Lattner24943d22010-06-08 16:52:24 +0000149}
150
Greg Clayton153ccd72011-08-10 02:10:13 +0000151void
152Target::Destroy()
153{
154 Mutex::Locker locker (m_mutex);
155 DeleteCurrentProcess ();
156 m_platform_sp.reset();
157 m_arch.Clear();
158 m_images.Clear();
159 m_section_load_list.Clear();
160 const bool notify = false;
161 m_breakpoint_list.RemoveAll(notify);
162 m_internal_breakpoint_list.RemoveAll(notify);
163 m_last_created_breakpoint.reset();
164 m_search_filter_sp.reset();
165 m_image_search_paths.Clear(notify);
166 m_scratch_ast_context_ap.reset();
167 m_persistent_variables.Clear();
168 m_stop_hooks.clear();
169 m_stop_hook_next_id = 0;
170 m_suppress_stop_hooks = false;
171}
172
173
Chris Lattner24943d22010-06-08 16:52:24 +0000174BreakpointList &
175Target::GetBreakpointList(bool internal)
176{
177 if (internal)
178 return m_internal_breakpoint_list;
179 else
180 return m_breakpoint_list;
181}
182
183const BreakpointList &
184Target::GetBreakpointList(bool internal) const
185{
186 if (internal)
187 return m_internal_breakpoint_list;
188 else
189 return m_breakpoint_list;
190}
191
192BreakpointSP
193Target::GetBreakpointByID (break_id_t break_id)
194{
195 BreakpointSP bp_sp;
196
197 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
198 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
199 else
200 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
201
202 return bp_sp;
203}
204
205BreakpointSP
206Target::CreateBreakpoint (const FileSpec *containingModule, const FileSpec &file, uint32_t line_no, bool check_inlines, bool internal)
207{
208 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
209 BreakpointResolverSP resolver_sp(new BreakpointResolverFileLine (NULL, file, line_no, check_inlines));
210 return CreateBreakpoint (filter_sp, resolver_sp, internal);
211}
212
213
214BreakpointSP
Greg Clayton33ed1702010-08-24 00:45:41 +0000215Target::CreateBreakpoint (lldb::addr_t addr, bool internal)
Chris Lattner24943d22010-06-08 16:52:24 +0000216{
Chris Lattner24943d22010-06-08 16:52:24 +0000217 Address so_addr;
218 // Attempt to resolve our load address if possible, though it is ok if
219 // it doesn't resolve to section/offset.
220
Greg Clayton33ed1702010-08-24 00:45:41 +0000221 // Try and resolve as a load address if possible
Greg Claytoneea26402010-09-14 23:36:40 +0000222 m_section_load_list.ResolveLoadAddress(addr, so_addr);
Greg Clayton33ed1702010-08-24 00:45:41 +0000223 if (!so_addr.IsValid())
224 {
225 // The address didn't resolve, so just set this as an absolute address
226 so_addr.SetOffset (addr);
227 }
228 BreakpointSP bp_sp (CreateBreakpoint(so_addr, internal));
Chris Lattner24943d22010-06-08 16:52:24 +0000229 return bp_sp;
230}
231
232BreakpointSP
233Target::CreateBreakpoint (Address &addr, bool internal)
234{
235 TargetSP target_sp = this->GetSP();
236 SearchFilterSP filter_sp(new SearchFilter (target_sp));
237 BreakpointResolverSP resolver_sp (new BreakpointResolverAddress (NULL, addr));
238 return CreateBreakpoint (filter_sp, resolver_sp, internal);
239}
240
241BreakpointSP
Greg Clayton7dd98df2011-07-12 17:06:17 +0000242Target::CreateBreakpoint (const FileSpec *containingModule,
243 const char *func_name,
244 uint32_t func_name_type_mask,
245 bool internal,
246 LazyBool skip_prologue)
Chris Lattner24943d22010-06-08 16:52:24 +0000247{
Greg Clayton12bec712010-06-28 21:30:43 +0000248 BreakpointSP bp_sp;
249 if (func_name)
250 {
251 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
Greg Clayton7dd98df2011-07-12 17:06:17 +0000252
253 BreakpointResolverSP resolver_sp (new BreakpointResolverName (NULL,
254 func_name,
255 func_name_type_mask,
256 Breakpoint::Exact,
257 skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue));
Greg Clayton12bec712010-06-28 21:30:43 +0000258 bp_sp = CreateBreakpoint (filter_sp, resolver_sp, internal);
259 }
260 return bp_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000261}
262
263
264SearchFilterSP
265Target::GetSearchFilterForModule (const FileSpec *containingModule)
266{
267 SearchFilterSP filter_sp;
268 lldb::TargetSP target_sp = this->GetSP();
269 if (containingModule != NULL)
270 {
271 // TODO: We should look into sharing module based search filters
272 // across many breakpoints like we do for the simple target based one
273 filter_sp.reset (new SearchFilterByModule (target_sp, *containingModule));
274 }
275 else
276 {
277 if (m_search_filter_sp.get() == NULL)
278 m_search_filter_sp.reset (new SearchFilter (target_sp));
279 filter_sp = m_search_filter_sp;
280 }
281 return filter_sp;
282}
283
284BreakpointSP
Greg Clayton7dd98df2011-07-12 17:06:17 +0000285Target::CreateBreakpoint (const FileSpec *containingModule,
286 RegularExpression &func_regex,
287 bool internal,
288 LazyBool skip_prologue)
Chris Lattner24943d22010-06-08 16:52:24 +0000289{
290 SearchFilterSP filter_sp(GetSearchFilterForModule (containingModule));
Greg Clayton7dd98df2011-07-12 17:06:17 +0000291 BreakpointResolverSP resolver_sp(new BreakpointResolverName (NULL,
292 func_regex,
293 skip_prologue == eLazyBoolCalculate ? GetSkipPrologue() : skip_prologue));
Chris Lattner24943d22010-06-08 16:52:24 +0000294
295 return CreateBreakpoint (filter_sp, resolver_sp, internal);
296}
297
298BreakpointSP
299Target::CreateBreakpoint (SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp, bool internal)
300{
301 BreakpointSP bp_sp;
302 if (filter_sp && resolver_sp)
303 {
304 bp_sp.reset(new Breakpoint (*this, filter_sp, resolver_sp));
305 resolver_sp->SetBreakpoint (bp_sp.get());
306
307 if (internal)
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000308 m_internal_breakpoint_list.Add (bp_sp, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000309 else
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000310 m_breakpoint_list.Add (bp_sp, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000311
Greg Claytone005f2c2010-11-06 01:53:30 +0000312 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000313 if (log)
314 {
315 StreamString s;
316 bp_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
317 log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData());
318 }
319
Chris Lattner24943d22010-06-08 16:52:24 +0000320 bp_sp->ResolveBreakpoint();
321 }
Jim Inghamd1686902010-10-14 23:45:03 +0000322
323 if (!internal && bp_sp)
324 {
325 m_last_created_breakpoint = bp_sp;
326 }
327
Chris Lattner24943d22010-06-08 16:52:24 +0000328 return bp_sp;
329}
330
Johnny Chen87ff53b2011-09-14 00:26:03 +0000331// See also WatchpointLocation::SetWatchpointType(uint32_t type) and
332// the OptionGroupWatchpoint::WatchType enum type.
Johnny Chen34bbf852011-09-12 23:38:44 +0000333WatchpointLocationSP
334Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type)
335{
Johnny Chen5b2fc572011-09-14 20:23:45 +0000336 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
337 if (log)
338 log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n",
339 __FUNCTION__, addr, size, type);
340
Johnny Chen34bbf852011-09-12 23:38:44 +0000341 WatchpointLocationSP wp_loc_sp;
Johnny Chen61286a52011-09-13 18:30:59 +0000342 bool process_is_valid = m_process_sp && m_process_sp->IsAlive();
343 if (!process_is_valid)
344 return wp_loc_sp;
Johnny Chen22a56cc2011-09-14 22:20:15 +0000345 if (addr == LLDB_INVALID_ADDRESS || size == 0)
Johnny Chen34bbf852011-09-12 23:38:44 +0000346 return wp_loc_sp;
Johnny Chen9bf11992011-09-13 01:15:36 +0000347
Johnny Chen87ff53b2011-09-14 00:26:03 +0000348 // Currently we only support one watchpoint location per address, with total
349 // number of watchpoint locations limited by the hardware which the inferior
350 // is running on.
Johnny Chen69b6ec82011-09-13 23:29:31 +0000351 WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr);
352 if (matched_sp)
353 {
Johnny Chen5b2fc572011-09-14 20:23:45 +0000354 size_t old_size = matched_sp->GetByteSize();
Johnny Chen69b6ec82011-09-13 23:29:31 +0000355 uint32_t old_type =
Johnny Chen5b2fc572011-09-14 20:23:45 +0000356 (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
357 (matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
Johnny Chen22a56cc2011-09-14 22:20:15 +0000358 // Return the existing watchpoint location if both size and type match.
359 if (size == old_size && type == old_type) {
360 wp_loc_sp = matched_sp;
361 wp_loc_sp->SetEnabled(false);
362 } else {
363 // Nil the matched watchpoint location; we will be creating a new one.
364 m_process_sp->DisableWatchpoint(matched_sp.get());
365 m_watchpoint_location_list.Remove(matched_sp->GetID());
366 }
Johnny Chen69b6ec82011-09-13 23:29:31 +0000367 }
368
Johnny Chen22a56cc2011-09-14 22:20:15 +0000369 if (!wp_loc_sp) {
370 WatchpointLocation *new_loc = new WatchpointLocation(addr, size);
371 if (!new_loc) {
372 printf("WatchpointLocation ctor failed, out of memory?\n");
373 return wp_loc_sp;
374 }
375 new_loc->SetWatchpointType(type);
376 wp_loc_sp.reset(new_loc);
377 m_watchpoint_location_list.Add(wp_loc_sp);
378 }
Johnny Chen5b2fc572011-09-14 20:23:45 +0000379
Johnny Chen5b2fc572011-09-14 20:23:45 +0000380 Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get());
Johnny Chen5b2fc572011-09-14 20:23:45 +0000381 if (log)
382 log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
383 __FUNCTION__,
384 rc.Success() ? "succeeded" : "failed",
385 wp_loc_sp->GetID());
386
Johnny Chen22a56cc2011-09-14 22:20:15 +0000387 if (rc.Fail()) wp_loc_sp.reset();
Johnny Chen9bf11992011-09-13 01:15:36 +0000388 return wp_loc_sp;
Johnny Chen34bbf852011-09-12 23:38:44 +0000389}
390
Chris Lattner24943d22010-06-08 16:52:24 +0000391void
392Target::RemoveAllBreakpoints (bool internal_also)
393{
Greg Claytone005f2c2010-11-06 01:53:30 +0000394 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000395 if (log)
396 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
397
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000398 m_breakpoint_list.RemoveAll (true);
Chris Lattner24943d22010-06-08 16:52:24 +0000399 if (internal_also)
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000400 m_internal_breakpoint_list.RemoveAll (false);
Jim Inghamd1686902010-10-14 23:45:03 +0000401
402 m_last_created_breakpoint.reset();
Chris Lattner24943d22010-06-08 16:52:24 +0000403}
404
405void
406Target::DisableAllBreakpoints (bool internal_also)
407{
Greg Claytone005f2c2010-11-06 01:53:30 +0000408 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000409 if (log)
410 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
411
412 m_breakpoint_list.SetEnabledAll (false);
413 if (internal_also)
414 m_internal_breakpoint_list.SetEnabledAll (false);
415}
416
417void
418Target::EnableAllBreakpoints (bool internal_also)
419{
Greg Claytone005f2c2010-11-06 01:53:30 +0000420 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000421 if (log)
422 log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no");
423
424 m_breakpoint_list.SetEnabledAll (true);
425 if (internal_also)
426 m_internal_breakpoint_list.SetEnabledAll (true);
427}
428
429bool
430Target::RemoveBreakpointByID (break_id_t break_id)
431{
Greg Claytone005f2c2010-11-06 01:53:30 +0000432 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000433 if (log)
434 log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
435
436 if (DisableBreakpointByID (break_id))
437 {
438 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000439 m_internal_breakpoint_list.Remove(break_id, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000440 else
Jim Inghamd1686902010-10-14 23:45:03 +0000441 {
Greg Clayton22c9e0d2011-01-24 23:35:47 +0000442 if (m_last_created_breakpoint)
443 {
444 if (m_last_created_breakpoint->GetID() == break_id)
445 m_last_created_breakpoint.reset();
446 }
Greg Claytonc7f5d5c2010-07-23 23:33:17 +0000447 m_breakpoint_list.Remove(break_id, true);
Jim Inghamd1686902010-10-14 23:45:03 +0000448 }
Chris Lattner24943d22010-06-08 16:52:24 +0000449 return true;
450 }
451 return false;
452}
453
454bool
455Target::DisableBreakpointByID (break_id_t break_id)
456{
Greg Claytone005f2c2010-11-06 01:53:30 +0000457 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000458 if (log)
459 log->Printf ("Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
460
461 BreakpointSP bp_sp;
462
463 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
464 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
465 else
466 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
467 if (bp_sp)
468 {
469 bp_sp->SetEnabled (false);
470 return true;
471 }
472 return false;
473}
474
475bool
476Target::EnableBreakpointByID (break_id_t break_id)
477{
Greg Claytone005f2c2010-11-06 01:53:30 +0000478 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS));
Chris Lattner24943d22010-06-08 16:52:24 +0000479 if (log)
480 log->Printf ("Target::%s (break_id = %i, internal = %s)\n",
481 __FUNCTION__,
482 break_id,
483 LLDB_BREAK_ID_IS_INTERNAL (break_id) ? "yes" : "no");
484
485 BreakpointSP bp_sp;
486
487 if (LLDB_BREAK_ID_IS_INTERNAL (break_id))
488 bp_sp = m_internal_breakpoint_list.FindBreakpointByID (break_id);
489 else
490 bp_sp = m_breakpoint_list.FindBreakpointByID (break_id);
491
492 if (bp_sp)
493 {
494 bp_sp->SetEnabled (true);
495 return true;
496 }
497 return false;
498}
499
500ModuleSP
501Target::GetExecutableModule ()
502{
Greg Clayton5beb99d2011-08-11 02:48:45 +0000503 return m_images.GetModuleAtIndex(0);
504}
505
506Module*
507Target::GetExecutableModulePointer ()
508{
509 return m_images.GetModulePointerAtIndex(0);
Chris Lattner24943d22010-06-08 16:52:24 +0000510}
511
512void
513Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files)
514{
515 m_images.Clear();
516 m_scratch_ast_context_ap.reset();
517
518 if (executable_sp.get())
519 {
520 Timer scoped_timer (__PRETTY_FUNCTION__,
521 "Target::SetExecutableModule (executable = '%s/%s')",
522 executable_sp->GetFileSpec().GetDirectory().AsCString(),
523 executable_sp->GetFileSpec().GetFilename().AsCString());
524
525 m_images.Append(executable_sp); // The first image is our exectuable file
526
Jim Ingham7508e732010-08-09 23:31:02 +0000527 // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module.
Greg Clayton24bc5d92011-03-30 18:16:51 +0000528 if (!m_arch.IsValid())
529 m_arch = executable_sp->GetArchitecture();
Jim Ingham7508e732010-08-09 23:31:02 +0000530
Chris Lattner24943d22010-06-08 16:52:24 +0000531 FileSpecList dependent_files;
Greg Claytone4b9c1f2011-03-08 22:40:15 +0000532 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
Jim Inghamfdf24ef2011-09-08 22:13:49 +0000533 // Let's find the file & line for main and set the default source file from there.
534 if (!m_source_manager.DefaultFileAndLineSet())
535 {
536 SymbolContextList sc_list;
537 uint32_t num_matches;
538 ConstString main_name("main");
539 bool symbols_okay = false; // Force it to be a debug symbol.
540 bool append = false;
541 num_matches = executable_sp->FindFunctions (main_name, eFunctionNameTypeBase, symbols_okay, append, sc_list);
542 for (uint32_t idx = 0; idx < num_matches; idx++)
543 {
544 SymbolContext sc;
545 sc_list.GetContextAtIndex(idx, sc);
546 if (sc.line_entry.file)
547 {
548 m_source_manager.SetDefaultFileAndLine(sc.line_entry.file, sc.line_entry.line);
549 break;
550 }
551 }
552 }
Chris Lattner24943d22010-06-08 16:52:24 +0000553
554 if (executable_objfile)
555 {
556 executable_objfile->GetDependentModules(dependent_files);
557 for (uint32_t i=0; i<dependent_files.GetSize(); i++)
558 {
Greg Claytonb1888f22011-03-19 01:12:21 +0000559 FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
560 FileSpec platform_dependent_file_spec;
561 if (m_platform_sp)
Greg Claytoncb8977d2011-03-23 00:09:55 +0000562 m_platform_sp->GetFile (dependent_file_spec, NULL, platform_dependent_file_spec);
Greg Claytonb1888f22011-03-19 01:12:21 +0000563 else
564 platform_dependent_file_spec = dependent_file_spec;
565
566 ModuleSP image_module_sp(GetSharedModule (platform_dependent_file_spec,
Greg Clayton24bc5d92011-03-30 18:16:51 +0000567 m_arch));
Chris Lattner24943d22010-06-08 16:52:24 +0000568 if (image_module_sp.get())
569 {
Chris Lattner24943d22010-06-08 16:52:24 +0000570 ObjectFile *objfile = image_module_sp->GetObjectFile();
571 if (objfile)
572 objfile->GetDependentModules(dependent_files);
573 }
574 }
575 }
576
Chris Lattner24943d22010-06-08 16:52:24 +0000577 }
Caroline Tice1ebef442010-09-27 00:30:10 +0000578
579 UpdateInstanceName();
Chris Lattner24943d22010-06-08 16:52:24 +0000580}
581
582
Jim Ingham7508e732010-08-09 23:31:02 +0000583bool
584Target::SetArchitecture (const ArchSpec &arch_spec)
585{
Greg Clayton24bc5d92011-03-30 18:16:51 +0000586 if (m_arch == arch_spec)
Jim Ingham7508e732010-08-09 23:31:02 +0000587 {
588 // If we're setting the architecture to our current architecture, we
589 // don't need to do anything.
590 return true;
591 }
Greg Clayton24bc5d92011-03-30 18:16:51 +0000592 else if (!m_arch.IsValid())
Jim Ingham7508e732010-08-09 23:31:02 +0000593 {
594 // If we haven't got a valid arch spec, then we just need to set it.
Greg Clayton24bc5d92011-03-30 18:16:51 +0000595 m_arch = arch_spec;
Jim Ingham7508e732010-08-09 23:31:02 +0000596 return true;
597 }
598 else
599 {
600 // If we have an executable file, try to reset the executable to the desired architecture
Greg Clayton24bc5d92011-03-30 18:16:51 +0000601 m_arch = arch_spec;
Jim Ingham7508e732010-08-09 23:31:02 +0000602 ModuleSP executable_sp = GetExecutableModule ();
603 m_images.Clear();
604 m_scratch_ast_context_ap.reset();
Jim Ingham7508e732010-08-09 23:31:02 +0000605 // Need to do something about unsetting breakpoints.
606
607 if (executable_sp)
608 {
609 FileSpec exec_file_spec = executable_sp->GetFileSpec();
610 Error error = ModuleList::GetSharedModule(exec_file_spec,
611 arch_spec,
612 NULL,
613 NULL,
614 0,
615 executable_sp,
616 NULL,
617 NULL);
618
619 if (!error.Fail() && executable_sp)
620 {
621 SetExecutableModule (executable_sp, true);
622 return true;
623 }
624 else
625 {
626 return false;
627 }
628 }
629 else
630 {
631 return false;
632 }
633 }
634}
Chris Lattner24943d22010-06-08 16:52:24 +0000635
Chris Lattner24943d22010-06-08 16:52:24 +0000636void
637Target::ModuleAdded (ModuleSP &module_sp)
638{
639 // A module is being added to this target for the first time
640 ModuleList module_list;
641 module_list.Append(module_sp);
642 ModulesDidLoad (module_list);
643}
644
645void
646Target::ModuleUpdated (ModuleSP &old_module_sp, ModuleSP &new_module_sp)
647{
Jim Ingham3b8a6052011-08-03 01:00:06 +0000648 // A module is replacing an already added module
Chris Lattner24943d22010-06-08 16:52:24 +0000649 ModuleList module_list;
650 module_list.Append (old_module_sp);
651 ModulesDidUnload (module_list);
652 module_list.Clear ();
653 module_list.Append (new_module_sp);
654 ModulesDidLoad (module_list);
655}
656
657void
658Target::ModulesDidLoad (ModuleList &module_list)
659{
660 m_breakpoint_list.UpdateBreakpoints (module_list, true);
661 // TODO: make event data that packages up the module_list
662 BroadcastEvent (eBroadcastBitModulesLoaded, NULL);
663}
664
665void
666Target::ModulesDidUnload (ModuleList &module_list)
667{
668 m_breakpoint_list.UpdateBreakpoints (module_list, false);
Greg Clayton7b9fcc02010-12-06 23:51:26 +0000669
670 // Remove the images from the target image list
671 m_images.Remove(module_list);
672
Chris Lattner24943d22010-06-08 16:52:24 +0000673 // TODO: make event data that packages up the module_list
674 BroadcastEvent (eBroadcastBitModulesUnloaded, NULL);
675}
676
677size_t
Greg Clayton26100dc2011-01-07 01:57:07 +0000678Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error)
679{
680 const Section *section = addr.GetSection();
681 if (section && section->GetModule())
682 {
683 ObjectFile *objfile = section->GetModule()->GetObjectFile();
684 if (objfile)
685 {
686 size_t bytes_read = section->ReadSectionDataFromObjectFile (objfile,
687 addr.GetOffset(),
688 dst,
689 dst_len);
690 if (bytes_read > 0)
691 return bytes_read;
692 else
693 error.SetErrorStringWithFormat("error reading data from section %s", section->GetName().GetCString());
694 }
695 else
696 {
697 error.SetErrorString("address isn't from a object file");
698 }
699 }
700 else
701 {
702 error.SetErrorString("address doesn't contain a section that points to a section in a object file");
703 }
704 return 0;
705}
706
707size_t
Enrico Granata91544802011-09-06 19:20:51 +0000708Target::ReadMemory (const Address& addr,
709 bool prefer_file_cache,
710 void *dst,
711 size_t dst_len,
712 Error &error,
713 lldb::addr_t *load_addr_ptr)
Chris Lattner24943d22010-06-08 16:52:24 +0000714{
Chris Lattner24943d22010-06-08 16:52:24 +0000715 error.Clear();
Greg Clayton26100dc2011-01-07 01:57:07 +0000716
Enrico Granata91544802011-09-06 19:20:51 +0000717 // if we end up reading this from process memory, we will fill this
718 // with the actual load address
719 if (load_addr_ptr)
720 *load_addr_ptr = LLDB_INVALID_ADDRESS;
721
Greg Clayton70436352010-06-30 23:03:03 +0000722 bool process_is_valid = m_process_sp && m_process_sp->IsAlive();
723
Greg Clayton26100dc2011-01-07 01:57:07 +0000724 size_t bytes_read = 0;
Greg Clayton9b82f862011-07-11 05:12:02 +0000725
726 addr_t load_addr = LLDB_INVALID_ADDRESS;
727 addr_t file_addr = LLDB_INVALID_ADDRESS;
Greg Clayton889fbd02011-03-26 19:14:58 +0000728 Address resolved_addr;
729 if (!addr.IsSectionOffset())
Greg Clayton70436352010-06-30 23:03:03 +0000730 {
Greg Clayton7dd98df2011-07-12 17:06:17 +0000731 if (m_section_load_list.IsEmpty())
Greg Clayton9b82f862011-07-11 05:12:02 +0000732 {
Greg Clayton7dd98df2011-07-12 17:06:17 +0000733 // No sections are loaded, so we must assume we are not running
734 // yet and anything we are given is a file address.
735 file_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the file address
736 m_images.ResolveFileAddress (file_addr, resolved_addr);
Greg Clayton9b82f862011-07-11 05:12:02 +0000737 }
Greg Clayton70436352010-06-30 23:03:03 +0000738 else
Greg Clayton9b82f862011-07-11 05:12:02 +0000739 {
Greg Clayton7dd98df2011-07-12 17:06:17 +0000740 // We have at least one section loaded. This can be becuase
741 // we have manually loaded some sections with "target modules load ..."
742 // or because we have have a live process that has sections loaded
743 // through the dynamic loader
744 load_addr = addr.GetOffset(); // "addr" doesn't have a section, so its offset is the load address
745 m_section_load_list.ResolveLoadAddress (load_addr, resolved_addr);
Greg Clayton9b82f862011-07-11 05:12:02 +0000746 }
Greg Clayton70436352010-06-30 23:03:03 +0000747 }
Greg Clayton889fbd02011-03-26 19:14:58 +0000748 if (!resolved_addr.IsValid())
749 resolved_addr = addr;
Greg Clayton70436352010-06-30 23:03:03 +0000750
Greg Clayton9b82f862011-07-11 05:12:02 +0000751
Greg Clayton26100dc2011-01-07 01:57:07 +0000752 if (prefer_file_cache)
753 {
754 bytes_read = ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
755 if (bytes_read > 0)
756 return bytes_read;
757 }
Greg Clayton70436352010-06-30 23:03:03 +0000758
759 if (process_is_valid)
760 {
Greg Clayton9b82f862011-07-11 05:12:02 +0000761 if (load_addr == LLDB_INVALID_ADDRESS)
762 load_addr = resolved_addr.GetLoadAddress (this);
763
Greg Clayton70436352010-06-30 23:03:03 +0000764 if (load_addr == LLDB_INVALID_ADDRESS)
765 {
766 if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec())
767 error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded.\n",
768 resolved_addr.GetModule()->GetFileSpec().GetFilename().AsCString(),
769 resolved_addr.GetFileAddress());
770 else
771 error.SetErrorStringWithFormat("0x%llx can't be resolved.\n", resolved_addr.GetFileAddress());
772 }
773 else
774 {
Greg Clayton26100dc2011-01-07 01:57:07 +0000775 bytes_read = m_process_sp->ReadMemory(load_addr, dst, dst_len, error);
Chris Lattner24943d22010-06-08 16:52:24 +0000776 if (bytes_read != dst_len)
777 {
778 if (error.Success())
779 {
780 if (bytes_read == 0)
Greg Clayton70436352010-06-30 23:03:03 +0000781 error.SetErrorStringWithFormat("Read memory from 0x%llx failed.\n", load_addr);
Chris Lattner24943d22010-06-08 16:52:24 +0000782 else
Greg Clayton70436352010-06-30 23:03:03 +0000783 error.SetErrorStringWithFormat("Only %zu of %zu bytes were read from memory at 0x%llx.\n", bytes_read, dst_len, load_addr);
Chris Lattner24943d22010-06-08 16:52:24 +0000784 }
785 }
Greg Clayton70436352010-06-30 23:03:03 +0000786 if (bytes_read)
Enrico Granata91544802011-09-06 19:20:51 +0000787 {
788 if (load_addr_ptr)
789 *load_addr_ptr = load_addr;
Greg Clayton70436352010-06-30 23:03:03 +0000790 return bytes_read;
Enrico Granata91544802011-09-06 19:20:51 +0000791 }
Greg Clayton70436352010-06-30 23:03:03 +0000792 // If the address is not section offset we have an address that
793 // doesn't resolve to any address in any currently loaded shared
794 // libaries and we failed to read memory so there isn't anything
795 // more we can do. If it is section offset, we might be able to
796 // read cached memory from the object file.
797 if (!resolved_addr.IsSectionOffset())
798 return 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000799 }
Chris Lattner24943d22010-06-08 16:52:24 +0000800 }
Greg Clayton70436352010-06-30 23:03:03 +0000801
Greg Clayton9b82f862011-07-11 05:12:02 +0000802 if (!prefer_file_cache && resolved_addr.IsSectionOffset())
Greg Clayton70436352010-06-30 23:03:03 +0000803 {
Greg Clayton26100dc2011-01-07 01:57:07 +0000804 // If we didn't already try and read from the object file cache, then
805 // try it after failing to read from the process.
806 return ReadMemoryFromFileCache (resolved_addr, dst, dst_len, error);
Greg Clayton70436352010-06-30 23:03:03 +0000807 }
808 return 0;
Chris Lattner24943d22010-06-08 16:52:24 +0000809}
810
Greg Clayton7dd98df2011-07-12 17:06:17 +0000811size_t
812Target::ReadScalarIntegerFromMemory (const Address& addr,
813 bool prefer_file_cache,
814 uint32_t byte_size,
815 bool is_signed,
816 Scalar &scalar,
817 Error &error)
818{
819 uint64_t uval;
820
821 if (byte_size <= sizeof(uval))
822 {
823 size_t bytes_read = ReadMemory (addr, prefer_file_cache, &uval, byte_size, error);
824 if (bytes_read == byte_size)
825 {
826 DataExtractor data (&uval, sizeof(uval), m_arch.GetByteOrder(), m_arch.GetAddressByteSize());
827 uint32_t offset = 0;
828 if (byte_size <= 4)
829 scalar = data.GetMaxU32 (&offset, byte_size);
830 else
831 scalar = data.GetMaxU64 (&offset, byte_size);
832
833 if (is_signed)
834 scalar.SignExtend(byte_size * 8);
835 return bytes_read;
836 }
837 }
838 else
839 {
840 error.SetErrorStringWithFormat ("byte size of %u is too large for integer scalar type", byte_size);
841 }
842 return 0;
843}
844
845uint64_t
846Target::ReadUnsignedIntegerFromMemory (const Address& addr,
847 bool prefer_file_cache,
848 size_t integer_byte_size,
849 uint64_t fail_value,
850 Error &error)
851{
852 Scalar scalar;
853 if (ReadScalarIntegerFromMemory (addr,
854 prefer_file_cache,
855 integer_byte_size,
856 false,
857 scalar,
858 error))
859 return scalar.ULongLong(fail_value);
860 return fail_value;
861}
862
863bool
864Target::ReadPointerFromMemory (const Address& addr,
865 bool prefer_file_cache,
866 Error &error,
867 Address &pointer_addr)
868{
869 Scalar scalar;
870 if (ReadScalarIntegerFromMemory (addr,
871 prefer_file_cache,
872 m_arch.GetAddressByteSize(),
873 false,
874 scalar,
875 error))
876 {
877 addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
878 if (pointer_vm_addr != LLDB_INVALID_ADDRESS)
879 {
880 if (m_section_load_list.IsEmpty())
881 {
882 // No sections are loaded, so we must assume we are not running
883 // yet and anything we are given is a file address.
884 m_images.ResolveFileAddress (pointer_vm_addr, pointer_addr);
885 }
886 else
887 {
888 // We have at least one section loaded. This can be becuase
889 // we have manually loaded some sections with "target modules load ..."
890 // or because we have have a live process that has sections loaded
891 // through the dynamic loader
892 m_section_load_list.ResolveLoadAddress (pointer_vm_addr, pointer_addr);
893 }
894 // We weren't able to resolve the pointer value, so just return
895 // an address with no section
896 if (!pointer_addr.IsValid())
897 pointer_addr.SetOffset (pointer_vm_addr);
898 return true;
899
900 }
901 }
902 return false;
903}
Chris Lattner24943d22010-06-08 16:52:24 +0000904
905ModuleSP
906Target::GetSharedModule
907(
908 const FileSpec& file_spec,
909 const ArchSpec& arch,
Greg Clayton0467c782011-02-04 18:53:10 +0000910 const lldb_private::UUID *uuid_ptr,
Chris Lattner24943d22010-06-08 16:52:24 +0000911 const ConstString *object_name,
912 off_t object_offset,
913 Error *error_ptr
914)
915{
916 // Don't pass in the UUID so we can tell if we have a stale value in our list
917 ModuleSP old_module_sp; // This will get filled in if we have a new version of the library
918 bool did_create_module = false;
919 ModuleSP module_sp;
920
Chris Lattner24943d22010-06-08 16:52:24 +0000921 Error error;
922
Greg Clayton24bc5d92011-03-30 18:16:51 +0000923 // If there are image search path entries, try to use them first to acquire a suitable image.
Chris Lattner24943d22010-06-08 16:52:24 +0000924 if (m_image_search_paths.GetSize())
925 {
926 FileSpec transformed_spec;
927 if (m_image_search_paths.RemapPath (file_spec.GetDirectory(), transformed_spec.GetDirectory()))
928 {
929 transformed_spec.GetFilename() = file_spec.GetFilename();
930 error = ModuleList::GetSharedModule (transformed_spec, arch, uuid_ptr, object_name, object_offset, module_sp, &old_module_sp, &did_create_module);
931 }
932 }
933
Greg Clayton24bc5d92011-03-30 18:16:51 +0000934 // The platform is responsible for finding and caching an appropriate
935 // module in the shared module cache.
936 if (m_platform_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000937 {
Greg Clayton24bc5d92011-03-30 18:16:51 +0000938 FileSpec platform_file_spec;
939 error = m_platform_sp->GetSharedModule (file_spec,
940 arch,
941 uuid_ptr,
942 object_name,
943 object_offset,
944 module_sp,
945 &old_module_sp,
946 &did_create_module);
947 }
948 else
949 {
950 error.SetErrorString("no platform is currently set");
Chris Lattner24943d22010-06-08 16:52:24 +0000951 }
952
Greg Clayton24bc5d92011-03-30 18:16:51 +0000953 // If a module hasn't been found yet, use the unmodified path.
Chris Lattner24943d22010-06-08 16:52:24 +0000954 if (module_sp)
955 {
956 m_images.Append (module_sp);
957 if (did_create_module)
958 {
959 if (old_module_sp && m_images.GetIndexForModule (old_module_sp.get()) != LLDB_INVALID_INDEX32)
960 ModuleUpdated(old_module_sp, module_sp);
961 else
962 ModuleAdded(module_sp);
963 }
964 }
965 if (error_ptr)
966 *error_ptr = error;
967 return module_sp;
968}
969
970
971Target *
972Target::CalculateTarget ()
973{
974 return this;
975}
976
977Process *
978Target::CalculateProcess ()
979{
980 return NULL;
981}
982
983Thread *
984Target::CalculateThread ()
985{
986 return NULL;
987}
988
989StackFrame *
990Target::CalculateStackFrame ()
991{
992 return NULL;
993}
994
995void
Greg Claytona830adb2010-10-04 01:05:56 +0000996Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000997{
998 exe_ctx.target = this;
999 exe_ctx.process = NULL; // Do NOT fill in process...
1000 exe_ctx.thread = NULL;
1001 exe_ctx.frame = NULL;
1002}
1003
1004PathMappingList &
1005Target::GetImageSearchPathList ()
1006{
1007 return m_image_search_paths;
1008}
1009
1010void
1011Target::ImageSearchPathsChanged
1012(
1013 const PathMappingList &path_list,
1014 void *baton
1015)
1016{
1017 Target *target = (Target *)baton;
Greg Clayton5beb99d2011-08-11 02:48:45 +00001018 ModuleSP exe_module_sp (target->GetExecutableModule());
1019 if (exe_module_sp)
Chris Lattner24943d22010-06-08 16:52:24 +00001020 {
Greg Clayton5beb99d2011-08-11 02:48:45 +00001021 target->m_images.Clear();
1022 target->SetExecutableModule (exe_module_sp, true);
Chris Lattner24943d22010-06-08 16:52:24 +00001023 }
1024}
1025
1026ClangASTContext *
1027Target::GetScratchClangASTContext()
1028{
Greg Clayton34ce4ea2011-08-03 01:23:55 +00001029 // Now see if we know the target triple, and if so, create our scratch AST context:
1030 if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid())
1031 m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str()));
Chris Lattner24943d22010-06-08 16:52:24 +00001032 return m_scratch_ast_context_ap.get();
1033}
Caroline Tice5bc8c972010-09-20 20:44:43 +00001034
Greg Clayton990de7b2010-11-18 23:32:35 +00001035void
Caroline Tice2a456812011-03-10 22:14:10 +00001036Target::SettingsInitialize ()
Caroline Tice5bc8c972010-09-20 20:44:43 +00001037{
Greg Clayton990de7b2010-11-18 23:32:35 +00001038 UserSettingsControllerSP &usc = GetSettingsController();
1039 usc.reset (new SettingsController);
1040 UserSettingsController::InitializeSettingsController (usc,
1041 SettingsController::global_settings_table,
1042 SettingsController::instance_settings_table);
Caroline Tice2a456812011-03-10 22:14:10 +00001043
1044 // Now call SettingsInitialize() on each 'child' setting of Target
1045 Process::SettingsInitialize ();
Greg Clayton990de7b2010-11-18 23:32:35 +00001046}
Caroline Tice5bc8c972010-09-20 20:44:43 +00001047
Greg Clayton990de7b2010-11-18 23:32:35 +00001048void
Caroline Tice2a456812011-03-10 22:14:10 +00001049Target::SettingsTerminate ()
Greg Clayton990de7b2010-11-18 23:32:35 +00001050{
Caroline Tice2a456812011-03-10 22:14:10 +00001051
1052 // Must call SettingsTerminate() on each settings 'child' of Target, before terminating Target's Settings.
1053
1054 Process::SettingsTerminate ();
1055
1056 // Now terminate Target Settings.
1057
Greg Clayton990de7b2010-11-18 23:32:35 +00001058 UserSettingsControllerSP &usc = GetSettingsController();
1059 UserSettingsController::FinalizeSettingsController (usc);
1060 usc.reset();
1061}
Caroline Tice5bc8c972010-09-20 20:44:43 +00001062
Greg Clayton990de7b2010-11-18 23:32:35 +00001063UserSettingsControllerSP &
1064Target::GetSettingsController ()
1065{
1066 static UserSettingsControllerSP g_settings_controller;
Caroline Tice5bc8c972010-09-20 20:44:43 +00001067 return g_settings_controller;
1068}
1069
1070ArchSpec
1071Target::GetDefaultArchitecture ()
1072{
Greg Clayton940b1032011-02-23 00:35:02 +00001073 lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
1074
1075 if (settings_controller_sp)
1076 return static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture ();
1077 return ArchSpec();
Caroline Tice5bc8c972010-09-20 20:44:43 +00001078}
1079
1080void
Greg Clayton940b1032011-02-23 00:35:02 +00001081Target::SetDefaultArchitecture (const ArchSpec& arch)
Caroline Tice5bc8c972010-09-20 20:44:43 +00001082{
Greg Clayton940b1032011-02-23 00:35:02 +00001083 lldb::UserSettingsControllerSP settings_controller_sp (GetSettingsController());
1084
1085 if (settings_controller_sp)
1086 static_cast<Target::SettingsController *>(settings_controller_sp.get())->GetArchitecture () = arch;
Caroline Tice5bc8c972010-09-20 20:44:43 +00001087}
1088
Greg Claytona830adb2010-10-04 01:05:56 +00001089Target *
1090Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
1091{
1092 // The target can either exist in the "process" of ExecutionContext, or in
1093 // the "target_sp" member of SymbolContext. This accessor helper function
1094 // will get the target from one of these locations.
1095
1096 Target *target = NULL;
1097 if (sc_ptr != NULL)
1098 target = sc_ptr->target_sp.get();
1099 if (target == NULL)
1100 {
1101 if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL)
1102 target = &exe_ctx_ptr->process->GetTarget();
1103 }
1104 return target;
1105}
1106
1107
Caroline Tice1ebef442010-09-27 00:30:10 +00001108void
1109Target::UpdateInstanceName ()
1110{
1111 StreamString sstr;
1112
Greg Clayton5beb99d2011-08-11 02:48:45 +00001113 Module *exe_module = GetExecutableModulePointer();
1114 if (exe_module)
Caroline Tice1ebef442010-09-27 00:30:10 +00001115 {
Greg Claytonbf6e2102010-10-27 02:06:37 +00001116 sstr.Printf ("%s_%s",
Greg Clayton5beb99d2011-08-11 02:48:45 +00001117 exe_module->GetFileSpec().GetFilename().AsCString(),
1118 exe_module->GetArchitecture().GetArchitectureName());
1119 GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData());
Caroline Tice1ebef442010-09-27 00:30:10 +00001120 }
1121}
1122
Sean Callanan77e93942010-10-29 00:29:03 +00001123const char *
1124Target::GetExpressionPrefixContentsAsCString ()
1125{
Greg Claytonff44ab42011-04-23 02:04:55 +00001126 if (m_expr_prefix_contents_sp)
1127 return (const char *)m_expr_prefix_contents_sp->GetBytes();
1128 return NULL;
Sean Callanan77e93942010-10-29 00:29:03 +00001129}
1130
Greg Clayton427f2902010-12-14 02:59:59 +00001131ExecutionResults
1132Target::EvaluateExpression
1133(
1134 const char *expr_cstr,
1135 StackFrame *frame,
Sean Callanan47dc4572011-09-15 02:13:07 +00001136 lldb_private::ExecutionPolicy execution_policy,
Greg Clayton427f2902010-12-14 02:59:59 +00001137 bool unwind_on_error,
Sean Callanan6a925532011-01-13 08:53:35 +00001138 bool keep_in_memory,
Jim Ingham10de7d12011-05-04 03:43:18 +00001139 lldb::DynamicValueType use_dynamic,
Greg Clayton427f2902010-12-14 02:59:59 +00001140 lldb::ValueObjectSP &result_valobj_sp
1141)
1142{
1143 ExecutionResults execution_results = eExecutionSetupError;
1144
1145 result_valobj_sp.reset();
Jim Ingham3613ae12011-05-12 02:06:14 +00001146
1147 // We shouldn't run stop hooks in expressions.
1148 // Be sure to reset this if you return anywhere within this function.
1149 bool old_suppress_value = m_suppress_stop_hooks;
1150 m_suppress_stop_hooks = true;
Greg Clayton427f2902010-12-14 02:59:59 +00001151
1152 ExecutionContext exe_ctx;
1153 if (frame)
1154 {
1155 frame->CalculateExecutionContext(exe_ctx);
Greg Claytonc3b61d22010-12-15 05:08:08 +00001156 Error error;
Greg Claytonc67efa42011-01-20 19:27:18 +00001157 const uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember |
Enrico Granataf6698502011-08-09 01:04:56 +00001158 StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
1159 StackFrame::eExpressionPathOptionsNoSyntheticChildren;
Jim Ingham10de7d12011-05-04 03:43:18 +00001160 lldb::VariableSP var_sp;
1161 result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr,
1162 use_dynamic,
1163 expr_path_options,
1164 var_sp,
1165 error);
Greg Clayton427f2902010-12-14 02:59:59 +00001166 }
1167 else if (m_process_sp)
1168 {
1169 m_process_sp->CalculateExecutionContext(exe_ctx);
1170 }
1171 else
1172 {
1173 CalculateExecutionContext(exe_ctx);
1174 }
1175
1176 if (result_valobj_sp)
1177 {
1178 execution_results = eExecutionCompleted;
1179 // We got a result from the frame variable expression path above...
1180 ConstString persistent_variable_name (m_persistent_variables.GetNextPersistentVariableName());
1181
1182 lldb::ValueObjectSP const_valobj_sp;
1183
1184 // Check in case our value is already a constant value
1185 if (result_valobj_sp->GetIsConstant())
1186 {
1187 const_valobj_sp = result_valobj_sp;
1188 const_valobj_sp->SetName (persistent_variable_name);
1189 }
1190 else
Jim Inghame41494a2011-04-16 00:01:13 +00001191 {
Jim Ingham10de7d12011-05-04 03:43:18 +00001192 if (use_dynamic != lldb::eNoDynamicValues)
Jim Inghame41494a2011-04-16 00:01:13 +00001193 {
Jim Ingham10de7d12011-05-04 03:43:18 +00001194 ValueObjectSP dynamic_sp = result_valobj_sp->GetDynamicValue(use_dynamic);
Jim Inghame41494a2011-04-16 00:01:13 +00001195 if (dynamic_sp)
1196 result_valobj_sp = dynamic_sp;
1197 }
1198
Jim Inghamfa3a16a2011-03-31 00:19:25 +00001199 const_valobj_sp = result_valobj_sp->CreateConstantValue (persistent_variable_name);
Jim Inghame41494a2011-04-16 00:01:13 +00001200 }
Greg Clayton427f2902010-12-14 02:59:59 +00001201
Sean Callanan6a925532011-01-13 08:53:35 +00001202 lldb::ValueObjectSP live_valobj_sp = result_valobj_sp;
1203
Greg Clayton427f2902010-12-14 02:59:59 +00001204 result_valobj_sp = const_valobj_sp;
1205
Sean Callanan6a925532011-01-13 08:53:35 +00001206 ClangExpressionVariableSP clang_expr_variable_sp(m_persistent_variables.CreatePersistentVariable(result_valobj_sp));
1207 assert (clang_expr_variable_sp.get());
1208
1209 // Set flags and live data as appropriate
1210
1211 const Value &result_value = live_valobj_sp->GetValue();
1212
1213 switch (result_value.GetValueType())
1214 {
1215 case Value::eValueTypeHostAddress:
1216 case Value::eValueTypeFileAddress:
1217 // we don't do anything with these for now
1218 break;
1219 case Value::eValueTypeScalar:
1220 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsLLDBAllocated;
1221 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVNeedsAllocation;
1222 break;
1223 case Value::eValueTypeLoadAddress:
1224 clang_expr_variable_sp->m_live_sp = live_valobj_sp;
1225 clang_expr_variable_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
1226 break;
1227 }
Greg Clayton427f2902010-12-14 02:59:59 +00001228 }
1229 else
1230 {
1231 // Make sure we aren't just trying to see the value of a persistent
1232 // variable (something like "$0")
Greg Claytona875b642011-01-09 21:07:35 +00001233 lldb::ClangExpressionVariableSP persistent_var_sp;
1234 // Only check for persistent variables the expression starts with a '$'
1235 if (expr_cstr[0] == '$')
1236 persistent_var_sp = m_persistent_variables.GetVariable (expr_cstr);
1237
Greg Clayton427f2902010-12-14 02:59:59 +00001238 if (persistent_var_sp)
1239 {
1240 result_valobj_sp = persistent_var_sp->GetValueObject ();
1241 execution_results = eExecutionCompleted;
1242 }
1243 else
1244 {
1245 const char *prefix = GetExpressionPrefixContentsAsCString();
Sean Callanan47dc4572011-09-15 02:13:07 +00001246
Greg Clayton427f2902010-12-14 02:59:59 +00001247 execution_results = ClangUserExpression::Evaluate (exe_ctx,
Sean Callanan47dc4572011-09-15 02:13:07 +00001248 execution_policy,
Sean Callanan6a925532011-01-13 08:53:35 +00001249 unwind_on_error,
Greg Clayton427f2902010-12-14 02:59:59 +00001250 expr_cstr,
1251 prefix,
1252 result_valobj_sp);
1253 }
1254 }
Jim Ingham3613ae12011-05-12 02:06:14 +00001255
1256 m_suppress_stop_hooks = old_suppress_value;
1257
Greg Clayton427f2902010-12-14 02:59:59 +00001258 return execution_results;
1259}
1260
Greg Claytonc0fa5332011-05-22 22:46:53 +00001261lldb::addr_t
1262Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const
1263{
1264 addr_t code_addr = load_addr;
1265 switch (m_arch.GetMachine())
1266 {
1267 case llvm::Triple::arm:
1268 case llvm::Triple::thumb:
1269 switch (addr_class)
1270 {
1271 case eAddressClassData:
1272 case eAddressClassDebug:
1273 return LLDB_INVALID_ADDRESS;
1274
1275 case eAddressClassUnknown:
1276 case eAddressClassInvalid:
1277 case eAddressClassCode:
1278 case eAddressClassCodeAlternateISA:
1279 case eAddressClassRuntime:
1280 // Check if bit zero it no set?
1281 if ((code_addr & 1ull) == 0)
1282 {
1283 // Bit zero isn't set, check if the address is a multiple of 2?
1284 if (code_addr & 2ull)
1285 {
1286 // The address is a multiple of 2 so it must be thumb, set bit zero
1287 code_addr |= 1ull;
1288 }
1289 else if (addr_class == eAddressClassCodeAlternateISA)
1290 {
1291 // We checked the address and the address claims to be the alternate ISA
1292 // which means thumb, so set bit zero.
1293 code_addr |= 1ull;
1294 }
1295 }
1296 break;
1297 }
1298 break;
1299
1300 default:
1301 break;
1302 }
1303 return code_addr;
1304}
1305
1306lldb::addr_t
1307Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const
1308{
1309 addr_t opcode_addr = load_addr;
1310 switch (m_arch.GetMachine())
1311 {
1312 case llvm::Triple::arm:
1313 case llvm::Triple::thumb:
1314 switch (addr_class)
1315 {
1316 case eAddressClassData:
1317 case eAddressClassDebug:
1318 return LLDB_INVALID_ADDRESS;
1319
1320 case eAddressClassInvalid:
1321 case eAddressClassUnknown:
1322 case eAddressClassCode:
1323 case eAddressClassCodeAlternateISA:
1324 case eAddressClassRuntime:
1325 opcode_addr &= ~(1ull);
1326 break;
1327 }
1328 break;
1329
1330 default:
1331 break;
1332 }
1333 return opcode_addr;
1334}
1335
Jim Inghamd60d94a2011-03-11 03:53:59 +00001336lldb::user_id_t
1337Target::AddStopHook (Target::StopHookSP &new_hook_sp)
1338{
1339 lldb::user_id_t new_uid = ++m_stop_hook_next_id;
1340 new_hook_sp.reset (new StopHook(GetSP(), new_uid));
1341 m_stop_hooks[new_uid] = new_hook_sp;
1342 return new_uid;
1343}
1344
1345bool
1346Target::RemoveStopHookByID (lldb::user_id_t user_id)
1347{
1348 size_t num_removed;
1349 num_removed = m_stop_hooks.erase (user_id);
1350 if (num_removed == 0)
1351 return false;
1352 else
1353 return true;
1354}
1355
1356void
1357Target::RemoveAllStopHooks ()
1358{
1359 m_stop_hooks.clear();
1360}
1361
1362Target::StopHookSP
1363Target::GetStopHookByID (lldb::user_id_t user_id)
1364{
1365 StopHookSP found_hook;
1366
1367 StopHookCollection::iterator specified_hook_iter;
1368 specified_hook_iter = m_stop_hooks.find (user_id);
1369 if (specified_hook_iter != m_stop_hooks.end())
1370 found_hook = (*specified_hook_iter).second;
1371 return found_hook;
1372}
1373
1374bool
1375Target::SetStopHookActiveStateByID (lldb::user_id_t user_id, bool active_state)
1376{
1377 StopHookCollection::iterator specified_hook_iter;
1378 specified_hook_iter = m_stop_hooks.find (user_id);
1379 if (specified_hook_iter == m_stop_hooks.end())
1380 return false;
1381
1382 (*specified_hook_iter).second->SetIsActive (active_state);
1383 return true;
1384}
1385
1386void
1387Target::SetAllStopHooksActiveState (bool active_state)
1388{
1389 StopHookCollection::iterator pos, end = m_stop_hooks.end();
1390 for (pos = m_stop_hooks.begin(); pos != end; pos++)
1391 {
1392 (*pos).second->SetIsActive (active_state);
1393 }
1394}
1395
1396void
1397Target::RunStopHooks ()
1398{
Jim Ingham3613ae12011-05-12 02:06:14 +00001399 if (m_suppress_stop_hooks)
1400 return;
1401
Jim Inghamd60d94a2011-03-11 03:53:59 +00001402 if (!m_process_sp)
1403 return;
1404
1405 if (m_stop_hooks.empty())
1406 return;
1407
1408 StopHookCollection::iterator pos, end = m_stop_hooks.end();
1409
1410 // If there aren't any active stop hooks, don't bother either:
1411 bool any_active_hooks = false;
1412 for (pos = m_stop_hooks.begin(); pos != end; pos++)
1413 {
1414 if ((*pos).second->IsActive())
1415 {
1416 any_active_hooks = true;
1417 break;
1418 }
1419 }
1420 if (!any_active_hooks)
1421 return;
1422
1423 CommandReturnObject result;
1424
1425 std::vector<ExecutionContext> exc_ctx_with_reasons;
1426 std::vector<SymbolContext> sym_ctx_with_reasons;
1427
1428 ThreadList &cur_threadlist = m_process_sp->GetThreadList();
1429 size_t num_threads = cur_threadlist.GetSize();
1430 for (size_t i = 0; i < num_threads; i++)
1431 {
1432 lldb::ThreadSP cur_thread_sp = cur_threadlist.GetThreadAtIndex (i);
1433 if (cur_thread_sp->ThreadStoppedForAReason())
1434 {
1435 lldb::StackFrameSP cur_frame_sp = cur_thread_sp->GetStackFrameAtIndex(0);
1436 exc_ctx_with_reasons.push_back(ExecutionContext(m_process_sp.get(), cur_thread_sp.get(), cur_frame_sp.get()));
1437 sym_ctx_with_reasons.push_back(cur_frame_sp->GetSymbolContext(eSymbolContextEverything));
1438 }
1439 }
1440
1441 // If no threads stopped for a reason, don't run the stop-hooks.
1442 size_t num_exe_ctx = exc_ctx_with_reasons.size();
1443 if (num_exe_ctx == 0)
1444 return;
1445
Jim Inghame5ed8e92011-06-02 23:58:26 +00001446 result.SetImmediateOutputStream (m_debugger.GetAsyncOutputStream());
1447 result.SetImmediateErrorStream (m_debugger.GetAsyncErrorStream());
Jim Inghamd60d94a2011-03-11 03:53:59 +00001448
1449 bool keep_going = true;
1450 bool hooks_ran = false;
Jim Inghamc54840c2011-03-22 01:47:27 +00001451 bool print_hook_header;
1452 bool print_thread_header;
1453
1454 if (num_exe_ctx == 1)
1455 print_thread_header = false;
1456 else
1457 print_thread_header = true;
1458
1459 if (m_stop_hooks.size() == 1)
1460 print_hook_header = false;
1461 else
1462 print_hook_header = true;
1463
Jim Inghamd60d94a2011-03-11 03:53:59 +00001464 for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++)
1465 {
1466 // result.Clear();
1467 StopHookSP cur_hook_sp = (*pos).second;
1468 if (!cur_hook_sp->IsActive())
1469 continue;
1470
1471 bool any_thread_matched = false;
1472 for (size_t i = 0; keep_going && i < num_exe_ctx; i++)
1473 {
1474 if ((cur_hook_sp->GetSpecifier () == NULL
1475 || cur_hook_sp->GetSpecifier()->SymbolContextMatches(sym_ctx_with_reasons[i]))
1476 && (cur_hook_sp->GetThreadSpecifier() == NULL
1477 || cur_hook_sp->GetThreadSpecifier()->ThreadPassesBasicTests(exc_ctx_with_reasons[i].thread)))
1478 {
1479 if (!hooks_ran)
1480 {
Jim Inghamc54840c2011-03-22 01:47:27 +00001481 result.AppendMessage("\n** Stop Hooks **");
Jim Inghamd60d94a2011-03-11 03:53:59 +00001482 hooks_ran = true;
1483 }
Jim Inghamc54840c2011-03-22 01:47:27 +00001484 if (print_hook_header && !any_thread_matched)
Jim Inghamd60d94a2011-03-11 03:53:59 +00001485 {
1486 result.AppendMessageWithFormat("\n- Hook %d\n", cur_hook_sp->GetID());
1487 any_thread_matched = true;
1488 }
1489
Jim Inghamc54840c2011-03-22 01:47:27 +00001490 if (print_thread_header)
1491 result.AppendMessageWithFormat("-- Thread %d\n", exc_ctx_with_reasons[i].thread->GetIndexID());
Jim Inghamd60d94a2011-03-11 03:53:59 +00001492
1493 bool stop_on_continue = true;
1494 bool stop_on_error = true;
1495 bool echo_commands = false;
1496 bool print_results = true;
1497 GetDebugger().GetCommandInterpreter().HandleCommands (cur_hook_sp->GetCommands(),
Greg Clayton24bc5d92011-03-30 18:16:51 +00001498 &exc_ctx_with_reasons[i],
1499 stop_on_continue,
1500 stop_on_error,
1501 echo_commands,
1502 print_results,
1503 result);
Jim Inghamd60d94a2011-03-11 03:53:59 +00001504
1505 // If the command started the target going again, we should bag out of
1506 // running the stop hooks.
Greg Clayton24bc5d92011-03-30 18:16:51 +00001507 if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
1508 (result.GetStatus() == eReturnStatusSuccessContinuingResult))
Jim Inghamd60d94a2011-03-11 03:53:59 +00001509 {
1510 result.AppendMessageWithFormat ("Aborting stop hooks, hook %d set the program running.", cur_hook_sp->GetID());
1511 keep_going = false;
1512 }
1513 }
1514 }
1515 }
1516 if (hooks_ran)
1517 result.AppendMessage ("\n** End Stop Hooks **\n");
Caroline Tice4a348082011-05-02 20:41:46 +00001518
1519 result.GetImmediateOutputStream()->Flush();
1520 result.GetImmediateErrorStream()->Flush();
Jim Inghamd60d94a2011-03-11 03:53:59 +00001521}
1522
Greg Claytonbbea1332011-07-08 00:48:09 +00001523bool
1524Target::LoadModuleWithSlide (Module *module, lldb::addr_t slide)
1525{
1526 bool changed = false;
1527 if (module)
1528 {
1529 ObjectFile *object_file = module->GetObjectFile();
1530 if (object_file)
1531 {
1532 SectionList *section_list = object_file->GetSectionList ();
1533 if (section_list)
1534 {
1535 // All sections listed in the dyld image info structure will all
1536 // either be fixed up already, or they will all be off by a single
1537 // slide amount that is determined by finding the first segment
1538 // that is at file offset zero which also has bytes (a file size
1539 // that is greater than zero) in the object file.
1540
1541 // Determine the slide amount (if any)
1542 const size_t num_sections = section_list->GetSize();
1543 size_t sect_idx = 0;
1544 for (sect_idx = 0; sect_idx < num_sections; ++sect_idx)
1545 {
1546 // Iterate through the object file sections to find the
1547 // first section that starts of file offset zero and that
1548 // has bytes in the file...
1549 Section *section = section_list->GetSectionAtIndex (sect_idx).get();
1550 if (section)
1551 {
1552 if (m_section_load_list.SetSectionLoadAddress (section, section->GetFileAddress() + slide))
1553 changed = true;
1554 }
1555 }
1556 }
1557 }
1558 }
1559 return changed;
1560}
1561
1562
Jim Inghamd60d94a2011-03-11 03:53:59 +00001563//--------------------------------------------------------------
1564// class Target::StopHook
1565//--------------------------------------------------------------
1566
1567
1568Target::StopHook::StopHook (lldb::TargetSP target_sp, lldb::user_id_t uid) :
1569 UserID (uid),
1570 m_target_sp (target_sp),
Jim Inghamd60d94a2011-03-11 03:53:59 +00001571 m_commands (),
1572 m_specifier_sp (),
Stephen Wilsondbeb3e12011-04-11 19:41:40 +00001573 m_thread_spec_ap(NULL),
1574 m_active (true)
Jim Inghamd60d94a2011-03-11 03:53:59 +00001575{
1576}
1577
1578Target::StopHook::StopHook (const StopHook &rhs) :
1579 UserID (rhs.GetID()),
1580 m_target_sp (rhs.m_target_sp),
1581 m_commands (rhs.m_commands),
1582 m_specifier_sp (rhs.m_specifier_sp),
Stephen Wilsondbeb3e12011-04-11 19:41:40 +00001583 m_thread_spec_ap (NULL),
1584 m_active (rhs.m_active)
Jim Inghamd60d94a2011-03-11 03:53:59 +00001585{
1586 if (rhs.m_thread_spec_ap.get() != NULL)
1587 m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get()));
1588}
1589
1590
1591Target::StopHook::~StopHook ()
1592{
1593}
1594
1595void
1596Target::StopHook::SetThreadSpecifier (ThreadSpec *specifier)
1597{
1598 m_thread_spec_ap.reset (specifier);
1599}
1600
1601
1602void
1603Target::StopHook::GetDescription (Stream *s, lldb::DescriptionLevel level) const
1604{
1605 int indent_level = s->GetIndentLevel();
1606
1607 s->SetIndentLevel(indent_level + 2);
1608
1609 s->Printf ("Hook: %d\n", GetID());
1610 if (m_active)
1611 s->Indent ("State: enabled\n");
1612 else
1613 s->Indent ("State: disabled\n");
1614
1615 if (m_specifier_sp)
1616 {
1617 s->Indent();
1618 s->PutCString ("Specifier:\n");
1619 s->SetIndentLevel (indent_level + 4);
1620 m_specifier_sp->GetDescription (s, level);
1621 s->SetIndentLevel (indent_level + 2);
1622 }
1623
1624 if (m_thread_spec_ap.get() != NULL)
1625 {
1626 StreamString tmp;
1627 s->Indent("Thread:\n");
1628 m_thread_spec_ap->GetDescription (&tmp, level);
1629 s->SetIndentLevel (indent_level + 4);
1630 s->Indent (tmp.GetData());
1631 s->PutCString ("\n");
1632 s->SetIndentLevel (indent_level + 2);
1633 }
1634
1635 s->Indent ("Commands: \n");
1636 s->SetIndentLevel (indent_level + 4);
1637 uint32_t num_commands = m_commands.GetSize();
1638 for (uint32_t i = 0; i < num_commands; i++)
1639 {
1640 s->Indent(m_commands.GetStringAtIndex(i));
1641 s->PutCString ("\n");
1642 }
1643 s->SetIndentLevel (indent_level);
1644}
1645
1646
Caroline Tice5bc8c972010-09-20 20:44:43 +00001647//--------------------------------------------------------------
1648// class Target::SettingsController
1649//--------------------------------------------------------------
1650
1651Target::SettingsController::SettingsController () :
1652 UserSettingsController ("target", Debugger::GetSettingsController()),
1653 m_default_architecture ()
1654{
1655 m_default_settings.reset (new TargetInstanceSettings (*this, false,
1656 InstanceSettings::GetDefaultName().AsCString()));
1657}
1658
1659Target::SettingsController::~SettingsController ()
1660{
1661}
1662
1663lldb::InstanceSettingsSP
1664Target::SettingsController::CreateInstanceSettings (const char *instance_name)
1665{
Greg Claytonc0c1b0c2010-11-19 03:46:01 +00001666 TargetInstanceSettings *new_settings = new TargetInstanceSettings (*GetSettingsController(),
1667 false,
1668 instance_name);
Caroline Tice5bc8c972010-09-20 20:44:43 +00001669 lldb::InstanceSettingsSP new_settings_sp (new_settings);
1670 return new_settings_sp;
1671}
1672
Caroline Tice5bc8c972010-09-20 20:44:43 +00001673
Jim Inghame41494a2011-04-16 00:01:13 +00001674#define TSC_DEFAULT_ARCH "default-arch"
1675#define TSC_EXPR_PREFIX "expr-prefix"
Jim Inghame41494a2011-04-16 00:01:13 +00001676#define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
Greg Clayton17cd9952011-04-22 03:55:06 +00001677#define TSC_SKIP_PROLOGUE "skip-prologue"
Greg Claytonff44ab42011-04-23 02:04:55 +00001678#define TSC_SOURCE_MAP "source-map"
Enrico Granata018921d2011-08-12 02:00:06 +00001679#define TSC_MAX_CHILDREN "max-children-count"
Enrico Granata91544802011-09-06 19:20:51 +00001680#define TSC_MAX_STRLENSUMMARY "max-string-summary-length"
Greg Claytond284b662011-02-18 01:44:25 +00001681
1682
1683static const ConstString &
1684GetSettingNameForDefaultArch ()
1685{
1686 static ConstString g_const_string (TSC_DEFAULT_ARCH);
Greg Claytond284b662011-02-18 01:44:25 +00001687 return g_const_string;
Caroline Tice5bc8c972010-09-20 20:44:43 +00001688}
1689
Greg Claytond284b662011-02-18 01:44:25 +00001690static const ConstString &
1691GetSettingNameForExpressionPrefix ()
1692{
1693 static ConstString g_const_string (TSC_EXPR_PREFIX);
1694 return g_const_string;
1695}
1696
1697static const ConstString &
Jim Inghame41494a2011-04-16 00:01:13 +00001698GetSettingNameForPreferDynamicValue ()
1699{
1700 static ConstString g_const_string (TSC_PREFER_DYNAMIC);
1701 return g_const_string;
1702}
1703
Greg Claytonff44ab42011-04-23 02:04:55 +00001704static const ConstString &
1705GetSettingNameForSourcePathMap ()
1706{
1707 static ConstString g_const_string (TSC_SOURCE_MAP);
1708 return g_const_string;
1709}
Greg Claytond284b662011-02-18 01:44:25 +00001710
Greg Clayton17cd9952011-04-22 03:55:06 +00001711static const ConstString &
1712GetSettingNameForSkipPrologue ()
1713{
1714 static ConstString g_const_string (TSC_SKIP_PROLOGUE);
1715 return g_const_string;
1716}
1717
Enrico Granata018921d2011-08-12 02:00:06 +00001718static const ConstString &
1719GetSettingNameForMaxChildren ()
1720{
1721 static ConstString g_const_string (TSC_MAX_CHILDREN);
1722 return g_const_string;
1723}
Greg Clayton17cd9952011-04-22 03:55:06 +00001724
Enrico Granata91544802011-09-06 19:20:51 +00001725static const ConstString &
1726GetSettingNameForMaxStringSummaryLength ()
1727{
1728 static ConstString g_const_string (TSC_MAX_STRLENSUMMARY);
1729 return g_const_string;
1730}
Greg Clayton17cd9952011-04-22 03:55:06 +00001731
Caroline Tice5bc8c972010-09-20 20:44:43 +00001732bool
1733Target::SettingsController::SetGlobalVariable (const ConstString &var_name,
1734 const char *index_value,
1735 const char *value,
1736 const SettingEntry &entry,
Greg Claytonb3448432011-03-24 21:19:54 +00001737 const VarSetOperationType op,
Caroline Tice5bc8c972010-09-20 20:44:43 +00001738 Error&err)
1739{
Greg Claytond284b662011-02-18 01:44:25 +00001740 if (var_name == GetSettingNameForDefaultArch())
Caroline Tice5bc8c972010-09-20 20:44:43 +00001741 {
Greg Claytonf15996e2011-04-07 22:46:35 +00001742 m_default_architecture.SetTriple (value, NULL);
Greg Clayton940b1032011-02-23 00:35:02 +00001743 if (!m_default_architecture.IsValid())
1744 err.SetErrorStringWithFormat ("'%s' is not a valid architecture or triple.", value);
Caroline Tice5bc8c972010-09-20 20:44:43 +00001745 }
1746 return true;
1747}
1748
1749
1750bool
1751Target::SettingsController::GetGlobalVariable (const ConstString &var_name,
1752 StringList &value,
1753 Error &err)
1754{
Greg Claytond284b662011-02-18 01:44:25 +00001755 if (var_name == GetSettingNameForDefaultArch())
Caroline Tice5bc8c972010-09-20 20:44:43 +00001756 {
Greg Claytonbf6e2102010-10-27 02:06:37 +00001757 // If the arch is invalid (the default), don't show a string for it
1758 if (m_default_architecture.IsValid())
Greg Clayton940b1032011-02-23 00:35:02 +00001759 value.AppendString (m_default_architecture.GetArchitectureName());
Caroline Tice5bc8c972010-09-20 20:44:43 +00001760 return true;
1761 }
1762 else
1763 err.SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
1764
1765 return false;
1766}
1767
1768//--------------------------------------------------------------
1769// class TargetInstanceSettings
1770//--------------------------------------------------------------
1771
Greg Clayton638351a2010-12-04 00:10:17 +00001772TargetInstanceSettings::TargetInstanceSettings
1773(
1774 UserSettingsController &owner,
1775 bool live_instance,
1776 const char *name
1777) :
Greg Claytond284b662011-02-18 01:44:25 +00001778 InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
Greg Claytonff44ab42011-04-23 02:04:55 +00001779 m_expr_prefix_file (),
1780 m_expr_prefix_contents_sp (),
Jim Ingham10de7d12011-05-04 03:43:18 +00001781 m_prefer_dynamic_value (2),
Greg Claytonff44ab42011-04-23 02:04:55 +00001782 m_skip_prologue (true, true),
Enrico Granata018921d2011-08-12 02:00:06 +00001783 m_source_map (NULL, NULL),
Enrico Granata91544802011-09-06 19:20:51 +00001784 m_max_children_display(256),
1785 m_max_strlen_length(1024)
Caroline Tice5bc8c972010-09-20 20:44:43 +00001786{
1787 // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
1788 // until the vtables for TargetInstanceSettings are properly set up, i.e. AFTER all the initializers.
1789 // For this reason it has to be called here, rather than in the initializer or in the parent constructor.
1790 // This is true for CreateInstanceName() too.
1791
1792 if (GetInstanceName () == InstanceSettings::InvalidName())
1793 {
1794 ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
1795 m_owner.RegisterInstanceSettings (this);
1796 }
1797
1798 if (live_instance)
1799 {
1800 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1801 CopyInstanceSettings (pending_settings,false);
Caroline Tice5bc8c972010-09-20 20:44:43 +00001802 }
1803}
1804
1805TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) :
Greg Claytonff44ab42011-04-23 02:04:55 +00001806 InstanceSettings (*Target::GetSettingsController(), CreateInstanceName().AsCString()),
1807 m_expr_prefix_file (rhs.m_expr_prefix_file),
1808 m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp),
1809 m_prefer_dynamic_value (rhs.m_prefer_dynamic_value),
1810 m_skip_prologue (rhs.m_skip_prologue),
Enrico Granata018921d2011-08-12 02:00:06 +00001811 m_source_map (rhs.m_source_map),
Enrico Granata91544802011-09-06 19:20:51 +00001812 m_max_children_display(rhs.m_max_children_display),
1813 m_max_strlen_length(rhs.m_max_strlen_length)
Caroline Tice5bc8c972010-09-20 20:44:43 +00001814{
1815 if (m_instance_name != InstanceSettings::GetDefaultName())
1816 {
1817 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1818 CopyInstanceSettings (pending_settings,false);
Caroline Tice5bc8c972010-09-20 20:44:43 +00001819 }
1820}
1821
1822TargetInstanceSettings::~TargetInstanceSettings ()
1823{
1824}
1825
1826TargetInstanceSettings&
1827TargetInstanceSettings::operator= (const TargetInstanceSettings &rhs)
1828{
1829 if (this != &rhs)
1830 {
1831 }
1832
1833 return *this;
1834}
1835
Caroline Tice5bc8c972010-09-20 20:44:43 +00001836void
1837TargetInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
1838 const char *index_value,
1839 const char *value,
1840 const ConstString &instance_name,
1841 const SettingEntry &entry,
Greg Claytonb3448432011-03-24 21:19:54 +00001842 VarSetOperationType op,
Caroline Tice5bc8c972010-09-20 20:44:43 +00001843 Error &err,
1844 bool pending)
1845{
Greg Claytond284b662011-02-18 01:44:25 +00001846 if (var_name == GetSettingNameForExpressionPrefix ())
Sean Callanan77e93942010-10-29 00:29:03 +00001847 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001848 err = UserSettingsController::UpdateFileSpecOptionValue (value, op, m_expr_prefix_file);
1849 if (err.Success())
Sean Callanan77e93942010-10-29 00:29:03 +00001850 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001851 switch (op)
Sean Callanan77e93942010-10-29 00:29:03 +00001852 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001853 default:
1854 break;
1855 case eVarSetOperationAssign:
1856 case eVarSetOperationAppend:
Sean Callanan77e93942010-10-29 00:29:03 +00001857 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001858 if (!m_expr_prefix_file.GetCurrentValue().Exists())
1859 {
1860 err.SetErrorToGenericError ();
1861 err.SetErrorStringWithFormat ("%s does not exist.\n", value);
1862 return;
1863 }
1864
1865 m_expr_prefix_contents_sp = m_expr_prefix_file.GetCurrentValue().ReadFileContents();
1866
1867 if (!m_expr_prefix_contents_sp && m_expr_prefix_contents_sp->GetByteSize() == 0)
1868 {
1869 err.SetErrorStringWithFormat ("Couldn't read data from '%s'\n", value);
1870 m_expr_prefix_contents_sp.reset();
1871 }
Sean Callanan77e93942010-10-29 00:29:03 +00001872 }
Greg Claytonff44ab42011-04-23 02:04:55 +00001873 break;
1874 case eVarSetOperationClear:
1875 m_expr_prefix_contents_sp.reset();
Sean Callanan77e93942010-10-29 00:29:03 +00001876 }
Sean Callanan77e93942010-10-29 00:29:03 +00001877 }
1878 }
Jim Inghame41494a2011-04-16 00:01:13 +00001879 else if (var_name == GetSettingNameForPreferDynamicValue())
1880 {
Jim Ingham10de7d12011-05-04 03:43:18 +00001881 int new_value;
1882 UserSettingsController::UpdateEnumVariable (g_dynamic_value_types, &new_value, value, err);
1883 if (err.Success())
1884 m_prefer_dynamic_value = new_value;
Greg Clayton17cd9952011-04-22 03:55:06 +00001885 }
1886 else if (var_name == GetSettingNameForSkipPrologue())
1887 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001888 err = UserSettingsController::UpdateBooleanOptionValue (value, op, m_skip_prologue);
1889 }
Enrico Granata018921d2011-08-12 02:00:06 +00001890 else if (var_name == GetSettingNameForMaxChildren())
1891 {
1892 bool ok;
1893 uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok);
1894 if (ok)
1895 m_max_children_display = new_value;
1896 }
Enrico Granata91544802011-09-06 19:20:51 +00001897 else if (var_name == GetSettingNameForMaxStringSummaryLength())
1898 {
1899 bool ok;
1900 uint32_t new_value = Args::StringToUInt32(value, 0, 10, &ok);
1901 if (ok)
1902 m_max_strlen_length = new_value;
1903 }
Greg Claytonff44ab42011-04-23 02:04:55 +00001904 else if (var_name == GetSettingNameForSourcePathMap ())
1905 {
1906 switch (op)
1907 {
1908 case eVarSetOperationReplace:
1909 case eVarSetOperationInsertBefore:
1910 case eVarSetOperationInsertAfter:
1911 case eVarSetOperationRemove:
1912 default:
1913 break;
1914 case eVarSetOperationAssign:
1915 m_source_map.Clear(true);
1916 // Fall through to append....
1917 case eVarSetOperationAppend:
1918 {
1919 Args args(value);
1920 const uint32_t argc = args.GetArgumentCount();
1921 if (argc & 1 || argc == 0)
1922 {
1923 err.SetErrorStringWithFormat ("an even number of paths must be supplied to to the source-map setting: %u arguments given", argc);
1924 }
1925 else
1926 {
1927 char resolved_new_path[PATH_MAX];
1928 FileSpec file_spec;
1929 const char *old_path;
1930 for (uint32_t idx = 0; (old_path = args.GetArgumentAtIndex(idx)) != NULL; idx += 2)
1931 {
1932 const char *new_path = args.GetArgumentAtIndex(idx+1);
1933 assert (new_path); // We have an even number of paths, this shouldn't happen!
1934
1935 file_spec.SetFile(new_path, true);
1936 if (file_spec.Exists())
1937 {
1938 if (file_spec.GetPath (resolved_new_path, sizeof(resolved_new_path)) >= sizeof(resolved_new_path))
1939 {
1940 err.SetErrorStringWithFormat("new path '%s' is too long", new_path);
1941 return;
1942 }
1943 }
1944 else
1945 {
1946 err.SetErrorStringWithFormat("new path '%s' doesn't exist", new_path);
1947 return;
1948 }
1949 m_source_map.Append(ConstString (old_path), ConstString (resolved_new_path), true);
1950 }
1951 }
1952 }
1953 break;
1954
1955 case eVarSetOperationClear:
1956 m_source_map.Clear(true);
1957 break;
1958 }
Jim Inghame41494a2011-04-16 00:01:13 +00001959 }
Caroline Tice5bc8c972010-09-20 20:44:43 +00001960}
1961
1962void
Greg Claytond284b662011-02-18 01:44:25 +00001963TargetInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending)
Caroline Tice5bc8c972010-09-20 20:44:43 +00001964{
Sean Callanan77e93942010-10-29 00:29:03 +00001965 TargetInstanceSettings *new_settings_ptr = static_cast <TargetInstanceSettings *> (new_settings.get());
1966
1967 if (!new_settings_ptr)
1968 return;
1969
Greg Claytonff44ab42011-04-23 02:04:55 +00001970 m_expr_prefix_file = new_settings_ptr->m_expr_prefix_file;
1971 m_expr_prefix_contents_sp = new_settings_ptr->m_expr_prefix_contents_sp;
1972 m_prefer_dynamic_value = new_settings_ptr->m_prefer_dynamic_value;
1973 m_skip_prologue = new_settings_ptr->m_skip_prologue;
Enrico Granata018921d2011-08-12 02:00:06 +00001974 m_max_children_display = new_settings_ptr->m_max_children_display;
Enrico Granata91544802011-09-06 19:20:51 +00001975 m_max_strlen_length = new_settings_ptr->m_max_strlen_length;
Caroline Tice5bc8c972010-09-20 20:44:43 +00001976}
1977
Caroline Ticebcb5b452010-09-20 21:37:42 +00001978bool
Caroline Tice5bc8c972010-09-20 20:44:43 +00001979TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
1980 const ConstString &var_name,
1981 StringList &value,
Caroline Ticebcb5b452010-09-20 21:37:42 +00001982 Error *err)
Caroline Tice5bc8c972010-09-20 20:44:43 +00001983{
Greg Claytond284b662011-02-18 01:44:25 +00001984 if (var_name == GetSettingNameForExpressionPrefix ())
Sean Callanan77e93942010-10-29 00:29:03 +00001985 {
Greg Claytonff44ab42011-04-23 02:04:55 +00001986 char path[PATH_MAX];
1987 const size_t path_len = m_expr_prefix_file.GetCurrentValue().GetPath (path, sizeof(path));
1988 if (path_len > 0)
1989 value.AppendString (path, path_len);
Sean Callanan77e93942010-10-29 00:29:03 +00001990 }
Jim Inghame41494a2011-04-16 00:01:13 +00001991 else if (var_name == GetSettingNameForPreferDynamicValue())
1992 {
Jim Ingham10de7d12011-05-04 03:43:18 +00001993 value.AppendString (g_dynamic_value_types[m_prefer_dynamic_value].string_value);
Jim Inghame41494a2011-04-16 00:01:13 +00001994 }
Greg Clayton17cd9952011-04-22 03:55:06 +00001995 else if (var_name == GetSettingNameForSkipPrologue())
1996 {
1997 if (m_skip_prologue)
1998 value.AppendString ("true");
1999 else
2000 value.AppendString ("false");
2001 }
Greg Claytonff44ab42011-04-23 02:04:55 +00002002 else if (var_name == GetSettingNameForSourcePathMap ())
2003 {
2004 }
Enrico Granata018921d2011-08-12 02:00:06 +00002005 else if (var_name == GetSettingNameForMaxChildren())
2006 {
2007 StreamString count_str;
2008 count_str.Printf ("%d", m_max_children_display);
2009 value.AppendString (count_str.GetData());
2010 }
Enrico Granata91544802011-09-06 19:20:51 +00002011 else if (var_name == GetSettingNameForMaxStringSummaryLength())
2012 {
2013 StreamString count_str;
2014 count_str.Printf ("%d", m_max_strlen_length);
2015 value.AppendString (count_str.GetData());
2016 }
Sean Callanan77e93942010-10-29 00:29:03 +00002017 else
2018 {
2019 if (err)
2020 err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
2021 return false;
2022 }
2023
2024 return true;
Caroline Tice5bc8c972010-09-20 20:44:43 +00002025}
2026
2027const ConstString
2028TargetInstanceSettings::CreateInstanceName ()
2029{
Caroline Tice5bc8c972010-09-20 20:44:43 +00002030 StreamString sstr;
Caroline Tice1ebef442010-09-27 00:30:10 +00002031 static int instance_count = 1;
2032
Caroline Tice5bc8c972010-09-20 20:44:43 +00002033 sstr.Printf ("target_%d", instance_count);
2034 ++instance_count;
2035
2036 const ConstString ret_val (sstr.GetData());
2037 return ret_val;
2038}
2039
2040//--------------------------------------------------
2041// Target::SettingsController Variable Tables
2042//--------------------------------------------------
Jim Ingham10de7d12011-05-04 03:43:18 +00002043OptionEnumValueElement
2044TargetInstanceSettings::g_dynamic_value_types[] =
2045{
Greg Clayton577fbc32011-05-30 00:39:48 +00002046{ eNoDynamicValues, "no-dynamic-values", "Don't calculate the dynamic type of values"},
2047{ eDynamicCanRunTarget, "run-target", "Calculate the dynamic type of values even if you have to run the target."},
2048{ eDynamicDontRunTarget, "no-run-target", "Calculate the dynamic type of values, but don't run the target."},
Jim Ingham10de7d12011-05-04 03:43:18 +00002049{ 0, NULL, NULL }
2050};
Caroline Tice5bc8c972010-09-20 20:44:43 +00002051
2052SettingEntry
2053Target::SettingsController::global_settings_table[] =
2054{
Greg Claytond284b662011-02-18 01:44:25 +00002055 // var-name var-type default enum init'd hidden help-text
2056 // ================= ================== =========== ==== ====== ====== =========================================================================
2057 { TSC_DEFAULT_ARCH , eSetVarTypeString , NULL , NULL, false, false, "Default architecture to choose, when there's a choice." },
2058 { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
2059};
2060
Caroline Tice5bc8c972010-09-20 20:44:43 +00002061SettingEntry
2062Target::SettingsController::instance_settings_table[] =
2063{
Enrico Granata91544802011-09-06 19:20:51 +00002064 // var-name var-type default enum init'd hidden help-text
2065 // ================= ================== =============== ======================= ====== ====== =========================================================================
2066 { TSC_EXPR_PREFIX , eSetVarTypeString , NULL , NULL, false, false, "Path to a file containing expressions to be prepended to all expressions." },
2067 { TSC_PREFER_DYNAMIC , eSetVarTypeEnum , NULL , g_dynamic_value_types, false, false, "Should printed values be shown as their dynamic value." },
2068 { TSC_SKIP_PROLOGUE , eSetVarTypeBoolean, "true" , NULL, false, false, "Skip function prologues when setting breakpoints by name." },
2069 { TSC_SOURCE_MAP , eSetVarTypeArray , NULL , NULL, false, false, "Source path remappings to use when locating source files from debug information." },
2070 { TSC_MAX_CHILDREN , eSetVarTypeInt , "256" , NULL, true, false, "Maximum number of children to expand in any level of depth." },
2071 { TSC_MAX_STRLENSUMMARY , eSetVarTypeInt , "1024" , NULL, true, false, "Maximum number of characters to show when using %s in summary strings." },
2072 { NULL , eSetVarTypeNone , NULL , NULL, false, false, NULL }
Caroline Tice5bc8c972010-09-20 20:44:43 +00002073};