-
Notifications
You must be signed in to change notification settings - Fork 66
[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?
Conversation
Just fixed message for |
After doing bit more research, doing asm replacements turned out not that difficult:
|
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
#elif _WIN32
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 would say basically whole file is only valid for _WIN32
. Code here is very windows specific... To target other platforms/OSes, big parts of platform specific debug code would need to be written for scratch (for given platform).
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).
myeip = gsContext.Eip; | ||
myesp = gsContext.Esp; | ||
myebp = gsContext.Ebp; | ||
#endif |
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.
#else
#error not implemented
#endif
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.
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 comment
The 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).
@@ -76,6 +76,7 @@ void StackDump(void (*callback)(const char*)) | |||
|
|||
DWORD myeip,myesp,myebp; | |||
|
|||
#ifdef _MSC_VER |
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.
#if defined(_MSC_VER) && _MSC_VER < 1300
Same for the various other ifdef's in this change.
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:
Retrieves a context record in the context of the caller.
I have done some experiments and it seems that caller here means not caller of the RtlCaptureContext
, but caller of function, which called RtlCaptureContext
. 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:
static void CaptureContextWrapper(CONTEXT *ctx) {
RtlCaptureContext(ctx);
}
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.
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 appreciate the effort to try and clean this up, but I'd be inclined to just dump the exception handler and go with an external library to handle this so we aren't trying to maintain a bunch of cross (or not so cross) platform code ourselves. Something like https://github.com/jeremy-rifkin/cpptrace has been suggested to me for light weight stack traces and we should consider a crashpad fork IMO for automated crash dump submissions from users once we dump VC6.
_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 comment
The 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?
This makes rest of asm code MSVC only, to allow build on other compilers. So far mostly unimplemented for other compilers (apart from debug breaks). However this is all debug stuff and should not be critical to run the game afaik. I have introducedUNIMPLEMENTED_ERROR
macro as placeholder for unimplemented code. (See dicussions for more aboutUNIMPLEMENTED_ERROR
macro)This does adds alternative code asm.
This was extracted from bigger change-set fixing build on MinGW: #547