Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 | |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 10 | #include "lldb/Core/Debugger.h" |
| 11 | |
| 12 | #include <map> |
| 13 | |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 14 | #include "clang/AST/DeclCXX.h" |
| 15 | #include "clang/AST/Type.h" |
| 16 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/lldb-private.h" |
| 18 | #include "lldb/Core/ConnectionFileDescriptor.h" |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 19 | #include "lldb/Core/FormatManager.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/InputReader.h" |
Greg Clayton | 7349bd9 | 2011-05-09 20:18:18 +0000 | [diff] [blame] | 21 | #include "lldb/Core/RegisterValue.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Core/State.h" |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 23 | #include "lldb/Core/StreamAsynchronousIO.h" |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 24 | #include "lldb/Core/StreamString.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 25 | #include "lldb/Core/Timer.h" |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 26 | #include "lldb/Core/ValueObject.h" |
Greg Clayton | a340661 | 2011-02-07 23:24:47 +0000 | [diff] [blame] | 27 | #include "lldb/Host/Terminal.h" |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 28 | #include "lldb/Interpreter/CommandInterpreter.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | #include "lldb/Target/TargetList.h" |
| 30 | #include "lldb/Target/Process.h" |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 31 | #include "lldb/Target/RegisterContext.h" |
| 32 | #include "lldb/Target/StopInfo.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | #include "lldb/Target/Thread.h" |
| 34 | |
| 35 | |
| 36 | using namespace lldb; |
| 37 | using namespace lldb_private; |
| 38 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 40 | static uint32_t g_shared_debugger_refcount = 0; |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 41 | static lldb::user_id_t g_unique_id = 1; |
| 42 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 43 | #pragma mark Static Functions |
| 44 | |
| 45 | static Mutex & |
| 46 | GetDebuggerListMutex () |
| 47 | { |
| 48 | static Mutex g_mutex(Mutex::eMutexTypeRecursive); |
| 49 | return g_mutex; |
| 50 | } |
| 51 | |
| 52 | typedef std::vector<DebuggerSP> DebuggerList; |
| 53 | |
| 54 | static DebuggerList & |
| 55 | GetDebuggerList() |
| 56 | { |
| 57 | // hide the static debugger list inside a singleton accessor to avoid |
| 58 | // global init contructors |
| 59 | static DebuggerList g_list; |
| 60 | return g_list; |
| 61 | } |
| 62 | |
| 63 | |
| 64 | #pragma mark Debugger |
| 65 | |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 66 | UserSettingsControllerSP & |
| 67 | Debugger::GetSettingsController () |
| 68 | { |
| 69 | static UserSettingsControllerSP g_settings_controller; |
| 70 | return g_settings_controller; |
| 71 | } |
| 72 | |
Caroline Tice | 2f88aad | 2011-01-14 00:29:16 +0000 | [diff] [blame] | 73 | int |
| 74 | Debugger::TestDebuggerRefCount () |
| 75 | { |
| 76 | return g_shared_debugger_refcount; |
| 77 | } |
| 78 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | void |
| 80 | Debugger::Initialize () |
| 81 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 82 | if (g_shared_debugger_refcount == 0) |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 83 | { |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 +0000 | [diff] [blame] | 84 | lldb_private::Initialize(); |
Enrico Granata | 217f91f | 2011-08-17 19:07:52 +0000 | [diff] [blame] | 85 | Debugger::FormatManagerInitialize(); |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 86 | } |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 87 | g_shared_debugger_refcount++; |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 88 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void |
| 92 | Debugger::Terminate () |
| 93 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 94 | if (g_shared_debugger_refcount > 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 95 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 96 | g_shared_debugger_refcount--; |
| 97 | if (g_shared_debugger_refcount == 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 98 | { |
Enrico Granata | 217f91f | 2011-08-17 19:07:52 +0000 | [diff] [blame] | 99 | Debugger::FormatManagerTerminate(); |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 +0000 | [diff] [blame] | 100 | lldb_private::WillTerminate(); |
| 101 | lldb_private::Terminate(); |
Caroline Tice | 6760a51 | 2011-01-17 21:55:19 +0000 | [diff] [blame] | 102 | |
| 103 | // Clear our master list of debugger objects |
| 104 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 105 | GetDebuggerList().clear(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 106 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | |
Caroline Tice | 20bd37f | 2011-03-10 22:14:10 +0000 | [diff] [blame] | 110 | void |
| 111 | Debugger::SettingsInitialize () |
| 112 | { |
| 113 | static bool g_initialized = false; |
| 114 | |
| 115 | if (!g_initialized) |
| 116 | { |
| 117 | g_initialized = true; |
| 118 | UserSettingsControllerSP &usc = GetSettingsController(); |
| 119 | usc.reset (new SettingsController); |
| 120 | UserSettingsController::InitializeSettingsController (usc, |
| 121 | SettingsController::global_settings_table, |
| 122 | SettingsController::instance_settings_table); |
| 123 | // Now call SettingsInitialize for each settings 'child' of Debugger |
| 124 | Target::SettingsInitialize (); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | void |
| 129 | Debugger::SettingsTerminate () |
| 130 | { |
| 131 | |
| 132 | // Must call SettingsTerminate() for each settings 'child' of Debugger, before terminating the Debugger's |
| 133 | // Settings. |
| 134 | |
| 135 | Target::SettingsTerminate (); |
| 136 | |
| 137 | // Now terminate the Debugger Settings. |
| 138 | |
| 139 | UserSettingsControllerSP &usc = GetSettingsController(); |
| 140 | UserSettingsController::FinalizeSettingsController (usc); |
| 141 | usc.reset(); |
| 142 | } |
| 143 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 144 | DebuggerSP |
| 145 | Debugger::CreateInstance () |
| 146 | { |
| 147 | DebuggerSP debugger_sp (new Debugger); |
| 148 | // Scope for locker |
| 149 | { |
| 150 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 151 | GetDebuggerList().push_back(debugger_sp); |
| 152 | } |
| 153 | return debugger_sp; |
| 154 | } |
| 155 | |
Caroline Tice | e02657b | 2011-01-22 01:02:07 +0000 | [diff] [blame] | 156 | void |
| 157 | Debugger::Destroy (lldb::DebuggerSP &debugger_sp) |
| 158 | { |
| 159 | if (debugger_sp.get() == NULL) |
| 160 | return; |
| 161 | |
| 162 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 163 | DebuggerList &debugger_list = GetDebuggerList (); |
| 164 | DebuggerList::iterator pos, end = debugger_list.end(); |
| 165 | for (pos = debugger_list.begin (); pos != end; ++pos) |
| 166 | { |
| 167 | if ((*pos).get() == debugger_sp.get()) |
| 168 | { |
| 169 | debugger_list.erase (pos); |
| 170 | return; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | } |
| 175 | |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 176 | lldb::DebuggerSP |
| 177 | Debugger::GetSP () |
| 178 | { |
| 179 | lldb::DebuggerSP debugger_sp; |
| 180 | |
| 181 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 182 | DebuggerList &debugger_list = GetDebuggerList(); |
| 183 | DebuggerList::iterator pos, end = debugger_list.end(); |
| 184 | for (pos = debugger_list.begin(); pos != end; ++pos) |
| 185 | { |
| 186 | if ((*pos).get() == this) |
| 187 | { |
| 188 | debugger_sp = *pos; |
| 189 | break; |
| 190 | } |
| 191 | } |
| 192 | return debugger_sp; |
| 193 | } |
| 194 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 195 | lldb::DebuggerSP |
| 196 | Debugger::FindDebuggerWithInstanceName (const ConstString &instance_name) |
| 197 | { |
| 198 | lldb::DebuggerSP debugger_sp; |
| 199 | |
| 200 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 201 | DebuggerList &debugger_list = GetDebuggerList(); |
| 202 | DebuggerList::iterator pos, end = debugger_list.end(); |
| 203 | |
| 204 | for (pos = debugger_list.begin(); pos != end; ++pos) |
| 205 | { |
| 206 | if ((*pos).get()->m_instance_name == instance_name) |
| 207 | { |
| 208 | debugger_sp = *pos; |
| 209 | break; |
| 210 | } |
| 211 | } |
| 212 | return debugger_sp; |
| 213 | } |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 214 | |
| 215 | TargetSP |
| 216 | Debugger::FindTargetWithProcessID (lldb::pid_t pid) |
| 217 | { |
| 218 | lldb::TargetSP target_sp; |
| 219 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 220 | DebuggerList &debugger_list = GetDebuggerList(); |
| 221 | DebuggerList::iterator pos, end = debugger_list.end(); |
| 222 | for (pos = debugger_list.begin(); pos != end; ++pos) |
| 223 | { |
| 224 | target_sp = (*pos)->GetTargetList().FindTargetWithProcessID (pid); |
| 225 | if (target_sp) |
| 226 | break; |
| 227 | } |
| 228 | return target_sp; |
| 229 | } |
| 230 | |
| 231 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 232 | Debugger::Debugger () : |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 233 | UserID (g_unique_id++), |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 +0000 | [diff] [blame] | 234 | DebuggerInstanceSettings (*GetSettingsController()), |
Greg Clayton | d46c87a | 2010-12-04 02:39:47 +0000 | [diff] [blame] | 235 | m_input_comm("debugger.input"), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 236 | m_input_file (), |
| 237 | m_output_file (), |
| 238 | m_error_file (), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | m_target_list (), |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 240 | m_platform_list (), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 241 | m_listener ("lldb.Debugger"), |
| 242 | m_source_manager (), |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 243 | m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 244 | m_input_reader_stack (), |
Greg Clayton | 4957bf6 | 2010-09-30 21:49:03 +0000 | [diff] [blame] | 245 | m_input_reader_data () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 246 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 247 | m_command_interpreter_ap->Initialize (); |
Greg Clayton | ded470d | 2011-03-19 01:12:21 +0000 | [diff] [blame] | 248 | // Always add our default platform to the platform list |
| 249 | PlatformSP default_platform_sp (Platform::GetDefaultPlatform()); |
| 250 | assert (default_platform_sp.get()); |
| 251 | m_platform_list.Append (default_platform_sp, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | Debugger::~Debugger () |
| 255 | { |
Caroline Tice | 3d6086f | 2010-12-20 18:35:50 +0000 | [diff] [blame] | 256 | CleanUpInputReaders(); |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 257 | int num_targets = m_target_list.GetNumTargets(); |
| 258 | for (int i = 0; i < num_targets; i++) |
| 259 | { |
| 260 | ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); |
| 261 | if (process_sp) |
| 262 | process_sp->Destroy(); |
| 263 | } |
| 264 | DisconnectInput(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | |
| 268 | bool |
Greg Clayton | fc3f027 | 2011-05-29 04:06:55 +0000 | [diff] [blame] | 269 | Debugger::GetCloseInputOnEOF () const |
| 270 | { |
| 271 | return m_input_comm.GetCloseOnEOF(); |
| 272 | } |
| 273 | |
| 274 | void |
| 275 | Debugger::SetCloseInputOnEOF (bool b) |
| 276 | { |
| 277 | m_input_comm.SetCloseOnEOF(b); |
| 278 | } |
| 279 | |
| 280 | bool |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 281 | Debugger::GetAsyncExecution () |
| 282 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 283 | return !m_command_interpreter_ap->GetSynchronous(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void |
| 287 | Debugger::SetAsyncExecution (bool async_execution) |
| 288 | { |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 289 | m_command_interpreter_ap->SetSynchronous (!async_execution); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 292 | |
| 293 | void |
| 294 | Debugger::SetInputFileHandle (FILE *fh, bool tranfer_ownership) |
| 295 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 296 | File &in_file = GetInputFile(); |
| 297 | in_file.SetStream (fh, tranfer_ownership); |
| 298 | if (in_file.IsValid() == false) |
| 299 | in_file.SetStream (stdin, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 300 | |
| 301 | // Disconnect from any old connection if we had one |
| 302 | m_input_comm.Disconnect (); |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 303 | m_input_comm.SetConnection (new ConnectionFileDescriptor (in_file.GetDescriptor(), true)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 304 | m_input_comm.SetReadThreadBytesReceivedCallback (Debugger::DispatchInputCallback, this); |
| 305 | |
| 306 | Error error; |
| 307 | if (m_input_comm.StartReadThread (&error) == false) |
| 308 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 309 | File &err_file = GetErrorFile(); |
| 310 | |
| 311 | err_file.Printf ("error: failed to main input read thread: %s", error.AsCString() ? error.AsCString() : "unkown error"); |
| 312 | exit(1); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 313 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 314 | } |
| 315 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 316 | void |
| 317 | Debugger::SetOutputFileHandle (FILE *fh, bool tranfer_ownership) |
| 318 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 319 | File &out_file = GetOutputFile(); |
| 320 | out_file.SetStream (fh, tranfer_ownership); |
| 321 | if (out_file.IsValid() == false) |
| 322 | out_file.SetStream (stdout, false); |
Caroline Tice | 2f88aad | 2011-01-14 00:29:16 +0000 | [diff] [blame] | 323 | |
| 324 | GetCommandInterpreter().GetScriptInterpreter()->ResetOutputFileHandle (fh); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 327 | void |
| 328 | Debugger::SetErrorFileHandle (FILE *fh, bool tranfer_ownership) |
| 329 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 330 | File &err_file = GetErrorFile(); |
| 331 | err_file.SetStream (fh, tranfer_ownership); |
| 332 | if (err_file.IsValid() == false) |
| 333 | err_file.SetStream (stderr, false); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 336 | ExecutionContext |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 337 | Debugger::GetSelectedExecutionContext () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 338 | { |
| 339 | ExecutionContext exe_ctx; |
| 340 | exe_ctx.Clear(); |
| 341 | |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 342 | lldb::TargetSP target_sp = GetSelectedTarget(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 343 | exe_ctx.target = target_sp.get(); |
| 344 | |
| 345 | if (target_sp) |
| 346 | { |
| 347 | exe_ctx.process = target_sp->GetProcessSP().get(); |
| 348 | if (exe_ctx.process && exe_ctx.process->IsRunning() == false) |
| 349 | { |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 350 | exe_ctx.thread = exe_ctx.process->GetThreadList().GetSelectedThread().get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 351 | if (exe_ctx.thread == NULL) |
| 352 | exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); |
| 353 | if (exe_ctx.thread) |
| 354 | { |
Jim Ingham | 2976d00 | 2010-08-26 21:32:51 +0000 | [diff] [blame] | 355 | exe_ctx.frame = exe_ctx.thread->GetSelectedFrame().get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 356 | if (exe_ctx.frame == NULL) |
| 357 | exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex (0).get(); |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | return exe_ctx; |
| 362 | |
| 363 | } |
| 364 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 365 | InputReaderSP |
| 366 | Debugger::GetCurrentInputReader () |
| 367 | { |
| 368 | InputReaderSP reader_sp; |
| 369 | |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 370 | if (!m_input_reader_stack.IsEmpty()) |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 371 | { |
| 372 | // Clear any finished readers from the stack |
| 373 | while (CheckIfTopInputReaderIsDone()) ; |
| 374 | |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 375 | if (!m_input_reader_stack.IsEmpty()) |
| 376 | reader_sp = m_input_reader_stack.Top(); |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | return reader_sp; |
| 380 | } |
| 381 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 382 | void |
| 383 | Debugger::DispatchInputCallback (void *baton, const void *bytes, size_t bytes_len) |
| 384 | { |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 385 | if (bytes_len > 0) |
| 386 | ((Debugger *)baton)->DispatchInput ((char *)bytes, bytes_len); |
| 387 | else |
| 388 | ((Debugger *)baton)->DispatchInputEndOfFile (); |
| 389 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | |
| 391 | |
| 392 | void |
| 393 | Debugger::DispatchInput (const char *bytes, size_t bytes_len) |
| 394 | { |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 395 | if (bytes == NULL || bytes_len == 0) |
| 396 | return; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 397 | |
| 398 | WriteToDefaultReader (bytes, bytes_len); |
| 399 | } |
| 400 | |
| 401 | void |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 402 | Debugger::DispatchInputInterrupt () |
| 403 | { |
| 404 | m_input_reader_data.clear(); |
| 405 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 406 | InputReaderSP reader_sp (GetCurrentInputReader ()); |
| 407 | if (reader_sp) |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 408 | { |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 409 | reader_sp->Notify (eInputReaderInterrupt); |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 410 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 411 | // If notifying the reader of the interrupt finished the reader, we should pop it off the stack. |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 412 | while (CheckIfTopInputReaderIsDone ()) ; |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | void |
| 417 | Debugger::DispatchInputEndOfFile () |
| 418 | { |
| 419 | m_input_reader_data.clear(); |
| 420 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 421 | InputReaderSP reader_sp (GetCurrentInputReader ()); |
| 422 | if (reader_sp) |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 423 | { |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 424 | reader_sp->Notify (eInputReaderEndOfFile); |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 425 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 426 | // If notifying the reader of the end-of-file finished the reader, we should pop it off the stack. |
Caroline Tice | efed613 | 2010-11-19 20:47:54 +0000 | [diff] [blame] | 427 | while (CheckIfTopInputReaderIsDone ()) ; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | void |
Caroline Tice | 3d6086f | 2010-12-20 18:35:50 +0000 | [diff] [blame] | 432 | Debugger::CleanUpInputReaders () |
| 433 | { |
| 434 | m_input_reader_data.clear(); |
| 435 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 436 | // The bottom input reader should be the main debugger input reader. We do not want to close that one here. |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 437 | while (m_input_reader_stack.GetSize() > 1) |
Caroline Tice | 3d6086f | 2010-12-20 18:35:50 +0000 | [diff] [blame] | 438 | { |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 439 | InputReaderSP reader_sp (GetCurrentInputReader ()); |
Caroline Tice | 3d6086f | 2010-12-20 18:35:50 +0000 | [diff] [blame] | 440 | if (reader_sp) |
| 441 | { |
| 442 | reader_sp->Notify (eInputReaderEndOfFile); |
| 443 | reader_sp->SetIsDone (true); |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | void |
Caroline Tice | 969ed3d | 2011-05-02 20:41:46 +0000 | [diff] [blame] | 449 | Debugger::NotifyTopInputReader (InputReaderAction notification) |
| 450 | { |
| 451 | InputReaderSP reader_sp (GetCurrentInputReader()); |
| 452 | if (reader_sp) |
| 453 | { |
| 454 | reader_sp->Notify (notification); |
| 455 | |
| 456 | // Flush out any input readers that are done. |
| 457 | while (CheckIfTopInputReaderIsDone ()) |
| 458 | /* Do nothing. */; |
| 459 | } |
| 460 | } |
| 461 | |
Caroline Tice | 9088b06 | 2011-05-09 23:06:58 +0000 | [diff] [blame] | 462 | bool |
| 463 | Debugger::InputReaderIsTopReader (const lldb::InputReaderSP& reader_sp) |
| 464 | { |
Caroline Tice | d61c10b | 2011-06-16 16:27:19 +0000 | [diff] [blame] | 465 | InputReaderSP top_reader_sp (GetCurrentInputReader()); |
Caroline Tice | 9088b06 | 2011-05-09 23:06:58 +0000 | [diff] [blame] | 466 | |
Caroline Tice | d61c10b | 2011-06-16 16:27:19 +0000 | [diff] [blame] | 467 | return (reader_sp.get() == top_reader_sp.get()); |
Caroline Tice | 9088b06 | 2011-05-09 23:06:58 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | |
Caroline Tice | 969ed3d | 2011-05-02 20:41:46 +0000 | [diff] [blame] | 471 | void |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 472 | Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len) |
| 473 | { |
| 474 | if (bytes && bytes_len) |
| 475 | m_input_reader_data.append (bytes, bytes_len); |
| 476 | |
| 477 | if (m_input_reader_data.empty()) |
| 478 | return; |
| 479 | |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 480 | while (!m_input_reader_stack.IsEmpty() && !m_input_reader_data.empty()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 481 | { |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 482 | // Get the input reader from the top of the stack |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 483 | InputReaderSP reader_sp (GetCurrentInputReader ()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | if (!reader_sp) |
| 485 | break; |
| 486 | |
Greg Clayton | 471b31c | 2010-07-20 22:52:08 +0000 | [diff] [blame] | 487 | size_t bytes_handled = reader_sp->HandleRawBytes (m_input_reader_data.c_str(), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 488 | m_input_reader_data.size()); |
| 489 | if (bytes_handled) |
| 490 | { |
| 491 | m_input_reader_data.erase (0, bytes_handled); |
| 492 | } |
| 493 | else |
| 494 | { |
| 495 | // No bytes were handled, we might not have reached our |
| 496 | // granularity, just return and wait for more data |
| 497 | break; |
| 498 | } |
| 499 | } |
| 500 | |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 501 | // Flush out any input readers that are done. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 502 | while (CheckIfTopInputReaderIsDone ()) |
| 503 | /* Do nothing. */; |
| 504 | |
| 505 | } |
| 506 | |
| 507 | void |
| 508 | Debugger::PushInputReader (const InputReaderSP& reader_sp) |
| 509 | { |
| 510 | if (!reader_sp) |
| 511 | return; |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 512 | |
| 513 | // Deactivate the old top reader |
| 514 | InputReaderSP top_reader_sp (GetCurrentInputReader ()); |
| 515 | |
| 516 | if (top_reader_sp) |
| 517 | top_reader_sp->Notify (eInputReaderDeactivate); |
| 518 | |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 519 | m_input_reader_stack.Push (reader_sp); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 520 | reader_sp->Notify (eInputReaderActivate); |
| 521 | ActivateInputReader (reader_sp); |
| 522 | } |
| 523 | |
| 524 | bool |
| 525 | Debugger::PopInputReader (const lldb::InputReaderSP& pop_reader_sp) |
| 526 | { |
| 527 | bool result = false; |
| 528 | |
| 529 | // The reader on the stop of the stack is done, so let the next |
| 530 | // read on the stack referesh its prompt and if there is one... |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 531 | if (!m_input_reader_stack.IsEmpty()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 532 | { |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 533 | // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 534 | InputReaderSP reader_sp(m_input_reader_stack.Top()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 535 | |
| 536 | if (!pop_reader_sp || pop_reader_sp.get() == reader_sp.get()) |
| 537 | { |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 538 | m_input_reader_stack.Pop (); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 539 | reader_sp->Notify (eInputReaderDeactivate); |
| 540 | reader_sp->Notify (eInputReaderDone); |
| 541 | result = true; |
| 542 | |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 543 | if (!m_input_reader_stack.IsEmpty()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 544 | { |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 545 | reader_sp = m_input_reader_stack.Top(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 546 | if (reader_sp) |
| 547 | { |
| 548 | ActivateInputReader (reader_sp); |
| 549 | reader_sp->Notify (eInputReaderReactivate); |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | return result; |
| 555 | } |
| 556 | |
| 557 | bool |
| 558 | Debugger::CheckIfTopInputReaderIsDone () |
| 559 | { |
| 560 | bool result = false; |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 561 | if (!m_input_reader_stack.IsEmpty()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 562 | { |
Caroline Tice | b44880c | 2011-02-10 01:15:13 +0000 | [diff] [blame] | 563 | // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. |
Caroline Tice | d5a0a01b | 2011-06-02 19:18:55 +0000 | [diff] [blame] | 564 | InputReaderSP reader_sp(m_input_reader_stack.Top()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 565 | |
| 566 | if (reader_sp && reader_sp->IsDone()) |
| 567 | { |
| 568 | result = true; |
| 569 | PopInputReader (reader_sp); |
| 570 | } |
| 571 | } |
| 572 | return result; |
| 573 | } |
| 574 | |
| 575 | void |
| 576 | Debugger::ActivateInputReader (const InputReaderSP &reader_sp) |
| 577 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 578 | int input_fd = m_input_file.GetFile().GetDescriptor(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 579 | |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 580 | if (input_fd >= 0) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 581 | { |
Greg Clayton | 51b1e2d | 2011-02-09 01:08:52 +0000 | [diff] [blame] | 582 | Terminal tty(input_fd); |
Greg Clayton | a340661 | 2011-02-07 23:24:47 +0000 | [diff] [blame] | 583 | |
| 584 | tty.SetEcho(reader_sp->GetEcho()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 585 | |
Greg Clayton | a340661 | 2011-02-07 23:24:47 +0000 | [diff] [blame] | 586 | switch (reader_sp->GetGranularity()) |
| 587 | { |
| 588 | case eInputReaderGranularityByte: |
| 589 | case eInputReaderGranularityWord: |
| 590 | tty.SetCanonical (false); |
| 591 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 592 | |
Greg Clayton | a340661 | 2011-02-07 23:24:47 +0000 | [diff] [blame] | 593 | case eInputReaderGranularityLine: |
| 594 | case eInputReaderGranularityAll: |
| 595 | tty.SetCanonical (true); |
| 596 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 597 | |
Greg Clayton | a340661 | 2011-02-07 23:24:47 +0000 | [diff] [blame] | 598 | default: |
| 599 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 600 | } |
| 601 | } |
| 602 | } |
Greg Clayton | 6611103 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 603 | |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 604 | StreamSP |
| 605 | Debugger::GetAsyncOutputStream () |
| 606 | { |
| 607 | return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(), |
| 608 | CommandInterpreter::eBroadcastBitAsynchronousOutputData)); |
| 609 | } |
| 610 | |
| 611 | StreamSP |
| 612 | Debugger::GetAsyncErrorStream () |
| 613 | { |
| 614 | return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(), |
| 615 | CommandInterpreter::eBroadcastBitAsynchronousErrorData)); |
| 616 | } |
| 617 | |
Caroline Tice | ebc1bb2 | 2010-06-30 16:22:25 +0000 | [diff] [blame] | 618 | DebuggerSP |
| 619 | Debugger::FindDebuggerWithID (lldb::user_id_t id) |
| 620 | { |
| 621 | lldb::DebuggerSP debugger_sp; |
| 622 | |
| 623 | Mutex::Locker locker (GetDebuggerListMutex ()); |
| 624 | DebuggerList &debugger_list = GetDebuggerList(); |
| 625 | DebuggerList::iterator pos, end = debugger_list.end(); |
| 626 | for (pos = debugger_list.begin(); pos != end; ++pos) |
| 627 | { |
| 628 | if ((*pos).get()->GetID() == id) |
| 629 | { |
| 630 | debugger_sp = *pos; |
| 631 | break; |
| 632 | } |
| 633 | } |
| 634 | return debugger_sp; |
| 635 | } |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 636 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 637 | static void |
| 638 | TestPromptFormats (StackFrame *frame) |
| 639 | { |
| 640 | if (frame == NULL) |
| 641 | return; |
| 642 | |
| 643 | StreamString s; |
| 644 | const char *prompt_format = |
| 645 | "{addr = '${addr}'\n}" |
| 646 | "{process.id = '${process.id}'\n}" |
| 647 | "{process.name = '${process.name}'\n}" |
| 648 | "{process.file.basename = '${process.file.basename}'\n}" |
| 649 | "{process.file.fullpath = '${process.file.fullpath}'\n}" |
| 650 | "{thread.id = '${thread.id}'\n}" |
| 651 | "{thread.index = '${thread.index}'\n}" |
| 652 | "{thread.name = '${thread.name}'\n}" |
| 653 | "{thread.queue = '${thread.queue}'\n}" |
| 654 | "{thread.stop-reason = '${thread.stop-reason}'\n}" |
| 655 | "{target.arch = '${target.arch}'\n}" |
| 656 | "{module.file.basename = '${module.file.basename}'\n}" |
| 657 | "{module.file.fullpath = '${module.file.fullpath}'\n}" |
| 658 | "{file.basename = '${file.basename}'\n}" |
| 659 | "{file.fullpath = '${file.fullpath}'\n}" |
| 660 | "{frame.index = '${frame.index}'\n}" |
| 661 | "{frame.pc = '${frame.pc}'\n}" |
| 662 | "{frame.sp = '${frame.sp}'\n}" |
| 663 | "{frame.fp = '${frame.fp}'\n}" |
| 664 | "{frame.flags = '${frame.flags}'\n}" |
| 665 | "{frame.reg.rdi = '${frame.reg.rdi}'\n}" |
| 666 | "{frame.reg.rip = '${frame.reg.rip}'\n}" |
| 667 | "{frame.reg.rsp = '${frame.reg.rsp}'\n}" |
| 668 | "{frame.reg.rbp = '${frame.reg.rbp}'\n}" |
| 669 | "{frame.reg.rflags = '${frame.reg.rflags}'\n}" |
| 670 | "{frame.reg.xmm0 = '${frame.reg.xmm0}'\n}" |
| 671 | "{frame.reg.carp = '${frame.reg.carp}'\n}" |
| 672 | "{function.id = '${function.id}'\n}" |
| 673 | "{function.name = '${function.name}'\n}" |
| 674 | "{function.addr-offset = '${function.addr-offset}'\n}" |
| 675 | "{function.line-offset = '${function.line-offset}'\n}" |
| 676 | "{function.pc-offset = '${function.pc-offset}'\n}" |
| 677 | "{line.file.basename = '${line.file.basename}'\n}" |
| 678 | "{line.file.fullpath = '${line.file.fullpath}'\n}" |
| 679 | "{line.number = '${line.number}'\n}" |
| 680 | "{line.start-addr = '${line.start-addr}'\n}" |
| 681 | "{line.end-addr = '${line.end-addr}'\n}" |
| 682 | ; |
| 683 | |
| 684 | SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything)); |
| 685 | ExecutionContext exe_ctx; |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 686 | frame->CalculateExecutionContext(exe_ctx); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 687 | const char *end = NULL; |
| 688 | if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end)) |
| 689 | { |
| 690 | printf("%s\n", s.GetData()); |
| 691 | } |
| 692 | else |
| 693 | { |
| 694 | printf ("error: at '%s'\n", end); |
| 695 | printf ("what we got: %s\n", s.GetData()); |
| 696 | } |
| 697 | } |
| 698 | |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 699 | #define IFERROR_PRINT_IT if (error.Fail()) \ |
| 700 | { \ |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 701 | if (log) \ |
| 702 | log->Printf("ERROR: %s\n", error.AsCString("unknown")); \ |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 703 | break; \ |
| 704 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 705 | |
| 706 | static bool |
| 707 | ScanFormatDescriptor(const char* var_name_begin, |
| 708 | const char* var_name_end, |
| 709 | const char** var_name_final, |
| 710 | const char** percent_position, |
| 711 | lldb::Format* custom_format, |
| 712 | ValueObject::ValueObjectRepresentationStyle* val_obj_display) |
| 713 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 714 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 715 | *percent_position = ::strchr(var_name_begin,'%'); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 716 | if (!*percent_position || *percent_position > var_name_end) |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 717 | { |
| 718 | if (log) |
| 719 | log->Printf("no format descriptor in string, skipping"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 720 | *var_name_final = var_name_end; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 721 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 722 | else |
| 723 | { |
| 724 | *var_name_final = *percent_position; |
| 725 | char* format_name = new char[var_name_end-*var_name_final]; format_name[var_name_end-*var_name_final-1] = '\0'; |
| 726 | memcpy(format_name, *var_name_final+1, var_name_end-*var_name_final-1); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 727 | if (log) |
| 728 | log->Printf("parsing %s as a format descriptor", format_name); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 729 | if ( !FormatManager::GetFormatFromCString(format_name, |
| 730 | true, |
| 731 | *custom_format) ) |
| 732 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 733 | if (log) |
| 734 | log->Printf("%s is an unknown format", format_name); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 735 | // if this is an @ sign, print ObjC description |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 736 | if (*format_name == '@') |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 737 | *val_obj_display = ValueObject::eDisplayLanguageSpecific; |
| 738 | // if this is a V, print the value using the default format |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 739 | else if (*format_name == 'V') |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 740 | *val_obj_display = ValueObject::eDisplayValue; |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 741 | // if this is an L, print the location of the value |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 742 | else if (*format_name == 'L') |
Enrico Granata | f2bbf71 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 743 | *val_obj_display = ValueObject::eDisplayLocation; |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 744 | // if this is an S, print the summary after all |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 745 | else if (*format_name == 'S') |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 746 | *val_obj_display = ValueObject::eDisplaySummary; |
Enrico Granata | 5dfd49c | 2011-08-04 02:34:29 +0000 | [diff] [blame] | 747 | else if (*format_name == '#') |
| 748 | *val_obj_display = ValueObject::eDisplayChildrenCount; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 749 | else if (log) |
| 750 | log->Printf("%s is an error, leaving the previous value alone", format_name); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 751 | } |
| 752 | // a good custom format tells us to print the value using it |
| 753 | else |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 754 | { |
| 755 | if (log) |
| 756 | log->Printf("will display value for this VO"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 757 | *val_obj_display = ValueObject::eDisplayValue; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 758 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 759 | delete format_name; |
| 760 | } |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 761 | if (log) |
| 762 | log->Printf("final format description outcome: custom_format = %d, val_obj_display = %d", |
| 763 | *custom_format, |
| 764 | *val_obj_display); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 765 | return true; |
| 766 | } |
| 767 | |
| 768 | static bool |
| 769 | ScanBracketedRange(const char* var_name_begin, |
| 770 | const char* var_name_end, |
| 771 | const char* var_name_final, |
| 772 | const char** open_bracket_position, |
| 773 | const char** separator_position, |
| 774 | const char** close_bracket_position, |
| 775 | const char** var_name_final_if_array_range, |
| 776 | int64_t* index_lower, |
| 777 | int64_t* index_higher) |
| 778 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 779 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 780 | *open_bracket_position = ::strchr(var_name_begin,'['); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 781 | if (*open_bracket_position && *open_bracket_position < var_name_final) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 782 | { |
| 783 | *separator_position = ::strchr(*open_bracket_position,'-'); // might be NULL if this is a simple var[N] bitfield |
| 784 | *close_bracket_position = ::strchr(*open_bracket_position,']'); |
| 785 | // as usual, we assume that [] will come before % |
| 786 | //printf("trying to expand a []\n"); |
| 787 | *var_name_final_if_array_range = *open_bracket_position; |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 788 | if (*close_bracket_position - *open_bracket_position == 1) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 789 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 790 | if (log) |
| 791 | log->Printf("[] detected.. going from 0 to end of data"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 792 | *index_lower = 0; |
| 793 | } |
| 794 | else if (*separator_position == NULL || *separator_position > var_name_end) |
| 795 | { |
| 796 | char *end = NULL; |
| 797 | *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); |
| 798 | *index_higher = *index_lower; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 799 | if (log) |
Enrico Granata | 8c9d356 | 2011-08-11 17:08:01 +0000 | [diff] [blame] | 800 | log->Printf("[%d] detected, high index is same", *index_lower); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 801 | } |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 802 | else if (*close_bracket_position && *close_bracket_position < var_name_end) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 803 | { |
| 804 | char *end = NULL; |
| 805 | *index_lower = ::strtoul (*open_bracket_position+1, &end, 0); |
| 806 | *index_higher = ::strtoul (*separator_position+1, &end, 0); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 807 | if (log) |
Enrico Granata | 8c9d356 | 2011-08-11 17:08:01 +0000 | [diff] [blame] | 808 | log->Printf("[%d-%d] detected", *index_lower, *index_higher); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 809 | } |
| 810 | else |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 811 | { |
| 812 | if (log) |
| 813 | log->Printf("expression is erroneous, cannot extract indices out of it"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 814 | return false; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 815 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 816 | if (*index_lower > *index_higher && *index_higher > 0) |
| 817 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 818 | if (log) |
| 819 | log->Printf("swapping indices"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 820 | int temp = *index_lower; |
| 821 | *index_lower = *index_higher; |
| 822 | *index_higher = temp; |
| 823 | } |
| 824 | } |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 825 | else if (log) |
| 826 | log->Printf("no bracketed range, skipping entirely"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 827 | return true; |
| 828 | } |
| 829 | |
| 830 | |
| 831 | static ValueObjectSP |
| 832 | ExpandExpressionPath(ValueObject* vobj, |
| 833 | StackFrame* frame, |
| 834 | bool* do_deref_pointer, |
| 835 | const char* var_name_begin, |
| 836 | const char* var_name_final, |
| 837 | Error& error) |
| 838 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 839 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 840 | StreamString sstring; |
| 841 | VariableSP var_sp; |
| 842 | |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 843 | if (*do_deref_pointer) |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 844 | { |
| 845 | if (log) |
| 846 | log->Printf("been told to deref_pointer by caller"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 847 | sstring.PutChar('*'); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 848 | } |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 849 | else if (vobj->IsDereferenceOfParent() && ClangASTContext::IsPointerType(vobj->GetParent()->GetClangType()) && !vobj->IsArrayItemForPointer()) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 850 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 851 | if (log) |
| 852 | log->Printf("decided to deref_pointer myself"); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 853 | sstring.PutChar('*'); |
| 854 | *do_deref_pointer = true; |
| 855 | } |
| 856 | |
| 857 | vobj->GetExpressionPath(sstring, true, ValueObject::eHonorPointers); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 858 | if (log) |
| 859 | log->Printf("expression path to expand in phase 0: %s",sstring.GetData()); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 860 | sstring.PutRawBytes(var_name_begin+3, var_name_final-var_name_begin-3); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 861 | if (log) |
| 862 | log->Printf("expression path to expand in phase 1: %s",sstring.GetData()); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 863 | std::string name = std::string(sstring.GetData()); |
| 864 | ValueObjectSP target = frame->GetValueForVariableExpressionPath (name.c_str(), |
| 865 | eNoDynamicValues, |
| 866 | 0, |
| 867 | var_sp, |
| 868 | error); |
| 869 | return target; |
| 870 | } |
| 871 | |
| 872 | static ValueObjectSP |
| 873 | ExpandIndexedExpression(ValueObject* vobj, |
| 874 | uint32_t index, |
| 875 | StackFrame* frame, |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 876 | bool deref_pointer) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 877 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 878 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 879 | const char* ptr_deref_format = "[%d]"; |
| 880 | std::auto_ptr<char> ptr_deref_buffer(new char[10]); |
| 881 | ::sprintf(ptr_deref_buffer.get(), ptr_deref_format, index); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 882 | if (log) |
| 883 | log->Printf("name to deref: %s",ptr_deref_buffer.get()); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 884 | const char* first_unparsed; |
| 885 | ValueObject::GetValueForExpressionPathOptions options; |
| 886 | ValueObject::ExpressionPathEndResultType final_value_type; |
| 887 | ValueObject::ExpressionPathScanEndReason reason_to_stop; |
| 888 | ValueObject::ExpressionPathAftermath what_next = (deref_pointer ? ValueObject::eDereference : ValueObject::eNothing); |
| 889 | ValueObjectSP item = vobj->GetValueForExpressionPath (ptr_deref_buffer.get(), |
| 890 | &first_unparsed, |
| 891 | &reason_to_stop, |
| 892 | &final_value_type, |
| 893 | options, |
| 894 | &what_next); |
| 895 | if (!item) |
| 896 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 897 | if (log) |
| 898 | log->Printf("ERROR: unparsed portion = %s, why stopping = %d," |
| 899 | " final_value_type %d", |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 900 | first_unparsed, reason_to_stop, final_value_type); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 901 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 902 | else |
| 903 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 904 | if (log) |
| 905 | log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d," |
| 906 | " final_value_type %d", |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 907 | first_unparsed, reason_to_stop, final_value_type); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 908 | } |
| 909 | return item; |
| 910 | } |
| 911 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 912 | bool |
| 913 | Debugger::FormatPrompt |
| 914 | ( |
| 915 | const char *format, |
| 916 | const SymbolContext *sc, |
| 917 | const ExecutionContext *exe_ctx, |
| 918 | const Address *addr, |
| 919 | Stream &s, |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 920 | const char **end, |
| 921 | ValueObject* vobj |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 922 | ) |
| 923 | { |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 924 | ValueObject* realvobj = NULL; // makes it super-easy to parse pointers |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 925 | bool success = true; |
| 926 | const char *p; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 927 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 928 | for (p = format; *p != '\0'; ++p) |
| 929 | { |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 930 | if (realvobj) |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 931 | { |
| 932 | vobj = realvobj; |
| 933 | realvobj = NULL; |
| 934 | } |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 935 | size_t non_special_chars = ::strcspn (p, "${}\\"); |
| 936 | if (non_special_chars > 0) |
| 937 | { |
| 938 | if (success) |
| 939 | s.Write (p, non_special_chars); |
| 940 | p += non_special_chars; |
| 941 | } |
| 942 | |
| 943 | if (*p == '\0') |
| 944 | { |
| 945 | break; |
| 946 | } |
| 947 | else if (*p == '{') |
| 948 | { |
| 949 | // Start a new scope that must have everything it needs if it is to |
| 950 | // to make it into the final output stream "s". If you want to make |
| 951 | // a format that only prints out the function or symbol name if there |
| 952 | // is one in the symbol context you can use: |
| 953 | // "{function =${function.name}}" |
| 954 | // The first '{' starts a new scope that end with the matching '}' at |
| 955 | // the end of the string. The contents "function =${function.name}" |
| 956 | // will then be evaluated and only be output if there is a function |
| 957 | // or symbol with a valid name. |
| 958 | StreamString sub_strm; |
| 959 | |
| 960 | ++p; // Skip the '{' |
| 961 | |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 962 | if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p, vobj)) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 963 | { |
| 964 | // The stream had all it needed |
| 965 | s.Write(sub_strm.GetData(), sub_strm.GetSize()); |
| 966 | } |
| 967 | if (*p != '}') |
| 968 | { |
| 969 | success = false; |
| 970 | break; |
| 971 | } |
| 972 | } |
| 973 | else if (*p == '}') |
| 974 | { |
| 975 | // End of a enclosing scope |
| 976 | break; |
| 977 | } |
| 978 | else if (*p == '$') |
| 979 | { |
| 980 | // We have a prompt variable to print |
| 981 | ++p; |
| 982 | if (*p == '{') |
| 983 | { |
| 984 | ++p; |
| 985 | const char *var_name_begin = p; |
| 986 | const char *var_name_end = ::strchr (p, '}'); |
| 987 | |
| 988 | if (var_name_end && var_name_begin < var_name_end) |
| 989 | { |
| 990 | // if we have already failed to parse, skip this variable |
| 991 | if (success) |
| 992 | { |
| 993 | const char *cstr = NULL; |
| 994 | Address format_addr; |
| 995 | bool calculate_format_addr_function_offset = false; |
| 996 | // Set reg_kind and reg_num to invalid values |
| 997 | RegisterKind reg_kind = kNumRegisterKinds; |
| 998 | uint32_t reg_num = LLDB_INVALID_REGNUM; |
| 999 | FileSpec format_file_spec; |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 1000 | const RegisterInfo *reg_info = NULL; |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1001 | RegisterContext *reg_ctx = NULL; |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1002 | bool do_deref_pointer = false; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1003 | ValueObject::ExpressionPathScanEndReason reason_to_stop = ValueObject::eEndOfString; |
| 1004 | ValueObject::ExpressionPathEndResultType final_value_type = ValueObject::ePlain; |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1005 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1006 | // Each variable must set success to true below... |
| 1007 | bool var_success = false; |
| 1008 | switch (var_name_begin[0]) |
| 1009 | { |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1010 | case '*': |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1011 | case 'v': |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1012 | case 's': |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1013 | { |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1014 | if (!vobj) |
| 1015 | break; |
| 1016 | |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1017 | if (log) |
| 1018 | log->Printf("initial string: %s",var_name_begin); |
| 1019 | |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1020 | // check for *var and *svar |
| 1021 | if (*var_name_begin == '*') |
| 1022 | { |
| 1023 | do_deref_pointer = true; |
| 1024 | var_name_begin++; |
| 1025 | } |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1026 | |
| 1027 | if (log) |
| 1028 | log->Printf("initial string: %s",var_name_begin); |
| 1029 | |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1030 | if (*var_name_begin == 's') |
| 1031 | { |
| 1032 | vobj = vobj->GetSyntheticValue(lldb::eUseSyntheticFilter).get(); |
| 1033 | var_name_begin++; |
| 1034 | } |
| 1035 | |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1036 | if (log) |
| 1037 | log->Printf("initial string: %s",var_name_begin); |
| 1038 | |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1039 | // should be a 'v' by now |
| 1040 | if (*var_name_begin != 'v') |
| 1041 | break; |
| 1042 | |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1043 | if (log) |
| 1044 | log->Printf("initial string: %s",var_name_begin); |
| 1045 | |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1046 | ValueObject::ExpressionPathAftermath what_next = (do_deref_pointer ? |
| 1047 | ValueObject::eDereference : ValueObject::eNothing); |
| 1048 | ValueObject::GetValueForExpressionPathOptions options; |
Enrico Granata | 8c9d356 | 2011-08-11 17:08:01 +0000 | [diff] [blame] | 1049 | options.DontCheckDotVsArrowSyntax().DoAllowBitfieldSyntax().DoAllowFragileIVar().DoAllowSyntheticChildren(); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1050 | ValueObject::ValueObjectRepresentationStyle val_obj_display = ValueObject::eDisplaySummary; |
| 1051 | ValueObject* target = NULL; |
| 1052 | lldb::Format custom_format = eFormatInvalid; |
| 1053 | const char* var_name_final = NULL; |
| 1054 | const char* var_name_final_if_array_range = NULL; |
| 1055 | const char* close_bracket_position = NULL; |
| 1056 | int64_t index_lower = -1; |
| 1057 | int64_t index_higher = -1; |
| 1058 | bool is_array_range = false; |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1059 | const char* first_unparsed; |
| 1060 | |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1061 | if (!vobj) break; |
| 1062 | // simplest case ${var}, just print vobj's value |
| 1063 | if (::strncmp (var_name_begin, "var}", strlen("var}")) == 0) |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1064 | { |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1065 | target = vobj; |
| 1066 | val_obj_display = ValueObject::eDisplayValue; |
| 1067 | } |
| 1068 | else if (::strncmp(var_name_begin,"var%",strlen("var%")) == 0) |
| 1069 | { |
| 1070 | // this is a variable with some custom format applied to it |
| 1071 | const char* percent_position; |
| 1072 | target = vobj; |
| 1073 | val_obj_display = ValueObject::eDisplayValue; |
| 1074 | ScanFormatDescriptor (var_name_begin, |
| 1075 | var_name_end, |
| 1076 | &var_name_final, |
| 1077 | &percent_position, |
| 1078 | &custom_format, |
| 1079 | &val_obj_display); |
| 1080 | } |
| 1081 | // this is ${var.something} or multiple .something nested |
| 1082 | else if (::strncmp (var_name_begin, "var", strlen("var")) == 0) |
| 1083 | { |
| 1084 | |
| 1085 | const char* percent_position; |
| 1086 | ScanFormatDescriptor (var_name_begin, |
| 1087 | var_name_end, |
| 1088 | &var_name_final, |
| 1089 | &percent_position, |
| 1090 | &custom_format, |
| 1091 | &val_obj_display); |
| 1092 | |
| 1093 | const char* open_bracket_position; |
| 1094 | const char* separator_position; |
| 1095 | ScanBracketedRange (var_name_begin, |
| 1096 | var_name_end, |
| 1097 | var_name_final, |
| 1098 | &open_bracket_position, |
| 1099 | &separator_position, |
| 1100 | &close_bracket_position, |
| 1101 | &var_name_final_if_array_range, |
| 1102 | &index_lower, |
| 1103 | &index_higher); |
| 1104 | |
| 1105 | Error error; |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1106 | |
| 1107 | std::auto_ptr<char> expr_path(new char[var_name_final-var_name_begin-1]); |
| 1108 | ::memset(expr_path.get(), 0, var_name_final-var_name_begin-1); |
| 1109 | memcpy(expr_path.get(), var_name_begin+3,var_name_final-var_name_begin-3); |
| 1110 | |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1111 | if (log) |
| 1112 | log->Printf("symbol to expand: %s",expr_path.get()); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1113 | |
| 1114 | target = vobj->GetValueForExpressionPath(expr_path.get(), |
| 1115 | &first_unparsed, |
| 1116 | &reason_to_stop, |
| 1117 | &final_value_type, |
| 1118 | options, |
| 1119 | &what_next).get(); |
| 1120 | |
| 1121 | if (!target) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1122 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1123 | if (log) |
| 1124 | log->Printf("ERROR: unparsed portion = %s, why stopping = %d," |
| 1125 | " final_value_type %d", |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1126 | first_unparsed, reason_to_stop, final_value_type); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1127 | break; |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1128 | } |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1129 | else |
| 1130 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1131 | if (log) |
| 1132 | log->Printf("ALL RIGHT: unparsed portion = %s, why stopping = %d," |
| 1133 | " final_value_type %d", |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1134 | first_unparsed, reason_to_stop, final_value_type); |
| 1135 | } |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1136 | } |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1137 | else |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1138 | break; |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1139 | |
| 1140 | is_array_range = (final_value_type == ValueObject::eBoundedRange || |
| 1141 | final_value_type == ValueObject::eUnboundedRange); |
| 1142 | |
| 1143 | do_deref_pointer = (what_next == ValueObject::eDereference); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1144 | |
Enrico Granata | a7187d0 | 2011-07-06 19:27:11 +0000 | [diff] [blame] | 1145 | if (do_deref_pointer && !is_array_range) |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1146 | { |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1147 | // I have not deref-ed yet, let's do it |
| 1148 | // this happens when we are not going through GetValueForVariableExpressionPath |
| 1149 | // to get to the target ValueObject |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1150 | Error error; |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1151 | target = target->Dereference(error).get(); |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1152 | IFERROR_PRINT_IT |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1153 | do_deref_pointer = false; |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1154 | } |
Enrico Granata | f4efecd | 2011-07-12 22:56:10 +0000 | [diff] [blame] | 1155 | |
| 1156 | bool is_array = ClangASTContext::IsArrayType(target->GetClangType()); |
| 1157 | bool is_pointer = ClangASTContext::IsPointerType(target->GetClangType()); |
| 1158 | |
| 1159 | if ((is_array || is_pointer) && (!is_array_range) && val_obj_display == ValueObject::eDisplayValue) // this should be wrong, but there are some exceptions |
| 1160 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1161 | if (log) |
| 1162 | log->Printf("I am into array || pointer && !range"); |
Enrico Granata | f4efecd | 2011-07-12 22:56:10 +0000 | [diff] [blame] | 1163 | // try to use the special cases |
| 1164 | var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format); |
| 1165 | if (!var_success) |
| 1166 | s << "<invalid, please use [] operator>"; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1167 | if (log) |
| 1168 | log->Printf("special cases did%s match", var_success ? "" : "n't"); |
Enrico Granata | f4efecd | 2011-07-12 22:56:10 +0000 | [diff] [blame] | 1169 | break; |
| 1170 | } |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1171 | |
| 1172 | if (!is_array_range) |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1173 | { |
| 1174 | if (log) |
| 1175 | log->Printf("dumping ordinary printable output"); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1176 | var_success = target->DumpPrintableRepresentation(s,val_obj_display, custom_format); |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1177 | } |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1178 | else |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1179 | { |
| 1180 | if (log) |
| 1181 | log->Printf("checking if I can handle as array"); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1182 | if (!is_array && !is_pointer) |
| 1183 | break; |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1184 | if (log) |
| 1185 | log->Printf("handle as array"); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1186 | const char* special_directions = NULL; |
| 1187 | StreamString special_directions_writer; |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1188 | if (close_bracket_position && (var_name_end-close_bracket_position > 1)) |
| 1189 | { |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1190 | ConstString additional_data; |
| 1191 | additional_data.SetCStringWithLength(close_bracket_position+1, var_name_end-close_bracket_position-1); |
| 1192 | special_directions_writer.Printf("${%svar%s}", |
| 1193 | do_deref_pointer ? "*" : "", |
| 1194 | additional_data.GetCString()); |
| 1195 | special_directions = special_directions_writer.GetData(); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | // let us display items index_lower thru index_higher of this array |
| 1199 | s.PutChar('['); |
| 1200 | var_success = true; |
| 1201 | |
| 1202 | if (index_higher < 0) |
| 1203 | index_higher = vobj->GetNumChildren() - 1; |
| 1204 | |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 1205 | uint32_t max_num_children = target->GetUpdatePoint().GetTargetSP()->GetMaximumNumberOfChildrenToDisplay(); |
| 1206 | |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1207 | for (;index_lower<=index_higher;index_lower++) |
| 1208 | { |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1209 | ValueObject* item = ExpandIndexedExpression(target, |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1210 | index_lower, |
| 1211 | exe_ctx->frame, |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1212 | false).get(); |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1213 | |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1214 | if (!item) |
| 1215 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1216 | if (log) |
| 1217 | log->Printf("ERROR in getting child item at index %d", index_lower); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1218 | } |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1219 | else |
| 1220 | { |
Enrico Granata | e992a08 | 2011-07-22 17:03:19 +0000 | [diff] [blame] | 1221 | if (log) |
| 1222 | log->Printf("special_directions for child item: %s",special_directions); |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1223 | } |
Enrico Granata | fc7a7f3 | 2011-07-08 02:51:01 +0000 | [diff] [blame] | 1224 | |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1225 | if (!special_directions) |
| 1226 | var_success &= item->DumpPrintableRepresentation(s,val_obj_display, custom_format); |
| 1227 | else |
| 1228 | var_success &= FormatPrompt(special_directions, sc, exe_ctx, addr, s, NULL, item); |
| 1229 | |
Enrico Granata | 22c55d1 | 2011-08-12 02:00:06 +0000 | [diff] [blame] | 1230 | if (--max_num_children == 0) |
| 1231 | { |
| 1232 | s.PutCString(", ..."); |
| 1233 | break; |
| 1234 | } |
| 1235 | |
Greg Clayton | 3413275 | 2011-07-06 04:07:21 +0000 | [diff] [blame] | 1236 | if (index_lower < index_higher) |
| 1237 | s.PutChar(','); |
| 1238 | } |
| 1239 | s.PutChar(']'); |
| 1240 | } |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1241 | } |
Enrico Granata | 9fc1944 | 2011-07-06 02:13:41 +0000 | [diff] [blame] | 1242 | break; |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1243 | case 'a': |
| 1244 | if (::strncmp (var_name_begin, "addr}", strlen("addr}")) == 0) |
| 1245 | { |
| 1246 | if (addr && addr->IsValid()) |
| 1247 | { |
| 1248 | var_success = true; |
| 1249 | format_addr = *addr; |
| 1250 | } |
| 1251 | } |
| 1252 | break; |
| 1253 | |
| 1254 | case 'p': |
| 1255 | if (::strncmp (var_name_begin, "process.", strlen("process.")) == 0) |
| 1256 | { |
| 1257 | if (exe_ctx && exe_ctx->process != NULL) |
| 1258 | { |
| 1259 | var_name_begin += ::strlen ("process."); |
| 1260 | if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) |
| 1261 | { |
| 1262 | s.Printf("%i", exe_ctx->process->GetID()); |
| 1263 | var_success = true; |
| 1264 | } |
| 1265 | else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) || |
| 1266 | (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) || |
| 1267 | (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0)) |
| 1268 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1269 | Module *exe_module = exe_ctx->process->GetTarget().GetExecutableModulePointer(); |
| 1270 | if (exe_module) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1271 | { |
| 1272 | if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f') |
| 1273 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1274 | format_file_spec.GetFilename() = exe_module->GetFileSpec().GetFilename(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1275 | var_success = format_file_spec; |
| 1276 | } |
| 1277 | else |
| 1278 | { |
Greg Clayton | aa149cb | 2011-08-11 02:48:45 +0000 | [diff] [blame] | 1279 | format_file_spec = exe_module->GetFileSpec(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1280 | var_success = format_file_spec; |
| 1281 | } |
| 1282 | } |
| 1283 | } |
| 1284 | } |
| 1285 | } |
| 1286 | break; |
| 1287 | |
| 1288 | case 't': |
| 1289 | if (::strncmp (var_name_begin, "thread.", strlen("thread.")) == 0) |
| 1290 | { |
| 1291 | if (exe_ctx && exe_ctx->thread) |
| 1292 | { |
| 1293 | var_name_begin += ::strlen ("thread."); |
| 1294 | if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) |
| 1295 | { |
| 1296 | s.Printf("0x%4.4x", exe_ctx->thread->GetID()); |
| 1297 | var_success = true; |
| 1298 | } |
| 1299 | else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) |
| 1300 | { |
| 1301 | s.Printf("%u", exe_ctx->thread->GetIndexID()); |
| 1302 | var_success = true; |
| 1303 | } |
| 1304 | else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) |
| 1305 | { |
| 1306 | cstr = exe_ctx->thread->GetName(); |
| 1307 | var_success = cstr && cstr[0]; |
| 1308 | if (var_success) |
| 1309 | s.PutCString(cstr); |
| 1310 | } |
| 1311 | else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0) |
| 1312 | { |
| 1313 | cstr = exe_ctx->thread->GetQueueName(); |
| 1314 | var_success = cstr && cstr[0]; |
| 1315 | if (var_success) |
| 1316 | s.PutCString(cstr); |
| 1317 | } |
| 1318 | else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0) |
| 1319 | { |
Jim Ingham | b15bfc7 | 2010-10-20 00:39:53 +0000 | [diff] [blame] | 1320 | StopInfoSP stop_info_sp = exe_ctx->thread->GetStopInfo (); |
| 1321 | if (stop_info_sp) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1322 | { |
Jim Ingham | b15bfc7 | 2010-10-20 00:39:53 +0000 | [diff] [blame] | 1323 | cstr = stop_info_sp->GetDescription(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1324 | if (cstr && cstr[0]) |
| 1325 | { |
| 1326 | s.PutCString(cstr); |
| 1327 | var_success = true; |
| 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | } |
| 1332 | } |
| 1333 | else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0) |
| 1334 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1335 | Target *target = Target::GetTargetFromContexts (exe_ctx, sc); |
| 1336 | if (target) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1337 | { |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1338 | var_name_begin += ::strlen ("target."); |
| 1339 | if (::strncmp (var_name_begin, "arch}", strlen("arch}")) == 0) |
| 1340 | { |
| 1341 | ArchSpec arch (target->GetArchitecture ()); |
| 1342 | if (arch.IsValid()) |
| 1343 | { |
Greg Clayton | 64195a2 | 2011-02-23 00:35:02 +0000 | [diff] [blame] | 1344 | s.PutCString (arch.GetArchitectureName()); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1345 | var_success = true; |
| 1346 | } |
| 1347 | } |
| 1348 | } |
| 1349 | } |
| 1350 | break; |
| 1351 | |
| 1352 | |
| 1353 | case 'm': |
| 1354 | if (::strncmp (var_name_begin, "module.", strlen("module.")) == 0) |
| 1355 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1356 | if (sc && sc->module_sp.get()) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1357 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1358 | Module *module = sc->module_sp.get(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1359 | var_name_begin += ::strlen ("module."); |
| 1360 | |
| 1361 | if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) |
| 1362 | { |
| 1363 | if (module->GetFileSpec()) |
| 1364 | { |
| 1365 | var_name_begin += ::strlen ("file."); |
| 1366 | |
| 1367 | if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) |
| 1368 | { |
| 1369 | format_file_spec.GetFilename() = module->GetFileSpec().GetFilename(); |
| 1370 | var_success = format_file_spec; |
| 1371 | } |
| 1372 | else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) |
| 1373 | { |
| 1374 | format_file_spec = module->GetFileSpec(); |
| 1375 | var_success = format_file_spec; |
| 1376 | } |
| 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | } |
| 1381 | break; |
| 1382 | |
| 1383 | |
| 1384 | case 'f': |
| 1385 | if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) |
| 1386 | { |
| 1387 | if (sc && sc->comp_unit != NULL) |
| 1388 | { |
| 1389 | var_name_begin += ::strlen ("file."); |
| 1390 | |
| 1391 | if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) |
| 1392 | { |
| 1393 | format_file_spec.GetFilename() = sc->comp_unit->GetFilename(); |
| 1394 | var_success = format_file_spec; |
| 1395 | } |
| 1396 | else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) |
| 1397 | { |
| 1398 | format_file_spec = *sc->comp_unit; |
| 1399 | var_success = format_file_spec; |
| 1400 | } |
| 1401 | } |
| 1402 | } |
| 1403 | else if (::strncmp (var_name_begin, "frame.", strlen("frame.")) == 0) |
| 1404 | { |
| 1405 | if (exe_ctx && exe_ctx->frame) |
| 1406 | { |
| 1407 | var_name_begin += ::strlen ("frame."); |
| 1408 | if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) |
| 1409 | { |
| 1410 | s.Printf("%u", exe_ctx->frame->GetFrameIndex()); |
| 1411 | var_success = true; |
| 1412 | } |
| 1413 | else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0) |
| 1414 | { |
| 1415 | reg_kind = eRegisterKindGeneric; |
| 1416 | reg_num = LLDB_REGNUM_GENERIC_PC; |
| 1417 | var_success = true; |
| 1418 | } |
| 1419 | else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0) |
| 1420 | { |
| 1421 | reg_kind = eRegisterKindGeneric; |
| 1422 | reg_num = LLDB_REGNUM_GENERIC_SP; |
| 1423 | var_success = true; |
| 1424 | } |
| 1425 | else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0) |
| 1426 | { |
| 1427 | reg_kind = eRegisterKindGeneric; |
| 1428 | reg_num = LLDB_REGNUM_GENERIC_FP; |
| 1429 | var_success = true; |
| 1430 | } |
| 1431 | else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0) |
| 1432 | { |
| 1433 | reg_kind = eRegisterKindGeneric; |
| 1434 | reg_num = LLDB_REGNUM_GENERIC_FLAGS; |
| 1435 | var_success = true; |
| 1436 | } |
| 1437 | else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0) |
| 1438 | { |
Greg Clayton | 5ccbd29 | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 1439 | reg_ctx = exe_ctx->frame->GetRegisterContext().get(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1440 | if (reg_ctx) |
| 1441 | { |
| 1442 | var_name_begin += ::strlen ("reg."); |
| 1443 | if (var_name_begin < var_name_end) |
| 1444 | { |
| 1445 | std::string reg_name (var_name_begin, var_name_end); |
| 1446 | reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str()); |
| 1447 | if (reg_info) |
| 1448 | var_success = true; |
| 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | } |
| 1453 | } |
| 1454 | else if (::strncmp (var_name_begin, "function.", strlen("function.")) == 0) |
| 1455 | { |
| 1456 | if (sc && (sc->function != NULL || sc->symbol != NULL)) |
| 1457 | { |
| 1458 | var_name_begin += ::strlen ("function."); |
| 1459 | if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) |
| 1460 | { |
| 1461 | if (sc->function) |
| 1462 | s.Printf("function{0x%8.8x}", sc->function->GetID()); |
| 1463 | else |
| 1464 | s.Printf("symbol[%u]", sc->symbol->GetID()); |
| 1465 | |
| 1466 | var_success = true; |
| 1467 | } |
| 1468 | else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) |
| 1469 | { |
| 1470 | if (sc->function) |
| 1471 | cstr = sc->function->GetName().AsCString (NULL); |
| 1472 | else if (sc->symbol) |
| 1473 | cstr = sc->symbol->GetName().AsCString (NULL); |
| 1474 | if (cstr) |
| 1475 | { |
| 1476 | s.PutCString(cstr); |
Greg Clayton | 0d9c993 | 2010-10-04 17:26:49 +0000 | [diff] [blame] | 1477 | |
| 1478 | if (sc->block) |
| 1479 | { |
| 1480 | Block *inline_block = sc->block->GetContainingInlinedBlock (); |
| 1481 | if (inline_block) |
| 1482 | { |
| 1483 | const InlineFunctionInfo *inline_info = sc->block->GetInlinedFunctionInfo(); |
| 1484 | if (inline_info) |
| 1485 | { |
| 1486 | s.PutCString(" [inlined] "); |
| 1487 | inline_info->GetName().Dump(&s); |
| 1488 | } |
| 1489 | } |
| 1490 | } |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1491 | var_success = true; |
| 1492 | } |
| 1493 | } |
| 1494 | else if (::strncmp (var_name_begin, "addr-offset}", strlen("addr-offset}")) == 0) |
| 1495 | { |
| 1496 | var_success = addr != NULL; |
| 1497 | if (var_success) |
| 1498 | { |
| 1499 | format_addr = *addr; |
| 1500 | calculate_format_addr_function_offset = true; |
| 1501 | } |
| 1502 | } |
| 1503 | else if (::strncmp (var_name_begin, "line-offset}", strlen("line-offset}")) == 0) |
| 1504 | { |
| 1505 | var_success = sc->line_entry.range.GetBaseAddress().IsValid(); |
| 1506 | if (var_success) |
| 1507 | { |
| 1508 | format_addr = sc->line_entry.range.GetBaseAddress(); |
| 1509 | calculate_format_addr_function_offset = true; |
| 1510 | } |
| 1511 | } |
| 1512 | else if (::strncmp (var_name_begin, "pc-offset}", strlen("pc-offset}")) == 0) |
| 1513 | { |
| 1514 | var_success = exe_ctx->frame; |
| 1515 | if (var_success) |
| 1516 | { |
| 1517 | format_addr = exe_ctx->frame->GetFrameCodeAddress(); |
| 1518 | calculate_format_addr_function_offset = true; |
| 1519 | } |
| 1520 | } |
| 1521 | } |
| 1522 | } |
| 1523 | break; |
| 1524 | |
| 1525 | case 'l': |
| 1526 | if (::strncmp (var_name_begin, "line.", strlen("line.")) == 0) |
| 1527 | { |
| 1528 | if (sc && sc->line_entry.IsValid()) |
| 1529 | { |
| 1530 | var_name_begin += ::strlen ("line."); |
| 1531 | if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) |
| 1532 | { |
| 1533 | var_name_begin += ::strlen ("file."); |
| 1534 | |
| 1535 | if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) |
| 1536 | { |
| 1537 | format_file_spec.GetFilename() = sc->line_entry.file.GetFilename(); |
| 1538 | var_success = format_file_spec; |
| 1539 | } |
| 1540 | else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) |
| 1541 | { |
| 1542 | format_file_spec = sc->line_entry.file; |
| 1543 | var_success = format_file_spec; |
| 1544 | } |
| 1545 | } |
| 1546 | else if (::strncmp (var_name_begin, "number}", strlen("number}")) == 0) |
| 1547 | { |
| 1548 | var_success = true; |
| 1549 | s.Printf("%u", sc->line_entry.line); |
| 1550 | } |
| 1551 | else if ((::strncmp (var_name_begin, "start-addr}", strlen("start-addr}")) == 0) || |
| 1552 | (::strncmp (var_name_begin, "end-addr}", strlen("end-addr}")) == 0)) |
| 1553 | { |
| 1554 | var_success = sc && sc->line_entry.range.GetBaseAddress().IsValid(); |
| 1555 | if (var_success) |
| 1556 | { |
| 1557 | format_addr = sc->line_entry.range.GetBaseAddress(); |
| 1558 | if (var_name_begin[0] == 'e') |
| 1559 | format_addr.Slide (sc->line_entry.range.GetByteSize()); |
| 1560 | } |
| 1561 | } |
| 1562 | } |
| 1563 | } |
| 1564 | break; |
| 1565 | } |
| 1566 | |
| 1567 | if (var_success) |
| 1568 | { |
| 1569 | // If format addr is valid, then we need to print an address |
| 1570 | if (reg_num != LLDB_INVALID_REGNUM) |
| 1571 | { |
| 1572 | // We have a register value to display... |
| 1573 | if (reg_num == LLDB_REGNUM_GENERIC_PC && reg_kind == eRegisterKindGeneric) |
| 1574 | { |
| 1575 | format_addr = exe_ctx->frame->GetFrameCodeAddress(); |
| 1576 | } |
| 1577 | else |
| 1578 | { |
| 1579 | if (reg_ctx == NULL) |
Greg Clayton | 5ccbd29 | 2011-01-06 22:15:06 +0000 | [diff] [blame] | 1580 | reg_ctx = exe_ctx->frame->GetRegisterContext().get(); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1581 | |
| 1582 | if (reg_ctx) |
| 1583 | { |
| 1584 | if (reg_kind != kNumRegisterKinds) |
| 1585 | reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num); |
| 1586 | reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num); |
| 1587 | var_success = reg_info != NULL; |
| 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | if (reg_info != NULL) |
| 1593 | { |
Greg Clayton | 7349bd9 | 2011-05-09 20:18:18 +0000 | [diff] [blame] | 1594 | RegisterValue reg_value; |
| 1595 | var_success = reg_ctx->ReadRegister (reg_info, reg_value); |
| 1596 | if (var_success) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1597 | { |
Greg Clayton | 9a8fa91 | 2011-05-15 04:12:07 +0000 | [diff] [blame] | 1598 | reg_value.Dump(&s, reg_info, false, false, eFormatDefault); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1599 | } |
| 1600 | } |
| 1601 | |
| 1602 | if (format_file_spec) |
| 1603 | { |
| 1604 | s << format_file_spec; |
| 1605 | } |
| 1606 | |
| 1607 | // If format addr is valid, then we need to print an address |
| 1608 | if (format_addr.IsValid()) |
| 1609 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1610 | var_success = false; |
| 1611 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1612 | if (calculate_format_addr_function_offset) |
| 1613 | { |
| 1614 | Address func_addr; |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1615 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1616 | if (sc) |
| 1617 | { |
| 1618 | if (sc->function) |
Greg Clayton | 0d9c993 | 2010-10-04 17:26:49 +0000 | [diff] [blame] | 1619 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1620 | func_addr = sc->function->GetAddressRange().GetBaseAddress(); |
Greg Clayton | 0d9c993 | 2010-10-04 17:26:49 +0000 | [diff] [blame] | 1621 | if (sc->block) |
| 1622 | { |
| 1623 | // Check to make sure we aren't in an inline |
| 1624 | // function. If we are, use the inline block |
| 1625 | // range that contains "format_addr" since |
| 1626 | // blocks can be discontiguous. |
| 1627 | Block *inline_block = sc->block->GetContainingInlinedBlock (); |
| 1628 | AddressRange inline_range; |
| 1629 | if (inline_block && inline_block->GetRangeContainingAddress (format_addr, inline_range)) |
| 1630 | func_addr = inline_range.GetBaseAddress(); |
| 1631 | } |
| 1632 | } |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1633 | else if (sc->symbol && sc->symbol->GetAddressRangePtr()) |
| 1634 | func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress(); |
| 1635 | } |
| 1636 | |
| 1637 | if (func_addr.IsValid()) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1638 | { |
| 1639 | if (func_addr.GetSection() == format_addr.GetSection()) |
| 1640 | { |
| 1641 | addr_t func_file_addr = func_addr.GetFileAddress(); |
| 1642 | addr_t addr_file_addr = format_addr.GetFileAddress(); |
| 1643 | if (addr_file_addr > func_file_addr) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1644 | s.Printf(" + %llu", addr_file_addr - func_file_addr); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1645 | else if (addr_file_addr < func_file_addr) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1646 | s.Printf(" - %llu", func_file_addr - addr_file_addr); |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1647 | var_success = true; |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1648 | } |
| 1649 | else |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1650 | { |
| 1651 | Target *target = Target::GetTargetFromContexts (exe_ctx, sc); |
| 1652 | if (target) |
| 1653 | { |
| 1654 | addr_t func_load_addr = func_addr.GetLoadAddress (target); |
| 1655 | addr_t addr_load_addr = format_addr.GetLoadAddress (target); |
| 1656 | if (addr_load_addr > func_load_addr) |
| 1657 | s.Printf(" + %llu", addr_load_addr - func_load_addr); |
| 1658 | else if (addr_load_addr < func_load_addr) |
| 1659 | s.Printf(" - %llu", func_load_addr - addr_load_addr); |
| 1660 | var_success = true; |
| 1661 | } |
| 1662 | } |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1663 | } |
| 1664 | } |
| 1665 | else |
| 1666 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1667 | Target *target = Target::GetTargetFromContexts (exe_ctx, sc); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1668 | addr_t vaddr = LLDB_INVALID_ADDRESS; |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1669 | if (exe_ctx && !target->GetSectionLoadList().IsEmpty()) |
| 1670 | vaddr = format_addr.GetLoadAddress (target); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1671 | if (vaddr == LLDB_INVALID_ADDRESS) |
| 1672 | vaddr = format_addr.GetFileAddress (); |
| 1673 | |
| 1674 | if (vaddr != LLDB_INVALID_ADDRESS) |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1675 | { |
Greg Clayton | 514487e | 2011-02-15 21:59:32 +0000 | [diff] [blame] | 1676 | int addr_width = target->GetArchitecture().GetAddressByteSize() * 2; |
Greg Clayton | 35f1a0d | 2010-11-19 04:16:11 +0000 | [diff] [blame] | 1677 | if (addr_width == 0) |
| 1678 | addr_width = 16; |
| 1679 | s.Printf("0x%*.*llx", addr_width, addr_width, vaddr); |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1680 | var_success = true; |
| 1681 | } |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1682 | } |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | if (var_success == false) |
| 1687 | success = false; |
| 1688 | } |
| 1689 | p = var_name_end; |
| 1690 | } |
| 1691 | else |
| 1692 | break; |
| 1693 | } |
| 1694 | else |
| 1695 | { |
| 1696 | // We got a dollar sign with no '{' after it, it must just be a dollar sign |
| 1697 | s.PutChar(*p); |
| 1698 | } |
| 1699 | } |
| 1700 | else if (*p == '\\') |
| 1701 | { |
| 1702 | ++p; // skip the slash |
| 1703 | switch (*p) |
| 1704 | { |
| 1705 | case 'a': s.PutChar ('\a'); break; |
| 1706 | case 'b': s.PutChar ('\b'); break; |
| 1707 | case 'f': s.PutChar ('\f'); break; |
| 1708 | case 'n': s.PutChar ('\n'); break; |
| 1709 | case 'r': s.PutChar ('\r'); break; |
| 1710 | case 't': s.PutChar ('\t'); break; |
| 1711 | case 'v': s.PutChar ('\v'); break; |
| 1712 | case '\'': s.PutChar ('\''); break; |
| 1713 | case '\\': s.PutChar ('\\'); break; |
| 1714 | case '0': |
| 1715 | // 1 to 3 octal chars |
| 1716 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1717 | // Make a string that can hold onto the initial zero char, |
| 1718 | // up to 3 octal digits, and a terminating NULL. |
| 1719 | char oct_str[5] = { 0, 0, 0, 0, 0 }; |
| 1720 | |
| 1721 | int i; |
| 1722 | for (i=0; (p[i] >= '0' && p[i] <= '7') && i<4; ++i) |
| 1723 | oct_str[i] = p[i]; |
| 1724 | |
| 1725 | // We don't want to consume the last octal character since |
| 1726 | // the main for loop will do this for us, so we advance p by |
| 1727 | // one less than i (even if i is zero) |
| 1728 | p += i - 1; |
| 1729 | unsigned long octal_value = ::strtoul (oct_str, NULL, 8); |
| 1730 | if (octal_value <= UINT8_MAX) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1731 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1732 | char octal_char = octal_value; |
| 1733 | s.Write (&octal_char, 1); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1734 | } |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1735 | } |
| 1736 | break; |
| 1737 | |
| 1738 | case 'x': |
| 1739 | // hex number in the format |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1740 | if (isxdigit(p[1])) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1741 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1742 | ++p; // Skip the 'x' |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1743 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1744 | // Make a string that can hold onto two hex chars plus a |
| 1745 | // NULL terminator |
| 1746 | char hex_str[3] = { 0,0,0 }; |
| 1747 | hex_str[0] = *p; |
| 1748 | if (isxdigit(p[1])) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1749 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1750 | ++p; // Skip the first of the two hex chars |
| 1751 | hex_str[1] = *p; |
| 1752 | } |
| 1753 | |
| 1754 | unsigned long hex_value = strtoul (hex_str, NULL, 16); |
| 1755 | if (hex_value <= UINT8_MAX) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1756 | s.PutChar (hex_value); |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1757 | } |
| 1758 | else |
| 1759 | { |
| 1760 | s.PutChar('x'); |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1761 | } |
| 1762 | break; |
| 1763 | |
| 1764 | default: |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 1765 | // Just desensitize any other character by just printing what |
| 1766 | // came after the '\' |
| 1767 | s << *p; |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 1768 | break; |
| 1769 | |
| 1770 | } |
| 1771 | |
| 1772 | } |
| 1773 | } |
| 1774 | if (end) |
| 1775 | *end = p; |
| 1776 | return success; |
| 1777 | } |
| 1778 | |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1779 | |
| 1780 | static FormatManager& |
| 1781 | GetFormatManager() { |
| 1782 | static FormatManager g_format_manager; |
| 1783 | return g_format_manager; |
| 1784 | } |
| 1785 | |
Enrico Granata | 217f91f | 2011-08-17 19:07:52 +0000 | [diff] [blame] | 1786 | // The platform should be responsible for initializing its own formatters |
| 1787 | // (e.g. to handle versioning, different runtime libraries, ...) |
| 1788 | // Currently, basic formatters for std:: objects as implemented by |
| 1789 | // the GNU libstdc++ are defined regardless, and enabled by default |
| 1790 | // This is going to be moved to some platform-dependent location |
| 1791 | // (in the meanwhile, these formatters should work for Mac OS X & Linux) |
| 1792 | void |
| 1793 | Debugger::FormatManagerInitialize() |
| 1794 | { |
| 1795 | static bool g_initialized = false; |
| 1796 | |
| 1797 | if (!g_initialized) |
| 1798 | { |
| 1799 | g_initialized = true; |
| 1800 | ConstString gnulib("gnu-libstdc++"); |
| 1801 | FormatManager& format_mgr = GetFormatManager(); |
| 1802 | lldb::FormatCategorySP osxcpp = format_mgr.Category(gnulib.AsCString()); |
| 1803 | osxcpp->Summary()->Add(ConstString("std::string").AsCString(), |
| 1804 | SummaryFormatSP(new StringSummaryFormat(true, |
| 1805 | false, |
| 1806 | false, |
| 1807 | true, |
| 1808 | true, |
| 1809 | false, |
| 1810 | "${var._M_dataplus._M_p}"))); |
| 1811 | osxcpp->Summary()->Add(ConstString("std::basic_string<char>").AsCString(), |
| 1812 | SummaryFormatSP(new StringSummaryFormat(true, |
| 1813 | false, |
| 1814 | false, |
| 1815 | true, |
| 1816 | true, |
| 1817 | false, |
| 1818 | "${var._M_dataplus._M_p}"))); |
| 1819 | osxcpp->Summary()->Add(ConstString("std::basic_string<char,std::char_traits<char>,std::allocator<char> >").AsCString(), |
| 1820 | SummaryFormatSP(new StringSummaryFormat(true, |
| 1821 | false, |
| 1822 | false, |
| 1823 | true, |
| 1824 | true, |
| 1825 | false, |
| 1826 | "${var._M_dataplus._M_p}"))); |
| 1827 | osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::vector<")), |
| 1828 | SyntheticChildrenSP(new SyntheticScriptProvider(true, |
| 1829 | false, |
| 1830 | false, |
| 1831 | "StdVectorSynthProvider"))); |
| 1832 | osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::map<")), |
| 1833 | SyntheticChildrenSP(new SyntheticScriptProvider(true, |
| 1834 | false, |
| 1835 | false, |
| 1836 | "StdMapSynthProvider"))); |
| 1837 | osxcpp->RegexSynth()->Add(RegularExpressionSP(new RegularExpression("std::list<")), |
| 1838 | SyntheticChildrenSP(new SyntheticScriptProvider(true, |
| 1839 | false, |
| 1840 | false, |
| 1841 | "StdListSynthProvider"))); |
| 1842 | |
| 1843 | format_mgr.EnableCategory(gnulib.AsCString()); |
| 1844 | |
| 1845 | } |
| 1846 | } |
| 1847 | |
| 1848 | void |
| 1849 | Debugger::FormatManagerTerminate() |
| 1850 | {} |
| 1851 | |
Enrico Granata | a37a065 | 2011-07-24 00:14:56 +0000 | [diff] [blame] | 1852 | void |
| 1853 | Debugger::Formatting::ForceUpdate() |
| 1854 | { |
| 1855 | GetFormatManager().Changed(); |
| 1856 | } |
| 1857 | |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1858 | bool |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1859 | Debugger::Formatting::ValueFormats::Get(ValueObject& vobj, lldb::DynamicValueType use_dynamic, ValueFormat::SharedPointer &entry) |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1860 | { |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1861 | return GetFormatManager().Value().Get(vobj,entry, use_dynamic); |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1862 | } |
| 1863 | |
| 1864 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1865 | Debugger::Formatting::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry) |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1866 | { |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1867 | GetFormatManager().Value().Add(type.AsCString(),entry); |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1868 | } |
| 1869 | |
| 1870 | bool |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1871 | Debugger::Formatting::ValueFormats::Delete(const ConstString &type) |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1872 | { |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1873 | return GetFormatManager().Value().Delete(type.AsCString()); |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1874 | } |
| 1875 | |
| 1876 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1877 | Debugger::Formatting::ValueFormats::Clear() |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1878 | { |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1879 | GetFormatManager().Value().Clear(); |
| 1880 | } |
| 1881 | |
| 1882 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1883 | Debugger::Formatting::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton) |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1884 | { |
| 1885 | GetFormatManager().Value().LoopThrough(callback, callback_baton); |
| 1886 | } |
| 1887 | |
| 1888 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1889 | Debugger::Formatting::ValueFormats::GetCurrentRevision() |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1890 | { |
| 1891 | return GetFormatManager().GetCurrentRevision(); |
| 1892 | } |
| 1893 | |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 1894 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1895 | Debugger::Formatting::ValueFormats::GetCount() |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 1896 | { |
| 1897 | return GetFormatManager().Value().GetCount(); |
| 1898 | } |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1899 | |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1900 | bool |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1901 | Debugger::Formatting::GetSummaryFormat(ValueObject& vobj, |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1902 | lldb::DynamicValueType use_dynamic, |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1903 | lldb::SummaryFormatSP& entry) |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1904 | { |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1905 | return GetFormatManager().Get(vobj, entry, use_dynamic); |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1906 | } |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 1907 | bool |
Enrico Granata | 68eb4bb | 2011-08-12 19:14:27 +0000 | [diff] [blame] | 1908 | Debugger::Formatting::GetSyntheticChildren(ValueObject& vobj, |
| 1909 | lldb::DynamicValueType use_dynamic, |
| 1910 | lldb::SyntheticChildrenSP& entry) |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 1911 | { |
Enrico Granata | c3e320a | 2011-08-02 17:27:39 +0000 | [diff] [blame] | 1912 | return GetFormatManager().Get(vobj, entry, use_dynamic); |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 1913 | } |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1914 | |
| 1915 | bool |
Enrico Granata | 68eb4bb | 2011-08-12 19:14:27 +0000 | [diff] [blame] | 1916 | Debugger::Formatting::AnyMatches(ConstString type_name, |
| 1917 | FormatCategory::FormatCategoryItems items, |
| 1918 | bool only_enabled, |
| 1919 | const char** matching_category, |
| 1920 | FormatCategory::FormatCategoryItems* matching_type) |
| 1921 | { |
| 1922 | return GetFormatManager().AnyMatches(type_name, |
| 1923 | items, |
| 1924 | only_enabled, |
| 1925 | matching_category, |
| 1926 | matching_type); |
| 1927 | } |
| 1928 | |
| 1929 | bool |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1930 | Debugger::Formatting::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry) |
| 1931 | { |
| 1932 | entry = GetFormatManager().Category(category.GetCString()); |
| 1933 | return true; |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1934 | } |
| 1935 | |
| 1936 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1937 | Debugger::Formatting::Categories::Add(const ConstString &category) |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1938 | { |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1939 | GetFormatManager().Category(category.GetCString()); |
| 1940 | } |
| 1941 | |
| 1942 | bool |
| 1943 | Debugger::Formatting::Categories::Delete(const ConstString &category) |
| 1944 | { |
| 1945 | GetFormatManager().DisableCategory(category.GetCString()); |
| 1946 | return GetFormatManager().Categories().Delete(category.GetCString()); |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1947 | } |
| 1948 | |
| 1949 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1950 | Debugger::Formatting::Categories::Clear() |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1951 | { |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1952 | GetFormatManager().Categories().Clear(); |
| 1953 | } |
| 1954 | |
| 1955 | void |
| 1956 | Debugger::Formatting::Categories::Clear(ConstString &category) |
| 1957 | { |
Enrico Granata | d55546b | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 1958 | GetFormatManager().Category(category.GetCString())->ClearSummaries(); |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | void |
| 1962 | Debugger::Formatting::Categories::Enable(ConstString& category) |
| 1963 | { |
| 1964 | if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false) |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1965 | GetFormatManager().EnableCategory(category.GetCString()); |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1966 | else |
| 1967 | { |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1968 | GetFormatManager().DisableCategory(category.GetCString()); |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1969 | GetFormatManager().EnableCategory(category.GetCString()); |
| 1970 | } |
| 1971 | } |
| 1972 | |
| 1973 | void |
| 1974 | Debugger::Formatting::Categories::Disable(ConstString& category) |
| 1975 | { |
| 1976 | if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true) |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1977 | GetFormatManager().DisableCategory(category.GetCString()); |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1978 | } |
| 1979 | |
| 1980 | void |
| 1981 | Debugger::Formatting::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton) |
| 1982 | { |
| 1983 | GetFormatManager().LoopThroughCategories(callback, callback_baton); |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1984 | } |
| 1985 | |
| 1986 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1987 | Debugger::Formatting::Categories::GetCurrentRevision() |
Enrico Granata | 4becb37 | 2011-06-29 22:27:15 +0000 | [diff] [blame] | 1988 | { |
| 1989 | return GetFormatManager().GetCurrentRevision(); |
Greg Clayton | 4a33d31 | 2011-06-23 17:59:56 +0000 | [diff] [blame] | 1990 | } |
| 1991 | |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 1992 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1993 | Debugger::Formatting::Categories::GetCount() |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 1994 | { |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1995 | return GetFormatManager().Categories().GetCount(); |
Enrico Granata | 0a3958e | 2011-07-02 00:25:22 +0000 | [diff] [blame] | 1996 | } |
| 1997 | |
| 1998 | bool |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 1999 | Debugger::Formatting::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry) |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2000 | { |
| 2001 | return GetFormatManager().NamedSummary().Get(type.AsCString(),entry); |
| 2002 | } |
| 2003 | |
| 2004 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2005 | Debugger::Formatting::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry) |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2006 | { |
| 2007 | GetFormatManager().NamedSummary().Add(type.AsCString(),entry); |
| 2008 | } |
| 2009 | |
| 2010 | bool |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2011 | Debugger::Formatting::NamedSummaryFormats::Delete(const ConstString &type) |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2012 | { |
| 2013 | return GetFormatManager().NamedSummary().Delete(type.AsCString()); |
| 2014 | } |
| 2015 | |
| 2016 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2017 | Debugger::Formatting::NamedSummaryFormats::Clear() |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2018 | { |
| 2019 | GetFormatManager().NamedSummary().Clear(); |
| 2020 | } |
| 2021 | |
| 2022 | void |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2023 | Debugger::Formatting::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton) |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2024 | { |
| 2025 | GetFormatManager().NamedSummary().LoopThrough(callback, callback_baton); |
| 2026 | } |
| 2027 | |
| 2028 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2029 | Debugger::Formatting::NamedSummaryFormats::GetCurrentRevision() |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2030 | { |
| 2031 | return GetFormatManager().GetCurrentRevision(); |
| 2032 | } |
| 2033 | |
| 2034 | uint32_t |
Enrico Granata | 1490c6f | 2011-07-19 02:34:21 +0000 | [diff] [blame] | 2035 | Debugger::Formatting::NamedSummaryFormats::GetCount() |
Enrico Granata | f9fa6ee | 2011-07-12 00:18:11 +0000 | [diff] [blame] | 2036 | { |
| 2037 | return GetFormatManager().NamedSummary().GetCount(); |
| 2038 | } |
| 2039 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2040 | #pragma mark Debugger::SettingsController |
| 2041 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2042 | //-------------------------------------------------- |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2043 | // class Debugger::SettingsController |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2044 | //-------------------------------------------------- |
| 2045 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2046 | Debugger::SettingsController::SettingsController () : |
Caroline Tice | 101c7c2 | 2010-09-09 06:25:08 +0000 | [diff] [blame] | 2047 | UserSettingsController ("", lldb::UserSettingsControllerSP()) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2048 | { |
Caroline Tice | 91123da | 2010-09-08 17:48:55 +0000 | [diff] [blame] | 2049 | m_default_settings.reset (new DebuggerInstanceSettings (*this, false, |
| 2050 | InstanceSettings::GetDefaultName().AsCString())); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2051 | } |
| 2052 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2053 | Debugger::SettingsController::~SettingsController () |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2054 | { |
| 2055 | } |
| 2056 | |
| 2057 | |
| 2058 | lldb::InstanceSettingsSP |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2059 | Debugger::SettingsController::CreateInstanceSettings (const char *instance_name) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2060 | { |
Greg Clayton | dbe5450 | 2010-11-19 03:46:01 +0000 | [diff] [blame] | 2061 | DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*GetSettingsController(), |
Caroline Tice | 91123da | 2010-09-08 17:48:55 +0000 | [diff] [blame] | 2062 | false, instance_name); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2063 | lldb::InstanceSettingsSP new_settings_sp (new_settings); |
| 2064 | return new_settings_sp; |
| 2065 | } |
| 2066 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2067 | #pragma mark DebuggerInstanceSettings |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2068 | //-------------------------------------------------- |
| 2069 | // class DebuggerInstanceSettings |
| 2070 | //-------------------------------------------------- |
| 2071 | |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2072 | DebuggerInstanceSettings::DebuggerInstanceSettings |
| 2073 | ( |
| 2074 | UserSettingsController &owner, |
| 2075 | bool live_instance, |
| 2076 | const char *name |
| 2077 | ) : |
Greg Clayton | 85851dd | 2010-12-04 00:10:17 +0000 | [diff] [blame] | 2078 | InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), |
Greg Clayton | a701509 | 2010-09-18 01:14:36 +0000 | [diff] [blame] | 2079 | m_term_width (80), |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2080 | m_prompt (), |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2081 | m_frame_format (), |
| 2082 | m_thread_format (), |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2083 | m_script_lang (), |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2084 | m_use_external_editor (false), |
| 2085 | m_auto_confirm_on (false) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2086 | { |
Caroline Tice | f20e823 | 2010-09-09 18:26:37 +0000 | [diff] [blame] | 2087 | // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called |
| 2088 | // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers. |
| 2089 | // For this reason it has to be called here, rather than in the initializer or in the parent constructor. |
Caroline Tice | 9e41c15 | 2010-09-16 19:05:55 +0000 | [diff] [blame] | 2090 | // The same is true of CreateInstanceName(). |
| 2091 | |
| 2092 | if (GetInstanceName() == InstanceSettings::InvalidName()) |
| 2093 | { |
| 2094 | ChangeInstanceName (std::string (CreateInstanceName().AsCString())); |
| 2095 | m_owner.RegisterInstanceSettings (this); |
| 2096 | } |
Caroline Tice | f20e823 | 2010-09-09 18:26:37 +0000 | [diff] [blame] | 2097 | |
| 2098 | if (live_instance) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2099 | { |
| 2100 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 2101 | CopyInstanceSettings (pending_settings, false); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2102 | } |
| 2103 | } |
| 2104 | |
| 2105 | DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) : |
Greg Clayton | 99d0faf | 2010-11-18 23:32:35 +0000 | [diff] [blame] | 2106 | InstanceSettings (*Debugger::GetSettingsController(), CreateInstanceName ().AsCString()), |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2107 | m_prompt (rhs.m_prompt), |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2108 | m_frame_format (rhs.m_frame_format), |
| 2109 | m_thread_format (rhs.m_thread_format), |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2110 | m_script_lang (rhs.m_script_lang), |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2111 | m_use_external_editor (rhs.m_use_external_editor), |
| 2112 | m_auto_confirm_on(rhs.m_auto_confirm_on) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2113 | { |
| 2114 | const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name); |
| 2115 | CopyInstanceSettings (pending_settings, false); |
| 2116 | m_owner.RemovePendingSettings (m_instance_name); |
| 2117 | } |
| 2118 | |
| 2119 | DebuggerInstanceSettings::~DebuggerInstanceSettings () |
| 2120 | { |
| 2121 | } |
| 2122 | |
| 2123 | DebuggerInstanceSettings& |
| 2124 | DebuggerInstanceSettings::operator= (const DebuggerInstanceSettings &rhs) |
| 2125 | { |
| 2126 | if (this != &rhs) |
| 2127 | { |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2128 | m_term_width = rhs.m_term_width; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2129 | m_prompt = rhs.m_prompt; |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2130 | m_frame_format = rhs.m_frame_format; |
| 2131 | m_thread_format = rhs.m_thread_format; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2132 | m_script_lang = rhs.m_script_lang; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2133 | m_use_external_editor = rhs.m_use_external_editor; |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2134 | m_auto_confirm_on = rhs.m_auto_confirm_on; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2135 | } |
| 2136 | |
| 2137 | return *this; |
| 2138 | } |
| 2139 | |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2140 | bool |
| 2141 | DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) |
| 2142 | { |
| 2143 | bool valid = false; |
| 2144 | |
| 2145 | // Verify we have a value string. |
| 2146 | if (value == NULL || value[0] == '\0') |
| 2147 | { |
| 2148 | err.SetErrorString ("Missing value. Can't set terminal width without a value.\n"); |
| 2149 | } |
| 2150 | else |
| 2151 | { |
| 2152 | char *end = NULL; |
| 2153 | const uint32_t width = ::strtoul (value, &end, 0); |
| 2154 | |
Johnny Chen | ea9fc18 | 2010-09-20 16:36:43 +0000 | [diff] [blame] | 2155 | if (end && end[0] == '\0') |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2156 | { |
Johnny Chen | 433d774 | 2010-09-20 17:04:41 +0000 | [diff] [blame] | 2157 | if (width >= 10 && width <= 1024) |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2158 | valid = true; |
| 2159 | else |
| 2160 | err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n"); |
| 2161 | } |
| 2162 | else |
| 2163 | err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value); |
| 2164 | } |
| 2165 | |
| 2166 | return valid; |
| 2167 | } |
| 2168 | |
| 2169 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2170 | void |
| 2171 | DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, |
| 2172 | const char *index_value, |
| 2173 | const char *value, |
| 2174 | const ConstString &instance_name, |
| 2175 | const SettingEntry &entry, |
Greg Clayton | e0d378b | 2011-03-24 21:19:54 +0000 | [diff] [blame] | 2176 | VarSetOperationType op, |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2177 | Error &err, |
| 2178 | bool pending) |
| 2179 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2180 | |
| 2181 | if (var_name == TermWidthVarName()) |
| 2182 | { |
| 2183 | if (ValidTermWidthValue (value, err)) |
| 2184 | { |
| 2185 | m_term_width = ::strtoul (value, NULL, 0); |
| 2186 | } |
| 2187 | } |
| 2188 | else if (var_name == PromptVarName()) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2189 | { |
Caroline Tice | 101c7c2 | 2010-09-09 06:25:08 +0000 | [diff] [blame] | 2190 | UserSettingsController::UpdateStringVariable (op, m_prompt, value, err); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2191 | if (!pending) |
| 2192 | { |
Caroline Tice | 49e2737 | 2010-09-07 18:35:40 +0000 | [diff] [blame] | 2193 | // 'instance_name' is actually (probably) in the form '[<instance_name>]'; if so, we need to |
| 2194 | // strip off the brackets before passing it to BroadcastPromptChange. |
| 2195 | |
| 2196 | std::string tmp_instance_name (instance_name.AsCString()); |
| 2197 | if ((tmp_instance_name[0] == '[') |
| 2198 | && (tmp_instance_name[instance_name.GetLength() - 1] == ']')) |
| 2199 | tmp_instance_name = tmp_instance_name.substr (1, instance_name.GetLength() - 2); |
| 2200 | ConstString new_name (tmp_instance_name.c_str()); |
| 2201 | |
| 2202 | BroadcastPromptChange (new_name, m_prompt.c_str()); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2203 | } |
| 2204 | } |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2205 | else if (var_name == GetFrameFormatName()) |
| 2206 | { |
| 2207 | UserSettingsController::UpdateStringVariable (op, m_frame_format, value, err); |
| 2208 | } |
| 2209 | else if (var_name == GetThreadFormatName()) |
| 2210 | { |
| 2211 | UserSettingsController::UpdateStringVariable (op, m_thread_format, value, err); |
| 2212 | } |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2213 | else if (var_name == ScriptLangVarName()) |
| 2214 | { |
| 2215 | bool success; |
| 2216 | m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault, |
| 2217 | &success); |
| 2218 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2219 | else if (var_name == UseExternalEditorVarName ()) |
| 2220 | { |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2221 | UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, false, err); |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2222 | } |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2223 | else if (var_name == AutoConfirmName ()) |
| 2224 | { |
Greg Clayton | 385aa28 | 2011-04-22 03:55:06 +0000 | [diff] [blame] | 2225 | UserSettingsController::UpdateBooleanVariable (op, m_auto_confirm_on, value, false, err); |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2226 | } |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2227 | } |
| 2228 | |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 +0000 | [diff] [blame] | 2229 | bool |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2230 | DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, |
| 2231 | const ConstString &var_name, |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2232 | StringList &value, |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 +0000 | [diff] [blame] | 2233 | Error *err) |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2234 | { |
| 2235 | if (var_name == PromptVarName()) |
| 2236 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2237 | value.AppendString (m_prompt.c_str(), m_prompt.size()); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2238 | |
| 2239 | } |
| 2240 | else if (var_name == ScriptLangVarName()) |
| 2241 | { |
| 2242 | value.AppendString (ScriptInterpreter::LanguageToString (m_script_lang).c_str()); |
| 2243 | } |
Caroline Tice | 101c7c2 | 2010-09-09 06:25:08 +0000 | [diff] [blame] | 2244 | else if (var_name == TermWidthVarName()) |
| 2245 | { |
| 2246 | StreamString width_str; |
| 2247 | width_str.Printf ("%d", m_term_width); |
| 2248 | value.AppendString (width_str.GetData()); |
| 2249 | } |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2250 | else if (var_name == GetFrameFormatName ()) |
| 2251 | { |
| 2252 | value.AppendString(m_frame_format.c_str(), m_frame_format.size()); |
| 2253 | } |
| 2254 | else if (var_name == GetThreadFormatName ()) |
| 2255 | { |
| 2256 | value.AppendString(m_thread_format.c_str(), m_thread_format.size()); |
| 2257 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2258 | else if (var_name == UseExternalEditorVarName()) |
| 2259 | { |
| 2260 | if (m_use_external_editor) |
| 2261 | value.AppendString ("true"); |
| 2262 | else |
| 2263 | value.AppendString ("false"); |
| 2264 | } |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2265 | else if (var_name == AutoConfirmName()) |
| 2266 | { |
| 2267 | if (m_auto_confirm_on) |
| 2268 | value.AppendString ("true"); |
| 2269 | else |
| 2270 | value.AppendString ("false"); |
| 2271 | } |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2272 | else |
Caroline Tice | 12cecd7 | 2010-09-20 21:37:42 +0000 | [diff] [blame] | 2273 | { |
| 2274 | if (err) |
| 2275 | err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString()); |
| 2276 | return false; |
| 2277 | } |
| 2278 | return true; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2279 | } |
| 2280 | |
| 2281 | void |
| 2282 | DebuggerInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, |
| 2283 | bool pending) |
| 2284 | { |
| 2285 | if (new_settings.get() == NULL) |
| 2286 | return; |
| 2287 | |
| 2288 | DebuggerInstanceSettings *new_debugger_settings = (DebuggerInstanceSettings *) new_settings.get(); |
| 2289 | |
| 2290 | m_prompt = new_debugger_settings->m_prompt; |
| 2291 | if (!pending) |
Caroline Tice | 49e2737 | 2010-09-07 18:35:40 +0000 | [diff] [blame] | 2292 | { |
| 2293 | // 'instance_name' is actually (probably) in the form '[<instance_name>]'; if so, we need to |
| 2294 | // strip off the brackets before passing it to BroadcastPromptChange. |
| 2295 | |
| 2296 | std::string tmp_instance_name (m_instance_name.AsCString()); |
| 2297 | if ((tmp_instance_name[0] == '[') |
| 2298 | && (tmp_instance_name[m_instance_name.GetLength() - 1] == ']')) |
| 2299 | tmp_instance_name = tmp_instance_name.substr (1, m_instance_name.GetLength() - 2); |
| 2300 | ConstString new_name (tmp_instance_name.c_str()); |
| 2301 | |
| 2302 | BroadcastPromptChange (new_name, m_prompt.c_str()); |
| 2303 | } |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2304 | m_frame_format = new_debugger_settings->m_frame_format; |
| 2305 | m_thread_format = new_debugger_settings->m_thread_format; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2306 | m_term_width = new_debugger_settings->m_term_width; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2307 | m_script_lang = new_debugger_settings->m_script_lang; |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2308 | m_use_external_editor = new_debugger_settings->m_use_external_editor; |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2309 | m_auto_confirm_on = new_debugger_settings->m_auto_confirm_on; |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2310 | } |
| 2311 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2312 | |
| 2313 | bool |
| 2314 | DebuggerInstanceSettings::BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt) |
| 2315 | { |
| 2316 | std::string tmp_prompt; |
| 2317 | |
| 2318 | if (new_prompt != NULL) |
| 2319 | { |
| 2320 | tmp_prompt = new_prompt ; |
| 2321 | int len = tmp_prompt.size(); |
| 2322 | if (len > 1 |
| 2323 | && (tmp_prompt[0] == '\'' || tmp_prompt[0] == '"') |
| 2324 | && (tmp_prompt[len-1] == tmp_prompt[0])) |
| 2325 | { |
| 2326 | tmp_prompt = tmp_prompt.substr(1,len-2); |
| 2327 | } |
| 2328 | len = tmp_prompt.size(); |
| 2329 | if (tmp_prompt[len-1] != ' ') |
| 2330 | tmp_prompt.append(" "); |
| 2331 | } |
| 2332 | EventSP new_event_sp; |
| 2333 | new_event_sp.reset (new Event(CommandInterpreter::eBroadcastBitResetPrompt, |
| 2334 | new EventDataBytes (tmp_prompt.c_str()))); |
| 2335 | |
| 2336 | if (instance_name.GetLength() != 0) |
| 2337 | { |
| 2338 | // Set prompt for a particular instance. |
| 2339 | Debugger *dbg = Debugger::FindDebuggerWithInstanceName (instance_name).get(); |
| 2340 | if (dbg != NULL) |
| 2341 | { |
| 2342 | dbg->GetCommandInterpreter().BroadcastEvent (new_event_sp); |
| 2343 | } |
| 2344 | } |
| 2345 | |
| 2346 | return true; |
| 2347 | } |
| 2348 | |
| 2349 | const ConstString |
| 2350 | DebuggerInstanceSettings::CreateInstanceName () |
| 2351 | { |
| 2352 | static int instance_count = 1; |
| 2353 | StreamString sstr; |
| 2354 | |
| 2355 | sstr.Printf ("debugger_%d", instance_count); |
| 2356 | ++instance_count; |
| 2357 | |
| 2358 | const ConstString ret_val (sstr.GetData()); |
| 2359 | |
| 2360 | return ret_val; |
| 2361 | } |
| 2362 | |
| 2363 | const ConstString & |
| 2364 | DebuggerInstanceSettings::PromptVarName () |
| 2365 | { |
| 2366 | static ConstString prompt_var_name ("prompt"); |
| 2367 | |
| 2368 | return prompt_var_name; |
| 2369 | } |
| 2370 | |
| 2371 | const ConstString & |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2372 | DebuggerInstanceSettings::GetFrameFormatName () |
| 2373 | { |
| 2374 | static ConstString prompt_var_name ("frame-format"); |
| 2375 | |
| 2376 | return prompt_var_name; |
| 2377 | } |
| 2378 | |
| 2379 | const ConstString & |
| 2380 | DebuggerInstanceSettings::GetThreadFormatName () |
| 2381 | { |
| 2382 | static ConstString prompt_var_name ("thread-format"); |
| 2383 | |
| 2384 | return prompt_var_name; |
| 2385 | } |
| 2386 | |
| 2387 | const ConstString & |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2388 | DebuggerInstanceSettings::ScriptLangVarName () |
| 2389 | { |
| 2390 | static ConstString script_lang_var_name ("script-lang"); |
| 2391 | |
| 2392 | return script_lang_var_name; |
| 2393 | } |
| 2394 | |
Caroline Tice | 101c7c2 | 2010-09-09 06:25:08 +0000 | [diff] [blame] | 2395 | const ConstString & |
| 2396 | DebuggerInstanceSettings::TermWidthVarName () |
| 2397 | { |
| 2398 | static ConstString term_width_var_name ("term-width"); |
| 2399 | |
| 2400 | return term_width_var_name; |
| 2401 | } |
| 2402 | |
Caroline Tice | daccaa9 | 2010-09-20 20:44:43 +0000 | [diff] [blame] | 2403 | const ConstString & |
| 2404 | DebuggerInstanceSettings::UseExternalEditorVarName () |
| 2405 | { |
| 2406 | static ConstString use_external_editor_var_name ("use-external-editor"); |
| 2407 | |
| 2408 | return use_external_editor_var_name; |
| 2409 | } |
| 2410 | |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2411 | const ConstString & |
| 2412 | DebuggerInstanceSettings::AutoConfirmName () |
| 2413 | { |
| 2414 | static ConstString use_external_editor_var_name ("auto-confirm"); |
| 2415 | |
| 2416 | return use_external_editor_var_name; |
| 2417 | } |
| 2418 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2419 | //-------------------------------------------------- |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2420 | // SettingsController Variable Tables |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2421 | //-------------------------------------------------- |
| 2422 | |
| 2423 | |
| 2424 | SettingEntry |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2425 | Debugger::SettingsController::global_settings_table[] = |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2426 | { |
| 2427 | //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, |
Caroline Tice | 101c7c2 | 2010-09-09 06:25:08 +0000 | [diff] [blame] | 2428 | // The Debugger level global table should always be empty; all Debugger settable variables should be instance |
| 2429 | // variables. |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2430 | { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } |
| 2431 | }; |
| 2432 | |
Greg Clayton | bb562b1 | 2010-10-04 02:44:26 +0000 | [diff] [blame] | 2433 | #define MODULE_WITH_FUNC "{ ${module.file.basename}{`${function.name}${function.pc-offset}}}" |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2434 | #define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}" |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2435 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2436 | #define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ |
| 2437 | "{, ${frame.pc}}"\ |
| 2438 | MODULE_WITH_FUNC\ |
Greg Clayton | cf4b907 | 2010-10-04 17:04:23 +0000 | [diff] [blame] | 2439 | FILE_AND_LINE\ |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2440 | "{, stop reason = ${thread.stop-reason}}"\ |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2441 | "\\n" |
| 2442 | |
Greg Clayton | 315d2ca | 2010-11-02 01:53:21 +0000 | [diff] [blame] | 2443 | //#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\ |
| 2444 | // "{, ${frame.pc}}"\ |
| 2445 | // MODULE_WITH_FUNC\ |
| 2446 | // FILE_AND_LINE\ |
| 2447 | // "{, stop reason = ${thread.stop-reason}}"\ |
| 2448 | // "{, name = ${thread.name}}"\ |
| 2449 | // "{, queue = ${thread.queue}}"\ |
| 2450 | // "\\n" |
| 2451 | |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2452 | #define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\ |
| 2453 | MODULE_WITH_FUNC\ |
| 2454 | FILE_AND_LINE\ |
| 2455 | "\\n" |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2456 | |
| 2457 | SettingEntry |
Greg Clayton | 1b65488 | 2010-09-19 02:33:57 +0000 | [diff] [blame] | 2458 | Debugger::SettingsController::instance_settings_table[] = |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2459 | { |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2460 | // NAME Setting variable type Default Enum Init'd Hidden Help |
| 2461 | // ======================= ======================= ====================== ==== ====== ====== ====================== |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2462 | { "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." }, |
Greg Clayton | 5418039 | 2010-10-22 21:15:00 +0000 | [diff] [blame] | 2463 | { "prompt", eSetVarTypeString, "(lldb) ", NULL, false, false, "The debugger command line prompt displayed for the user." }, |
Jim Ingham | 3bcdb29 | 2010-10-04 22:44:14 +0000 | [diff] [blame] | 2464 | { "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, |
| 2465 | { "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2466 | { "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, |
Jim Ingham | 06e827c | 2010-11-11 19:26:09 +0000 | [diff] [blame] | 2467 | { "use-external-editor", eSetVarTypeBoolean, "false", NULL, false, false, "Whether to use an external editor or not." }, |
| 2468 | { "auto-confirm", eSetVarTypeBoolean, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, |
Greg Clayton | 0603aa9 | 2010-10-04 01:05:56 +0000 | [diff] [blame] | 2469 | { NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 2470 | }; |