Skip to content

Commit e5e71c9

Browse files
author
imdex
committed
xrCPU_Pipe: __asm pause replaced by _mm_pause.
bugtrap: added __asm code replacement for x64.
1 parent 7b9b838 commit e5e71c9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

code/3rd-party/bugtrap/SymEngine.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ BOOL CSymEngine::InitStackTrace(LPSTACKFRAME64 pStackFrame)
11651165
if (! GetThreadContext(hThread, &m_StartExceptionContext))
11661166
return FALSE;
11671167
*/
1168+
#ifdef _M_IX86
11681169
__asm
11691170
{
11701171
push eax
@@ -1222,6 +1223,11 @@ BOOL CSymEngine::InitStackTrace(LPSTACKFRAME64 pStackFrame)
12221223
pop edi
12231224
pop eax
12241225
}
1226+
#elif defined(_M_IX64)
1227+
RtlCaptureContext(&m_StartExceptionContext);
1228+
#else
1229+
# error "Unsupported architecture"
1230+
#endif
12251231
}
12261232

12271233
ZeroMemory(pStackFrame, sizeof(*pStackFrame));
@@ -2715,10 +2721,16 @@ BOOL CSymEngine::GetNextStackTraceEntry(CStackTraceEntry& rEntry)
27152721
if (hModule != NULL)
27162722
GetModuleFileName(hModule, rEntry.m_szModule, countof(rEntry.m_szModule));
27172723
DWORD64 dwExceptionAddress = m_swContext.m_stFrame.AddrPC.Offset;
2718-
WORD wExceptionSegment; // wExceptionSegment = m_swContext.m_stFrame.AddrPC.Segment;
2719-
__asm { mov word ptr [wExceptionSegment], cs }
2724+
WORD wExceptionSegment = m_swContext.m_stFrame.AddrPC.Segment;
2725+
#ifdef _M_IX86
27202726
_stprintf_s(rEntry.m_szAddress, countof(rEntry.m_szAddress),
2721-
_T("%04lX:%08llu"), wExceptionSegment, dwExceptionAddress);
2727+
_T("%04lX:%08I64X"), wExceptionSegment, dwExceptionAddress);
2728+
#elif defined(_M_IX64)
2729+
_stprintf_s(rEntry.m_szAddress, countof(rEntry.m_szAddress),
2730+
_T("%04lX:%016lX"), wExceptionSegment, dwExceptionAddress);
2731+
#else
2732+
# error "Unsupported architecture"
2733+
#endif
27222734

27232735
BYTE arrSymBuffer[512];
27242736
ZeroMemory(arrSymBuffer, sizeof(arrSymBuffer));

code/engine/xrCPU_Pipe/ttapi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ DWORD ttapi_Init( processor_info* ID )
121121
for ( i = 0 ; i < dwNumIter ; ++i ) {
122122
if ( dwDummy == 0 )
123123
goto process1;
124-
__asm pause;
124+
_mm_pause();
125125
}
126126
process1:
127127
QueryPerformanceCounter( &liEnd );
@@ -244,7 +244,7 @@ VOID ttapi_RunAllWorkers()
244244
// Waiting task queue to become empty
245245
//Start = __rdtsc();
246246
while( ttapi_queue_size.size )
247-
__asm pause;
247+
_mm_pause();
248248
//Stop = __rdtsc();
249249
//Msg( "Wait: %u ticks" , Stop - Start );
250250

0 commit comments

Comments
 (0)