-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecution_time.cpp
More file actions
41 lines (36 loc) · 1.59 KB
/
execution_time.cpp
File metadata and controls
41 lines (36 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <lldb/API/LLDB.h>
int main()
{
lldb::SBDebugger::Initialize();
lldb::SBDebugger debugger = lldb::SBDebugger::Create();
debugger.SetAsync(false);
lldb::SBTarget target = debugger.CreateTarget("main");
// breakpoint
lldb::SBBreakpoint b_st = target.BreakpointCreateByLocation("baseline.cpp", 10);
lldb::SBBreakpoint b_ed = target.BreakpointCreateByLocation("baseline.cpp", 38);
lldb::SBBreakpoint t_st = target.BreakpointCreateByLocation("threaded.cpp", 20);
lldb::SBBreakpoint t_ed = target.BreakpointCreateByLocation("threaded.cpp", 45);
// process
lldb::SBProcess process = target.LaunchSimple(nullptr, nullptr, nullptr);
lldb::StateType state = process.GetState();
lldb::SBThread thread = process.GetThreadAtIndex(0);
int count = 0;
while (state != lldb::eStateExited && state != lldb::eStateInvalid)
{
if (state == lldb::eStateStopped)
{
// std::cout << count << ": " << thread.GetFrameAtIndex(0).GetLineEntry().GetFileSpec().GetFilename() << ":" << thread.GetFrameAtIndex(0).GetLineEntry().GetLine() << std::endl;
if (thread.GetStopReason() == lldb::eStopReasonBreakpoint)
{
std::cout << "count" << count << std::endl;
std::cout << " " << thread.GetFrameAtIndex(0).GetFunctionName() << " " << thread.GetFrameAtIndex(0).GetLineEntry().GetLine() << std::endl;
}
count += 1;
thread.StepInstruction(true);
}
state = process.GetState();
}
lldb::SBDebugger::Terminate();
return 0;
}