-
Notifications
You must be signed in to change notification settings - Fork 81
[GEN][ZH] Replacements for rest of asm code #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ void StackDump(void (*callback)(const char*)) | |
|
||
DWORD myeip,myesp,myebp; | ||
|
||
#ifdef _MSC_VER | ||
_asm | ||
{ | ||
MYEIP1: | ||
|
@@ -86,6 +87,12 @@ _asm | |
mov eax, ebp | ||
mov dword ptr [myebp] , eax | ||
} | ||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say basically whole file is only valid for Also code is currently for x86 (32-bit) only. It would need more fixes to support windows x86_64. Currently it would not even compile (but that is out of scope of this PR). |
||
RtlCaptureContext(&gsContext); | ||
myeip = gsContext.Eip; | ||
myesp = gsContext.Esp; | ||
myebp = gsContext.Ebp; | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as higher, it would basically hold for file as a whole, which would currently not even compile on anything other than Windows x86 (32-bit). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That code in particular will also not compile on anything other that Windows x86, because it accesses x86 specific 32-bit registers ( Eip Esp Ebp). |
||
|
||
|
||
MakeStackTrace(myeip,myesp,myebp, 2, callback); | ||
|
@@ -340,6 +347,7 @@ void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip) | |
gsContext.ContextFlags = CONTEXT_FULL; | ||
|
||
DWORD myeip,myesp,myebp; | ||
#ifdef _MSC_VER | ||
_asm | ||
{ | ||
MYEIP2: | ||
|
@@ -351,6 +359,12 @@ _asm | |
mov dword ptr [myebp] , eax | ||
xor eax,eax | ||
} | ||
#else | ||
RtlCaptureContext(&gsContext); | ||
myeip = gsContext.Eip; | ||
myesp = gsContext.Esp; | ||
myebp = gsContext.Ebp; | ||
#endif | ||
memset(&stack_frame, 0, sizeof(STACKFRAME)); | ||
stack_frame.AddrPC.Mode = AddrModeFlat; | ||
stack_frame.AddrPC.Offset = myeip; | ||
|
@@ -360,17 +374,6 @@ stack_frame.AddrFrame.Mode = AddrModeFlat; | |
stack_frame.AddrFrame.Offset = myebp; | ||
|
||
{ | ||
/* | ||
if(GetThreadContext(thread, &gsContext)) | ||
{ | ||
memset(&stack_frame, 0, sizeof(STACKFRAME)); | ||
stack_frame.AddrPC.Mode = AddrModeFlat; | ||
stack_frame.AddrPC.Offset = gsContext.Eip; | ||
stack_frame.AddrStack.Mode = AddrModeFlat; | ||
stack_frame.AddrStack.Offset = gsContext.Esp; | ||
stack_frame.AddrFrame.Mode = AddrModeFlat; | ||
stack_frame.AddrFrame.Offset = gsContext.Ebp; | ||
*/ | ||
|
||
Bool stillgoing = TRUE; | ||
// unsigned int cd = count; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,12 +173,18 @@ void DebugExceptionhandler::LogFPURegisters(Debug &dbg, struct _EXCEPTION_POINTE | |
double fpVal; | ||
|
||
// convert from temporary real (10 byte) to double | ||
#ifdef _MSC_VER | ||
_asm | ||
{ | ||
mov eax,value | ||
fld tbyte ptr [eax] | ||
fstp qword ptr [fpVal] | ||
} | ||
#else | ||
__float80 fp80val; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes a lot IMO, should be gated to GCC and X86 only as I'm not sure the type exists elsewhere and give an unimplemented error or message otherwise? |
||
memcpy(&fp80val, value, 10); | ||
fpVal = (double) fp80val; | ||
#endif | ||
|
||
dbg << " " << fpVal << "\n"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to make this VS6 build specific.
Same for the various other ifdef's in this change.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably true, I was just being conservative. This code will need to be properly tested, but I am now not in position to do so.. :/
Btw doc for
RtlCaptureContext
says:I have done some experiments and it seems that caller here means not caller of the
RtlCaptureContext
, but caller of function, which calledRtlCaptureContext
. So maybe context will be one frame off compared to asm. If that is the case, either skip value would need to be adjusted by one or dummy wrapper function would need to be created such as:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this also with MSVC, seems that
RtlCaptureContext
really captures context one frame higher then, where it was called (see my experiment).I think placing
RtlCaptureContext
in dummy wrapper function will probably be easiest and least invasive solution to match the asm behavior.