Пример #1
0
int f3(void)
{
    uwx_self_init_context(uenv);
    printf("In f3():\n");
    dump_context((uint64_t *)uenv);
    return f4();
}
Пример #2
0
// FIXME: There should be a destructor for this function to free env and info
void GetBackTrace(address_t* ipStackBuffer, int iTotalDepth, int iSkipLevel)
{
	uint64_t ip;
	int status;
	int index = 0;
	int nPos = 0;

	if (!env) {
		env = uwx_init();
		info = uwx_self_init_info(env);
		status = uwx_register_callbacks(env, (intptr_t)info, uwx_self_copyin,
				uwx_self_lookupip);
		if (status != UWX_OK) {
			env = NULL;
			return ;
		}
	}

	status = uwx_self_init_context(env);
	if (status != UWX_OK) {
		//hk_printf("uwx_self_init_context() error\n");
		return ;
	}

	for(;;) {
		if (index >= iTotalDepth)
			break;

		if (nPos++ >= iSkipLevel + iTotalDepth)
			break;

		status = uwx_get_reg(env, UWX_REG_IP, &ip);
		if (status != UWX_OK)
			break;

		if (nPos > iSkipLevel)
			ipStackBuffer[index++] = (address_t)ip;

		status = uwx_step(env);
		if (status != UWX_OK)
			break;
	}
	// seal the array
	if(index < iTotalDepth)
	{
		ipStackBuffer[index] = 0;
	}
	return ;
}
Пример #3
0
int f4(void)
{
    int status;
    int foo[10];
    f5(foo);
    uwx_self_init_context(uenv);
    printf("In f4():\n");
    dump_context((uint64_t *)uenv);
    for (;;) {
	status = uwx_step(uenv);
	printf("uwx_step returned %d\n", status);
	if (status != UWX_OK)
	    break;
	printf("After step:\n");
	dump_context((uint64_t *)uenv);
    }
    return 0;
}
Пример #4
0
int main(int argc, char **argv)
{
    int status;
    unsigned int *wp;
    uenv = uwx_init();
    printf("uwx_init returned %08x\n", uenv);
    cbinfo = uwx_self_init_info(uenv);
    status = uwx_register_callbacks(
		uenv,
		(intptr_t)cbinfo,
		uwx_self_copyin,
		uwx_self_lookupip);
    printf("uwx_register_callbacks returned %d\n", status);
    uwx_self_init_context(uenv);
    printf("In main():\n");
    dump_context((uint64_t *)uenv);
    (void) f1();
    uwx_free(uenv);
    return 0;
}