For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support. Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls. In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation. To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter. The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values. Reviewers: jingham, spyffe Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427 Differential Revision: http://reviews.llvm.org/D9404 llvm-svn: 242137
54 lines
812 B
C++
54 lines
812 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <cstring>
|
|
|
|
struct Five
|
|
{
|
|
int number;
|
|
const char *name;
|
|
};
|
|
|
|
Five
|
|
returnsFive()
|
|
{
|
|
Five my_five = { 5, "five" };
|
|
return my_five;
|
|
}
|
|
|
|
unsigned int
|
|
fib(unsigned int n)
|
|
{
|
|
if (n < 2)
|
|
return n;
|
|
else
|
|
return fib(n - 1) + fib(n - 2);
|
|
}
|
|
|
|
int
|
|
add(int a, int b)
|
|
{
|
|
return a + b;
|
|
}
|
|
|
|
bool
|
|
stringCompare(const char *str)
|
|
{
|
|
if (strcmp( str, "Hello world" ) == 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
int main (int argc, char const *argv[])
|
|
{
|
|
std::string str = "Hello world";
|
|
std::cout << str << std::endl;
|
|
std::cout << str.c_str() << std::endl;
|
|
Five main_five = returnsFive();
|
|
#if 0
|
|
print str
|
|
print str.c_str()
|
|
#endif
|
|
return 0; // Please test these expressions while stopped at this line:
|
|
}
|