VirtualBox

Changeset 37233 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
May 27, 2011 1:31:57 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71955
Message:

IRPT: Adding RTErrVarsSave/Restore/++ to preserve errno, h_error/WSAGetLastError and GetLastError accross assertions.

Location:
trunk/src/VBox/Runtime
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r37228 r37233  
    546546        r3/win/alloc-win.cpp \
    547547        r3/win/dir-win.cpp \
     548        r3/win/errvars-win.cpp \
    548549        r3/win/fileio-win.cpp \
    549550        r3/win/fs-win.cpp \
     
    611612        r3/posix/dir-posix.cpp \
    612613        r3/posix/env-posix.cpp \
     614        r3/posix/errvars-posix.cpp \
    613615        r3/posix/fileio-posix.cpp \
    614616        r3/posix/fileio2-posix.cpp \
     
    702704        r3/posix/dir-posix.cpp \
    703705        r3/posix/env-posix.cpp \
     706        r3/posix/errvars-posix.cpp \
    704707        r3/posix/fileio-posix.cpp \
    705708        r3/posix/fileio2-posix.cpp \
     
    760763        r3/posix/dir-posix.cpp \
    761764        r3/posix/env-posix.cpp \
     765        r3/posix/errvars-posix.cpp \
    762766        r3/posix/fileio-posix.cpp \
    763767        r3/posix/fileio2-posix.cpp \
     
    818822        r3/posix/dir-posix.cpp \
    819823        r3/posix/env-posix.cpp \
     824        r3/posix/errvars-posix.cpp \
    820825        r3/posix/fileio-posix.cpp \
    821826        r3/posix/fileio2-posix.cpp \
     
    874879        r3/posix/dir-posix.cpp \
    875880        r3/posix/env-posix.cpp \
     881        r3/posix/errvars-posix.cpp \
    876882        r3/posix/fileio-posix.cpp \
    877883        r3/posix/fileio2-posix.cpp \
     
    932938
    933939RuntimeR3L4_SOURCES = \
     940        generic/errvars-generic.cpp \
    934941        generic/fs-stubs-generic.cpp \
    935942        generic/pathhost-generic.cpp \
     
    11341141        generic/pathhost-generic.cpp \
    11351142        generic/RTAssertShouldPanic-generic.cpp \
     1143        generic/errvars-generic.cpp \
    11361144        r3/alloc.cpp \
    11371145        r3/alloc-ef.cpp \
     
    16301638        generic/RTSemEventMultiWait-2-ex-generic.cpp \
    16311639        generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp \
     1640        generic/errvars-generic.cpp \
    16321641        generic/uuid-generic.cpp \
    16331642        r0drv/alloc-r0drv.cpp \
     
    19501959        gc/initterm-gc.cpp \
    19511960        generic/RTAssertShouldPanic-generic.cpp \
     1961        generic/errvars-generic.cpp \
    19521962        \
    19531963        $(RuntimeNoCrt_SOURCES)
  • trunk/src/VBox/Runtime/VBox/RTAssertShouldPanic-vbox.cpp

    r33806 r37233  
    3131#include <iprt/assert.h>
    3232#include <iprt/env.h>
     33#include <iprt/err.h>
    3334#include <iprt/string.h>
    3435
     
    5253
    5354
    54 RTDECL(bool) RTAssertShouldPanic(void)
     55/**
     56 * Worker that we can wrap with error variable saving and restoring.
     57 */
     58static bool rtAssertShouldPanicWorker(void)
    5559{
    56     /*
    57      * Check if panicing is excluded by the the RTAssert settings first.
    58      */
    59     if (!RTAssertMayPanic())
    60         return false;
    61 
    6260    /*
    6361     * Check for the VBOX_ASSERT variable.
     
    143141}
    144142
     143
     144RTDECL(bool) RTAssertShouldPanic(void)
     145{
     146    /*
     147     * Check if panicing is excluded by the the RTAssert settings first.
     148     */
     149    if (!RTAssertMayPanic())
     150        return false;
     151
     152    /*
     153     * Preserve error state variables.
     154     */
     155    RTERRVARS SavedErrVars;
     156    RTErrVarsSave(&SavedErrVars);
     157
     158    bool fRc = rtAssertShouldPanicWorker();
     159
     160    RTErrVarsRestore(&SavedErrVars);
     161    return fRc;
     162}
     163
  • trunk/src/VBox/Runtime/common/misc/assert.cpp

    r36827 r37233  
    3333
    3434#include <iprt/asm.h>
     35#include <iprt/err.h>
    3536#include <iprt/log.h>
    3637#include <iprt/string.h>
     
    122123    if (!RTAssertAreQuiet())
    123124    {
     125        RTERRVARS SavedErrVars;
     126        RTErrVarsSave(&SavedErrVars);
     127
    124128#ifdef IN_RING0
    125129# ifdef IN_GUEST_R0
     
    182186# endif
    183187#endif /* !IN_RING0 */
     188
     189        RTErrVarsRestore(&SavedErrVars);
    184190    }
    185191}
     
    226232    if (!RTAssertAreQuiet())
    227233    {
     234        RTERRVARS SavedErrVars;
     235        RTErrVarsSave(&SavedErrVars);
     236
    228237#ifdef IN_RING0
    229238# ifdef IN_GUEST_R0
     
    274283# endif
    275284#endif /* !IN_RING0 */
     285
     286        RTErrVarsRestore(&SavedErrVars);
    276287    }
    277 
    278288}
    279289
  • trunk/src/VBox/Runtime/include/internal/magics.h

    r37196 r37233  
    5959/** The value of RTENVINTERNAL::u32Magic. (Rumiko Takahashi) */
    6060#define RTENV_MAGIC                     UINT32_C(0x19571010)
     61/** The value of RTERRVARS::ai32Vars[0]. (Ryuichi Sakamoto) */
     62#define RTERRVARS_MAGIC                 UINT32_C(0x19520117)
    6163/** Magic number for RTHANDLETABLEINT::u32Magic. (Hitomi Kanehara) */
    6264#define RTHANDLETABLE_MAGIC             UINT32_C(0x19830808)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette