Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[x86/Linux][SOS] Fix clrstack command of lldb sosplugin on x86 #13973

Merged
merged 5 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[x86/Linux] Fix undefined references in libmscordbi.so on x86
Asm block like following:
__asm fnsave currentFPUState

where currentFPUState is structure works with MSVC but leads to
undefined reference currentFPUState in the binary with other
compilers. So rewrite such asm blocks for them.

This patch fixes error "Unable to load 'libmscordbi.so'" during
execution of 'clrstack -f' command of SOS plugin on x86.
  • Loading branch information
Konstantin Baladurin committed Oct 2, 2017
commit 8f642e176238054a2276a5ae230a316067d48fa8
30 changes: 29 additions & 1 deletion src/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,15 @@ void CordbThread::Get32bitFPRegisters(CONTEXT * pContext)

FLOATING_SAVE_AREA currentFPUState;

#ifdef _MSC_VER
__asm fnsave currentFPUState // save the current FPU state.
#else
__asm__ __volatile__
(
" fnsave %0\n" \
: "=m"(currentFPUState)
);
#endif

floatarea.StatusWord &= 0xFF00; // remove any error codes.
floatarea.ControlWord |= 0x3F; // mask all exceptions.
Expand All @@ -1482,12 +1490,22 @@ void CordbThread::Get32bitFPRegisters(CONTEXT * pContext)
// @dbgtodo Microsoft crossplat: the conversion from a series of bytes to a floating
// point value will need to be done with an explicit conversion routine to unpack
// the IEEE format and compute the real number value represented.


#ifdef _MSC_VER
__asm
{
fninit
frstor floatarea ;; reload the threads FPU state.
}
#else
__asm__
(
" fninit\n" \
" frstor %0\n" \
: /* no outputs */
: "m"(floatarea)
);
#endif

unsigned int i;

Expand All @@ -1498,11 +1516,21 @@ void CordbThread::Get32bitFPRegisters(CONTEXT * pContext)
m_floatValues[i] = td;
}

#ifdef _MSC_VER
__asm
{
fninit
frstor currentFPUState ;; restore our saved FPU state.
}
#else
__asm__
(
" fninit\n" \
" frstor %0\n" \
: /* no outputs */
: "m"(currentFPUState)
);
#endif

m_fFloatStateValid = true;
m_floatStackTop = floatStackTop;
Expand Down
36 changes: 36 additions & 0 deletions src/debug/di/valuehome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,18 +481,36 @@ void FloatRegValueHome::SetEnregisteredValue(MemoryRange newValue,
// restore our original state.
DT_FLOATING_SAVE_AREA currentFPUState;

#ifdef _MSC_VER
__asm fnsave currentFPUState // save the current FPU state.
#else
__asm__ __volatile__
(
" fnsave %0\n" \
: "=m"(currentFPUState)
);
#endif

// Copy the state out of the context.
DT_FLOATING_SAVE_AREA floatarea = pContext->FloatSave;
floatarea.StatusWord &= 0xFF00; // remove any error codes.
floatarea.ControlWord |= 0x3F; // mask all exceptions.

#ifdef _MSC_VER
__asm
{
fninit
frstor floatarea ;; reload the threads FPU state.
}
#else
__asm__
(
" fninit\n" \
" frstor %0\n" \
: /* no outputs */
: "m"(floatarea)
);
#endif

double td; // temp double
double popArea[DebuggerIPCE_FloatCount];
Expand All @@ -519,17 +537,35 @@ void FloatRegValueHome::SetEnregisteredValue(MemoryRange newValue,
}

// Save out the modified float area.
#ifdef _MSC_VER
__asm fnsave floatarea
#else
__asm__ __volatile__
(
" fnsave %0\n" \
: "=m"(floatarea)
);
#endif

// Put it into the context.
pContext->FloatSave= floatarea;

// Restore our FPU state
#ifdef _MSC_VER
__asm
{
fninit
frstor currentFPUState ;; restore our saved FPU state.
}
#else
__asm__
(
" fninit\n" \
" frstor %0\n" \
: /* no outputs */
: "m"(currentFPUState)
);
#endif
#endif // DBG_TARGET_X86

// update the thread's floating point stack
Expand Down