mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-08 20:04:02 +00:00
Fixed the lldb_perf_clang.cpp test case to be able to run correctly.
1 - There were some outdated options being passed to clang 2 - There were some bad paths being passed as options 3 - The path to the main.cpp file ("/tmp/main.cpp") was wrong when the tests were being run, now we create a temp file 4 - Added a new ActionType::eNone to do nothing (no continue, step, or kill) llvm-svn: 202431
This commit is contained in:
parent
4e764b4cb1
commit
46822c7c72
@ -84,6 +84,8 @@ public:
|
||||
virtual void
|
||||
TestStep (int counter, ActionWanted &next_action)
|
||||
{
|
||||
char temp_source_path[PATH_MAX] = "/tmp/main.XXXXXX.cpp";
|
||||
|
||||
switch (counter)
|
||||
{
|
||||
case 0:
|
||||
@ -98,6 +100,47 @@ public:
|
||||
|
||||
m_time_set_bp_main();
|
||||
|
||||
int fd = mkstemps(temp_source_path, 4);
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
const char *source_content = R"(
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
struct Foo
|
||||
{
|
||||
int i; int j;
|
||||
};
|
||||
void doit (const Foo &foo)
|
||||
{
|
||||
printf ("doit(%i)\n", foo.i);
|
||||
}
|
||||
}
|
||||
|
||||
int main (int argc, char const *argv[], char const *envp[])
|
||||
{
|
||||
std::vector<int> ints;
|
||||
for (int i=0;i<10;++i)
|
||||
ints.push_back(i);
|
||||
printf ("hello world\n");
|
||||
Foo foo = { 12, 13 };
|
||||
doit (foo);
|
||||
return 0;
|
||||
}
|
||||
)";
|
||||
write (fd, source_content, strlen(source_content));
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *error_cstr = strerror(errno);
|
||||
fprintf (stderr, "error: failed to created temporary source file: '%s' (%s)", temp_source_path, error_cstr);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
m_time_launch_stop_main.Start();
|
||||
const char *clang_argv[] = {
|
||||
"-cc1",
|
||||
@ -116,10 +159,8 @@ public:
|
||||
"-target-linker-version", "132.10.1",
|
||||
"-v",
|
||||
"-g",
|
||||
"-resource-dir", "/tmp/clang-176809/llvm-build/build/Debug/bin/../lib/clang/3.3",
|
||||
"-O0",
|
||||
"-fdeprecated-macro",
|
||||
"-fdebug-compilation-dir", "/tmp/clang-176809/llvm-build/build/Debug/bin",
|
||||
"-ferror-limit", "19",
|
||||
"-fmessage-length", "298",
|
||||
"-stack-protector", "1",
|
||||
@ -127,7 +168,6 @@ public:
|
||||
"-fblocks",
|
||||
"-fobjc-runtime=macosx-10.8.0",
|
||||
"-fobjc-dispatch-method=mixed",
|
||||
"-fobjc-default-synthesize-properties",
|
||||
"-fencode-extended-block-signature",
|
||||
"-fcxx-exceptions",
|
||||
"-fexceptions",
|
||||
@ -137,18 +177,18 @@ public:
|
||||
"-vectorize-loops",
|
||||
"-o", "/tmp/main.o",
|
||||
"-x", "c++",
|
||||
"/tmp/main.cpp",
|
||||
NULL,
|
||||
NULL };
|
||||
clang_argv[sizeof(clang_argv)/sizeof(const char *)-2] = temp_source_path;
|
||||
SBLaunchInfo launch_info(clang_argv);
|
||||
Launch (launch_info);
|
||||
next_action.None(); // Don't continue or do anything, just wait for next event...
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
puts("stop");
|
||||
{
|
||||
m_time_launch_stop_main.Stop();
|
||||
m_time_total.Stop();
|
||||
case 2:
|
||||
{
|
||||
SBFrame frame (m_thread.GetFrameAtIndex(0));
|
||||
|
||||
// Time the first expression evaluation
|
||||
@ -163,7 +203,7 @@ public:
|
||||
next_action.Continue();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 2:
|
||||
{
|
||||
SBFrame frame (m_thread.GetFrameAtIndex(21));
|
||||
SBValue result;
|
||||
@ -171,7 +211,6 @@ public:
|
||||
{
|
||||
m_expr_frame_non_zero(frame);
|
||||
}
|
||||
m_target.BreakpointCreateByName("DeclContext::lookup");
|
||||
next_action.Continue();
|
||||
}
|
||||
break;
|
||||
|
@ -152,7 +152,24 @@ TestCase::Loop ()
|
||||
if (m_verbose)
|
||||
printf("event = %s\n",SBDebugger::StateAsCString(state));
|
||||
if (SBProcess::GetRestartedFromEvent(evt))
|
||||
continue;
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
const uint32_t num_threads = m_process.GetNumThreads();
|
||||
for (auto thread_index = 0; thread_index < num_threads; thread_index++)
|
||||
{
|
||||
SBThread thread(m_process.GetThreadAtIndex(thread_index));
|
||||
SBFrame frame(thread.GetFrameAtIndex(0));
|
||||
SBStream strm;
|
||||
strm.RedirectToFileHandle(stdout, false);
|
||||
frame.GetDescription(strm);
|
||||
}
|
||||
puts("restarted");
|
||||
}
|
||||
call_test_step = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case eStateInvalid:
|
||||
@ -167,17 +184,23 @@ TestCase::Loop ()
|
||||
case eStateLaunching:
|
||||
case eStateRunning:
|
||||
case eStateStepping:
|
||||
continue;
|
||||
call_test_step = false;
|
||||
break;
|
||||
|
||||
case eStateStopped:
|
||||
case eStateSuspended:
|
||||
{
|
||||
call_test_step = true;
|
||||
bool fatal = false;
|
||||
bool selected_thread = false;
|
||||
for (auto thread_index = 0; thread_index < m_process.GetNumThreads(); thread_index++)
|
||||
const uint32_t num_threads = m_process.GetNumThreads();
|
||||
for (auto thread_index = 0; thread_index < num_threads; thread_index++)
|
||||
{
|
||||
SBThread thread(m_process.GetThreadAtIndex(thread_index));
|
||||
SBFrame frame(thread.GetFrameAtIndex(0));
|
||||
SBStream strm;
|
||||
strm.RedirectToFileHandle(stdout, false);
|
||||
frame.GetDescription(strm);
|
||||
bool select_thread = false;
|
||||
StopReason stop_reason = thread.GetStopReason();
|
||||
if (m_verbose) printf("tid = 0x%llx pc = 0x%llx ",thread.GetThreadID(),frame.GetPC());
|
||||
@ -248,6 +271,7 @@ TestCase::Loop ()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
call_test_step = true;
|
||||
@ -264,6 +288,9 @@ TestCase::Loop ()
|
||||
SBError err;
|
||||
switch (action.type)
|
||||
{
|
||||
case ActionWanted::Type::eNone:
|
||||
// Just exit and wait for the next event
|
||||
break;
|
||||
case ActionWanted::Type::eContinue:
|
||||
err = m_process.Continue();
|
||||
break;
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
eStepOut,
|
||||
eRelaunch,
|
||||
eCallNext,
|
||||
eNone,
|
||||
eKill
|
||||
} type;
|
||||
lldb::SBThread thread;
|
||||
@ -44,6 +45,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
None ()
|
||||
{
|
||||
type = Type::eNone;
|
||||
thread = lldb::SBThread();
|
||||
}
|
||||
|
||||
void
|
||||
Continue()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user