1 //===-- Xcode.cpp -----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 using namespace lldb_perf;
17 Xcode::FetchVariable (SBValue value, uint32_t expand, bool verbose)
19 auto name = value.GetName();
20 auto num_value = value.GetValueAsUnsigned(0);
21 auto summary = value.GetSummary();
22 auto in_scope = value.IsInScope();
23 auto has_children = value.MightHaveChildren();
24 auto type_1 = value.GetType();
25 auto type_2 = value.GetType();
26 auto type_name_1 = value.GetTypeName();
27 auto type_3 = value.GetType();
28 auto type_name_2 = value.GetTypeName();
30 printf("%s %s = 0x%llx (%llu) %s\n",value.GetTypeName(),value.GetName(),num_value, num_value,summary);
33 auto count = value.GetNumChildren();
34 for (int i = 0; i < count; i++)
36 SBValue child(value.GetChildAtIndex(i, lldb::eDynamicCanRunTarget, true));
37 FetchVariable (child,expand-1,verbose);
43 Xcode::FetchModules (SBTarget target, bool verbose)
45 auto count = target.GetNumModules();
46 for (int i = 0; i < count; i++)
48 SBModule module(target.GetModuleAtIndex(i));
49 auto fspec = module.GetFileSpec();
50 std::string path(1024,0);
51 fspec.GetPath(&path[0],1024);
52 auto uuid = module.GetUUIDBytes();
55 printf("%s %s\n",path.c_str(),module.GetUUIDString());
61 Xcode::FetchVariables (SBFrame frame, uint32_t expand, bool verbose)
63 auto values = frame.GetVariables (true,true,true,false, eDynamicCanRunTarget);
64 auto count = values.GetSize();
65 for (int i = 0; i < count; i++)
67 SBValue value(values.GetValueAtIndex(i));
68 FetchVariable (value,expand,verbose);
73 Xcode::FetchFrames(SBProcess process, bool variables, bool verbose)
75 auto pCount = process.GetNumThreads();
76 for (int p = 0; p < pCount; p++)
78 SBThread thread(process.GetThreadAtIndex(p));
79 auto tCount = thread.GetNumFrames ();
81 printf("%s %d %d {%d}\n",thread.GetQueueName(),tCount,thread.GetStopReason(),eStopReasonBreakpoint);
82 for (int t = 0; t < tCount; t++)
84 SBFrame frame(thread.GetFrameAtIndex(t));
85 auto fp = frame.GetFP();
86 SBThread thread_dup = frame.GetThread();
87 SBFileSpec filespec(process.GetTarget().GetExecutable());
88 std::string path(1024,0);
89 filespec.GetPath(&path[0],1024);
90 auto state = process.GetState();
91 auto pCount_dup = process.GetNumThreads();
92 auto byte_size = process.GetAddressByteSize();
93 auto pc = frame.GetPC();
94 SBSymbolContext context(frame.GetSymbolContext(0x0000006e));
95 SBModule module(context.GetModule());
96 SBLineEntry entry(context.GetLineEntry());
97 SBFileSpec entry_filespec(process.GetTarget().GetExecutable());
98 std::string entry_path(1024,0);
99 entry_filespec.GetPath(&entry_path[0],1024);
100 auto line_1 = entry.GetLine();
101 auto line_2 = entry.GetLine();
102 auto fname = frame.GetFunctionName();
104 printf("%llu %s %d %d %llu %s %d %s\n",fp,path.c_str(),state,byte_size,pc,entry_path.c_str(),line_1,fname);
106 FetchVariables (frame, 0, verbose);
112 Xcode::RunExpression (SBFrame frame, const char* expression, bool po, bool verbose)
114 SBValue value (frame.EvaluateExpression (expression, eDynamicCanRunTarget));
115 FetchVariable (value,0,verbose);
118 auto descr = value.GetObjectDescription();
120 printf("po = %s\n",descr);
125 Xcode::Next (SBThread thread)
131 Xcode::Continue (SBProcess process)
137 Xcode::RunCommand (SBDebugger debugger, const char* cmd, bool verbose)
139 SBCommandReturnObject sb_ret;
140 auto interpreter = debugger.GetCommandInterpreter();
141 interpreter.HandleCommand(cmd,sb_ret);
143 printf("%s\n%s\n",sb_ret.GetOutput(false),sb_ret.GetError(false));
147 Xcode::GetThreadWithStopReason (SBProcess process, StopReason reason)
149 auto threads_count = process.GetNumThreads();
150 for (auto thread_num = 0; thread_num < threads_count; thread_num++)
152 SBThread thread(process.GetThreadAtIndex(thread_num));
153 if (thread.GetStopReason() == reason)
162 Xcode::CreateFileLineBreakpoint (SBTarget target, const char* file, uint32_t line)
164 return target.BreakpointCreateByLocation(file, line);