Skip to content

Commit c6b0893

Browse files
committed
[GEN][ZH] Rest of asm code made VC only
1 parent d00df38 commit c6b0893

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

Dependencies/Utility/Utility/CppMacros.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
// This file contains macros to help upgrade the code for newer cpp standards.
2020
#pragma once
2121

22+
#include <cassert>
23+
#define UNIMPLEMENTED_ERROR(msg) do { \
24+
assert(("Unimplemented: ", msg, 0)); \
25+
} while(0)
26+
2227
#if __cplusplus >= 201703L
2328
#define NOEXCEPT_17 noexcept
2429
#else

Generals/Code/GameEngine/Source/Common/System/StackDump.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#pragma pack(push, 8)
3030

31+
#include <Lib/BaseType.h>
3132
#include "Common/StackDump.h"
3233
#include "Common/Debug.h"
3334

@@ -76,6 +77,7 @@ void StackDump(void (*callback)(const char*))
7677

7778
DWORD myeip,myesp,myebp;
7879

80+
#ifdef _MSC_VER
7981
_asm
8082
{
8183
MYEIP1:
@@ -86,6 +88,9 @@ _asm
8688
mov eax, ebp
8789
mov dword ptr [myebp] , eax
8890
}
91+
#else
92+
UNIMPLEMENTED_ERROR("StackDump");
93+
#endif
8994

9095

9196
MakeStackTrace(myeip,myesp,myebp, 2, callback);
@@ -340,6 +345,7 @@ void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip)
340345
gsContext.ContextFlags = CONTEXT_FULL;
341346

342347
DWORD myeip,myesp,myebp;
348+
#ifdef _MSC_VER
343349
_asm
344350
{
345351
MYEIP2:
@@ -351,6 +357,9 @@ _asm
351357
mov dword ptr [myebp] , eax
352358
xor eax,eax
353359
}
360+
#else
361+
UNIMPLEMENTED_ERROR("FillStackAddresses");
362+
#endif
354363
memset(&stack_frame, 0, sizeof(STACKFRAME));
355364
stack_frame.AddrPC.Mode = AddrModeFlat;
356365
stack_frame.AddrPC.Offset = myeip;

GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#pragma pack(push, 8)
3030

31+
#include <Lib/BaseType.h>
3132
#include "Common/StackDump.h"
3233
#include "Common/Debug.h"
3334

@@ -76,6 +77,7 @@ void StackDump(void (*callback)(const char*))
7677

7778
DWORD myeip,myesp,myebp;
7879

80+
#ifdef _MSC_VER
7981
_asm
8082
{
8183
MYEIP1:
@@ -86,6 +88,9 @@ _asm
8688
mov eax, ebp
8789
mov dword ptr [myebp] , eax
8890
}
91+
#else
92+
UNIMPLEMENTED_ERROR("StackDump");
93+
#endif
8994

9095

9196
MakeStackTrace(myeip,myesp,myebp, 2, callback);
@@ -340,6 +345,7 @@ void FillStackAddresses(void**addresses, unsigned int count, unsigned int skip)
340345
gsContext.ContextFlags = CONTEXT_FULL;
341346

342347
DWORD myeip,myesp,myebp;
348+
#ifdef _MSC_VER
343349
_asm
344350
{
345351
MYEIP2:
@@ -351,6 +357,9 @@ _asm
351357
mov dword ptr [myebp] , eax
352358
xor eax,eax
353359
}
360+
#else
361+
UNIMPLEMENTED_ERROR("FillStackAddresses");
362+
#endif
354363
memset(&stack_frame, 0, sizeof(STACKFRAME));
355364
stack_frame.AddrPC.Mode = AddrModeFlat;
356365
stack_frame.AddrPC.Offset = myeip;

GeneralsMD/Code/Libraries/Source/debug/debug_debug.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <stdio.h>
3232
#include <string.h>
3333
#include <new> // needed for placement new prototype
34+
#include <Lib/BaseType.h>
35+
#include <Utility/intrin_compat.h>
3436

3537
// a little dummy variable that makes the linker actually include
3638
// us...
@@ -270,11 +272,15 @@ bool Debug::SkipNext(void)
270272
// do not implement this function inline, we do need
271273
// a valid frame pointer here!
272274
unsigned help;
275+
#ifdef _MSC_VER
273276
_asm
274277
{
275278
mov eax,[ebp+4] // return address
276279
mov help,eax
277280
};
281+
#else
282+
UNIMPLEMEMTED_ERROR("Debug::SkipNext");
283+
#endif
278284
curStackFrame=help;
279285

280286
// do we know if to skip the following code?
@@ -386,7 +392,7 @@ bool Debug::AssertDone(void)
386392
}
387393
break;
388394
case IDRETRY:
389-
_asm int 0x03
395+
__debugbreak();
390396
break;
391397
default:
392398
((void)0);
@@ -654,7 +660,7 @@ bool Debug::CrashDone(bool die)
654660
}
655661
break;
656662
case IDRETRY:
657-
_asm int 0x03
663+
__debugbreak();
658664
break;
659665
default:
660666
((void)0);

GeneralsMD/Code/Libraries/Source/debug/debug_except.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
//////////////////////////////////////////////////////////////////////////////
2929
#include "_pch.h"
3030
#include <commctrl.h>
31+
#include <Lib/BaseType.h>
3132

3233
DebugExceptionhandler::DebugExceptionhandler(void)
3334
{
@@ -173,12 +174,16 @@ void DebugExceptionhandler::LogFPURegisters(Debug &dbg, struct _EXCEPTION_POINTE
173174
double fpVal;
174175

175176
// convert from temporary real (10 byte) to double
177+
#ifdef _MSC_VER
176178
_asm
177179
{
178180
mov eax,value
179181
fld tbyte ptr [eax]
180182
fstp qword ptr [fpVal]
181183
}
184+
#else
185+
UNIMPLEMENTED_ERROR("LogFPURegisters");
186+
#endif
182187

183188
dbg << " " << fpVal << "\n";
184189
}

GeneralsMD/Code/Libraries/Source/debug/debug_stack.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
//////////////////////////////////////////////////////////////////////////////
2929
#include "_pch.h"
3030
#include <imagehlp.h>
31+
#include <Lib/BaseType.h>
3132

3233
// Definitions to allow run-time linking to the dbghelp.dll functions.
3334

@@ -363,6 +364,7 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx)
363364
{
364365
// walk stack back using current call chain
365366
unsigned long reg_eip, reg_ebp, reg_esp;
367+
#ifdef _MSC_VER
366368
__asm
367369
{
368370
here:
@@ -371,6 +373,9 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx)
371373
mov reg_ebp,ebp
372374
mov reg_esp,esp
373375
};
376+
#else
377+
UNIMPLEMENTED_ERROR("DebugStackwalk::StackWalk");
378+
#endif
374379
stackFrame.AddrPC.Offset = reg_eip;
375380
stackFrame.AddrStack.Offset = reg_esp;
376381
stackFrame.AddrFrame.Offset = reg_ebp;

0 commit comments

Comments
 (0)