How to debug the function that the compiler emited

61 views
Skip to first unread message

hbc...@126.com

unread,
Dec 29, 2013, 5:13:14 AM12/29/13
to asmji...@googlegroups.com
the compiler can emit function that I want and the result is right. But when I want to debug the function that compiler emited with visual studio, I found that I can't debug it.
Does anyone know how to debug the function that the compiler emited.

this is my test code.

int add(int value1, int value2)
{
cout << "arg1: " << value1 << "  arg2: " << value2 << endl;
return value1 + value2;
}

int main(int argc, char* argv[])
{
int value3 = add(1, 2);
cout << value3 << endl;

X86Compiler c;
FileLogger Logger(stdout);
c.setLogger(&Logger);

c.newFunc(kX86FuncConvDefault, FuncBuilder1<void, int>());

GpVar result(c.newGpVar());
c.push(Imm(9));
c.push(Imm(10));
c.call((void*)add);
//c.mov(dword_ptr(result), eax);
c.endFunc();
typedef void (*myfun)(void);
myfun fun = asmjit_cast<myfun>(c.make());
fun();

__asm{

mov value3, eax
}

cout << value3 << endl;

MemoryManager::getGlobal()->free(fun);

return 0;
}

Ryan Gonzalez

unread,
Dec 29, 2013, 4:05:49 PM12/29/13
to asmji...@googlegroups.com
Put it in an X86 emulator.



--
 
---
You received this message because you are subscribed to the Google Groups "asmjit-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asmjit-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Ryan
When your hammer is C++, everything begins to look like a thumb.

Mike Tajmajer

unread,
Dec 29, 2013, 4:57:39 PM12/29/13
to asmji...@googlegroups.com

Or just step into the “fun()” call with the disassembly view open; so that you’re stepping into the actual call instruction.

Ryan Gonzalez

unread,
Dec 29, 2013, 5:42:22 PM12/29/13
to asmji...@googlegroups.com
Can't believe I didn't think of that...

hbc...@126.com

unread,
Dec 29, 2013, 8:21:09 PM12/29/13
to asmji...@googlegroups.com
Thank you for your answer, can you say some details

在 2013年12月30日星期一UTC+8上午5时05分49秒,Ryan Gonzalez写道:

hbc...@126.com

unread,
Dec 29, 2013, 8:22:02 PM12/29/13
to asmji...@googlegroups.com
Thank you for your answer, can you say some details

在 2013年12月30日星期一UTC+8上午5时05分49秒,Ryan Gonzalez写道:
Put it in an X86 emulator.

hbc...@126.com

unread,
Dec 30, 2013, 12:27:19 AM12/30/13
to asmji...@googlegroups.com
I can step into the "fun()" call, but I can't see the actual call instruction.
I can only see a lot of question marks.

Palo Marton

unread,
Dec 30, 2013, 3:34:46 AM12/30/13
to asmjit-dev
I have the same problem with VS2012. Sometimes it shows questionmarks instead of emitted code. This usually happens at the beginning of emitted code, but after few bytes it shows code properly.
This seems to be some bug of VS.
Reply all
Reply to author
Forward
0 new messages