blob: 179e4607c573d771f027f9c5d9765919aeff4afe [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- Debugger.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/lldb-private.h"
11#include "lldb/Core/ConnectionFileDescriptor.h"
12#include "lldb/Core/Debugger.h"
13#include "lldb/Core/InputReader.h"
14#include "lldb/Core/State.h"
Greg Clayton1b654882010-09-19 02:33:57 +000015#include "lldb/Core/StreamString.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000016#include "lldb/Core/Timer.h"
Greg Clayton66111032010-06-23 01:19:29 +000017#include "lldb/Interpreter/CommandInterpreter.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/Target/TargetList.h"
19#include "lldb/Target/Process.h"
Greg Clayton1b654882010-09-19 02:33:57 +000020#include "lldb/Target/RegisterContext.h"
21#include "lldb/Target/StopInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/Target/Thread.h"
23
24
25using namespace lldb;
26using namespace lldb_private;
27
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028
Greg Clayton1b654882010-09-19 02:33:57 +000029static uint32_t g_shared_debugger_refcount = 0;
Caroline Ticeebc1bb22010-06-30 16:22:25 +000030static lldb::user_id_t g_unique_id = 1;
31
Greg Clayton1b654882010-09-19 02:33:57 +000032#pragma mark Static Functions
33
34static Mutex &
35GetDebuggerListMutex ()
36{
37 static Mutex g_mutex(Mutex::eMutexTypeRecursive);
38 return g_mutex;
39}
40
41typedef std::vector<DebuggerSP> DebuggerList;
42
43static DebuggerList &
44GetDebuggerList()
45{
46 // hide the static debugger list inside a singleton accessor to avoid
47 // global init contructors
48 static DebuggerList g_list;
49 return g_list;
50}
51
52
53#pragma mark Debugger
54
Greg Clayton99d0faf2010-11-18 23:32:35 +000055UserSettingsControllerSP &
56Debugger::GetSettingsController ()
57{
58 static UserSettingsControllerSP g_settings_controller;
59 return g_settings_controller;
60}
61
Chris Lattner30fdc8d2010-06-08 16:52:24 +000062void
63Debugger::Initialize ()
64{
Greg Clayton66111032010-06-23 01:19:29 +000065 if (g_shared_debugger_refcount == 0)
Greg Clayton99d0faf2010-11-18 23:32:35 +000066 {
Greg Clayton99d0faf2010-11-18 23:32:35 +000067 UserSettingsControllerSP &usc = GetSettingsController();
68 usc.reset (new SettingsController);
69 UserSettingsController::InitializeSettingsController (usc,
70 SettingsController::global_settings_table,
71 SettingsController::instance_settings_table);
Greg Claytondbe54502010-11-19 03:46:01 +000072 lldb_private::Initialize();
Greg Clayton99d0faf2010-11-18 23:32:35 +000073 }
Greg Clayton66111032010-06-23 01:19:29 +000074 g_shared_debugger_refcount++;
Greg Clayton99d0faf2010-11-18 23:32:35 +000075
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076}
77
78void
79Debugger::Terminate ()
80{
Greg Clayton66111032010-06-23 01:19:29 +000081 if (g_shared_debugger_refcount > 0)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000082 {
Greg Clayton66111032010-06-23 01:19:29 +000083 g_shared_debugger_refcount--;
84 if (g_shared_debugger_refcount == 0)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085 {
Greg Claytondbe54502010-11-19 03:46:01 +000086 lldb_private::WillTerminate();
87 lldb_private::Terminate();
Greg Clayton99d0faf2010-11-18 23:32:35 +000088 UserSettingsControllerSP &usc = GetSettingsController();
89 UserSettingsController::FinalizeSettingsController (usc);
90 usc.reset();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000092 }
Greg Clayton99d0faf2010-11-18 23:32:35 +000093 // Clear our master list of debugger objects
94 Mutex::Locker locker (GetDebuggerListMutex ());
95 GetDebuggerList().clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000096}
97
Greg Clayton66111032010-06-23 01:19:29 +000098DebuggerSP
99Debugger::CreateInstance ()
100{
101 DebuggerSP debugger_sp (new Debugger);
102 // Scope for locker
103 {
104 Mutex::Locker locker (GetDebuggerListMutex ());
105 GetDebuggerList().push_back(debugger_sp);
106 }
107 return debugger_sp;
108}
109
110lldb::DebuggerSP
111Debugger::GetSP ()
112{
113 lldb::DebuggerSP debugger_sp;
114
115 Mutex::Locker locker (GetDebuggerListMutex ());
116 DebuggerList &debugger_list = GetDebuggerList();
117 DebuggerList::iterator pos, end = debugger_list.end();
118 for (pos = debugger_list.begin(); pos != end; ++pos)
119 {
120 if ((*pos).get() == this)
121 {
122 debugger_sp = *pos;
123 break;
124 }
125 }
126 return debugger_sp;
127}
128
Caroline Tice3df9a8d2010-09-04 00:03:46 +0000129lldb::DebuggerSP
130Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name)
131{
132 lldb::DebuggerSP debugger_sp;
133
134 Mutex::Locker locker (GetDebuggerListMutex ());
135 DebuggerList &debugger_list = GetDebuggerList();
136 DebuggerList::iterator pos, end = debugger_list.end();
137
138 for (pos = debugger_list.begin(); pos != end; ++pos)
139 {
140 if ((*pos).get()->m_instance_name == instance_name)
141 {
142 debugger_sp = *pos;
143 break;
144 }
145 }
146 return debugger_sp;
147}
Greg Clayton66111032010-06-23 01:19:29 +0000148
149TargetSP
150Debugger::FindTargetWithProcessID (lldb::pid_t pid)
151{
152 lldb::TargetSP target_sp;
153 Mutex::Locker locker (GetDebuggerListMutex ());
154 DebuggerList &debugger_list = GetDebuggerList();
155 DebuggerList::iterator pos, end = debugger_list.end();
156 for (pos = debugger_list.begin(); pos != end; ++pos)
157 {
158 target_sp = (*pos)->GetTargetList().FindTargetWithProcessID (pid);
159 if (target_sp)
160 break;
161 }
162 return target_sp;
163}
164
165
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000166Debugger::Debugger () :
Caroline Ticeebc1bb22010-06-30 16:22:25 +0000167 UserID (g_unique_id++),
Greg Claytondbe54502010-11-19 03:46:01 +0000168 DebuggerInstanceSettings (*GetSettingsController()),
Greg Claytond46c87a2010-12-04 02:39:47 +0000169 m_input_comm("debugger.input"),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000170 m_input_file (),
171 m_output_file (),
172 m_error_file (),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000173 m_target_list (),
174 m_listener ("lldb.Debugger"),
175 m_source_manager (),
Greg Clayton66111032010-06-23 01:19:29 +0000176 m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
177 m_exe_ctx (),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000178 m_input_readers (),
Greg Clayton4957bf62010-09-30 21:49:03 +0000179 m_input_reader_data ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000180{
Greg Claytond46c87a2010-12-04 02:39:47 +0000181 m_input_comm.SetCloseOnEOF(false);
Greg Clayton66111032010-06-23 01:19:29 +0000182 m_command_interpreter_ap->Initialize ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000183}
184
185Debugger::~Debugger ()
186{
Greg Clayton66111032010-06-23 01:19:29 +0000187 int num_targets = m_target_list.GetNumTargets();
188 for (int i = 0; i < num_targets; i++)
189 {
190 ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP());
191 if (process_sp)
192 process_sp->Destroy();
193 }
194 DisconnectInput();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000195}
196
197
198bool
199Debugger::GetAsyncExecution ()
200{
Greg Clayton66111032010-06-23 01:19:29 +0000201 return !m_command_interpreter_ap->GetSynchronous();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000202}
203
204void
205Debugger::SetAsyncExecution (bool async_execution)
206{
Greg Clayton66111032010-06-23 01:19:29 +0000207 m_command_interpreter_ap->SetSynchronous (!async_execution);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000208}
209
210void
211Debugger::DisconnectInput()
212{
213 m_input_comm.Clear ();
214}
215
216void
217Debugger::SetInputFileHandle (FILE *fh, bool tranfer_ownership)
218{
219 m_input_file.SetFileHandle (fh, tranfer_ownership);
220 if (m_input_file.GetFileHandle() == NULL)
221 m_input_file.SetFileHandle (stdin, false);
222
223 // Disconnect from any old connection if we had one
224 m_input_comm.Disconnect ();
225 m_input_comm.SetConnection (new ConnectionFileDescriptor (::fileno (GetInputFileHandle()), true));
226 m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this);
227
228 Error error;
229 if (m_input_comm.StartReadThread (&error) == false)
230 {
231 FILE *err_fh = GetErrorFileHandle();
232 if (err_fh)
233 {
234 ::fprintf (err_fh, "error: failed to main input read thread: %s", error.AsCString() ? error.AsCString() : "unkown error");
235 exit(1);
236 }
237 }
238
239}
240
241FILE *
242Debugger::GetInputFileHandle ()
243{
244 return m_input_file.GetFileHandle();
245}
246
247
248void
249Debugger::SetOutputFileHandle (FILE *fh, bool tranfer_ownership)
250{
251 m_output_file.SetFileHandle (fh, tranfer_ownership);
252 if (m_output_file.GetFileHandle() == NULL)
253 m_output_file.SetFileHandle (stdin, false);
254}
255
256FILE *
257Debugger::GetOutputFileHandle ()
258{
259 return m_output_file.GetFileHandle();
260}
261
262void
263Debugger::SetErrorFileHandle (FILE *fh, bool tranfer_ownership)
264{
265 m_error_file.SetFileHandle (fh, tranfer_ownership);
266 if (m_error_file.GetFileHandle() == NULL)
267 m_error_file.SetFileHandle (stdin, false);
268}
269
270
271FILE *
272Debugger::GetErrorFileHandle ()
273{
274 return m_error_file.GetFileHandle();
275}
276
277CommandInterpreter &
278Debugger::GetCommandInterpreter ()
279{
Greg Clayton66111032010-06-23 01:19:29 +0000280 assert (m_command_interpreter_ap.get());
281 return *m_command_interpreter_ap;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000282}
283
284Listener &
285Debugger::GetListener ()
286{
287 return m_listener;
288}
289
290
291TargetSP
Jim Ingham2976d002010-08-26 21:32:51 +0000292Debugger::GetSelectedTarget ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000293{
Jim Ingham2976d002010-08-26 21:32:51 +0000294 return m_target_list.GetSelectedTarget ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000295}
296
297ExecutionContext
Jim Ingham2976d002010-08-26 21:32:51 +0000298Debugger::GetSelectedExecutionContext ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000299{
300 ExecutionContext exe_ctx;
301 exe_ctx.Clear();
302
Jim Ingham2976d002010-08-26 21:32:51 +0000303 lldb::TargetSP target_sp = GetSelectedTarget();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000304 exe_ctx.target = target_sp.get();
305
306 if (target_sp)
307 {
308 exe_ctx.process = target_sp->GetProcessSP().get();
309 if (exe_ctx.process && exe_ctx.process->IsRunning() == false)
310 {
Jim Ingham2976d002010-08-26 21:32:51 +0000311 exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000312 if (exe_ctx.thread == NULL)
313 exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
314 if (exe_ctx.thread)
315 {
Jim Ingham2976d002010-08-26 21:32:51 +0000316 exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000317 if (exe_ctx.frame == NULL)
318 exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex (0).get();
319 }
320 }
321 }
322 return exe_ctx;
323
324}
325
326SourceManager &
327Debugger::GetSourceManager ()
328{
329 return m_source_manager;
330}
331
332
333TargetList&
334Debugger::GetTargetList ()
335{
336 return m_target_list;
337}
338
339void
340Debugger::DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len)
341{
Caroline Ticeefed6132010-11-19 20:47:54 +0000342 if (bytes_len > 0)
343 ((Debugger *)baton)->DispatchInput ((char *)bytes, bytes_len);
344 else
345 ((Debugger *)baton)->DispatchInputEndOfFile ();
346}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000347
348
349void
350Debugger::DispatchInput (const char *bytes, size_t bytes_len)
351{
Caroline Ticeefed6132010-11-19 20:47:54 +0000352 if (bytes == NULL || bytes_len == 0)
353 return;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000354
355 WriteToDefaultReader (bytes, bytes_len);
356}
357
358void
Caroline Ticeefed6132010-11-19 20:47:54 +0000359Debugger::DispatchInputInterrupt ()
360{
361 m_input_reader_data.clear();
362
363 if (!m_input_readers.empty())
364 {
365 while (CheckIfTopInputReaderIsDone ()) ;
366
367 InputReaderSP reader_sp(m_input_readers.top());
368 if (reader_sp)
369 reader_sp->Notify (eInputReaderInterrupt);
370
371 while (CheckIfTopInputReaderIsDone ()) ;
372 }
373}
374
375void
376Debugger::DispatchInputEndOfFile ()
377{
378 m_input_reader_data.clear();
379
380 if (!m_input_readers.empty())
381 {
382 while (CheckIfTopInputReaderIsDone ()) ;
383
384 InputReaderSP reader_sp(m_input_readers.top());
385 if (reader_sp)
386 reader_sp->Notify (eInputReaderEndOfFile);
387
388 while (CheckIfTopInputReaderIsDone ()) ;
389 }
390}
391
392void
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000393Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len)
394{
395 if (bytes && bytes_len)
396 m_input_reader_data.append (bytes, bytes_len);
397
398 if (m_input_reader_data.empty())
399 return;
400
401 while (!m_input_readers.empty() && !m_input_reader_data.empty())
402 {
403 while (CheckIfTopInputReaderIsDone ())
404 /* Do nothing. */;
405
406 // Get the input reader from the top of the stack
407 InputReaderSP reader_sp(m_input_readers.top());
408
409 if (!reader_sp)
410 break;
411
Greg Clayton471b31c2010-07-20 22:52:08 +0000412 size_t bytes_handled = reader_sp->HandleRawBytes (m_input_reader_data.c_str(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000413 m_input_reader_data.size());
414 if (bytes_handled)
415 {
416 m_input_reader_data.erase (0, bytes_handled);
417 }
418 else
419 {
420 // No bytes were handled, we might not have reached our
421 // granularity, just return and wait for more data
422 break;
423 }
424 }
425
426 // Flush out any input readers that are donesvn
427 while (CheckIfTopInputReaderIsDone ())
428 /* Do nothing. */;
429
430}
431
432void
433Debugger::PushInputReader (const InputReaderSP& reader_sp)
434{
435 if (!reader_sp)
436 return;
437 if (!m_input_readers.empty())
438 {
439 // Deactivate the old top reader
440 InputReaderSP top_reader_sp (m_input_readers.top());
441 if (top_reader_sp)
442 top_reader_sp->Notify (eInputReaderDeactivate);
443 }
444 m_input_readers.push (reader_sp);
445 reader_sp->Notify (eInputReaderActivate);
446 ActivateInputReader (reader_sp);
447}
448
449bool
450Debugger::PopInputReader (const lldb::InputReaderSP& pop_reader_sp)
451{
452 bool result = false;
453
454 // The reader on the stop of the stack is done, so let the next
455 // read on the stack referesh its prompt and if there is one...
456 if (!m_input_readers.empty())
457 {
458 InputReaderSP reader_sp(m_input_readers.top());
459
460 if (!pop_reader_sp || pop_reader_sp.get() == reader_sp.get())
461 {
462 m_input_readers.pop ();
463 reader_sp->Notify (eInputReaderDeactivate);
464 reader_sp->Notify (eInputReaderDone);
465 result = true;
466
467 if (!m_input_readers.empty())
468 {
469 reader_sp = m_input_readers.top();
470 if (reader_sp)
471 {
472 ActivateInputReader (reader_sp);
473 reader_sp->Notify (eInputReaderReactivate);
474 }
475 }
476 }
477 }
478 return result;
479}
480
481bool
482Debugger::CheckIfTopInputReaderIsDone ()
483{
484 bool result = false;
485 if (!m_input_readers.empty())
486 {
487 InputReaderSP reader_sp(m_input_readers.top());
488
489 if (reader_sp && reader_sp->IsDone())
490 {
491 result = true;
492 PopInputReader (reader_sp);
493 }
494 }
495 return result;
496}
497
498void
499Debugger::ActivateInputReader (const InputReaderSP &reader_sp)
500{
501 FILE *in_fh = GetInputFileHandle();
502
503 if (in_fh)
504 {
505 struct termios in_fh_termios;
506 int in_fd = fileno (in_fh);
507 if (::tcgetattr(in_fd, &in_fh_termios) == 0)
508 {
509 if (reader_sp->GetEcho())
510 in_fh_termios.c_lflag |= ECHO; // Turn on echoing
511 else
512 in_fh_termios.c_lflag &= ~ECHO; // Turn off echoing
513
514 switch (reader_sp->GetGranularity())
515 {
516 case eInputReaderGranularityByte:
517 case eInputReaderGranularityWord:
518 in_fh_termios.c_lflag &= ~ICANON; // Get one char at a time
519 break;
520
521 case eInputReaderGranularityLine:
522 case eInputReaderGranularityAll:
523 in_fh_termios.c_lflag |= ICANON; // Get lines at a time
524 break;
525
526 default:
527 break;
528 }
529 ::tcsetattr (in_fd, TCSANOW, &in_fh_termios);
530 }
531 }
532}
Greg Clayton66111032010-06-23 01:19:29 +0000533
534void
535Debugger::UpdateExecutionContext (ExecutionContext *override_context)
536{
537 m_exe_ctx.Clear();
538
539 if (override_context != NULL)
540 {
541 m_exe_ctx.target = override_context->target;
542 m_exe_ctx.process = override_context->process;
543 m_exe_ctx.thread = override_context->thread;
544 m_exe_ctx.frame = override_context->frame;
545 }
546 else
547 {
Jim Ingham2976d002010-08-26 21:32:51 +0000548 TargetSP target_sp (GetSelectedTarget());
Greg Clayton66111032010-06-23 01:19:29 +0000549 if (target_sp)
550 {
551 m_exe_ctx.target = target_sp.get();
552 m_exe_ctx.process = target_sp->GetProcessSP().get();
Johnny Chen725945d2010-09-03 22:35:47 +0000553 if (m_exe_ctx.process && m_exe_ctx.process->IsAlive() && !m_exe_ctx.process->IsRunning())
Greg Clayton66111032010-06-23 01:19:29 +0000554 {
Jim Ingham2976d002010-08-26 21:32:51 +0000555 m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetSelectedThread().get();
Greg Clayton66111032010-06-23 01:19:29 +0000556 if (m_exe_ctx.thread == NULL)
Jim Ingham59ce7fe2010-09-10 23:06:30 +0000557 {
Greg Clayton66111032010-06-23 01:19:29 +0000558 m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get();
Jim Ingham59ce7fe2010-09-10 23:06:30 +0000559 // If we didn't have a selected thread, select one here.
560 if (m_exe_ctx.thread != NULL)
Johnny Chenc13ee522010-09-14 00:53:53 +0000561 m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID());
Jim Ingham59ce7fe2010-09-10 23:06:30 +0000562 }
Greg Clayton66111032010-06-23 01:19:29 +0000563 if (m_exe_ctx.thread)
564 {
Jim Ingham2976d002010-08-26 21:32:51 +0000565 m_exe_ctx.frame = m_exe_ctx.thread->GetSelectedFrame().get();
Greg Clayton66111032010-06-23 01:19:29 +0000566 if (m_exe_ctx.frame == NULL)
Jim Ingham59ce7fe2010-09-10 23:06:30 +0000567 {
Greg Clayton66111032010-06-23 01:19:29 +0000568 m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get();
Jim Ingham59ce7fe2010-09-10 23:06:30 +0000569 // If we didn't have a selected frame select one here.
570 if (m_exe_ctx.frame != NULL)
571 m_exe_ctx.thread->SetSelectedFrame(m_exe_ctx.frame);
572 }
Greg Clayton66111032010-06-23 01:19:29 +0000573 }
574 }
575 }
576 }
577}
578
Caroline Ticeebc1bb22010-06-30 16:22:25 +0000579DebuggerSP
580Debugger::FindDebuggerWithID (lldb::user_id_t id)
581{
582 lldb::DebuggerSP debugger_sp;
583
584 Mutex::Locker locker (GetDebuggerListMutex ());
585 DebuggerList &debugger_list = GetDebuggerList();
586 DebuggerList::iterator pos, end = debugger_list.end();
587 for (pos = debugger_list.begin(); pos != end; ++pos)
588 {
589 if ((*pos).get()->GetID() == id)
590 {
591 debugger_sp = *pos;
592 break;
593 }
594 }
595 return debugger_sp;
596}
Caroline Tice3df9a8d2010-09-04 00:03:46 +0000597
Greg Clayton1b654882010-09-19 02:33:57 +0000598static void
599TestPromptFormats (StackFrame *frame)
600{
601 if (frame == NULL)
602 return;
603
604 StreamString s;
605 const char *prompt_format =
606 "{addr = '${addr}'\n}"
607 "{process.id = '${process.id}'\n}"
608 "{process.name = '${process.name}'\n}"
609 "{process.file.basename = '${process.file.basename}'\n}"
610 "{process.file.fullpath = '${process.file.fullpath}'\n}"
611 "{thread.id = '${thread.id}'\n}"
612 "{thread.index = '${thread.index}'\n}"
613 "{thread.name = '${thread.name}'\n}"
614 "{thread.queue = '${thread.queue}'\n}"
615 "{thread.stop-reason = '${thread.stop-reason}'\n}"
616 "{target.arch = '${target.arch}'\n}"
617 "{module.file.basename = '${module.file.basename}'\n}"
618 "{module.file.fullpath = '${module.file.fullpath}'\n}"
619 "{file.basename = '${file.basename}'\n}"
620 "{file.fullpath = '${file.fullpath}'\n}"
621 "{frame.index = '${frame.index}'\n}"
622 "{frame.pc = '${frame.pc}'\n}"
623 "{frame.sp = '${frame.sp}'\n}"
624 "{frame.fp = '${frame.fp}'\n}"
625 "{frame.flags = '${frame.flags}'\n}"
626 "{frame.reg.rdi = '${frame.reg.rdi}'\n}"
627 "{frame.reg.rip = '${frame.reg.rip}'\n}"
628 "{frame.reg.rsp = '${frame.reg.rsp}'\n}"
629 "{frame.reg.rbp = '${frame.reg.rbp}'\n}"
630 "{frame.reg.rflags = '${frame.reg.rflags}'\n}"
631 "{frame.reg.xmm0 = '${frame.reg.xmm0}'\n}"
632 "{frame.reg.carp = '${frame.reg.carp}'\n}"
633 "{function.id = '${function.id}'\n}"
634 "{function.name = '${function.name}'\n}"
635 "{function.addr-offset = '${function.addr-offset}'\n}"
636 "{function.line-offset = '${function.line-offset}'\n}"
637 "{function.pc-offset = '${function.pc-offset}'\n}"
638 "{line.file.basename = '${line.file.basename}'\n}"
639 "{line.file.fullpath = '${line.file.fullpath}'\n}"
640 "{line.number = '${line.number}'\n}"
641 "{line.start-addr = '${line.start-addr}'\n}"
642 "{line.end-addr = '${line.end-addr}'\n}"
643;
644
645 SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything));
646 ExecutionContext exe_ctx;
Greg Clayton0603aa92010-10-04 01:05:56 +0000647 frame->CalculateExecutionContext(exe_ctx);
Greg Clayton1b654882010-09-19 02:33:57 +0000648 const char *end = NULL;
649 if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end))
650 {
651 printf("%s\n", s.GetData());
652 }
653 else
654 {
655 printf ("error: at '%s'\n", end);
656 printf ("what we got: %s\n", s.GetData());
657 }
658}
659
660bool
661Debugger::FormatPrompt
662(
663 const char *format,
664 const SymbolContext *sc,
665 const ExecutionContext *exe_ctx,
666 const Address *addr,
667 Stream &s,
668 const char **end
669)
670{
671 bool success = true;
672 const char *p;
673 for (p = format; *p != '\0'; ++p)
674 {
675 size_t non_special_chars = ::strcspn (p, "${}\\");
676 if (non_special_chars > 0)
677 {
678 if (success)
679 s.Write (p, non_special_chars);
680 p += non_special_chars;
681 }
682
683 if (*p == '\0')
684 {
685 break;
686 }
687 else if (*p == '{')
688 {
689 // Start a new scope that must have everything it needs if it is to
690 // to make it into the final output stream "s". If you want to make
691 // a format that only prints out the function or symbol name if there
692 // is one in the symbol context you can use:
693 // "{function =${function.name}}"
694 // The first '{' starts a new scope that end with the matching '}' at
695 // the end of the string. The contents "function =${function.name}"
696 // will then be evaluated and only be output if there is a function
697 // or symbol with a valid name.
698 StreamString sub_strm;
699
700 ++p; // Skip the '{'
701
702 if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p))
703 {
704 // The stream had all it needed
705 s.Write(sub_strm.GetData(), sub_strm.GetSize());
706 }
707 if (*p != '}')
708 {
709 success = false;
710 break;
711 }
712 }
713 else if (*p == '}')
714 {
715 // End of a enclosing scope
716 break;
717 }
718 else if (*p == '$')
719 {
720 // We have a prompt variable to print
721 ++p;
722 if (*p == '{')
723 {
724 ++p;
725 const char *var_name_begin = p;
726 const char *var_name_end = ::strchr (p, '}');
727
728 if (var_name_end && var_name_begin < var_name_end)
729 {
730 // if we have already failed to parse, skip this variable
731 if (success)
732 {
733 const char *cstr = NULL;
734 Address format_addr;
735 bool calculate_format_addr_function_offset = false;
736 // Set reg_kind and reg_num to invalid values
737 RegisterKind reg_kind = kNumRegisterKinds;
738 uint32_t reg_num = LLDB_INVALID_REGNUM;
739 FileSpec format_file_spec;
740 const lldb::RegisterInfo *reg_info = NULL;
741 RegisterContext *reg_ctx = NULL;
742
743 // Each variable must set success to true below...
744 bool var_success = false;
745 switch (var_name_begin[0])
746 {
747 case 'a':
748 if (::strncmp (var_name_begin, "addr}", strlen("addr}")) == 0)
749 {
750 if (addr && addr->IsValid())
751 {
752 var_success = true;
753 format_addr = *addr;
754 }
755 }
756 break;
757
758 case 'p':
759 if (::strncmp (var_name_begin, "process.", strlen("process.")) == 0)
760 {
761 if (exe_ctx && exe_ctx->process != NULL)
762 {
763 var_name_begin += ::strlen ("process.");
764 if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
765 {
766 s.Printf("%i", exe_ctx->process->GetID());
767 var_success = true;
768 }
769 else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) ||
770 (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) ||
771 (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0))
772 {
773 ModuleSP exe_module_sp (exe_ctx->process->GetTarget().GetExecutableModule());
774 if (exe_module_sp)
775 {
776 if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f')
777 {
778 format_file_spec.GetFilename() = exe_module_sp->GetFileSpec().GetFilename();
779 var_success = format_file_spec;
780 }
781 else
782 {
783 format_file_spec = exe_module_sp->GetFileSpec();
784 var_success = format_file_spec;
785 }
786 }
787 }
788 }
789 }
790 break;
791
792 case 't':
793 if (::strncmp (var_name_begin, "thread.", strlen("thread.")) == 0)
794 {
795 if (exe_ctx && exe_ctx->thread)
796 {
797 var_name_begin += ::strlen ("thread.");
798 if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
799 {
800 s.Printf("0x%4.4x", exe_ctx->thread->GetID());
801 var_success = true;
802 }
803 else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
804 {
805 s.Printf("%u", exe_ctx->thread->GetIndexID());
806 var_success = true;
807 }
808 else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0)
809 {
810 cstr = exe_ctx->thread->GetName();
811 var_success = cstr && cstr[0];
812 if (var_success)
813 s.PutCString(cstr);
814 }
815 else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0)
816 {
817 cstr = exe_ctx->thread->GetQueueName();
818 var_success = cstr && cstr[0];
819 if (var_success)
820 s.PutCString(cstr);
821 }
822 else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0)
823 {
Jim Inghamb15bfc72010-10-20 00:39:53 +0000824 StopInfoSP stop_info_sp = exe_ctx->thread->GetStopInfo ();
825 if (stop_info_sp)
Greg Clayton1b654882010-09-19 02:33:57 +0000826 {
Jim Inghamb15bfc72010-10-20 00:39:53 +0000827 cstr = stop_info_sp->GetDescription();
Greg Clayton1b654882010-09-19 02:33:57 +0000828 if (cstr && cstr[0])
829 {
830 s.PutCString(cstr);
831 var_success = true;
832 }
833 }
834 }
835 }
836 }
837 else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0)
838 {
Greg Clayton0603aa92010-10-04 01:05:56 +0000839 Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
840 if (target)
Greg Clayton1b654882010-09-19 02:33:57 +0000841 {
Greg Clayton1b654882010-09-19 02:33:57 +0000842 var_name_begin += ::strlen ("target.");
843 if (::strncmp (var_name_begin, "arch}", strlen("arch}")) == 0)
844 {
845 ArchSpec arch (target->GetArchitecture ());
846 if (arch.IsValid())
847 {
848 s.PutCString (arch.AsCString());
849 var_success = true;
850 }
851 }
852 }
853 }
854 break;
855
856
857 case 'm':
858 if (::strncmp (var_name_begin, "module.", strlen("module.")) == 0)
859 {
Greg Clayton0603aa92010-10-04 01:05:56 +0000860 if (sc && sc->module_sp.get())
Greg Clayton1b654882010-09-19 02:33:57 +0000861 {
Greg Clayton0603aa92010-10-04 01:05:56 +0000862 Module *module = sc->module_sp.get();
Greg Clayton1b654882010-09-19 02:33:57 +0000863 var_name_begin += ::strlen ("module.");
864
865 if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0)
866 {
867 if (module->GetFileSpec())
868 {
869 var_name_begin += ::strlen ("file.");
870
871 if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0)
872 {
873 format_file_spec.GetFilename() = module->GetFileSpec().GetFilename();
874 var_success = format_file_spec;
875 }
876 else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0)
877 {
878 format_file_spec = module->GetFileSpec();
879 var_success = format_file_spec;
880 }
881 }
882 }
883 }
884 }
885 break;
886
887
888 case 'f':
889 if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0)
890 {
891 if (sc && sc->comp_unit != NULL)
892 {
893 var_name_begin += ::strlen ("file.");
894
895 if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0)
896 {
897 format_file_spec.GetFilename() = sc->comp_unit->GetFilename();
898 var_success = format_file_spec;
899 }
900 else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0)
901 {
902 format_file_spec = *sc->comp_unit;
903 var_success = format_file_spec;
904 }
905 }
906 }
907 else if (::strncmp (var_name_begin, "frame.", strlen("frame.")) == 0)
908 {
909 if (exe_ctx && exe_ctx->frame)
910 {
911 var_name_begin += ::strlen ("frame.");
912 if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0)
913 {
914 s.Printf("%u", exe_ctx->frame->GetFrameIndex());
915 var_success = true;
916 }
917 else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0)
918 {
919 reg_kind = eRegisterKindGeneric;
920 reg_num = LLDB_REGNUM_GENERIC_PC;
921 var_success = true;
922 }
923 else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0)
924 {
925 reg_kind = eRegisterKindGeneric;
926 reg_num = LLDB_REGNUM_GENERIC_SP;
927 var_success = true;
928 }
929 else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0)
930 {
931 reg_kind = eRegisterKindGeneric;
932 reg_num = LLDB_REGNUM_GENERIC_FP;
933 var_success = true;
934 }
935 else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0)
936 {
937 reg_kind = eRegisterKindGeneric;
938 reg_num = LLDB_REGNUM_GENERIC_FLAGS;
939 var_success = true;
940 }
941 else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0)
942 {
943 reg_ctx = exe_ctx->frame->GetRegisterContext();
944 if (reg_ctx)
945 {
946 var_name_begin += ::strlen ("reg.");
947 if (var_name_begin < var_name_end)
948 {
949 std::string reg_name (var_name_begin, var_name_end);
950 reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str());
951 if (reg_info)
952 var_success = true;
953 }
954 }
955 }
956 }
957 }
958 else if (::strncmp (var_name_begin, "function.", strlen("function.")) == 0)
959 {
960 if (sc && (sc->function != NULL || sc->symbol != NULL))
961 {
962 var_name_begin += ::strlen ("function.");
963 if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0)
964 {
965 if (sc->function)
966 s.Printf("function{0x%8.8x}", sc->function->GetID());
967 else
968 s.Printf("symbol[%u]", sc->symbol->GetID());
969
970 var_success = true;
971 }
972 else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0)
973 {
974 if (sc->function)
975 cstr = sc->function->GetName().AsCString (NULL);
976 else if (sc->symbol)
977 cstr = sc->symbol->GetName().AsCString (NULL);
978 if (cstr)
979 {
980 s.PutCString(cstr);
Greg Clayton0d9c9932010-10-04 17:26:49 +0000981
982 if (sc->block)
983 {
984 Block *inline_block = sc->block->GetContainingInlinedBlock ();
985 if (inline_block)
986 {
987 const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo();
988 if (inline_info)
989 {
990 s.PutCString(" [inlined] ");
991 inline_info->GetName().Dump(&s);
992 }
993 }
994 }
Greg Clayton1b654882010-09-19 02:33:57 +0000995 var_success = true;
996 }
997 }
998 else if (::strncmp (var_name_begin, "addr-offset}", strlen("addr-offset}")) == 0)
999 {
1000 var_success = addr != NULL;
1001 if (var_success)
1002 {
1003 format_addr = *addr;
1004 calculate_format_addr_function_offset = true;
1005 }
1006 }
1007 else if (::strncmp (var_name_begin, "line-offset}", strlen("line-offset}")) == 0)
1008 {
1009 var_success = sc->line_entry.range.GetBaseAddress().IsValid();
1010 if (var_success)
1011 {
1012 format_addr = sc->line_entry.range.GetBaseAddress();
1013 calculate_format_addr_function_offset = true;
1014 }
1015 }
1016 else if (::strncmp (var_name_begin, "pc-offset}", strlen("pc-offset}")) == 0)
1017 {
1018 var_success = exe_ctx->frame;
1019 if (var_success)
1020 {
1021 format_addr = exe_ctx->frame->GetFrameCodeAddress();
1022 calculate_format_addr_function_offset = true;
1023 }
1024 }
1025 }
1026 }
1027 break;
1028
1029 case 'l':
1030 if (::strncmp (var_name_begin, "line.", strlen("line.")) == 0)
1031 {
1032 if (sc && sc->line_entry.IsValid())
1033 {
1034 var_name_begin += ::strlen ("line.");
1035 if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0)
1036 {
1037 var_name_begin += ::strlen ("file.");
1038
1039 if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0)
1040 {
1041 format_file_spec.GetFilename() = sc->line_entry.file.GetFilename();
1042 var_success = format_file_spec;
1043 }
1044 else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0)
1045 {
1046 format_file_spec = sc->line_entry.file;
1047 var_success = format_file_spec;
1048 }
1049 }
1050 else if (::strncmp (var_name_begin, "number}", strlen("number}")) == 0)
1051 {
1052 var_success = true;
1053 s.Printf("%u", sc->line_entry.line);
1054 }
1055 else if ((::strncmp (var_name_begin, "start-addr}", strlen("start-addr}")) == 0) ||
1056 (::strncmp (var_name_begin, "end-addr}", strlen("end-addr}")) == 0))
1057 {
1058 var_success = sc && sc->line_entry.range.GetBaseAddress().IsValid();
1059 if (var_success)
1060 {
1061 format_addr = sc->line_entry.range.GetBaseAddress();
1062 if (var_name_begin[0] == 'e')
1063 format_addr.Slide (sc->line_entry.range.GetByteSize());
1064 }
1065 }
1066 }
1067 }
1068 break;
1069 }
1070
1071 if (var_success)
1072 {
1073 // If format addr is valid, then we need to print an address
1074 if (reg_num != LLDB_INVALID_REGNUM)
1075 {
1076 // We have a register value to display...
1077 if (reg_num == LLDB_REGNUM_GENERIC_PC && reg_kind == eRegisterKindGeneric)
1078 {
1079 format_addr = exe_ctx->frame->GetFrameCodeAddress();
1080 }
1081 else
1082 {
1083 if (reg_ctx == NULL)
1084 reg_ctx = exe_ctx->frame->GetRegisterContext();
1085
1086 if (reg_ctx)
1087 {
1088 if (reg_kind != kNumRegisterKinds)
1089 reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
1090 reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num);
1091 var_success = reg_info != NULL;
1092 }
1093 }
1094 }
1095
1096 if (reg_info != NULL)
1097 {
1098 DataExtractor reg_data;
1099 var_success = reg_ctx->ReadRegisterBytes (reg_info->kinds[eRegisterKindLLDB], reg_data);
1100 {
1101 reg_data.Dump(&s, 0, reg_info->format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0);
1102 }
1103 }
1104
1105 if (format_file_spec)
1106 {
1107 s << format_file_spec;
1108 }
1109
1110 // If format addr is valid, then we need to print an address
1111 if (format_addr.IsValid())
1112 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001113 var_success = false;
1114
Greg Clayton1b654882010-09-19 02:33:57 +00001115 if (calculate_format_addr_function_offset)
1116 {
1117 Address func_addr;
Greg Clayton1b654882010-09-19 02:33:57 +00001118
Greg Clayton0603aa92010-10-04 01:05:56 +00001119 if (sc)
1120 {
1121 if (sc->function)
Greg Clayton0d9c9932010-10-04 17:26:49 +00001122 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001123 func_addr = sc->function->GetAddressRange().GetBaseAddress();
Greg Clayton0d9c9932010-10-04 17:26:49 +00001124 if (sc->block)
1125 {
1126 // Check to make sure we aren't in an inline
1127 // function. If we are, use the inline block
1128 // range that contains "format_addr" since
1129 // blocks can be discontiguous.
1130 Block *inline_block = sc->block->GetContainingInlinedBlock ();
1131 AddressRange inline_range;
1132 if (inline_block && inline_block->GetRangeContainingAddress (format_addr, inline_range))
1133 func_addr = inline_range.GetBaseAddress();
1134 }
1135 }
Greg Clayton0603aa92010-10-04 01:05:56 +00001136 else if (sc->symbol && sc->symbol->GetAddressRangePtr())
1137 func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress();
1138 }
1139
1140 if (func_addr.IsValid())
Greg Clayton1b654882010-09-19 02:33:57 +00001141 {
1142 if (func_addr.GetSection() == format_addr.GetSection())
1143 {
1144 addr_t func_file_addr = func_addr.GetFileAddress();
1145 addr_t addr_file_addr = format_addr.GetFileAddress();
1146 if (addr_file_addr > func_file_addr)
Greg Clayton1b654882010-09-19 02:33:57 +00001147 s.Printf(" + %llu", addr_file_addr - func_file_addr);
Greg Clayton1b654882010-09-19 02:33:57 +00001148 else if (addr_file_addr < func_file_addr)
Greg Clayton1b654882010-09-19 02:33:57 +00001149 s.Printf(" - %llu", func_file_addr - addr_file_addr);
Greg Clayton0603aa92010-10-04 01:05:56 +00001150 var_success = true;
Greg Clayton1b654882010-09-19 02:33:57 +00001151 }
1152 else
Greg Clayton0603aa92010-10-04 01:05:56 +00001153 {
1154 Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
1155 if (target)
1156 {
1157 addr_t func_load_addr = func_addr.GetLoadAddress (target);
1158 addr_t addr_load_addr = format_addr.GetLoadAddress (target);
1159 if (addr_load_addr > func_load_addr)
1160 s.Printf(" + %llu", addr_load_addr - func_load_addr);
1161 else if (addr_load_addr < func_load_addr)
1162 s.Printf(" - %llu", func_load_addr - addr_load_addr);
1163 var_success = true;
1164 }
1165 }
Greg Clayton1b654882010-09-19 02:33:57 +00001166 }
1167 }
1168 else
1169 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001170 Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
Greg Clayton1b654882010-09-19 02:33:57 +00001171 addr_t vaddr = LLDB_INVALID_ADDRESS;
Greg Clayton0603aa92010-10-04 01:05:56 +00001172 if (exe_ctx && !target->GetSectionLoadList().IsEmpty())
1173 vaddr = format_addr.GetLoadAddress (target);
Greg Clayton1b654882010-09-19 02:33:57 +00001174 if (vaddr == LLDB_INVALID_ADDRESS)
1175 vaddr = format_addr.GetFileAddress ();
1176
1177 if (vaddr != LLDB_INVALID_ADDRESS)
Greg Clayton0603aa92010-10-04 01:05:56 +00001178 {
Greg Clayton35f1a0d2010-11-19 04:16:11 +00001179 int addr_width = 0;
1180 if (exe_ctx && exe_ctx->process)
1181 addr_width = exe_ctx->process->GetAddressByteSize() * 2;
1182 if (addr_width == 0)
1183 addr_width = 16;
1184 s.Printf("0x%*.*llx", addr_width, addr_width, vaddr);
Greg Clayton0603aa92010-10-04 01:05:56 +00001185 var_success = true;
1186 }
Greg Clayton1b654882010-09-19 02:33:57 +00001187 }
1188 }
1189 }
1190
1191 if (var_success == false)
1192 success = false;
1193 }
1194 p = var_name_end;
1195 }
1196 else
1197 break;
1198 }
1199 else
1200 {
1201 // We got a dollar sign with no '{' after it, it must just be a dollar sign
1202 s.PutChar(*p);
1203 }
1204 }
1205 else if (*p == '\\')
1206 {
1207 ++p; // skip the slash
1208 switch (*p)
1209 {
1210 case 'a': s.PutChar ('\a'); break;
1211 case 'b': s.PutChar ('\b'); break;
1212 case 'f': s.PutChar ('\f'); break;
1213 case 'n': s.PutChar ('\n'); break;
1214 case 'r': s.PutChar ('\r'); break;
1215 case 't': s.PutChar ('\t'); break;
1216 case 'v': s.PutChar ('\v'); break;
1217 case '\'': s.PutChar ('\''); break;
1218 case '\\': s.PutChar ('\\'); break;
1219 case '0':
1220 // 1 to 3 octal chars
1221 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001222 // Make a string that can hold onto the initial zero char,
1223 // up to 3 octal digits, and a terminating NULL.
1224 char oct_str[5] = { 0, 0, 0, 0, 0 };
1225
1226 int i;
1227 for (i=0; (p[i] >= '0' && p[i] <= '7') && i<4; ++i)
1228 oct_str[i] = p[i];
1229
1230 // We don't want to consume the last octal character since
1231 // the main for loop will do this for us, so we advance p by
1232 // one less than i (even if i is zero)
1233 p += i - 1;
1234 unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
1235 if (octal_value <= UINT8_MAX)
Greg Clayton1b654882010-09-19 02:33:57 +00001236 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001237 char octal_char = octal_value;
1238 s.Write (&octal_char, 1);
Greg Clayton1b654882010-09-19 02:33:57 +00001239 }
Greg Clayton1b654882010-09-19 02:33:57 +00001240 }
1241 break;
1242
1243 case 'x':
1244 // hex number in the format
Greg Clayton0603aa92010-10-04 01:05:56 +00001245 if (isxdigit(p[1]))
Greg Clayton1b654882010-09-19 02:33:57 +00001246 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001247 ++p; // Skip the 'x'
Greg Clayton1b654882010-09-19 02:33:57 +00001248
Greg Clayton0603aa92010-10-04 01:05:56 +00001249 // Make a string that can hold onto two hex chars plus a
1250 // NULL terminator
1251 char hex_str[3] = { 0,0,0 };
1252 hex_str[0] = *p;
1253 if (isxdigit(p[1]))
Greg Clayton1b654882010-09-19 02:33:57 +00001254 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001255 ++p; // Skip the first of the two hex chars
1256 hex_str[1] = *p;
1257 }
1258
1259 unsigned long hex_value = strtoul (hex_str, NULL, 16);
1260 if (hex_value <= UINT8_MAX)
Greg Clayton1b654882010-09-19 02:33:57 +00001261 s.PutChar (hex_value);
Greg Clayton0603aa92010-10-04 01:05:56 +00001262 }
1263 else
1264 {
1265 s.PutChar('x');
Greg Clayton1b654882010-09-19 02:33:57 +00001266 }
1267 break;
1268
1269 default:
Greg Clayton0603aa92010-10-04 01:05:56 +00001270 // Just desensitize any other character by just printing what
1271 // came after the '\'
1272 s << *p;
Greg Clayton1b654882010-09-19 02:33:57 +00001273 break;
1274
1275 }
1276
1277 }
1278 }
1279 if (end)
1280 *end = p;
1281 return success;
1282}
1283
1284#pragma mark Debugger::SettingsController
1285
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001286//--------------------------------------------------
Greg Clayton1b654882010-09-19 02:33:57 +00001287// class Debugger::SettingsController
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001288//--------------------------------------------------
1289
Greg Clayton1b654882010-09-19 02:33:57 +00001290Debugger::SettingsController::SettingsController () :
Caroline Tice101c7c22010-09-09 06:25:08 +00001291 UserSettingsController ("", lldb::UserSettingsControllerSP())
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001292{
Caroline Tice91123da2010-09-08 17:48:55 +00001293 m_default_settings.reset (new DebuggerInstanceSettings (*this, false,
1294 InstanceSettings::GetDefaultName().AsCString()));
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001295}
1296
Greg Clayton1b654882010-09-19 02:33:57 +00001297Debugger::SettingsController::~SettingsController ()
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001298{
1299}
1300
1301
1302lldb::InstanceSettingsSP
Greg Clayton1b654882010-09-19 02:33:57 +00001303Debugger::SettingsController::CreateInstanceSettings (const char *instance_name)
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001304{
Greg Claytondbe54502010-11-19 03:46:01 +00001305 DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*GetSettingsController(),
Caroline Tice91123da2010-09-08 17:48:55 +00001306 false, instance_name);
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001307 lldb::InstanceSettingsSP new_settings_sp (new_settings);
1308 return new_settings_sp;
1309}
1310
Greg Clayton1b654882010-09-19 02:33:57 +00001311#pragma mark DebuggerInstanceSettings
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001312//--------------------------------------------------
1313// class DebuggerInstanceSettings
1314//--------------------------------------------------
1315
Greg Claytona7015092010-09-18 01:14:36 +00001316DebuggerInstanceSettings::DebuggerInstanceSettings
1317(
1318 UserSettingsController &owner,
1319 bool live_instance,
1320 const char *name
1321) :
Greg Clayton85851dd2010-12-04 00:10:17 +00001322 InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance),
Greg Claytona7015092010-09-18 01:14:36 +00001323 m_term_width (80),
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001324 m_prompt (),
Greg Clayton0603aa92010-10-04 01:05:56 +00001325 m_frame_format (),
1326 m_thread_format (),
Caroline Ticedaccaa92010-09-20 20:44:43 +00001327 m_script_lang (),
Jim Ingham3bcdb292010-10-04 22:44:14 +00001328 m_use_external_editor (false),
1329 m_auto_confirm_on (false)
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001330{
Caroline Ticef20e8232010-09-09 18:26:37 +00001331 // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called
1332 // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers.
1333 // For this reason it has to be called here, rather than in the initializer or in the parent constructor.
Caroline Tice9e41c152010-09-16 19:05:55 +00001334 // The same is true of CreateInstanceName().
1335
1336 if (GetInstanceName() == InstanceSettings::InvalidName())
1337 {
1338 ChangeInstanceName (std::string (CreateInstanceName().AsCString()));
1339 m_owner.RegisterInstanceSettings (this);
1340 }
Caroline Ticef20e8232010-09-09 18:26:37 +00001341
1342 if (live_instance)
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001343 {
1344 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1345 CopyInstanceSettings (pending_settings, false);
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001346 }
1347}
1348
1349DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) :
Greg Clayton99d0faf2010-11-18 23:32:35 +00001350 InstanceSettings (*Debugger::GetSettingsController(), CreateInstanceName ().AsCString()),
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001351 m_prompt (rhs.m_prompt),
Greg Clayton0603aa92010-10-04 01:05:56 +00001352 m_frame_format (rhs.m_frame_format),
1353 m_thread_format (rhs.m_thread_format),
Caroline Ticedaccaa92010-09-20 20:44:43 +00001354 m_script_lang (rhs.m_script_lang),
Jim Ingham3bcdb292010-10-04 22:44:14 +00001355 m_use_external_editor (rhs.m_use_external_editor),
1356 m_auto_confirm_on(rhs.m_auto_confirm_on)
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001357{
1358 const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
1359 CopyInstanceSettings (pending_settings, false);
1360 m_owner.RemovePendingSettings (m_instance_name);
1361}
1362
1363DebuggerInstanceSettings::~DebuggerInstanceSettings ()
1364{
1365}
1366
1367DebuggerInstanceSettings&
1368DebuggerInstanceSettings::operator= (const DebuggerInstanceSettings &rhs)
1369{
1370 if (this != &rhs)
1371 {
Greg Clayton1b654882010-09-19 02:33:57 +00001372 m_term_width = rhs.m_term_width;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001373 m_prompt = rhs.m_prompt;
Greg Clayton0603aa92010-10-04 01:05:56 +00001374 m_frame_format = rhs.m_frame_format;
1375 m_thread_format = rhs.m_thread_format;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001376 m_script_lang = rhs.m_script_lang;
Caroline Ticedaccaa92010-09-20 20:44:43 +00001377 m_use_external_editor = rhs.m_use_external_editor;
Jim Ingham3bcdb292010-10-04 22:44:14 +00001378 m_auto_confirm_on = rhs.m_auto_confirm_on;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001379 }
1380
1381 return *this;
1382}
1383
Greg Clayton1b654882010-09-19 02:33:57 +00001384bool
1385DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err)
1386{
1387 bool valid = false;
1388
1389 // Verify we have a value string.
1390 if (value == NULL || value[0] == '\0')
1391 {
1392 err.SetErrorString ("Missing value. Can't set terminal width without a value.\n");
1393 }
1394 else
1395 {
1396 char *end = NULL;
1397 const uint32_t width = ::strtoul (value, &end, 0);
1398
Johnny Chenea9fc182010-09-20 16:36:43 +00001399 if (end && end[0] == '\0')
Greg Clayton1b654882010-09-19 02:33:57 +00001400 {
Johnny Chen433d7742010-09-20 17:04:41 +00001401 if (width >= 10 && width <= 1024)
Greg Clayton1b654882010-09-19 02:33:57 +00001402 valid = true;
1403 else
1404 err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n");
1405 }
1406 else
1407 err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value);
1408 }
1409
1410 return valid;
1411}
1412
1413
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001414void
1415DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,
1416 const char *index_value,
1417 const char *value,
1418 const ConstString &instance_name,
1419 const SettingEntry &entry,
1420 lldb::VarSetOperationType op,
1421 Error &err,
1422 bool pending)
1423{
Greg Clayton0603aa92010-10-04 01:05:56 +00001424
1425 if (var_name == TermWidthVarName())
1426 {
1427 if (ValidTermWidthValue (value, err))
1428 {
1429 m_term_width = ::strtoul (value, NULL, 0);
1430 }
1431 }
1432 else if (var_name == PromptVarName())
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001433 {
Caroline Tice101c7c22010-09-09 06:25:08 +00001434 UserSettingsController::UpdateStringVariable (op, m_prompt, value, err);
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001435 if (!pending)
1436 {
Caroline Tice49e27372010-09-07 18:35:40 +00001437 // 'instance_name' is actually (probably) in the form '[<instance_name>]'; if so, we need to
1438 // strip off the brackets before passing it to BroadcastPromptChange.
1439
1440 std::string tmp_instance_name (instance_name.AsCString());
1441 if ((tmp_instance_name[0] == '[')
1442 && (tmp_instance_name[instance_name.GetLength() - 1] == ']'))
1443 tmp_instance_name = tmp_instance_name.substr (1, instance_name.GetLength() - 2);
1444 ConstString new_name (tmp_instance_name.c_str());
1445
1446 BroadcastPromptChange (new_name, m_prompt.c_str());
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001447 }
1448 }
Greg Clayton0603aa92010-10-04 01:05:56 +00001449 else if (var_name == GetFrameFormatName())
1450 {
1451 UserSettingsController::UpdateStringVariable (op, m_frame_format, value, err);
1452 }
1453 else if (var_name == GetThreadFormatName())
1454 {
1455 UserSettingsController::UpdateStringVariable (op, m_thread_format, value, err);
1456 }
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001457 else if (var_name == ScriptLangVarName())
1458 {
1459 bool success;
1460 m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault,
1461 &success);
1462 }
Caroline Ticedaccaa92010-09-20 20:44:43 +00001463 else if (var_name == UseExternalEditorVarName ())
1464 {
1465 UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, err);
1466 }
Jim Ingham3bcdb292010-10-04 22:44:14 +00001467 else if (var_name == AutoConfirmName ())
1468 {
1469 UserSettingsController::UpdateBooleanVariable (op, m_auto_confirm_on, value, err);
1470 }
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001471}
1472
Caroline Tice12cecd72010-09-20 21:37:42 +00001473bool
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001474DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
1475 const ConstString &var_name,
Caroline Ticedaccaa92010-09-20 20:44:43 +00001476 StringList &value,
Caroline Tice12cecd72010-09-20 21:37:42 +00001477 Error *err)
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001478{
1479 if (var_name == PromptVarName())
1480 {
Greg Clayton0603aa92010-10-04 01:05:56 +00001481 value.AppendString (m_prompt.c_str(), m_prompt.size());
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001482
1483 }
1484 else if (var_name == ScriptLangVarName())
1485 {
1486 value.AppendString (ScriptInterpreter::LanguageToString (m_script_lang).c_str());
1487 }
Caroline Tice101c7c22010-09-09 06:25:08 +00001488 else if (var_name == TermWidthVarName())
1489 {
1490 StreamString width_str;
1491 width_str.Printf ("%d", m_term_width);
1492 value.AppendString (width_str.GetData());
1493 }
Greg Clayton0603aa92010-10-04 01:05:56 +00001494 else if (var_name == GetFrameFormatName ())
1495 {
1496 value.AppendString(m_frame_format.c_str(), m_frame_format.size());
1497 }
1498 else if (var_name == GetThreadFormatName ())
1499 {
1500 value.AppendString(m_thread_format.c_str(), m_thread_format.size());
1501 }
Caroline Ticedaccaa92010-09-20 20:44:43 +00001502 else if (var_name == UseExternalEditorVarName())
1503 {
1504 if (m_use_external_editor)
1505 value.AppendString ("true");
1506 else
1507 value.AppendString ("false");
1508 }
Jim Ingham3bcdb292010-10-04 22:44:14 +00001509 else if (var_name == AutoConfirmName())
1510 {
1511 if (m_auto_confirm_on)
1512 value.AppendString ("true");
1513 else
1514 value.AppendString ("false");
1515 }
Caroline Ticedaccaa92010-09-20 20:44:43 +00001516 else
Caroline Tice12cecd72010-09-20 21:37:42 +00001517 {
1518 if (err)
1519 err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
1520 return false;
1521 }
1522 return true;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001523}
1524
1525void
1526DebuggerInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
1527 bool pending)
1528{
1529 if (new_settings.get() == NULL)
1530 return;
1531
1532 DebuggerInstanceSettings *new_debugger_settings = (DebuggerInstanceSettings *) new_settings.get();
1533
1534 m_prompt = new_debugger_settings->m_prompt;
1535 if (!pending)
Caroline Tice49e27372010-09-07 18:35:40 +00001536 {
1537 // 'instance_name' is actually (probably) in the form '[<instance_name>]'; if so, we need to
1538 // strip off the brackets before passing it to BroadcastPromptChange.
1539
1540 std::string tmp_instance_name (m_instance_name.AsCString());
1541 if ((tmp_instance_name[0] == '[')
1542 && (tmp_instance_name[m_instance_name.GetLength() - 1] == ']'))
1543 tmp_instance_name = tmp_instance_name.substr (1, m_instance_name.GetLength() - 2);
1544 ConstString new_name (tmp_instance_name.c_str());
1545
1546 BroadcastPromptChange (new_name, m_prompt.c_str());
1547 }
Greg Clayton0603aa92010-10-04 01:05:56 +00001548 m_frame_format = new_debugger_settings->m_frame_format;
1549 m_thread_format = new_debugger_settings->m_thread_format;
Caroline Ticedaccaa92010-09-20 20:44:43 +00001550 m_term_width = new_debugger_settings->m_term_width;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001551 m_script_lang = new_debugger_settings->m_script_lang;
Caroline Ticedaccaa92010-09-20 20:44:43 +00001552 m_use_external_editor = new_debugger_settings->m_use_external_editor;
Jim Ingham3bcdb292010-10-04 22:44:14 +00001553 m_auto_confirm_on = new_debugger_settings->m_auto_confirm_on;
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001554}
1555
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001556
1557bool
1558DebuggerInstanceSettings::BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt)
1559{
1560 std::string tmp_prompt;
1561
1562 if (new_prompt != NULL)
1563 {
1564 tmp_prompt = new_prompt ;
1565 int len = tmp_prompt.size();
1566 if (len > 1
1567 && (tmp_prompt[0] == '\'' || tmp_prompt[0] == '"')
1568 && (tmp_prompt[len-1] == tmp_prompt[0]))
1569 {
1570 tmp_prompt = tmp_prompt.substr(1,len-2);
1571 }
1572 len = tmp_prompt.size();
1573 if (tmp_prompt[len-1] != ' ')
1574 tmp_prompt.append(" ");
1575 }
1576 EventSP new_event_sp;
1577 new_event_sp.reset (new Event(CommandInterpreter::eBroadcastBitResetPrompt,
1578 new EventDataBytes (tmp_prompt.c_str())));
1579
1580 if (instance_name.GetLength() != 0)
1581 {
1582 // Set prompt for a particular instance.
1583 Debugger *dbg = Debugger::FindDebuggerWithInstanceName (instance_name).get();
1584 if (dbg != NULL)
1585 {
1586 dbg->GetCommandInterpreter().BroadcastEvent (new_event_sp);
1587 }
1588 }
1589
1590 return true;
1591}
1592
1593const ConstString
1594DebuggerInstanceSettings::CreateInstanceName ()
1595{
1596 static int instance_count = 1;
1597 StreamString sstr;
1598
1599 sstr.Printf ("debugger_%d", instance_count);
1600 ++instance_count;
1601
1602 const ConstString ret_val (sstr.GetData());
1603
1604 return ret_val;
1605}
1606
1607const ConstString &
1608DebuggerInstanceSettings::PromptVarName ()
1609{
1610 static ConstString prompt_var_name ("prompt");
1611
1612 return prompt_var_name;
1613}
1614
1615const ConstString &
Greg Clayton0603aa92010-10-04 01:05:56 +00001616DebuggerInstanceSettings::GetFrameFormatName ()
1617{
1618 static ConstString prompt_var_name ("frame-format");
1619
1620 return prompt_var_name;
1621}
1622
1623const ConstString &
1624DebuggerInstanceSettings::GetThreadFormatName ()
1625{
1626 static ConstString prompt_var_name ("thread-format");
1627
1628 return prompt_var_name;
1629}
1630
1631const ConstString &
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001632DebuggerInstanceSettings::ScriptLangVarName ()
1633{
1634 static ConstString script_lang_var_name ("script-lang");
1635
1636 return script_lang_var_name;
1637}
1638
Caroline Tice101c7c22010-09-09 06:25:08 +00001639const ConstString &
1640DebuggerInstanceSettings::TermWidthVarName ()
1641{
1642 static ConstString term_width_var_name ("term-width");
1643
1644 return term_width_var_name;
1645}
1646
Caroline Ticedaccaa92010-09-20 20:44:43 +00001647const ConstString &
1648DebuggerInstanceSettings::UseExternalEditorVarName ()
1649{
1650 static ConstString use_external_editor_var_name ("use-external-editor");
1651
1652 return use_external_editor_var_name;
1653}
1654
Jim Ingham3bcdb292010-10-04 22:44:14 +00001655const ConstString &
1656DebuggerInstanceSettings::AutoConfirmName ()
1657{
1658 static ConstString use_external_editor_var_name ("auto-confirm");
1659
1660 return use_external_editor_var_name;
1661}
1662
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001663//--------------------------------------------------
Greg Clayton1b654882010-09-19 02:33:57 +00001664// SettingsController Variable Tables
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001665//--------------------------------------------------
1666
1667
1668SettingEntry
Greg Clayton1b654882010-09-19 02:33:57 +00001669Debugger::SettingsController::global_settings_table[] =
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001670{
1671 //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
Caroline Tice101c7c22010-09-09 06:25:08 +00001672 // The Debugger level global table should always be empty; all Debugger settable variables should be instance
1673 // variables.
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001674 { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
1675};
1676
Greg Claytonbb562b12010-10-04 02:44:26 +00001677#define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name}${function.pc-offset}}}"
Greg Clayton0603aa92010-10-04 01:05:56 +00001678#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001679
Greg Clayton0603aa92010-10-04 01:05:56 +00001680#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
1681 "{, ${frame.pc}}"\
1682 MODULE_WITH_FUNC\
Greg Claytoncf4b9072010-10-04 17:04:23 +00001683 FILE_AND_LINE\
Greg Clayton0603aa92010-10-04 01:05:56 +00001684 "{, stop reason = ${thread.stop-reason}}"\
Greg Clayton0603aa92010-10-04 01:05:56 +00001685 "\\n"
1686
Greg Clayton315d2ca2010-11-02 01:53:21 +00001687//#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
1688// "{, ${frame.pc}}"\
1689// MODULE_WITH_FUNC\
1690// FILE_AND_LINE\
1691// "{, stop reason = ${thread.stop-reason}}"\
1692// "{, name = ${thread.name}}"\
1693// "{, queue = ${thread.queue}}"\
1694// "\\n"
1695
Greg Clayton0603aa92010-10-04 01:05:56 +00001696#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\
1697 MODULE_WITH_FUNC\
1698 FILE_AND_LINE\
1699 "\\n"
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001700
1701SettingEntry
Greg Clayton1b654882010-09-19 02:33:57 +00001702Debugger::SettingsController::instance_settings_table[] =
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001703{
Greg Clayton0603aa92010-10-04 01:05:56 +00001704// NAME Setting variable type Default Enum Init'd Hidden Help
1705// ======================= ======================= ====================== ==== ====== ====== ======================
Greg Clayton0603aa92010-10-04 01:05:56 +00001706{ "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." },
Greg Clayton54180392010-10-22 21:15:00 +00001707{ "prompt", eSetVarTypeString, "(lldb) ", NULL, false, false, "The debugger command line prompt displayed for the user." },
Jim Ingham3bcdb292010-10-04 22:44:14 +00001708{ "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." },
1709{ "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." },
Greg Clayton0603aa92010-10-04 01:05:56 +00001710{ "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." },
Jim Ingham06e827c2010-11-11 19:26:09 +00001711{ "use-external-editor", eSetVarTypeBoolean, "false", NULL, false, false, "Whether to use an external editor or not." },
1712{ "auto-confirm", eSetVarTypeBoolean, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." },
Greg Clayton0603aa92010-10-04 01:05:56 +00001713{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL }
Caroline Tice3df9a8d2010-09-04 00:03:46 +00001714};