- Main Page
- Modules
- Classes

- Search for |

# Exception API

## Typedefs

typedef EXCEPTION_INFO | EXCEPTION_INFO

## Enumerations

enum | EXCEPTION_CLASS { EXCEPTCLASS_NONE, EXCEPTCLASS_UNKNOWN, EXCEPTCLASS_ACCESS_FAULT, EXCEPTCLASS_INVALID_INS,
EXCEPTCLASS_INT_ERROR,
EXCEPTCLASS_FP_ERROR,
EXCEPTCLASS_MULTIPLE_FP_ERROR,
EXCEPTCLASS_DEBUG,
EXCEPTCLASS_OS
}
enum | EXCEPTION_CODE { EXCEPTCODE_NONE, EXCEPTCODE_ACCESS_INVALID_ADDRESS, EXCEPTCODE_ACCESS_DENIED, EXCEPTCODE_ACCESS_INVALID_PAGE,
EXCEPTCODE_ACCESS_MISALIGNED,
EXCEPTCODE_ILLEGAL_INS,
EXCEPTCODE_PRIVILEGED_INS,
EXCEPTCODE_INT_DIVIDE_BY_ZERO,
EXCEPTCODE_INT_OVERFLOW_TRAP,
EXCEPTCODE_INT_BOUNDS_EXCEEDED,
EXCEPTCODE_X87_DIVIDE_BY_ZERO,
EXCEPTCODE_X87_OVERFLOW,
EXCEPTCODE_X87_UNDERFLOW,
EXCEPTCODE_X87_INEXACT_RESULT,
EXCEPTCODE_X87_INVALID_OPERATION,
EXCEPTCODE_X87_DENORMAL_OPERAND,
EXCEPTCODE_X87_STACK_ERROR,
EXCEPTCODE_SIMD_DIVIDE_BY_ZERO,
EXCEPTCODE_SIMD_OVERFLOW,
EXCEPTCODE_SIMD_UNDERFLOW,
EXCEPTCODE_SIMD_INEXACT_RESULT,
EXCEPTCODE_SIMD_INVALID_OPERATION,
EXCEPTCODE_SIMD_DENORMAL_OPERAND,
EXCEPTCODE_DBG_BREAKPOINT_TRAP,
EXCEPTCODE_DBG_SINGLE_STEP_TRAP,
EXCEPTCODE_ACCESS_WINDOWS_GUARD_PAGE,
EXCEPTCODE_ACCESS_WINDOWS_STACK_OVERFLOW,
EXCEPTCODE_WINDOWS,
EXCEPTCODE_RECEIVED_UNKNOWN,
EXCEPTCODE_RECEIVED_ACCESS_FAULT,
EXCEPTCODE_RECEIVED_AMBIGUOUS_X87,
EXCEPTCODE_RECEIVED_AMBIGUOUS_SIMD
}
enum | FAULTY_ACCESS_TYPE { FAULTY_ACCESS_TYPE_UNKNOWN, FAULTY_ACCESS_READ, FAULTY_ACCESS_WRITE, FAULTY_ACCESS_EXECUTE
}
enum | FPERROR { FPERROR_DIVIDE_BY_ZERO = (1<<0), FPERROR_OVERFLOW = (1<<1), FPERROR_UNDERFLOW = (1<<2), FPERROR_INEXACT_RESULT = (1<<3),
FPERROR_INVALID_OPERATION = (1<<4),
FPERROR_DENORMAL_OPERAND = (1<<5),
FPERROR_X87_STACK_ERROR = (1<<6)
}

## Functions

VOID | PIN_InitExceptionInfo (EXCEPTION_INFO *pExceptInfo, EXCEPTION_CODE exceptCode, ADDRINT exceptAddress)
VOID | PIN_InitAccessFaultInfo (EXCEPTION_INFO *pExceptInfo, EXCEPTION_CODE exceptCode, ADDRINT exceptAddress, ADDRINT accessAddress, FAULTY_ACCESS_TYPE accessType=FAULTY_ACCESS_TYPE_UNKNOWN)
VOID | PIN_InitWindowsExceptionInfo (EXCEPTION_INFO *pExceptInfo, UINT32 sysExceptCode, ADDRINT exceptAddress, UINT32 numArgs=0, const ADDRINT *pArgs=0)
EXCEPTION_CODE | PIN_GetExceptionCode (const EXCEPTION_INFO *pExceptInfo)
EXCEPTION_CLASS | PIN_GetExceptionClass (EXCEPTION_CODE exceptCode)
ADDRINT | PIN_GetExceptionAddress (const EXCEPTION_INFO *pExceptInfo)
VOID | PIN_SetExceptionAddress (EXCEPTION_INFO *pExceptInfo, ADDRINT exceptAddress)
FAULTY_ACCESS_TYPE | PIN_GetFaultyAccessType (const EXCEPTION_INFO *pExceptInfo)
BOOL | PIN_GetFaultyAccessAddress (const EXCEPTION_INFO *pExceptInfo, ADDRINT *pAccessAddress)
UINT32 | PIN_GetFpErrorSet (const EXCEPTION_INFO *pExceptInfo)
UINT32 | PIN_GetWindowsExceptionCode (const EXCEPTION_INFO *pExceptInfo)
UINT32 | PIN_CountWindowsExceptionArguments (const EXCEPTION_INFO *pExceptInfo)
ADDRINT | PIN_GetWindowsExceptionArgument (const EXCEPTION_INFO *pExceptInfo, UINT32 argNum)
string | PIN_ExceptionToString (const EXCEPTION_INFO *pExceptInfo)
VOID | LEVEL_PINCLIENT::PIN_RaiseException (const CONTEXT *ctxt, THREADID tid, const EXCEPTION_INFO *pExceptInfo)

## Variables

GLOBALCONST UINT32 | MAX_WINDOWS_EXCEPTION_ARGS = 5

## Detailed Description

This API allows the user to raise exceptions on behalf of the application and also analyze information associated with exceptions.

## Typedef Documentation

typedef struct EXCEPTION_INFO EXCEPTION_INFO

| Structure that describes an exception. The tool should not read or modify data members of this structure directly, but must treat the structure as logically opaque and use the Exception API functions to manage it.

## Enumeration Type Documentation

enum EXCEPTION_CLASS

| Identifiers of exception classes. Exception class indicates the type of information (set of attributes) that accompanies exceptions of this class.

Enumerator:

  EXCEPTCLASS_NONE | Reserved. No real exception belongs to this class.
  EXCEPTCLASS_UNKNOWN | Unknown exception.
  EXCEPTCLASS_ACCESS_FAULT | Memory access fault.
  EXCEPTCLASS_INVALID_INS | Invalid instruction.
  EXCEPTCLASS_INT_ERROR | Erroneous integer operation.
  EXCEPTCLASS_FP_ERROR | Erroneous floating point operation.
  EXCEPTCLASS_MULTIPLE_FP_ERROR | Received an ambiguous floating point exception.
  EXCEPTCLASS_DEBUG | Debugging trap.
  EXCEPTCLASS_OS | O/S specific exception.

enum EXCEPTION_CODE

| Identifiers for all possible exception codes. The codes below are divided into two groups. The first group list all the exceptions that can be raised by PIN_RaiseException(). Tools that want to be portable across operating systems should use codes from this first group when raising exceptions via PIN_RaiseException().

When Pin receives an exception and reports it to the tool, it may report an exception in either the first or second group. This can happen, for example, when using the PIN_SafeCopyEx() function. When Pin can identify a specific exception, it reports a code from the first group. Sometimes, though, the host operating system does not provide enough information for Pin to determine the exact exception. In these cases, Pin reports a code from the second group (one of the EXCEPTCODE_RECEIVED_ codes). A tool can always re-raise one of these exceptions by passing it to PIN_RaiseException(). However, portable tools should avoid creating new exceptions using codes from the second group, because these codes are not supported on all operating systems.

Enumerator:

  EXCEPTCODE_NONE | Reserved. No real exception has this code.
  EXCEPTCODE_ACCESS_INVALID_ADDRESS | Virtual address not mapped (the #PF exception). Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_ACCESS_DENIED | Access not permitted due to protection violation (the #PF exception). Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_ACCESS_INVALID_PAGE | A #PF exception for some reason other than the cases above. Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_ACCESS_MISALIGNED | Misaligned memory reference (the #AC exception). Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_ILLEGAL_INS | Illegal instruction (the #UD exception). Belongs to EXCEPTCLASS_INVALID_INS.
  EXCEPTCODE_PRIVILEGED_INS | Privileged instruction (the #GP exception). Belongs to EXCEPTCLASS_INVALID_INS.
  EXCEPTCODE_INT_DIVIDE_BY_ZERO | Integer divide by zero (the #DE exception). Belongs to EXCEPTCLASS_INT_ERROR.
  EXCEPTCODE_INT_OVERFLOW_TRAP | Integer overflow trap (the #OF trap). Belongs to EXCEPTCLASS_INT_ERROR.
  EXCEPTCODE_INT_BOUNDS_EXCEEDED | Array index is out of bounds (#BR exception). Belongs to EXCEPTCLASS_INT_ERROR.
  EXCEPTCODE_X87_DIVIDE_BY_ZERO | x87 FPU divide by zero (the #MF/#Z exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_OVERFLOW | x87 FPU overflow (the #MF/#O exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_UNDERFLOW | x87 FPU underflow (the #MF/#U exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_INEXACT_RESULT | x87 FPU inexact result (the #MF/#P exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_INVALID_OPERATION | x87 FPU invalid operation (the #MF/#IA exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_DENORMAL_OPERAND | x87 FPU denormal operand (the #MF/#D exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_X87_STACK_ERROR | x87 FPU stack overflowed or underflowed (the #MF/#IS exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_DIVIDE_BY_ZERO | SIMD floating point divide by zero (the #XM/#Z exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_OVERFLOW | SIMD floating point overflow (the #XM/#O exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_UNDERFLOW | SIMD floating point underflow (the #XM/#U exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_INEXACT_RESULT | SIMD floating point inexact result (the #XM/#P exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_INVALID_OPERATION | SIMD invalid floating point operation (the #XM/#I exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_SIMD_DENORMAL_OPERAND | SIMD denormal floating point operand (the #XM/#D exception). Belongs to EXCEPTCLASS_FP_ERROR.
  EXCEPTCODE_DBG_BREAKPOINT_TRAP | Breakpoint trap (the #BP trap). Belongs to EXCEPTCLASS_DEBUG.
  EXCEPTCODE_DBG_SINGLE_STEP_TRAP | Trace trap (the #DB trap). Belongs to EXCEPTCLASS_DEBUG.
  EXCEPTCODE_ACCESS_WINDOWS_GUARD_PAGE | Guard page access (the Windows STATUS_GUARD_PAGE_VIOLATION exception). Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_ACCESS_WINDOWS_STACK_OVERFLOW | Thread stack overflowed (the Windows STATUS_STACK_OVERFLOW exception). Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_WINDOWS | Generic Windows exception. Belongs to EXCEPTCLASS_OS.
  EXCEPTCODE_RECEIVED_UNKNOWN | Unknown exception, cannot be re-raised. Belongs to EXCEPTCLASS_UNKNOWN.
  EXCEPTCODE_RECEIVED_ACCESS_FAULT | General memory access fault. Belongs to EXCEPTCLASS_ACCESS_FAULT.
  EXCEPTCODE_RECEIVED_AMBIGUOUS_X87 | Ambiguous x87 FPU exception. PIN_GetFpErrorSet() tell which are possible. Belongs to EXCEPTCLASS_MULTIPLE_FP_ERROR.
  EXCEPTCODE_RECEIVED_AMBIGUOUS_SIMD | Ambiguous SIMD FPU exception. PIN_GetFpErrorSet() tell which are possible. Belongs to EXCEPTCLASS_MULTIPLE_FP_ERROR.

enum FAULTY_ACCESS_TYPE

| Types of faulty memory accesses that may cause an EXCEPTCLASS_ACCESS_FAULT exception

Enumerator:

  FAULTY_ACCESS_TYPE_UNKNOWN | Unknown access violation.
  FAULTY_ACCESS_READ | Read access.
  FAULTY_ACCESS_WRITE | Write access.
  FAULTY_ACCESS_EXECUTE | Execute access.

enum FPERROR

| Possible types of FPU exceptions.

Enumerator:

  FPERROR_DIVIDE_BY_ZERO | The DE exception.
  FPERROR_OVERFLOW | The O exception.
  FPERROR_UNDERFLOW | The U exception.
  FPERROR_INEXACT_RESULT | The P exception.
  FPERROR_INVALID_OPERATION | The IA exception on x87 or I exception on SIMD.
  FPERROR_DENORMAL_OPERAND | The D exception.
  FPERROR_X87_STACK_ERROR | The IS exception on x87.

## Function Documentation

UINT32 PIN_CountWindowsExceptionArguments | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the number of Windows system exception's arguments from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  The number of arguments associated with the system exception

Precondition:
  The specified exception information should describe an EXCEPTCODE_WINDOWS exception.

Availability:
  Mode: All
  O/S: Windows
  CPU: All

string PIN_ExceptionToString | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Get a string representation of the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be stringized

Returns:
  The string representation of this structure.

Availability:
  Mode: All
  O/S: All
  CPU: All

ADDRINT PIN_GetExceptionAddress | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the address of the instruction that caused the specified exception.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  The address of the instruction that caused the exception

Availability:
  Mode: All
  O/S: All
  CPU: All

EXCEPTION_CLASS PIN_GetExceptionClass | ( | EXCEPTION_CODE | exceptCode | ) |

| Given an exception code, return the corresponding exception class.

Parameters:

  `[in]` | exceptCode | exception code

Returns:
  The class of the exception

Availability:
  Mode: All
  O/S: All
  CPU: All

EXCEPTION_CODE PIN_GetExceptionCode | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the exception code from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  The code of the exception

Availability:
  Mode: All
  O/S: All
  CPU: All

BOOL PIN_GetFaultyAccessAddress | ( | const EXCEPTION_INFO * | pExceptInfo,
|  | ADDRINT * | pAccessAddress
| ) |

| Retrieve the address of the faulty memory access from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried
  `[out]` | pAccessAddress | pointer to variable that receives the address of the faulty memory access, if known. If this pointer is NULL, the function only checks if the requested address is known but does not return its value.

Returns:
  TRUE, if the address of the faulty memory access is known

Precondition:
  The specified exception information should describe an EXCEPTCLASS_ACCESS_FAULT exception.

Availability:
  Mode: All
  O/S: All
  CPU: All

FAULTY_ACCESS_TYPE PIN_GetFaultyAccessType | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the type of the faulty memory access from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  The type of the faulty memory access that caused the exception

Precondition:
  The specified exception information should describe an EXCEPTCLASS_ACCESS_FAULT exception.

Availability:
  Mode: All
  O/S: All
  CPU: All

UINT32 PIN_GetFpErrorSet | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the set of floating point exception codes from the specified EXCEPTION_INFO structure. For EXCEPTCODE_RECEIVED_AMBIGUOUS_X87 and EXCEPTCODE_RECEIVED_AMBIGUOUS_SIMD exceptions, this is the set of possible causes for the exception.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  A bitmask of FPERROR values.

Precondition:
  The specified exception information should describe an EXCEPTCLASS_MULTIPLE_FP_ERROR exception.

Availability:
  Mode: All
  O/S: All
  CPU: All

ADDRINT PIN_GetWindowsExceptionArgument | ( | const EXCEPTION_INFO * | pExceptInfo,
|  | UINT32 | argNum
| ) |

| Retrieve the specified Windows system exception's argument from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried
  `[in]` | argNum | ordinal number of the argument to be retrieved, starting from zero. The value of this parameter should not exceed the value returned by the PIN_CountWindowsExceptionArguments function.

Returns:
  The value of the specified system exception's argument

Precondition:
  The specified exception information should describe an EXCEPTCODE_WINDOWS exception.

Availability:
  Mode: All
  O/S: Windows
  CPU: All

UINT32 PIN_GetWindowsExceptionCode | ( | const EXCEPTION_INFO * | pExceptInfo | ) |

| Retrieve the Windows system exception code from the specified EXCEPTION_INFO structure.

Parameters:

  `[in]` | pExceptInfo | pointer to the exception information structure to be queried

Returns:
  The system exception code

Precondition:
  The specified exception information should describe an EXCEPTCODE_WINDOWS exception.

Availability:
  Mode: All
  O/S: Windows
  CPU: All

VOID PIN_InitAccessFaultInfo | ( | EXCEPTION_INFO * | pExceptInfo,
|  | EXCEPTION_CODE | exceptCode,
|  | ADDRINT | exceptAddress,
|  | ADDRINT | accessAddress,
|  | FAULTY_ACCESS_TYPE | accessType = `FAULTY_ACCESS_TYPE_UNKNOWN`
| ) |

| Initialize the specified EXCEPTION_INFO structure with the given attributes of an EXCEPTCLASS_ACCESS_FAULT exception.

Parameters:

  `[out]` | pExceptInfo | pointer to the exception information structure to be initialized
  `[in]` | exceptCode | exception code that specifies an EXCEPTCLASS_ACCESS_FAULT exception
  `[in]` | exceptAddress | address of the instruction that caused the exception
  `[in]` | accessAddress | address of the faulty memory access
  `[in]` | accessType | type of the faulty memory access

Availability:
  Mode: All
  O/S: All
  CPU: All

VOID PIN_InitExceptionInfo | ( | EXCEPTION_INFO * | pExceptInfo,
|  | EXCEPTION_CODE | exceptCode,
|  | ADDRINT | exceptAddress
| ) |

| Initialize the specified EXCEPTION_INFO structure with the given generic exception's attributes. Set "unknown" state for all exception-specific attributes.

Note:
  This function is useful when the specified exception code does not require any additional exception information or such information is not available. The function can not be used to initialize EXCEPTCODE_WINDOWS exception information.
  Use exception-specific initialization functions if an additional exception information is available/required.

Parameters:

  `[out]` | pExceptInfo | pointer to the exception information structure to be initialized
  `[in]` | exceptCode | exception code. It could specify any exception other than EXCEPTCODE_WINDOWS
  `[in]` | exceptAddress | address of the instruction that caused the exception

Availability:
  Mode: All
  O/S: All
  CPU: All

VOID PIN_InitWindowsExceptionInfo | ( | EXCEPTION_INFO * | pExceptInfo,
|  | UINT32 | sysExceptCode,
|  | ADDRINT | exceptAddress,
|  | UINT32 | numArgs = `0`,
|  | const ADDRINT * | pArgs = `0`
| ) |

| Initialize the specified EXCEPTION_INFO structure with the given attributes of an EXCEPTCODE_WINDOWS exception.

Parameters:

  `[out]` | pExceptInfo | pointer to the exception information structure to be initialized
  `[in]` | sysExceptCode | the system exception code
  `[in]` | exceptAddress | address of the instruction that caused the exception
  `[in]` | numArgs | number of arguments associated with the system exception. This is the number of elements in the <pArgs> array; it should not exceed the MAX_WINDOWS_EXCEPTION_ARGS value.
  `[in]` | pArgs | pointer to an array of arguments associated with the system exception or NULL if the number of arguments is zero

Availability:
  Mode: All
  O/S: Windows
  CPU: All

VOID LEVEL_PINCLIENT::PIN_RaiseException | ( | const CONTEXT * | ctxt,
|  | THREADID | tid,
|  | const EXCEPTION_INFO * | pExceptInfo
| ) |

| A tool can call this API to raise an emulated exception in the application's calling thread. Calling this API abandons the current analysis function and immediately starts executing at the application's exception handler (if there is one) or terminates the application (if there is no handler). This API does not return back to the calling analysis function.

When raising a floating point exception, this method merely raises the exception. It does not set any bits in the floating point status register, nor does it check that the exception is enabled via the exception mask. If the tool wishes to examine or change the floating point status register bits, it may do so via the ctxt parameter.

This function can be called from an analysis function or a replacement routine, but not from an instrumentation callback.

Parameters:

  `[in]` | ctxt | Register state to be reported as the application's context at the exception point.
  `[in]` | tid | Id of the calling thread.
  `[in]` | pExceptInfo | Pointer to the EXCEPTION_INFO structure that describes the exception. The exception information should be properly initialized.

Returns:
  This API never returns.

Precondition:
  All locks must be released before calling to this function.

Note:
  The vm lock is obtained during the call of this API.

Availability:
  Mode: JIT
  O/S: Windows
  CPU: IA-32 and Intel(R) 64 architectures

VOID PIN_SetExceptionAddress | ( | EXCEPTION_INFO * | pExceptInfo,
|  | ADDRINT | exceptAddress
| ) |

| Set the address of the instruction that caused the specified exception.

Parameters:

  `[in,out]` | pExceptInfo | pointer to the exception information structure that receives the new exception address
  `[in]` | exceptAddress | address of the instruction that caused the exception

## Variable Documentation

GLOBALCONST UINT32 MAX_WINDOWS_EXCEPTION_ARGS = 5

| Maximum number of arguments that can be associated with an EXCEPTCODE_WINDOWS exception.