summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorYuri Dario <ydario@apache.org>2012-03-27 14:15:48 +0000
committerYuri Dario <ydario@apache.org>2012-03-27 14:15:48 +0000
commit3ed84db393d36fb44c44b0191424614877e972f4 (patch)
tree643096b9c8b489a6cdb33f6b4267d8cf3419b441 /sal
parentac5a2c91b0bcffb4bb57641bdda65374597c1faf (diff)
i119097: remove OS/2 exception handling and menu hilite code due to incorrect licensing (code will be reworked soon).
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/os2/debug.c2148
-rw-r--r--sal/osl/os2/except.c1055
-rw-r--r--sal/osl/os2/helpers/debug.h1775
-rw-r--r--sal/osl/os2/helpers/dosh.h45
-rw-r--r--sal/osl/os2/helpers/except.h251
-rw-r--r--sal/osl/os2/helpers/setup.h143
-rw-r--r--sal/osl/os2/makefile.mk4
-rw-r--r--sal/osl/os2/process.c1
-rw-r--r--sal/osl/os2/salinit.cxx7
9 files changed, 4 insertions, 5425 deletions
diff --git a/sal/osl/os2/debug.c b/sal/osl/os2/debug.c
deleted file mode 100644
index 0cc5e759748d..000000000000
--- a/sal/osl/os2/debug.c
+++ /dev/null
@@ -1,2148 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/*
- *@@sourcefile debug.c:
- * this file contains debugging functions for the
- * exception handlers in except.c.
- *
- * This code is capable of unwinding the stack from
- * a given address and trying to get function names
- * and source line numbers, either from the respective
- * module's debug code (if present) or from a SYM file,
- * which is searched for in the directory of the module
- * or in ?:\OS2\PDPSI\PMDF\WARP4.
- *
- * This file incorporates code from the following:
- * -- Marc Fiammante, John Currier, Kim Rasmussen,
- * Anthony Cruise (EXCEPT3.ZIP package for a generic
- * exception handling DLL, available at Hobbes).
- *
- * Usage: All OS/2 programs.
- *
- * Note: Version numbering in this file relates to XWorkplace version
- * numbering.
- *
- *@@changed V0.9.0 [umoeller]: made some declarations C++-compatible
- *@@changed V0.9.1 (2000-01-30) [umoeller]: greatly cleaned up this file
- *
- *@@header "helpers\debug.h"
- */
-
-/*
- * This file Copyright (C) 1992-99 Ulrich M�ller,
- * Kim Rasmussen,
- * Marc Fiammante,
- * John Currier,
- * Anthony Cruise.
- * This file is part of the "XWorkplace helpers" source package.
- *
- * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
- *
- */
-
-//#define DEBUG_SYMDUMP // enable to dump sym file to log
-
-//YD commented, since we need unsigned char BYTE!
-//#define OS2EMX_PLAIN_CHAR
-//Also gcc char is signed, while most structures requires unsigned data!
-//Raised limits for all fields!
-
- // this is needed for "os2emx.h"; if this is defined,
- // emx will define PSZ as _signed_ char, otherwise
- // as unsigned char
-
-#define INCL_DOSPROCESS
-#define INCL_DOSMODULEMGR
-#define INCL_DOSMISC
-#define INCL_DOSERRORS
-#include <os2.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define DONT_REPLACE_MALLOC
-#include "helpers\setup.h" // code generation and debugging options
-
-#include "helpers\debug.h"
-#include "helpers\dosh.h"
-
-#pragma hdrstop
-
-#include <fcntl.h>
-#ifdef __EMX__
- #include <sys\types.h> // required for sys\stat.h; UM 99-10-22
-#endif
-#include <sys\stat.h>
-#include <share.h>
-#include <io.h>
-
-#ifndef DWORD
-#define DWORD unsigned long
-#endif
-#ifndef WORD
-#define WORD unsigned short
-#endif
-
-#pragma stack16(512)
-#define HF_STDERR 2
-
-/*
- *@@category: Helpers\Control program helpers\Exceptions/debugging
- * See except.c and debug.c.
- */
-
-/* ******************************************************************
- *
- * Global variables
- *
- ********************************************************************/
-
-// this specifies whether we're dealing with 32-bit code;
-// this gets changed whenever 16-bit count is detected
-static BOOL f32bit = TRUE;
-
-/*
- * Global variables for Read32PmDebug:
- *
- */
-
-ULONG func_ofs;
-ULONG pubfunc_ofs;
-//YD 17/07/06 c++ namespace can generate really long
-//YD names, use a large buffer!
-char func_name[16*1024];
-ULONG var_ofs = 0;
-
-struct {
- BYTE name[128];
- ULONG stack_offset;
- USHORT type_idx;
-} autovar_def[1024];
-
-#pragma pack(1)
-
-BYTE *type_name[] =
-{
- "8 bit signed ",
- "16 bit signed ",
- "32 bit signed ",
- "Unknown (0x83) ",
- "8 bit unsigned ",
- "16 bit unsigned ",
- "32 bit unsigned ",
- "Unknown (0x87) ",
- "32 bit real ",
- "64 bit real ",
- "80 bit real ",
- "Unknown (0x8B) ",
- "64 bit complex ",
- "128 bit complex ",
- "160 bit complex ",
- "Unknown (0x8F) ",
- "8 bit boolean ",
- "16 bit boolean ",
- "32 bit boolean ",
- "Unknown (0x93) ",
- "8 bit character ",
- "16 bit characters ",
- "32 bit characters ",
- "void ",
- "15 bit unsigned ",
- "24 bit unsigned ",
- "31 bit unsigned ",
- "Unknown (0x9B) ",
- "Unknown (0x9C) ",
- "Unknown (0x9D) ",
- "Unknown (0x9E) ",
- "Unknown (0x9F) ",
- "near pointer to 8 bit signed ",
- "near pointer to 16 bit signed ",
- "near pointer to 32 bit signed ",
- "Unknown (0xA3) ",
- "near pointer to 8 bit unsigned ",
- "near pointer to 16 bit unsigned ",
- "near pointer to 32 bit unsigned ",
- "Unknown (0xA7) ",
- "near pointer to 32 bit real ",
- "near pointer to 64 bit real ",
- "near pointer to 80 bit real ",
- "Unknown (0xAB) ",
- "near pointer to 64 bit complex ",
- "near pointer to 128 bit complex ",
- "near pointer to 160 bit complex ",
- "Unknown (0xAF) ",
- "near pointer to 8 bit boolean ",
- "near pointer to 16 bit boolean ",
- "near pointer to 32 bit boolean ",
- "Unknown (0xB3) ",
- "near pointer to 8 bit character ",
- "near pointer to 16 bit characters",
- "near pointer to 32 bit characters",
- "near pointer to void ",
- "near pointer to 15 bit unsigned ",
- "near pointer to 24 bit unsigned ",
- "near pointer to 31 bit unsigned ",
- "Unknown (0xBB) ",
- "Unknown (0xBC) ",
- "Unknown (0xBD) ",
- "Unknown (0xBE) ",
- "Unknown (0xBF) ",
- "far pointer to 8 bit signed ",
- "far pointer to 16 bit signed ",
- "far pointer to 32 bit signed ",
- "Unknown (0xC3) ",
- "far pointer to 8 bit unsigned ",
- "far pointer to 16 bit unsigned ",
- "far pointer to 32 bit unsigned ",
- "Unknown (0xC7) ",
- "far pointer to 32 bit real ",
- "far pointer to 64 bit real ",
- "far pointer to 80 bit real ",
- "Unknown (0xCB) ",
- "far pointer to 64 bit complex ",
- "far pointer to 128 bit complex ",
- "far pointer to 160 bit complex ",
- "Unknown (0xCF) ",
- "far pointer to 8 bit boolean ",
- "far pointer to 16 bit boolean ",
- "far pointer to 32 bit boolean ",
- "Unknown (0xD3) ",
- "far pointer to 8 bit character ",
- "far pointer to 16 bit characters ",
- "far pointer to 32 bit characters ",
- "far pointer to void ",
- "far pointer to 15 bit unsigned ",
- "far pointer to 24 bit unsigned ",
- "far pointer to 31 bit unsigned ",
-};
-
-// Thanks to John Currier:
-// Do not call 16 bit code in myHandler function to prevent call
-// to __EDCThunkProlog and problems is guard page exception handling
-// Also reduce the stack size to 1K for true 16 bit calls.
-// 16 bit calls thunk will now only occur on fatal exceptions
-#pragma stack16(1024)
-
-// ------------------------------------------------------------------
-// Last 8 bytes of 16:16 file when CODEVIEW debugging info is present
-#pragma pack(1)
-struct _eodbug
-{
- unsigned short dbug; // 'NB' signature
- unsigned short ver; // version
- unsigned long dfaBase; // size of codeview info
-} G_eodbug;
-
-#define DBUGSIG 0x424E
-#define SSTMODULES 0x0101
-#define SSTPUBLICS 0x0102
-#define SSTTYPES 0x0103
-#define SSTSYMBOLS 0x0104
-#define SSTSRCLINES 0x0105
-#define SSTLIBRARIES 0x0106
-#define SSTSRCLINES2 0x0109
-#define SSTSRCLINES32 0x010B
-
-typedef struct _SYMBASE
-{
- unsigned short dbug; // 'NB' signature
- unsigned short ver; // version
- unsigned long lfoDir; // file offset to dir entries
-} SYMBASE;
-
-typedef struct _SSDIR
-{
- unsigned short sst; // SubSection Type
- unsigned short modindex; // Module index number
- unsigned long lfoStart; // Start of section
- unsigned short cb; // Size of section
-} SSDIR;
-
-typedef struct _SSDIR32
-{
- unsigned short sst; // SubSection Type
- unsigned short modindex; // Module index number
- unsigned long lfoStart; // Start of section
- unsigned long cb; // Size of section
-} SSDIR32;
-
-typedef struct _SSMODULE
-{
- unsigned short csBase; // code segment base
- unsigned short csOff; // code segment offset
- unsigned short csLen; // code segment length
- unsigned short ovrNum; // overlay number
- unsigned short indxSS; // Index into sstLib or 0
- unsigned short reserved;
- BYTE csize; // size of prefix string
-} SSMODULE;
-
-typedef struct _SSMOD32
-{
- unsigned short csBase; // code segment base
- unsigned long csOff; // code segment offset
- unsigned long csLen; // code segment length
- unsigned long ovrNum; // overlay number
- unsigned short indxSS; // Index into sstLib or 0
- unsigned long reserved;
- BYTE csize; // size of prefix string
-} SSMOD32;
-
-typedef struct _SSPUBLIC
-{
- unsigned short offset;
- unsigned short segment;
- unsigned short type;
- BYTE csize;
-} SSPUBLIC;
-
-typedef struct _SSPUBLIC32
-{
- unsigned long offset;
- unsigned short segment;
- unsigned short type;
- BYTE csize;
-} SSPUBLIC32;
-
-typedef struct _SSLINEENTRY32
-{
- unsigned short LineNum;
- unsigned short FileNum;
- unsigned long Offset;
-} SSLINEENTRY32;
-
-typedef struct _FIRSTLINEENTRY32
-{
- unsigned short LineNum;
- unsigned char entry_type;
- unsigned char reserved;
- unsigned short numlines;
- unsigned short segnum;
-} FIRSTLINEENTRY32;
-
-typedef struct _SSFILENUM32
-{
- unsigned long first_displayable; // Not used
- unsigned long number_displayable; // Not used
- unsigned long file_count; // number of source files
-} SSFILENUM32;
-
-/*
- *@@ XDEBUGINFO:
- * buffers for Read... funcs.
- *
- *@@added V0.9.4 (2000-06-15) [umoeller]
- */
-
-typedef struct _XDEBUGINFO
-{
- char szNrFile[300]; // receives source file
- char szNrLine[300]; // receives line number
- //YD 17/07/06 c++ namespace can generate really long
- //YD names, use a large buffer!
- char szNrPub[16*1024]; // receives function name
-
- struct new_seg *pseg;
- struct o32_obj *pobj; // flat .EXE object table entry
-
- SYMBASE base;
-
- SSDIR *pDirTab;
- SSDIR32 *pDirTab32;
- unsigned char *pEntTab;
- unsigned long lfaBase;
- SSMOD32 ssmod32;
- SSPUBLIC32 sspub32;
-
- SSMODULE ssmod;
- SSPUBLIC sspub;
-} XDEBUGINFO, *PXDEBUGINFO;
-
-
-USHORT _THUNK_FUNCTION (Dos16SizeSeg) ();
-//APIRET16 APIENTRY16 DOS16SIZESEG(USHORT Seg, PULONG16 Size);
-USHORT DosSizeSeg (USHORT Seg, PULONG16 Size)
-{
- return ((USHORT)
- (_THUNK_PROLOG (2+4);
- _THUNK_SHORT (Seg);
- _THUNK_FLAT (Size);
- _THUNK_CALL (Dos16SizeSeg)));
-}
-
-#pragma pack()
-
-/* ******************************************************************
- *
- * PART 1: ANALYZE DEBUG CODE
- *
- ********************************************************************/
-
-static int Read16CodeView(FILE *LogFile, PXDEBUGINFO pxdi, int fh, int TrapSeg, int TrapOff, CHAR *FileName);
-static int Read32PmDebug(FILE *LogFile, PXDEBUGINFO pxdi, int fh, int TrapSeg, int TrapOff, CHAR *FileName);
-
-/*
- *@@ WriteAddressInfo:
- * formats and writes a line into the trap log
- * file.
- *
- * This gets called for each line from the
- * stack dump. At this point, the line in the
- * trap log already has:
- *
- + CS:EIP : 000109FF XMLVIEW :0
- + ^^^ and we write here
- * After this call, we have.
- *
- + CS:EIP : 000109FF XMLVIEW :0 xxx.c 123 ConfirmCreate__Fv
- + ^^^ and we write here
- *
- *@@added V0.9.12 (2001-05-12) [umoeller]
- */
-
-static VOID WriteDebugInfo(FILE *LogFile, // in: open log file
- PXDEBUGINFO pxdi) // in: debug info
-{
- fprintf(LogFile,
- "%s%s%s",
- pxdi->szNrFile,
- pxdi->szNrLine,
- pxdi->szNrPub);
-}
-
-/*
- *@@ dbgPrintDebugInfo:
- * this is the main entry point into analyzing debug
- * code.
- *
- * This analyzes a given address and tries to find
- * debug code descriptions for this address. If found,
- * the information is written to the given log file.
- *
- * Gets called from dbgPrintStack.
- *
- * This returns NO_ERROR if the could was successfully
- * analyzed or something != 0 if we failed.
- *
- * New with V0.84.
- */
-
-APIRET dbgPrintDebugInfo(FILE *LogFile, // out: log file to write to
- CHAR *FileName, // in: EXE/DLL module file name
- ULONG Object, // in: trapping object (from DosQueryModFromEIP)
- ULONG TrapOffset) // in: trapping address (from DosQueryModFromEIP)
-{
- APIRET rc = 0;
- int ModuleFile = 0;
- static struct exe_hdr OldExeHeader;
- static struct new_exe NewExeHeader;
-
- ULONG ulSegment = Object + 1; // segment no. is object no. + 1
-
- XDEBUGINFO xdi;
- memset(&xdi, 0, sizeof(xdi));
-
- // open the module file for reading to analyze the code
- ModuleFile = sopen(FileName, O_RDONLY | O_BINARY, SH_DENYNO);
-
- if (ModuleFile != -1)
- {
- // file found:
- // read old Exe header
- if (read(ModuleFile, (void*)&OldExeHeader, 64) == -1L)
- {
- fprintf(LogFile, "errno %d reading old exe header\n", errno);
- close(ModuleFile);
- return 2;
- }
- // seek to new Exe header
- if (lseek(ModuleFile, (long)E_LFANEW(OldExeHeader), SEEK_SET) == -1L)
- {
- fprintf(LogFile, "errno %d seeking to new exe header\n", errno);
- close(ModuleFile);
- return 3;
- }
- if (read(ModuleFile, (void *)&NewExeHeader, 64) == -1L)
- {
- fprintf(LogFile, "errno %d reading new exe header\n", errno);
- close(ModuleFile);
- return 4;
- }
-
- // check EXE signature
- if (NE_MAGIC(NewExeHeader) == E32MAGIC)
- {
- /*
- * flat 32 executable:
- *
- */
-
- // do analysis for 32-bit code
- if (!(rc = Read32PmDebug(LogFile,
- &xdi, // output
- ModuleFile,
- ulSegment,
- TrapOffset,
- FileName)))
- WriteDebugInfo(LogFile, &xdi);
-
- close(ModuleFile);
-
- // rc !=0 try with DBG file
- if (rc != 0)
- {
- strcpy(FileName + strlen(FileName) - 3, "DBG"); // Build DBG File name
- ModuleFile = sopen(FileName, O_RDONLY | O_BINARY, SH_DENYNO);
- if (ModuleFile != -1)
- {
- if (!(rc = Read32PmDebug(LogFile,
- &xdi,
- ModuleFile,
- ulSegment,
- TrapOffset,
- FileName)))
- WriteDebugInfo(LogFile, &xdi);
-
- close(ModuleFile);
- }
- }
-
- return rc;
- }
- else
- {
- if (NE_MAGIC(NewExeHeader) == NEMAGIC)
- {
- /*
- * 16:16 executable:
- *
- */
-
- if ((xdi.pseg = (struct new_seg *)calloc(NE_CSEG(NewExeHeader),
- sizeof(struct new_seg)))
- == NULL)
- {
- fprintf(LogFile, "Out of memory!");
- close(ModuleFile);
- return -1;
- }
- if ( lseek(ModuleFile,
- E_LFANEW(OldExeHeader) + NE_SEGTAB(NewExeHeader),
- SEEK_SET) == -1L)
- {
- fprintf(LogFile, "Error %u seeking segment table in %s\n", errno, FileName);
- free(xdi.pseg);
- close(ModuleFile);
- return 9;
- }
-
- if (read(ModuleFile,
- (void *)xdi.pseg,
- NE_CSEG(NewExeHeader) * sizeof(struct new_seg))
- == -1)
- {
- fprintf(LogFile, "Error %u reading segment table from %s\n", errno, FileName);
- free(xdi.pseg);
- close(ModuleFile);
- return 10;
- }
-
- if (!(rc = Read16CodeView(LogFile,
- &xdi,
- ModuleFile,
- ulSegment,
- TrapOffset,
- FileName)))
- WriteDebugInfo(LogFile, &xdi);
-
- free(xdi.pseg);
- close(ModuleFile);
-
- // rc !=0 try with DBG file
- if (rc != 0)
- {
- strcpy(FileName + strlen(FileName) - 3, "DBG"); // Build DBG File name
- ModuleFile = sopen(FileName,
- O_RDONLY | O_BINARY, SH_DENYNO);
- if (ModuleFile != -1)
- {
- if (!(rc = Read16CodeView(LogFile,
- &xdi,
- ModuleFile,
- ulSegment,
- TrapOffset,
- FileName)))
- WriteDebugInfo(LogFile, &xdi);
-
- close(ModuleFile);
- }
- }
- return rc;
- }
- else
- {
- /*
- * Unknown executable:
- *
- */
-
- fprintf(LogFile, "Error, could not find exe signature");
- close(ModuleFile);
- return 11;
- }
- }
- } // end if (ModuleFile != -1)
- else
- {
- fprintf(LogFile, "Error %d opening module file %s", errno, FileName);
- return 1;
- } // endif
-
- // return 0; we never get here
-}
-
-char fname[256],
- ModName[80];
-char ename[256],
- dummy[256];
-
-#define MAX_USERDEFS 300 // raised from 150 V0.9.1 (2000-01-30) [umoeller]
-#define MAX_POINTERS 300 // raised from 150 V0.9.1 (2000-01-30) [umoeller]
-
-USHORT userdef_count;
-USHORT pointer_count;
-
-struct one_userdef_rec
-{
- USHORT idx;
- USHORT type_index;
- BYTE name[33];
-} one_userdef[MAX_USERDEFS];
-
-struct one_pointer_rec
-{
- USHORT idx;
- USHORT type_index;
- BYTE type_qual;
- BYTE name[33];
-} one_pointer[MAX_POINTERS];
-
-/*
- * Read32PmDebug:
- * parses 32-bit debug code.
- * Called from dbgPrintDebugInfo for 32-bit modules.
- */
-
-static int Read32PmDebug(FILE *LogFile, // in: text log file to write to
- PXDEBUGINFO pxdi,
- int ModuleFile, // in: module file opened with sopen()
- int TrapSeg,
- int TrapOff,
- CHAR *FileName)
-{
- static unsigned int CurrSymSeg, NrSymbol,
- /* offset, */ NrPublic,
- NrFile, NrLine, /* NrEntry */
- numdir, namelen,
- numlines /* , line */;
- static int ModIndex;
- static int bytesread, i, j;
- static SSLINEENTRY32 LineEntry;
- static SSFILENUM32 FileInfo;
- static FIRSTLINEENTRY32 FirstLine;
- static BYTE dump_vars = FALSE;
- static USHORT idx;
- static BOOL read_types;
- static LONG lSize;
-
- ModIndex = 0;
- // See if any CODEVIEW info
- if (lseek(ModuleFile, -8L, SEEK_END) == -1)
- {
- fprintf(LogFile, "Error %u seeking CodeView table in %s\n", errno, FileName);
- return (18);
- }
-
- if (read(ModuleFile,
- (void *)&G_eodbug, 8)
- == -1)
- {
- fprintf(LogFile, "Error %u reading debug info from %s\n", errno, FileName);
- return (19);
- }
- if (G_eodbug.dbug != DBUGSIG)
- {
- // fprintf(LogFile,"\nNo CodeView information stored.\n");
- return (100);
- }
-
- if ( (pxdi->lfaBase = lseek(ModuleFile,
- -(LONG)G_eodbug.dfaBase,
- SEEK_END))
- == -1L)
- {
- fprintf(LogFile, "Error %u seeking base codeview data in %s\n", errno, FileName);
- return (20);
- }
-
- if (read(ModuleFile,
- (void *)&pxdi->base, 8)
- == -1)
- {
- fprintf(LogFile, "Error %u reading base codeview data in %s\n", errno, FileName);
- return (21);
- }
-
- if (lseek(ModuleFile,
- pxdi->base.lfoDir - 8 + 4,
- SEEK_CUR)
- == -1)
- {
- fprintf(LogFile, "Error %u seeking dir codeview data in %s\n", errno, FileName);
- return (22);
- }
-
- if (read(ModuleFile,
- (void *)&numdir, 4)
- == -1)
- {
- fprintf(LogFile, "Error %u reading dir codeview data in %s\n", errno, FileName);
- return (23);
- }
-
- // Read dir table into buffer
- if ( (pxdi->pDirTab32 = (SSDIR32*)calloc(numdir,
- sizeof(SSDIR32)))
- == NULL)
- {
- fprintf(LogFile, "Out of memory!");
- return (-1);
- }
-
- if (read(ModuleFile,
- (void*)pxdi->pDirTab32,
- numdir * sizeof(SSDIR32))
- == -1)
- {
- fprintf(LogFile, "Error %u reading codeview dir table from %s\n", errno, FileName);
- free(pxdi->pDirTab32);
- return (24);
- }
-
- i = 0;
- while (i < numdir)
- {
- if (pxdi->pDirTab32[i].sst != SSTMODULES)
- {
- i++;
- continue;
- }
-
- NrPublic = 0x0;
- NrSymbol = 0;
- NrLine = 0x0;
- NrFile = 0x0;
- CurrSymSeg = 0;
- // point to subsection
- lseek(ModuleFile,
- pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase,
- SEEK_SET);
- read(ModuleFile,
- (void*)&pxdi->ssmod32.csBase,
- sizeof(SSMOD32));
- read(ModuleFile,
- (void*)ModName,
- (unsigned)pxdi->ssmod32.csize);
- ModIndex = pxdi->pDirTab32[i].modindex;
- ModName[pxdi->ssmod32.csize] = '\0';
- i++;
-
- read_types = FALSE;
-
- while ( (pxdi->pDirTab32[i].modindex == ModIndex)
- && (i < numdir)
- )
- {
- // point to subsection
- lseek(ModuleFile,
- pxdi->pDirTab32[i].lfoStart + pxdi->lfaBase,
- SEEK_SET);
-
- switch (pxdi->pDirTab32[i].sst)
- {
- case SSTPUBLICS:
- bytesread = 0;
- while (bytesread < pxdi->pDirTab32[i].cb)
- {
- bytesread += read(ModuleFile,
- (void *)&pxdi->sspub32.offset,
- sizeof(pxdi->sspub32));
- bytesread += read(ModuleFile,
- (void*)ename,
- (unsigned)pxdi->sspub32.csize);
- ename[pxdi->sspub32.csize] = '\0';
- if ( (pxdi->sspub32.segment == TrapSeg)
- && (pxdi->sspub32.offset <= TrapOff)
- && (pxdi->sspub32.offset >= NrPublic)
- )
- {
- NrPublic = pubfunc_ofs = pxdi->sspub32.offset;
- read_types = TRUE;
- sprintf(pxdi->szNrPub,
- "%s %s (%s)\n",
- (pxdi->sspub32.type == 1)
- ? " Abs"
- : " ",
- ename,
- ModName
- );
- // but continue, because there might be a
- // symbol that comes closer
- }
- }
- break;
-
- // Read symbols, so we can dump the variables on the stack
- case SSTSYMBOLS:
- if (TrapSeg != pxdi->ssmod32.csBase)
- break;
-
- bytesread = 0;
- while (bytesread < pxdi->pDirTab32[i].cb)
- {
- static USHORT usLength;
- static USHORT usLengthSym;
- static BYTE b1,
- b2;
- static BYTE bType;
- // *ptr;
- static ULONG ofs;
- // static ULONG last_addr = 0;
- //YD 17/07/06 c++ namespace can generate really long
- //YD names, use a large buffer!
- static BYTE str[16*1024];
- static struct symseg_rec symseg;
- static struct symauto_rec symauto;
- static struct symproc_rec symproc;
-
- // Read the length of this subentry
- bytesread += read(ModuleFile, &b1, 1);
- if (b1 & 0x80)
- {
- bytesread += read(ModuleFile, &b2, 1);
- usLength = ((b1 & 0x7F) << 8) + b2;
- }
- else
- usLength = b1;
-
- ofs = tell(ModuleFile);
-
- bytesread += read(ModuleFile, &bType, 1);
-
- switch (bType)
- {
- case SYM_CHANGESEG:
- read(ModuleFile, &symseg, sizeof(symseg));
- CurrSymSeg = symseg.seg_no;
- break;
-
- case SYM_PROC:
- case SYM_CPPPROC:
- read(ModuleFile, &symproc, sizeof(symproc));
- if (symproc.name_len & 0x80)
- {
- read(ModuleFile, &b2, 1);
- usLengthSym = ((symproc.name_len & 0x7F) << 8) + b2;
- }
- else
- {
- usLengthSym = symproc.name_len;
- }
- read(ModuleFile, str, usLengthSym);
- str[usLengthSym] = 0;
-
- if ((CurrSymSeg == TrapSeg) &&
- (symproc.offset <= TrapOff) &&
- (symproc.offset >= NrSymbol))
- {
-
- dump_vars = TRUE;
- var_ofs = 0;
- NrSymbol = symproc.offset;
- func_ofs = symproc.offset;
-
- strcpy(func_name, str);
- }
- else
- {
- dump_vars = FALSE;
- }
- break;
-
- case SYM_AUTO:
- if (!dump_vars)
- break;
-
- read(ModuleFile, &symauto, sizeof(symauto));
- read(ModuleFile, str, symauto.name_len);
- if (symauto.name_len==0x80)
- printf("symauto.name_len==0x80\n");
- str[symauto.name_len] = 0;
-
- strcpy(autovar_def[var_ofs].name, str);
- autovar_def[var_ofs].stack_offset = symauto.stack_offset;
- autovar_def[var_ofs].type_idx = symauto.type_idx;
- var_ofs++;
- break;
-
- }
-
- bytesread += usLength;
-
- lseek(ModuleFile, ofs + usLength, SEEK_SET);
- }
- break;
-
- case SSTTYPES:
- // if (ModIndex != TrapSeg)
- if (!read_types)
- break;
-
- bytesread = 0;
- idx = 0x200;
- userdef_count = 0;
- pointer_count = 0;
- while (bytesread < pxdi->pDirTab32[i].cb)
- {
- static struct type_rec type;
- static struct type_userdefrec udef;
- static struct type_pointerrec point;
- static ULONG ofs;
- static BYTE str[256];
-
- // Read the length of this subentry
- ofs = tell(ModuleFile);
-
- read(ModuleFile, &type, sizeof(type));
- bytesread += sizeof(type);
-
- switch (type.type)
- {
- case TYPE_USERDEF:
- if (userdef_count >= MAX_USERDEFS)
- break;
-
- read(ModuleFile, &udef, sizeof(udef));
- read(ModuleFile, str, udef.name_len);
- str[udef.name_len] = 0;
-
- // Insert userdef in table
- one_userdef[userdef_count].idx = idx;
- one_userdef[userdef_count].type_index = udef.type_index;
- memcpy(one_userdef[userdef_count].name,
- str,
- _min(udef.name_len + 1, 32));
- one_userdef[userdef_count].name[32] = 0;
- userdef_count++;
- break;
-
- case TYPE_POINTER:
- if (pointer_count >= MAX_POINTERS)
- break;
-
- read(ModuleFile, &point, sizeof(point));
- read(ModuleFile, str, point.name_len);
- str[point.name_len] = 0;
-
- // Insert userdef in table
- one_pointer[pointer_count].idx = idx;
- one_pointer[pointer_count].type_index = point.type_index;
- memcpy(one_pointer[pointer_count].name,
- str,
- _min(point.name_len + 1, 32));
- one_pointer[pointer_count].name[32] = 0;
- one_pointer[pointer_count].type_qual = type.type_qual;
- pointer_count++;
- break;
- }
-
- ++idx;
-
- bytesread += type.length;
-
- lseek(ModuleFile, ofs + type.length + 2, SEEK_SET);
- }
- break;
-
- case SSTSRCLINES32:
- if (TrapSeg != pxdi->ssmod32.csBase)
- break;
-
- // read first line
- do
- {
- read(ModuleFile, (void *)&FirstLine, sizeof(FirstLine));
-
- if (FirstLine.LineNum != 0)
- {
- fprintf(LogFile, "Missing Line table information\n");
- break;
- } // endif
- numlines = FirstLine.numlines;
- // Other type of data skip 4 more bytes
- if (FirstLine.entry_type < 4)
- {
- read(ModuleFile, (void *)&lSize, 4);
- if (FirstLine.entry_type == 3)
- lseek(ModuleFile, lSize, SEEK_CUR);
- }
- }
- while (FirstLine.entry_type == 3);
-
- for (j = 0; j < numlines; j++)
- {
- switch (FirstLine.entry_type)
- {
- case 0:
- read(ModuleFile, (void *)&LineEntry, sizeof(LineEntry));
- // Changed by Kim Rasmussen 26/06 1996 to ignore linenumber 0
- // if (LineEntry.Offset+ssmod32.csOff<=TrapOff && LineEntry.Offset+ssmod32.csOff>=NrLine) {
- if ( (LineEntry.LineNum)
- && (LineEntry.Offset + pxdi->ssmod32.csOff
- <= TrapOff)
- && (LineEntry.Offset + pxdi->ssmod32.csOff >= NrLine)
- )
- {
- NrLine = LineEntry.Offset;
- NrFile = LineEntry.FileNum;
- /*pOffset =sprintf(szNrLine,"%04X:%08X line #%hu ",
- * ssmod32.csBase,LineEntry.Offset,
- * LineEntry.LineNum); */
- sprintf(pxdi->szNrLine, "% 6hu", LineEntry.LineNum);
- }
- break;
-
- case 1:
- lseek(ModuleFile, sizeof(struct linlist_rec), SEEK_CUR);
- break;
-
- case 2:
- lseek(ModuleFile, sizeof(struct linsourcelist_rec), SEEK_CUR);
- break;
-
- case 3:
- lseek(ModuleFile, sizeof(struct filenam_rec), SEEK_CUR);
- break;
-
- case 4:
- lseek(ModuleFile, sizeof(struct pathtab_rec), SEEK_CUR);
- break;
-
- }
- }
-
- if (NrFile != 0)
- {
- // file found:
- read(ModuleFile, (void*)&FileInfo, sizeof(FileInfo));
- namelen = 0;
- for (j = 1; j <= FileInfo.file_count; j++)
- {
- namelen = 0;
- read(ModuleFile, (void *)&namelen, 1);
- read(ModuleFile, (void *)ename, namelen);
- if (j == NrFile)
- break;
- }
- ename[namelen] = '\0';
- // pOffset=sprintf(szNrLine+pOffset," (%s) (%s)\n",ename,ModName);
- sprintf(pxdi->szNrFile, "%11.11s ", ename);
- }
- else
- {
- // strcat(szNrLine,"\n"); avoid new line for empty name fill
- strcpy(pxdi->szNrFile, "file? ");
- } // endif
- break;
- } // end switch
-
- i++;
- } // end while modindex
- } // End While i < numdir
- free(pxdi->pDirTab32);
- return (0);
-}
-
-/*
- * Read16CodeView:
- * parses 16-bit debug code.
- * Called from dbgPrintDebugInfo for 16-bit modules.
- */
-
-static int Read16CodeView(FILE *LogFile, // in: text log file to write to
- PXDEBUGINFO pxdi,
- int fh,
- int TrapSeg,
- int TrapOff,
- CHAR *FileName)
-{
- static unsigned short int offset,
- NrPublic, NrLine,
- numdir,
- namelen, numlines,
- line;
- static int ModIndex;
- static int bytesread, i, j;
-
- ModIndex = 0;
- // See if any CODEVIEW info
- if (lseek(fh, -8L, SEEK_END) == -1)
- {
- fprintf(LogFile, "Error %u seeking CodeView table in %s\n", errno, FileName);
- return (18);
- }
-
- if (read(fh, (void *)&G_eodbug, 8) == -1)
- {
- fprintf(LogFile, "Error %u reading debug info from %s\n", errno, FileName);
- return (19);
- }
- if (G_eodbug.dbug != DBUGSIG)
- {
- // fprintf(LogFile,"\nNo CodeView information stored.\n");
- return (100);
- }
-
- if ((pxdi->lfaBase = lseek(fh, -(LONG)G_eodbug.dfaBase, SEEK_END)) == -1L)
- {
- fprintf(LogFile, "Error %u seeking base codeview data in %s\n", errno, FileName);
- return (20);
- }
-
- if (read(fh, (void *)&pxdi->base, 8) == -1)
- {
- fprintf(LogFile, "Error %u reading base codeview data in %s\n", errno, FileName);
- return (21);
- }
-
- if (lseek(fh, pxdi->base.lfoDir - 8, SEEK_CUR) == -1)
- {
- fprintf(LogFile, "Error %u seeking dir codeview data in %s\n", errno, FileName);
- return (22);
- }
-
- if (read(fh, (void *)&numdir, 2) == -1)
- {
- fprintf(LogFile, "Error %u reading dir codeview data in %s\n", errno, FileName);
- return (23);
- }
-
- // Read dir table into buffer
- if ((pxdi->pDirTab = (SSDIR*)calloc(numdir, sizeof(SSDIR))) == NULL)
- {
- fprintf(LogFile, "Out of memory!");
- return (-1);
- }
-
- if (read(fh, (void*)pxdi->pDirTab, numdir * sizeof(SSDIR)) == -1)
- {
- fprintf(LogFile, "Error %u reading codeview dir table from %s\n", errno, FileName);
- free(pxdi->pDirTab);
- return (24);
- }
-
- i = 0;
- while (i < numdir)
- {
- if (pxdi->pDirTab[i].sst != SSTMODULES)
- {
- i++;
- continue;
- }
- NrPublic = 0x0;
- NrLine = 0x0;
- // point to subsection
- lseek(fh, pxdi->pDirTab[i].lfoStart + pxdi->lfaBase, SEEK_SET);
- read(fh, (void *)&pxdi->ssmod.csBase, sizeof(SSMODULE));
- read(fh, (void *)ModName, (unsigned)pxdi->ssmod.csize);
- ModIndex = pxdi->pDirTab[i].modindex;
- ModName[pxdi->ssmod.csize] = '\0';
- i++;
- while (pxdi->pDirTab[i].modindex == ModIndex && i < numdir)
- {
- // point to subsection
- lseek(fh, pxdi->pDirTab[i].lfoStart + pxdi->lfaBase, SEEK_SET);
- switch (pxdi->pDirTab[i].sst)
- {
- case SSTPUBLICS:
- bytesread = 0;
- while (bytesread < pxdi->pDirTab[i].cb)
- {
- bytesread += read(fh, (void *)&pxdi->sspub.offset, sizeof(pxdi->sspub));
- bytesread += read(fh, (void *)ename, (unsigned)pxdi->sspub.csize);
- ename[pxdi->sspub.csize] = '\0';
- if ((pxdi->sspub.segment == TrapSeg) &&
- (pxdi->sspub.offset <= TrapOff) &&
- (pxdi->sspub.offset >= NrPublic))
- {
- NrPublic = pxdi->sspub.offset;
- sprintf(pxdi->szNrPub, "%s %s (%s) %04hX:%04hX\n",
- (pxdi->sspub.type == 1) ? " Abs" : " ", ename,
- ModName, // ()
- pxdi->sspub.segment,
- pxdi->sspub.offset
- );
- }
- }
- break;
-
- case SSTSRCLINES2:
- case SSTSRCLINES:
- if (TrapSeg != pxdi->ssmod.csBase)
- break;
- namelen = 0;
- read(fh, (void *)&namelen, 1);
- read(fh, (void *)ename, namelen);
- ename[namelen] = '\0';
- // skip 2 zero bytes
- if (pxdi->pDirTab[i].sst == SSTSRCLINES2)
- read(fh, (void *)&numlines, 2);
- read(fh, (void *)&numlines, 2);
- for (j = 0; j < numlines; j++)
- {
- read(fh, (void *)&line, 2);
- read(fh, (void *)&offset, 2);
- if (offset <= TrapOff && offset >= NrLine)
- {
- NrLine = offset;
- sprintf(pxdi->szNrFile, "% 12.12s ", ename);
- sprintf(pxdi->szNrLine, "% 6hu", line);
- /*sprintf(szNrLine,"%04hX:%04hX line #%hu (%s) (%s)\n",
- * ssmod.csBase,offset,line,ModName,ename); */
- }
- }
- break;
- } // end switch
- i++;
- } // end while modindex
- } // End While i < numdir
- free(pxdi->pDirTab);
- return (0);
-}
-
-/* ******************************************************************
- *
- * PART 2: ANALYZE VARIABLES
- *
- ********************************************************************/
-
-/*
- * var_value:
- * writes a description of a variable type to
- * the specified buffer, depending on "type".
- *
- *@@changed V0.9.1 (2000-01-30) [umoeller]: changed prototype to use external buffer
- */
-
-static VOID var_value(void *varptr, // in: address of the variable on the stack
- char *pszBuf, // out: information
- BYTE type) // in: type; if >= 32, we'll call DosQueryMem
-{
- ULONG Size = 1,
- Attr = 0;
-
- if (DosQueryMem(varptr, &Size, &Attr) != NO_ERROR)
- {
- sprintf(pszBuf, "type %d, DosQueryMem failed", type);
- return;
- }
-
- if ((Attr & PAG_READ) == 0)
- {
- sprintf(pszBuf, "type %d, read-access to value denied", type);
- return;
- }
-
- if (type == 0)
- sprintf(pszBuf, "%hd", *(signed char*)varptr);
- else if (type == 1)
- sprintf(pszBuf, "%hd", *(signed short*)varptr);
- else if (type == 2)
- sprintf(pszBuf, "%ld", *(signed long*)varptr);
- else if (type == 4)
- sprintf(pszBuf, "%hu", *(BYTE*) varptr);
- else if (type == 5)
- sprintf(pszBuf, "%hu", *(USHORT*)varptr);
- else if (type == 6)
- sprintf(pszBuf, "0x%lX (%lu)", *((ULONG*)varptr), *((ULONG*)varptr));
- else if (type == 8)
- sprintf(pszBuf, "%f", *(float*)varptr);
- else if (type == 9)
- sprintf(pszBuf, "%f", *(double*)varptr);
- else if (type == 10)
- sprintf(pszBuf, "%f", (double)(*(long double*)varptr));
- else if (type == 16)
- sprintf(pszBuf, "%s", *(char*)varptr ? "TRUE" : "FALSE");
- else if (type == 17)
- sprintf(pszBuf, "%s", *(short*)varptr ? "TRUE" : "FALSE");
- else if (type == 18)
- sprintf(pszBuf, "%s", *(long*)varptr ? "TRUE" : "FALSE");
- else if (type == 20)
- sprintf(pszBuf, "%c", *(char*)varptr);
- else if (type == 21)
- sprintf(pszBuf, "%hd", (*(short*)varptr));
- else if (type == 22)
- sprintf(pszBuf, "%ld", *(long*)varptr);
- else if (type == 23)
- sprintf(pszBuf, "void");
- else if (type >= 32)
- {
- sprintf(pszBuf, "0x%p", (void*)(*(ULONG*)varptr));
- if (Attr & PAG_FREE)
- {
- strcat(pszBuf, " unallocated memory");
- }
- else
- {
- if ((Attr & PAG_COMMIT) == 0x0U)
- {
- strcat(pszBuf, " uncommitted");
- } // endif
- if ((Attr & PAG_WRITE) == 0x0U)
- {
- strcat(pszBuf, " unwritable");
- } // endif
- if ((Attr & PAG_READ) == 0x0U)
- {
- strcat(pszBuf, " unreadable");
- } // endif
- } // endif
- } // endif
- else
- sprintf(pszBuf, "Unknown type %d", type);
-}
-
-/*
- * search_userdefs:
- * searches the table of userdef's-
- * Return TRUE if found.
- */
-
-static BOOL search_userdefs(FILE *LogFile, // in: text log file to write to
- ULONG stackofs,
- USHORT var_no)
-{
- USHORT pos;
-
- for (pos = 0;
- pos < userdef_count;
- pos++)
- {
- if (one_userdef[pos].idx == autovar_def[var_no].type_idx)
- {
- if ( (one_userdef[pos].type_index >= 0x80)
- // && (one_userdef[pos].type_index <= 0xDA)
- )
- {
- static char sszVar3[500] = "complex";
- if (one_userdef[pos].type_index <= 0xDA)
- var_value((void*)(stackofs + autovar_def[var_no].stack_offset),
- sszVar3,
- one_userdef[pos].type_index - 0x80);
-
- fprintf(LogFile,
- " %- 6ld %- 20.20s %- 33.33s %s (user)\n",
- autovar_def[var_no].stack_offset, // stack offset
- autovar_def[var_no].name, // identifier
- one_userdef[pos].name, // type name
- sszVar3 // composed by var_value
- );
- return TRUE;
- }
- else
- return FALSE;
- }
- }
-
- return FALSE;
-}
-
-/*
- * search_pointers:
- *
- */
-
-static BOOL search_pointers(FILE *LogFile, // in: text log file to write to
- ULONG stackofs,
- USHORT var_no)
-{
- USHORT pos, upos;
- static BYTE str[35];
- static char sszVar[500];
-
- // BYTE type_index;
-
- for (pos = 0;
- ( (pos < pointer_count)
- && (one_pointer[pos].idx != autovar_def[var_no].type_idx)
- );
- pos++);
-
- if (pos < pointer_count)
- {
- if ( (one_pointer[pos].type_index >= 0x80)
- && (one_pointer[pos].type_index <= 0xDA)
- )
- {
- strcpy(str, type_name[one_pointer[pos].type_index - 0x80]);
- strcat(str, " *");
- var_value((void*)(stackofs + autovar_def[var_no].stack_offset),
- sszVar,
- 32);
- fprintf(LogFile, " %- 6ld %- 20.20s %- 33.33s %s (ptr1)\n",
- autovar_def[var_no].stack_offset,
- autovar_def[var_no].name,
- str,
- sszVar);
- return TRUE;
- }
- else
- {
- // If the result isn't a simple type, look for it in the other lists
- for (upos = 0;
- ( (upos < userdef_count)
- && (one_userdef[upos].idx != one_pointer[pos].type_index)
- );
- upos++)
- ;
-
- if (upos < userdef_count)
- {
- strcpy(str, one_userdef[upos].name);
- strcat(str, " *");
- var_value((void *)(stackofs + autovar_def[var_no].stack_offset),
- sszVar,
- 32);
- fprintf(LogFile, " %- 6ld %- 20.20s %- 33.33s %s (ptr2)\n",
- autovar_def[var_no].stack_offset,
- autovar_def[var_no].name,
- str,
- sszVar);
- return TRUE;
- }
- else
- {
- // if it isn't a userdef, for now give up and just print
- // as much as we know
- sprintf(str, "Pointer to type 0x%X", one_pointer[pos].type_index);
-
- var_value((void *)(stackofs + autovar_def[var_no].stack_offset),
- sszVar,
- 32);
- fprintf(LogFile, " %- 6ld %- 20.20s %- 33.33s %s (ptr3)\n",
- autovar_def[var_no].stack_offset,
- autovar_def[var_no].name,
- str,
- sszVar);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-/*
- *@@ dbgPrintVariables:
- * Dumps variables for the specified stack offset
- * to the specified log file.
- *
- * New with V0.84.
- */
-
-void dbgPrintVariables(FILE *LogFile, // in: text log file to write to
- ULONG stackofs)
-{
- USHORT n; // , pos;
- BOOL AutoVarsFound = FALSE;
-
- if (/* 1 || */ func_ofs == pubfunc_ofs)
- {
- for (n = 0;
- n < var_ofs;
- n++)
- {
- if (AutoVarsFound == FALSE)
- {
- AutoVarsFound = TRUE;
- fprintf(LogFile, " List of auto variables at EBP %p in %s:\n",
- (PVOID)stackofs,
- func_name);
- fprintf(LogFile, " Offset Name Type Value \n");
- fprintf(LogFile, " ������ �������������������� ��������������������������������� �����������������\n");
- }
-
- // If it's one of the simple types
- if ( (autovar_def[n].type_idx >= 0x80)
- && (autovar_def[n].type_idx <= 0xDA)
- )
- {
- static char sszVar2[500];
-
- var_value((void *)(stackofs + autovar_def[n].stack_offset),
- sszVar2,
- autovar_def[n].type_idx - 0x80);
-
- fprintf(LogFile, " %- 6ld %- 20.20s %- 33.33s %s (simple)\n",
- autovar_def[n].stack_offset,
- autovar_def[n].name,
- type_name[autovar_def[n].type_idx - 0x80],
- sszVar2);
- }
- else
- { // Complex type, check if we know what it is
- if (!search_userdefs(LogFile, stackofs, n))
- {
- if (!search_pointers(LogFile, stackofs, n))
- {
- fprintf(LogFile, " %- 6ld %-20.20s 0x%X (unknown)\n",
- autovar_def[n].stack_offset,
- autovar_def[n].name,
- autovar_def[n].type_idx);
- }
- }
- }
- }
- /* if (AutoVarsFound == FALSE)
- {
- fprintf(LogFile, " No auto variables found in %s.\n", func_name);
- } */
- fprintf(LogFile, "\n");
- }
-}
-
-/* ******************************************************************
- *
- * PART 3: ANALYZE SYMBOL (.SYM) FILE
- *
- ********************************************************************/
-
-/*
- *@@ dbgPrintSYMInfo:
- * this gets called by dbgPrintStack if dbgPrintDebugInfo
- * failed (because no debug code was found) to check if
- * maybe a SYM file with the same filename exists and try
- * to get the info from there.
- *
- * This gets called for every line of the stack
- * walk, but only if getting the information from
- * the debug code failed, e.g. because no debug code
- * was available for an address.
- *
- * The file pointer is in the "Source file" column
- * every time this gets called.
- *
- * New with V0.84.
- *
- * Returns 0 if reading the SYM file was successful.
- *
- *@@changed V0.9.1 (2000-01-30) [umoeller]: added return code; this used to be VOID
- */
-
-int dbgPrintSYMInfo(FILE *LogFile, // in: text log file to write to
- CHAR *SymFileName, // in: SYM file name (can be fully q'fied)
- ULONG Object,
- ULONG TrapOffset)
-{
- static FILE *SymFile;
- static MAPDEF MapDef;
- static SEGDEF SegDef;
- static SYMDEF32 SymDef32;
- static SYMDEF16 SymDef16;
- static char Buffer[256];
- static int SegNum, SymNum, LastVal;
- static unsigned long int SegOffset,
- SymOffset, SymPtrOffset;
-
- // open .SYM file
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"Dump of '%s' for object %d\n",SymFileName,Object);
-#endif
- SymFile = fopen(SymFileName, "rb");
- if (SymFile == 0)
- return (2);
-
- // read in first map definition
- fread(&MapDef, sizeof(MAPDEF), 1, SymFile);
-#ifdef DEBUG_SYMDUMP
- Buffer[0] = MapDef.achModName[0];
- fread(&Buffer[1], 1, MapDef.cbModName-1, SymFile);
- Buffer[MapDef.cbModName] = 0x00;
- fprintf(LogFile,"Module name '%s'\n",Buffer);
-#endif
-
- SegOffset = SEGDEFOFFSET(MapDef);
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"SegOffset %0x\n",SegOffset);
-#endif
-
- // go thru all segments
- for (SegNum = 0;
- SegNum < MapDef.cSegs;
- SegNum++)
- {
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"Scanning segment #%d Offset %08X\n",SegNum,SegOffset);
-#endif
- if (fseek(SymFile, SegOffset, SEEK_SET))
- // seek error
- return (3);
-
- // read in segment definition
- fread(&SegDef, sizeof(SEGDEF), 1, SymFile);
-#ifdef DEBUG_SYMDUMP
- Buffer[0] = 0x00;
- if (SegDef.cbSegName>0) {
- Buffer[0] = SegDef.achSegName[0];
- fread(&Buffer[1], 1, SegDef.cbSegName-1, SymFile);
- Buffer[SegDef.cbSegName] = 0x00;
- }
- fprintf(LogFile,"Segment name '%s', number %d, flags %02x\n",Buffer,SegNum,SegDef.bFlags);
-#endif
-
- if (SegNum == Object)
- {
- // stack object found:
- Buffer[0] = 0x00;
- LastVal = 0;
-
- // go thru all symbols in this object
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"Scanning #%d symbols\n",SegDef.cSymbols);
-#endif
- for (SymNum = 0; SymNum < SegDef.cSymbols; SymNum++)
- {
- SymPtrOffset=SYMDEFOFFSET(SegOffset,SegDef,SymNum);
- fseek(SymFile,SymPtrOffset,SEEK_SET);
- fread(&SymOffset,sizeof(unsigned short int),1,SymFile);
- fseek(SymFile,SymOffset+SegOffset,SEEK_SET);
- if (SegDef.bFlags & 0x01)
- {
- // 32-bit symbol:
- fread(&SymDef32, sizeof(SYMDEF32), 1, SymFile);
- if (SymDef32.wSymVal > TrapOffset)
- {
- // symbol found
- fprintf(LogFile,
- "between %s + 0x%lX ",
- Buffer,
- TrapOffset - LastVal);
- /* fprintf(LogFile, "(ppLineDef: 0x%lX) ",
- LINEDEFOFFSET(SegDef)
- ); */
- fprintf(LogFile, "\n");
- }
-
- LastVal = SymDef32.wSymVal;
- Buffer[0] = SymDef32.achSymName[0];
- fread(&Buffer[1], 1, SymDef32.cbSymName-1, SymFile);
- Buffer[SymDef32.cbSymName] = 0x00;
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"32 Bit Symbol Address %08p <%s> \n",SymDef32.wSymVal,Buffer);
-#endif
-
- if (SymDef32.wSymVal > TrapOffset)
- {
- // symbol found, as above
- fprintf(LogFile,
- " "
- "and %s - 0x%lX ",
- Buffer,
- LastVal - TrapOffset);
- fprintf(LogFile, "\n");
- break;
- }
- }
- else
- {
- // 16-bit symbol:
- fread(&SymDef16, sizeof(SYMDEF16), 1, SymFile);
- if (SymDef16.wSymVal > TrapOffset)
- {
- fprintf(LogFile,
- "between %s + %lX\n",
- Buffer,
- TrapOffset - LastVal);
- }
- LastVal = SymDef16.wSymVal;
- Buffer[0] = SymDef16.achSymName[0];
- fread(&Buffer[1], 1, SymDef16.cbSymName-1, SymFile);
- Buffer[SymDef16.cbSymName] = 0x00;
- if (SymDef16.wSymVal > TrapOffset)
- {
- fprintf(LogFile,
- " "
- "and %s - %lX\n",
- Buffer,
- LastVal - TrapOffset);
- break;
- }
-#ifdef DEBUG_SYMDUMP
- fprintf(LogFile,"16 Bit Symbol <%s> Address %p\n",Buffer,SymDef16.wSymVal);
-#endif
- } // endif
- }
- break;
- } // endif
- SegOffset = NEXTSEGDEFOFFSET(SegDef);
- } // endwhile
- fclose(SymFile);
- return (0); // no error
-}
-
-/* ******************************************************************
- *
- * PART 4: dbgPrintStack
- *
- ********************************************************************/
-
-/*
- *@@ dbgPrintStackFrame:
- * parses and dumps one stack frame.
- * Called from excPrintStackFrame.
- *
- * This calls dbgPrintDebugInfo and, if
- * that fails, dbgPrintSYMInfo.
- *
- *@@added V0.9.2 (2000-03-10) [umoeller]
- *@@changed V0.9.3 (2000-04-10) [umoeller]: added support for non-Warp 4 SYM files
- *@@changed V0.9.3 (2000-04-26) [umoeller]: this broke Warp 4 FP 13, fixed
- */
-
-BOOL dbgPrintStackFrame(FILE *LogFile,
- PSZ pszModuleName, // in: module name (fully q'fied)
- ULONG ulObject,
- ULONG ulOffset)
-{
- APIRET arc = 0;
- // "Source file"... columns
-
-//YD do not use debug info
-#define ENABLE_DEBUG_INFO
-#ifdef ENABLE_DEBUG_INFO
- // first attempt to analyze the debug code
- arc = dbgPrintDebugInfo(LogFile,
- pszModuleName,
- ulObject,
- ulOffset);
-#else
- arc = 1;
-#endif
-
- // if no debug code is available, analyze
- // the SYM file instead
- if (arc != NO_ERROR)
- {
- CHAR szSymName[CCHMAXPATH];
- strcpy(szSymName, pszModuleName);
- strcpy(szSymName + strlen(szSymName) - 3, "SYM");
- arc = dbgPrintSYMInfo(LogFile,
- szSymName,
- ulObject,
- ulOffset);
- if (arc != 0)
- {
- // SYM file not found in current directory:
- // check the SYM files in the \OS2 directory,
- // depending on the OS/2 version level:
- CHAR szSymFile2[CCHMAXPATH];
- PSZ pszFilename = strrchr(szSymName, '\\');
- if (pszFilename)
- {
- PSZ pszVersionDir = "WARP4";
- ULONG aulBuf[3];
-
- DosQuerySysInfo(QSV_VERSION_MAJOR, // 11
- QSV_VERSION_MINOR, // 12
- &aulBuf, sizeof(aulBuf));
- // Warp 3 is reported as 20.30
- // Warp 4 is reported as 20.40
- // Aurora is reported as 20.45
-
- if (aulBuf[0] == 20)
- {
- if (aulBuf[1] == 30)
- // Warp 3:
- pszVersionDir = "WARP3";
- else if (aulBuf[1] >= 40)
- // Warp 4 or higher:
- // (NOTE: Warp 4 FP 13 now returns 45 also,
- // but the SYM files are still in the WARP4 directory...)
- // V0.9.3 (2000-04-26) [umoeller]
- pszVersionDir = "WARP4";
- }
-
- pszFilename++;
- sprintf(szSymFile2,
- "%c:\\OS2\\PDPSI\\PMDF\\%s\\%s",
- doshQueryBootDrive(),
- pszVersionDir,
- pszFilename);
- arc = dbgPrintSYMInfo(LogFile,
- szSymFile2,
- ulObject,
- ulOffset);
-
- // V0.9.3 (2000-04-26) [umoeller]
- if ( (arc != 0) // still not found
- && (aulBuf[1] == 45) // and running Aurora or Warp 4 FP13?
- )
- {
- // Warp Server for e-Business (aka Warp 4.5):
- // we use the SYM files for the UNI kernel,
- // I have found no way to find out whether
- // we're running on an SMP kernel
- sprintf(szSymFile2,
- "%c:\\OS2\\PDPSI\\PMDF\\%s\\%s",
- doshQueryBootDrive(),
- "WARP45_U",
- pszFilename);
- arc = dbgPrintSYMInfo(LogFile,
- szSymFile2,
- ulObject,
- ulOffset);
- }
- }
- }
-
- if (arc == 2) // file not found
- fprintf(LogFile,
- "Cannot find symbol file %s\n",
- szSymName);
- else if (arc != 0)
- fprintf(LogFile,
- "Error %lu reading symbol file %s\n",
- arc,
- szSymName);
- }
-
- return (arc == NO_ERROR);
-}
-
-/*
- *@@ dbgPrintStack:
- * this takes stack data from the TIB and
- * context record data structures and tries
- * to analyse what the different stack frames
- * point to.
- *
- * For each stack frame, this calls dbgPrintDebugInfo,
- * and, if that fails, dbgPrintSYMInfo.
- *
- * New with V0.84.
- *
- *@@changed V0.9.2 (2000-03-08) [umoeller]: now searching OS2\PDPSI\PMDF for SYM files also
- */
-
-VOID dbgPrintStack(FILE *LogFile, // in: text log file to write to
- PUSHORT StackBottom,
- PUSHORT StackTop,
- PUSHORT Ebp,
- PUSHORT ExceptionAddress)
-{
- PUSHORT RetAddr = 0;
- PUSHORT LastEbp = 0;
- APIRET rc = 0;
- ULONG Size = 0,
- Attr = 0;
- USHORT Cs = 0,
- Ip = 0,
- // Bp,
- Sp = 0;
- static char Name[CCHMAXPATH];
- HMODULE hMod = 0;
- ULONG ObjNum = 0;
- ULONG Offset = 0;
- BOOL fExceptionAddress = TRUE; // Use Exception Addr 1st time thru
-
- // Note: we can't handle stacks bigger than 64K for now...
- Sp = (USHORT) (((ULONG) StackBottom) >> 16);
- // Bp = ;
-
- if (!f32bit)
- Ebp = (PUSHORT) MAKEULONG(((USHORT)(ULONG)Ebp), Sp);
-
- fprintf(LogFile, "\n\nCall stack:\n");
- fprintf(LogFile, " Source Line Nearest\n");
- fprintf(LogFile, " EBP Address Module Obj# File Numbr Public Symbol\n");
- fprintf(LogFile, " �������� ��������- �������� ���� ������������ ����� ������������-\n");
-
- do
- {
- Size = 10;
- rc = DosQueryMem((PVOID) (Ebp + 2), &Size, &Attr);
- if (rc != NO_ERROR)
- {
- fprintf(LogFile, "Invalid EBP %8.8lX (DosQueryMem returned %lu)\n", (ULONG)Ebp, rc);
- break;
- }
- if (!(Attr & PAG_COMMIT))
- {
- fprintf(LogFile, "Invalid EBP %8.8lX (not committed)\n", (ULONG)Ebp);
- break;
- }
- if (Size < 10)
- {
- fprintf(LogFile, "Invalid EBP %8.8lX (mem block size < 10)\n", (ULONG)Ebp);
- break;
- }
-
- if (fExceptionAddress)
- RetAddr = ExceptionAddress;
- else
- RetAddr = (PUSHORT) (*((PULONG) (Ebp + 2)));
-
- if (RetAddr == (PUSHORT) 0x00000053)
- {
- // For some reason there's a "return address" of 0x53 following
- // EBP on the stack and we have to adjust EBP by 44 bytes to get
- // at the real return address. This has something to do with
- // thunking from 32bits to 16bits...
- // Serious kludge, and it's probably dependent on versions of C(++)
- // runtime or OS, but it works for now!
- Ebp += 22;
- RetAddr = (PUSHORT) (*((PULONG) (Ebp + 2)));
- }
-
- // Get the (possibly) 16bit CS and IP
- if (fExceptionAddress)
- {
- Cs = (USHORT) (((ULONG) ExceptionAddress) >> 16);
- Ip = (USHORT) (ULONG) ExceptionAddress;
- }
- else
- {
- Cs = *(Ebp + 2);
- Ip = *(Ebp + 1);
- }
-
- // if the return address points to the stack then it's really just
- // a pointer to the return address (UGH!).
- if ( (USHORT) (((ULONG) RetAddr) >> 16) == Sp
- )
- RetAddr = (PUSHORT) (*((PULONG) RetAddr));
-
- if (Ip == 0 && *Ebp == 0)
- {
- // End of the stack so these are both shifted by 2 bytes:
- Cs = *(Ebp + 3);
- Ip = *(Ebp + 2);
- }
-
- // 16bit programs have on the stack:
- // BP:IP:CS
- // where CS may be thunked
- //
- // in dump swapped
- // BP IP CS BP CS IP
- // 4677 53B5 F7D0 7746 D0F7 B553
- //
- // 32bit programs have:
- // EBP:EIP
- // and you'd have something like this (with SP added) (not
- // accurate values)
- //
- // in dump swapped
- // EBP EIP EBP EIP
- // 4677 2900 53B5 F7D0 0029 7746 D0F7 B553
- //
- // So the basic difference is that 32bit programs have a 32bit
- // EBP and we can attempt to determine whether we have a 32bit
- // EBP by checking to see if its 'selector' is the same as SP.
- // Note that this technique limits us to checking stacks < 64K.
- //
- // Soooo, if IP (which maps into the same USHORT as the swapped
- // stack page in EBP) doesn't point to the stack (i.e. it could
- // be a 16bit IP) then see if CS is valid (as is or thunked).
- //
- // Note that there's the possibility of a 16bit return address
- // that has an offset that's the same as SP so we'll think it's
- // a 32bit return address and won't be able to successfully resolve
- // its details.
- if (Ip != Sp)
- {
- if (DosSizeSeg(Cs, &Size) == NO_ERROR)
- {
- RetAddr = (USHORT * _Seg16) MAKEULONG(Ip, Cs);
- f32bit = FALSE;
- }
- else if (DosSizeSeg((Cs << 3) + 7, &Size) == NO_ERROR)
- {
- Cs = (Cs << 3) + 7;
- RetAddr = (USHORT * _Seg16) MAKEULONG(Ip, Cs);
- f32bit = FALSE;
- }
- else
- f32bit = TRUE;
- }
- else
- f32bit = TRUE;
-
-
- // "EBP" column
- if (fExceptionAddress)
- fprintf(LogFile, " Trap -> ");
- else
- fprintf(LogFile, " %8.8lX ", (ULONG)Ebp);
-
- // "Address" column
- if (f32bit)
- fprintf(LogFile, ":%8.8lX ", (ULONG)RetAddr);
- else
- fprintf(LogFile, "%04.04X:%04.04X ", Cs, Ip);
-
- // Version check omitted; the following requires
- // OS/2 2.10 or later (*UM)
- // if (Version[0] >= 20 && Version[1] >= 10)
- {
- // Make a 'tick' sound to let the user know we're still alive
- DosBeep(2000, 10);
-
- Size = 10; // Inserted by Kim Rasmussen 26/06 1996 to avoid error 87 when Size is 0
-
- // "Module"/"Object" columns
- rc = DosQueryMem((PVOID) RetAddr, &Size, &Attr);
- if (rc != NO_ERROR || !(Attr & PAG_COMMIT))
- {
- fprintf(LogFile, "Invalid RetAddr: %8.8lX\n", (ULONG)RetAddr);
- break; // avoid infinite loops
- }
- else
- {
- rc = DosQueryModFromEIP(&hMod,
- &ObjNum,
- sizeof(Name), Name,
- &Offset,
- (PVOID)RetAddr);
- if ( (rc == NO_ERROR)
- // && (ObjNum != -1)
- )
- {
- // static char szJunk[_MAX_FNAME];
- static char szName[_MAX_FNAME];
-
- DosQueryModuleName(hMod, sizeof(Name), Name);
- // _splitpath(Name, szJunk, szJunk, szName, szJunk);
-
- // print module and object
- fprintf(LogFile, "%-8s %04lX ", szName, ObjNum + 1);
-
- if (strlen(Name) > 3)
- {
- dbgPrintStackFrame(LogFile,
- Name,
- ObjNum,
- Offset);
- }
- }
- else
- fprintf(LogFile,
- "DosQueryModFromEIP failed, returned %lu\n",
- rc);
- }
- }
-
- if ( ((*Ebp) == 0)
- && ((*Ebp + 1) == 0)
- )
- {
- fprintf(LogFile, "End of call stack\n");
- break;
- }
-
- if (!fExceptionAddress)
- {
- LastEbp = Ebp;
-#if 0
- Ebp = (PUSHORT) MAKEULONG(Bp, Sp);
-#else // Inserted by Kim Rasmussen 26/06 1996 to allow big stacks
- if (f32bit)
- Ebp = (PUSHORT) *(PULONG) LastEbp;
- else
- Ebp = (PUSHORT) MAKEULONG((*Ebp), Sp);
-#endif
- if (f32bit)
- {
- dbgPrintVariables(LogFile, (ULONG) Ebp);
- } // endif
-
- if (Ebp < LastEbp)
- {
- fprintf(LogFile, "... lost stack chain - new EBP below previous\n");
- break;
- }
- }
- else
- fExceptionAddress = FALSE;
-
- Size = 4;
- rc = DosQueryMem((PVOID) Ebp, &Size, &Attr);
- if ((rc != NO_ERROR) || (Size < 4))
- {
- fprintf(LogFile, "... lost stack chain - invalid EBP: %8.8lX\n", (ULONG)Ebp);
- break;
- }
- } while (TRUE);
-
- fprintf(LogFile, "\n");
-}
-
-/*
- *@@ doshQueryBootDrive:
- * returns the letter of the boot drive as a
- * single (capital) character, which is useful for
- * constructing file names using sprintf and such.
- *
- *@@changed V0.9.16 (2002-01-13) [umoeller]: optimized
- */
-
-CHAR doshQueryBootDrive(VOID)
-{
- // this can never change, so query this only once
- // V0.9.16 (2002-01-13) [umoeller]
- static CHAR cBootDrive = '\0';
-
- if (!cBootDrive)
- {
- ULONG ulBootDrive;
- DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
- &ulBootDrive,
- sizeof(ulBootDrive));
- cBootDrive = (CHAR)ulBootDrive + 'A' - 1;
- }
-
- return (cBootDrive);
-}
diff --git a/sal/osl/os2/except.c b/sal/osl/os2/except.c
deleted file mode 100644
index 2b4812ebe4eb..000000000000
--- a/sal/osl/os2/except.c
+++ /dev/null
@@ -1,1055 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/*
- *@@sourcefile except.c:
- * this file contains powerful exception handlers.
- * except.h also defines easy-to-use macros for them.
- *
- * Usage: All OS/2 programs, PM or text mode.
- *
- * <B>Introduction</B>
- *
- * OS/2 exception handlers are a mess to program and,
- * if installed wrongly, almost impossible to debug.
- * The problem is that for any program that does a bit
- * more than showing a message box, using exception
- * handlers is a must to avoid system hangs. This
- * especially applies to multi-thread programs using
- * mutex semaphores (more on that below). The functions
- * and macros in here are designed to make that more
- * simple.
- *
- * The macros in except.h automatically insert code for
- * properly registering and deregistering the handlers
- * in except.c. You should ALWAYS use these macros
- * instead of directly registering the handlers to avoid
- * accidentally forgetting to deregister them. If you
- * forget to deregister an exception handler, this can
- * lead to really strange errors (crashes, hangs) which
- * are nearly impossible to debug because the thread's
- * stack probably got completely messed up.
- *
- * The general idea of these macros is to define
- * TRY / CATCH blocks similar to C++. If an exception
- * occurs in the TRY block, execution is transferred to
- * the CATCH block. (This works in both C and C++, by the
- * way.)
- *
- * The "OnKill" function that was added with V0.9.0 has
- * been removed again with V0.9.7.
- *
- * The general usage is like this:
- *
- + int your_protected_func(int ...)
- + {
- + TRY_LOUD(excptid) // or: TRY_QUIET(excptid)
- + {
- + char *p = NULL;
- +
- + .... // the stuff in here is protected by
- + // the excHandlerLoud or excHandlerQuiet
- + // exception handler
- + *p = "A";
- + }
- + CATCH(excptid)
- + {
- + .... // exception occured: react here
- + } END_CATCH(); // always needed!
- + } // end of your_func
- *
- * TRY_LOUD is for installing excHandlerLoud.
- * TRY_QUIET is for installing excHandlerQuiet.
- * CATCH / END_CATCH are the same for the two. This
- * is where the exception handler jumps to if an
- * exception occurs.
- * The CATCH block is _required_ even if you do nothing
- * in there, because the CATCH() macro will deregister
- * the handler.
- *
- * "excptid" can be any C identifier which is not used in
- * your current variable scope, e.g. "excpt1". This
- * is used for creating an EXCEPTSTRUCT variable of
- * that name on the stack. The "excptid"'s in TRY_* and
- * CATCH must match, since this is where the macros
- * store the exception handler data.
- *
- * These macros may be nested if you use different
- * "excptid"'s for sub-macros.
- *
- * Inside the TRY and CATCH blocks, you must not use
- * "goto" (to a location outside the block) or "return",
- * because this will not deregister the handler.
- *
- * Keep in mind that all the code in the TRY_* block is
- * protected by the handler, including all functions that
- * get called. So if you enclose your main() code in a
- * TRY_* block, your entire application is protected.
- * If any subfunction fails, execution is transferred to
- * the closest CATCH() that was installed (as with C++
- * try and catch).
- *
- * <B>Asynchronous exceptions</B>
- *
- * The exception handlers in this file (which are installed
- * with the TRY/CATCH mechanism) only intercept synchronous
- * exceptions, most importantly, XCPT_ACCESS_VIOLATION (see
- * excHandlerLoud for a list). They do not protect your code
- * against asynchronous exceptions.
- *
- * OS/2 defines asynchronous exceptions to be those that
- * can be delayed. With OS/2, there are only three of these:
- *
- * -- XCPT_PROCESS_TERMINATE
- * -- XCPT_ASYNC_PROCESS_TERMINATE
- * -- XCPT_SIGNAL (thread 1 only)
- *
- * To protect yourself against these also, put the section
- * in question in a DosEnterMustComplete/DosExitMustComplete
- * block as well.
- *
- * <B>Mutex semaphores</B>
- *
- * The problem with OS/2 mutex semaphores is that they are
- * sometimes not automatically released when a thread terminates.
- * If there are several mutexes involved and they are released
- * in improper order, you can get zombie threads on exit.
- * Even worse, if this happens to a PM thread, this will hang
- * the system.
- *
- * As a result, you should protect any section of code which
- * requests a semaphore with the exception handlers.
- *
- * So _whenever_ you request a mutex semaphore, enclose
- * the block with TRY/CATCH in case the code crashes.
- * Besides, enclose the TRY/CATCH block in a must-complete
- * section, like this:
- *
- + HMTX hmtx = ...
- +
- + int your_func(int)
- + {
- + BOOL fSemOwned = FALSE;
- +
- + TRY_QUIET(excpt1) // or TRY_LOUD
- + {
- + if (fSemOwned = !DosRequestMutexSem(hmtx, ...))
- + { ... // work on your protected data
- + }
- + // mutex gets released below
- + }
- + CATCH(excpt1) { } END_CATCH(); // always needed!
- +
- + if (fSemOwned)
- + // this gets executed always, even if an exception occured
- + DosReleaseMutexSem(hmtx);
- + } // end of your_func
- *
- * This way your mutex semaphore gets released in every
- * possible condition.
- *
- * <B>Customizing</B>
- *
- * As opposed to versions before 0.9.0, this code is now
- * completely independent of XWorkplace. This file now
- * contains "pure" exception handlers only.
- *
- * However, you can customize these exception handlers by
- * calling excRegisterHooks. This is what XWorkplace does now.
- * This should be done upon initialization of your application.
- * If excRegisterHooks is not called, the following safe
- * defaults are used:
- *
- * -- the trap log file is TRAP.LOG in the root
- * directory of your boot drive.
- *
- * For details on the provided exception handlers, refer
- * to excHandlerLoud and excHandlerQuiet.
- *
- * More useful debug information can be found in the "OS/2 Debugging
- * Handbook", which is now available in INF format on the IBM
- * DevCon site ("http://service2.boulder.ibm.com/devcon/").
- * This book shows worked examples of how to unwind a stack dump.
- *
- * This file incorporates code from the following:
- * -- Monte Copeland, IBM Boca Ration, Florida, USA (1993)
- * -- Roman Stangl, from the Program Commander/2 sources
- * (1997-98)
- * -- Marc Fiammante, John Currier, Kim Rasmussen,
- * Anthony Cruise (EXCEPT3.ZIP package for a generic
- * exception handling DLL, available at Hobbes).
- *
- * If not explicitly stated otherwise, the code has been written
- * by me, Ulrich M�ller.
- *
- * Note: Version numbering in this file relates to XWorkplace version
- * numbering.
- *
- *@@header "helpers\except.h"
- */
-
-/*
- * This file Copyright (C) 1992-99 Ulrich M�ller,
- * Monte Copeland,
- * Roman Stangl,
- * Kim Rasmussen,
- * Marc Fiammante,
- * John Currier,
- * Anthony Cruise.
- * This file is part of the "XWorkplace helpers" source package.
- *
- * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
- *
- */
-
-#define OS2EMX_PLAIN_CHAR
- // this is needed for "os2emx.h"; if this is defined,
- // emx will define PSZ as _signed_ char, otherwise
- // as unsigned char
-
-#define INCL_DOSMODULEMGR
-#define INCL_DOSEXCEPTIONS
-#define INCL_DOSPROCESS
-#define INCL_DOSMISC
-#define INCL_DOSERRORS
-#include <os2.h>
-
-// C library headers
-#include <stdio.h> // needed for except.h
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <setjmp.h> // needed for except.h
-#include <assert.h> // needed for except.h
-
-#define DONT_REPLACE_MALLOC
-#include "helpers\setup.h" // code generation and debugging options
-
-// headers in /helpers
-#include "helpers\dosh.h" // Control Program helper routines
-#include "helpers\except.h" // exception handling
-#include "helpers\debug.h" // symbol/debug code analysis
-
-#pragma hdrstop
-
-/* ******************************************************************
- *
- * Global variables
- *
- ********************************************************************/
-
-// hooks to be registered using excRegisterHooks
-PFNEXCOPENFILE G_pfnExcOpenFile = 0;
-PFNEXCHOOK G_pfnExcHook = 0;
-PFNEXCHOOKERROR G_pfnExcHookError = 0;
-// beep flag for excHandlerLoud
-BOOL G_fBeepOnException = TRUE;
-
-ULONG G_ulExplainExceptionRunning = 0;
- // global flag which is != 0 if some exception handler
- // is inside excExplainException, so that XShutdown can
- // wait until the trap log is done;
- // this is exported thru except.h
- // V0.9.13 (2001-06-19) [umoeller]
-
-/*
- *@@category: Helpers\Control program helpers\Exceptions/debugging
- * See except.c.
- */
-
-/* ******************************************************************
- *
- * Exception helper routines
- *
- ********************************************************************/
-
-/*
- *@@ excDescribePage:
- *
- */
-
-VOID excDescribePage(FILE *file, ULONG ulCheck)
-{
- APIRET arc;
- ULONG ulCountPages = 1;
- ULONG ulFlagsPage = 0;
- arc = DosQueryMem((PVOID)ulCheck, &ulCountPages, &ulFlagsPage);
-
- if (arc == NO_ERROR)
- {
- fprintf(file, "valid, flags: ");
- if (ulFlagsPage & PAG_READ)
- fprintf(file, "read ");
- if (ulFlagsPage & PAG_WRITE)
- fprintf(file, "write ");
- if (ulFlagsPage & PAG_EXECUTE)
- fprintf(file, "execute ");
- if (ulFlagsPage & PAG_GUARD)
- fprintf(file, "guard ");
- if (ulFlagsPage & PAG_COMMIT)
- fprintf(file, "committed ");
- if (ulFlagsPage & PAG_SHARED)
- fprintf(file, "shared ");
- if (ulFlagsPage & PAG_FREE)
- fprintf(file, "free ");
- if (ulFlagsPage & PAG_BASE)
- fprintf(file, "base ");
- }
- else if (arc == ERROR_INVALID_ADDRESS)
- fprintf(file, "invalid");
-}
-
-/*
- *@@ excPrintStackFrame:
- * wrapper for dbgPrintStackFrame to format
- * output stuff right.
- *
- *@@added V0.9.2 (2000-03-10) [umoeller]
- *@@changed V0.9.12 (2001-05-12) [umoeller]: added seg:ofs to output always
- */
-
-VOID excPrintStackFrame(FILE *file, // in: output log file
- PSZ pszDescription, // in: description for stack frame (should be eight chars)
- ULONG ulAddress) // in: address to debug
-{
- APIRET arc = NO_ERROR;
- HMODULE hmod1 = NULLHANDLE;
- CHAR szMod1[2*CCHMAXPATH] = "unknown";
- ULONG ulObject = 0,
- ulOffset = 0;
- fprintf(file,
- " %-8s: %08lX ",
- pszDescription,
- ulAddress);
- arc = DosQueryModFromEIP(&hmod1,
- &ulObject,
- sizeof(szMod1), szMod1,
- &ulOffset,
- ulAddress);
-
- if (arc != NO_ERROR)
- {
- // error:
- fprintf(file,
- " %-8s Error: DosQueryModFromEIP returned %lu\n",
- szMod1,
- arc);
- }
- else
- {
- CHAR szFullName[2*CCHMAXPATH];
-
- fprintf(file,
- " %-8s %02lX:%08lX\n ",
- szMod1,
- ulObject + 1, // V0.9.12 (2001-05-12) [umoeller]
- ulOffset); // V0.9.12 (2001-05-12) [umoeller]
-
- DosQueryModuleName(hmod1, sizeof(szFullName), szFullName);
- dbgPrintStackFrame(file,
- szFullName,
- ulObject,
- ulOffset);
-
- fprintf(file, "\n");
-
- // make a 'tick' sound to let the user know we're still alive
- DosBeep(2000, 10);
- }
-}
-
-/*
- *@@ excDumpStackFrames:
- * called from excExplainException to dump the
- * thread's stack frames. This calls excPrintStackFrame
- * for each stack frame found.
- *
- *@@added V0.9.4 (2000-06-15) [umoeller]
- */
-
-VOID excDumpStackFrames(FILE *file, // in: logfile from fopen()
- PTIB ptib,
- PCONTEXTRECORD pContextRec) // in: excpt info
-{
- PULONG pulStackWord = 0;
-
- fprintf(file, "\n\nStack frames:\n Address Module seg:ofs\n");
-
- // first the trapping address itself
- excPrintStackFrame(file,
- "CS:EIP ",
- pContextRec->ctx_RegEip);
-
-
- pulStackWord = (PULONG)pContextRec->ctx_RegEbp;
- /* if (pContextRec->ctx_RegEbp < pContextRec->ctx_RegEsp)
- pulStackWord = (PULONG)(pContextRec->ctx_RegEbp & 0xFFFFFFF0);
- else
- pulStackWord = (PULONG)(pContextRec->ctx_RegEsp & 0xFFFFFFF0); */
-
- while ( (pulStackWord != 0)
- && (pulStackWord < (PULONG)ptib->tib_pstacklimit)
- )
- {
- CHAR szAddress[20];
-
- if (((ULONG)pulStackWord & 0x00000FFF) == 0x00000000)
- {
- // we're on a page boundary: check access
- ULONG ulCountPages = 0x1000;
- ULONG ulFlagsPage = 0;
- APIRET arc = DosQueryMem((void *)pulStackWord,
- &ulCountPages,
- &ulFlagsPage);
- if ( (arc != NO_ERROR)
- || ( (arc == NO_ERROR)
- && ( !( ((ulFlagsPage & (PAG_COMMIT|PAG_READ))
- == (PAG_COMMIT|PAG_READ)
- )
- )
- )
- )
- )
- {
- fprintf(file, "\n %08lX: ", (ULONG)pulStackWord);
- fprintf(file, "Page inaccessible");
- pulStackWord += 0x1000;
- continue; // for
- }
- }
-
- sprintf(szAddress, "%08lX",
- (ULONG)pulStackWord);
- excPrintStackFrame(file,
- szAddress,
- *(pulStackWord+1));
- pulStackWord = (PULONG)*(pulStackWord);
-
- if (pulStackWord == 0)
- fprintf(file, "\n pulStackWord == 0");
- else if (pulStackWord >= (PULONG)ptib->tib_pstacklimit)
- fprintf(file, "\n pulStackWord >= (PULONG)ptib->tib_pstacklimit");
- } // end while
-}
-
-/*
- *@@ excExplainException:
- * used by the exception handlers below to write
- * LOTS of information about the exception into a logfile.
- *
- * This calls excPrintStackFrame for each stack frame.
- *
- *@@changed V0.9.0 [umoeller]: added support for application hook
- *@@changed V0.9.0 (99-11-02) [umoeller]: added TID to dump
- *@@changed V0.9.2 (2000-03-10) [umoeller]: now using excPrintStackFrame
- *@@changed V0.9.3 (2000-05-03) [umoeller]: fixed crashes
- *@@changed V0.9.6 (2000-11-06) [umoeller]: added more register dumps
- *@@changed V0.9.13 (2001-06-19) [umoeller]: added global flag for whether this is running
- *@@changed V0.9.16 (2001-11-02) [pr]: make object display signed
- *@@changed V0.9.19 (2002-03-28) [umoeller]: added thread ordinal
- */
-
-VOID excExplainException(FILE *file, // in: logfile from fopen()
- PSZ pszHandlerName, // in: descriptive string
- PEXCEPTIONREPORTRECORD pReportRec, // in: excpt info
- PCONTEXTRECORD pContextRec) // in: excpt info
-{
- ULONG aulBuf[3];
- const char *pcszVersion = "unknown";
-
- PTIB ptib = NULL;
- PPIB ppib = NULL;
- HMODULE hMod1, hMod2;
- CHAR szMod1[CCHMAXPATH] = "unknown",
- szMod2[CCHMAXPATH] = "unknown";
- ULONG ulObjNum,
- ulOffset;
- ULONG ul;
-
- ULONG ulOldPriority = 0x0100; // regular, delta 0
-
- // raise global flag for whether this func is running
- // V0.9.13 (2001-06-19) [umoeller]
- G_ulExplainExceptionRunning++;
-
- // raise this thread's priority, because this
- // might take some time
- if (DosGetInfoBlocks(&ptib, &ppib) == NO_ERROR)
- if (ptib)
- if (ptib->tib_ptib2)
- {
- ulOldPriority = ptib->tib_ptib2->tib2_ulpri;
- DosSetPriority(PRTYS_THREAD,
- PRTYC_REGULAR,
- PRTYD_MAXIMUM,
- 0); // current thread
- }
-
- // make some noise
-#ifndef __NOEXCEPTIONBEEPS__ // V0.9.19 (2002-04-17) [umoeller]
- if (G_fBeepOnException)
- {
- DosBeep( 250, 30);
- DosBeep( 500, 30);
- DosBeep(1000, 30);
- DosBeep(2000, 30);
- DosBeep(4000, 30);
- DosBeep(2000, 30);
- DosBeep(1000, 30);
- DosBeep( 500, 30);
- DosBeep( 250, 30);
- }
-#endif
-
- // generic exception info
- DosQuerySysInfo(QSV_VERSION_MAJOR, // 11
- QSV_VERSION_MINOR, // 12
- &aulBuf, sizeof(aulBuf));
- // Warp 3 is reported as 20.30
- // Warp 4 is reported as 20.40
- // Aurora is reported as 20.45
-
- if (aulBuf[0] == 20)
- {
- switch (aulBuf[1])
- {
- case 30: pcszVersion = "Warp 3"; break;
- case 40: pcszVersion = "Warp 4"; break;
- case 45: pcszVersion = "WSeB kernel"; break;
- }
- }
- fprintf(file,
- "Running OS/2 version: %u.%u (%s)\n",
- aulBuf[0], // major
- aulBuf[1],
- pcszVersion);
-
-
- // generic exception info
- fprintf(file,
- "\n%s:\n Exception type: %08lX\n Address: %08lX\n Params: ",
- pszHandlerName,
- pReportRec->ExceptionNum,
- (ULONG)pReportRec->ExceptionAddress);
- for (ul = 0; ul < pReportRec->cParameters; ul++)
- {
- fprintf(file, "%08lX ",
- pReportRec->ExceptionInfo[ul]);
- }
-
- // now explain the exception in a bit more detail;
- // depending on the exception, pReportRec->ExceptionInfo
- // contains some useful data
- switch (pReportRec->ExceptionNum)
- {
- case XCPT_ACCESS_VIOLATION:
- fprintf(file, "\nXCPT_ACCESS_VIOLATION: ");
- if (pReportRec->ExceptionInfo[0] & XCPT_READ_ACCESS)
- fprintf(file, "Invalid read access from 0x%04lX:%08lX.\n",
- pContextRec->ctx_SegDs, pReportRec->ExceptionInfo[1]);
- else if (pReportRec->ExceptionInfo[0] & XCPT_WRITE_ACCESS)
- fprintf(file, "Invalid write access to 0x%04lX:%08lX.\n",
- pContextRec->ctx_SegDs, pReportRec->ExceptionInfo[1]);
- else if (pReportRec->ExceptionInfo[0] & XCPT_SPACE_ACCESS)
- fprintf(file, "Invalid space access at 0x%04lX.\n",
- pReportRec->ExceptionInfo[1]);
- else if (pReportRec->ExceptionInfo[0] & XCPT_LIMIT_ACCESS)
- fprintf(file, "Invalid limit access occurred.\n");
- else if (pReportRec->ExceptionInfo[0] == XCPT_UNKNOWN_ACCESS)
- fprintf(file, "unknown at 0x%04lX:%08lX\n",
- pContextRec->ctx_SegDs, pReportRec->ExceptionInfo[1]);
- fprintf(file,
- "Explanation: An attempt was made to access a memory object which does\n"
- " not belong to the current process. Most probable causes\n"
- " for this are that an invalid pointer was used, there was\n"
- " confusion with administering memory or error conditions \n"
- " were not properly checked for.\n");
- break;
-
- case XCPT_INTEGER_DIVIDE_BY_ZERO:
- fprintf(file, "\nXCPT_INTEGER_DIVIDE_BY_ZERO.\n");
- fprintf(file,
- "Explanation: An attempt was made to divide an integer value by zero,\n"
- " which is not defined.\n");
- break;
-
- case XCPT_ILLEGAL_INSTRUCTION:
- fprintf(file, "\nXCPT_ILLEGAL_INSTRUCTION.\n");
- fprintf(file,
- "Explanation: An attempt was made to execute an instruction that\n"
- " is not defined on this machine's architecture.\n");
- break;
-
- case XCPT_PRIVILEGED_INSTRUCTION:
- fprintf(file, "\nXCPT_PRIVILEGED_INSTRUCTION.\n");
- fprintf(file,
- "Explanation: An attempt was made to execute an instruction that\n"
- " is not permitted in the current machine mode or that\n"
- " the program had no permission to execute.\n");
- break;
-
- case XCPT_INTEGER_OVERFLOW:
- fprintf(file, "\nXCPT_INTEGER_OVERFLOW.\n");
- fprintf(file,
- "Explanation: An integer operation generated a carry-out of the most\n"
- " significant bit. This is a sign of an attempt to store\n"
- " a value which does not fit into an integer variable.\n");
- break;
-
- default:
- fprintf(file, "\nUnknown OS/2 exception number %d.\n", pReportRec->ExceptionNum);
- fprintf(file, "Look this up in the OS/2 header files.\n");
- break;
- }
-
- // V0.9.16 (2001-11-02) [pr]: We already got this info. above - this overwrites the
- // original values before the priority change, which is rather confusing.
- // if (DosGetInfoBlocks(&ptib, &ppib) == NO_ERROR)
- {
- /*
- * process info:
- *
- */
-
- if ((ptib) && (ppib)) // (99-11-01) [umoeller]
- {
- if (pContextRec->ContextFlags & CONTEXT_CONTROL)
- {
- // get the main module
- hMod1 = ppib->pib_hmte;
- DosQueryModuleName(hMod1,
- sizeof(szMod1),
- szMod1);
-
- // get the trapping module
- DosQueryModFromEIP(&hMod2,
- &ulObjNum,
- sizeof(szMod2),
- szMod2,
- &ulOffset,
- pContextRec->ctx_RegEip);
- DosQueryModuleName(hMod2,
- sizeof(szMod2),
- szMod2);
- }
-
- fprintf(file,
- "\nProcess information:"
- "\n Process ID: 0x%lX"
- "\n Process module: 0x%lX (%s)"
- "\n Trapping module: 0x%lX (%s)"
- "\n Object: %ld\n", // V0.9.16 (2001-11-02) [pr]: make this display signed
- ppib->pib_ulpid,
- hMod1, szMod1,
- hMod2, szMod2,
- ulObjNum);
-
- fprintf(file,
- "\nTrapping thread information:"
- "\n Thread ID: 0x%lX (%lu)"
- "\n Thread slot ID: 0x%lX (%lu)" // added V0.9.19 (2002-03-28) [umoeller]
- "\n Priority: 0x%lX\n",
- ptib->tib_ptib2->tib2_ultid, ptib->tib_ptib2->tib2_ultid,
- ptib->tib_ordinal, ptib->tib_ordinal,
- ulOldPriority);
- }
- else
- fprintf(file, "\nProcess information was not available.");
-
- /*
- * now call the hook, if one has been defined,
- * so that the application can write additional
- * information to the traplog (V0.9.0)
- */
-
- if (G_pfnExcHook)
- G_pfnExcHook(file, ptib, ulOldPriority); // V0.9.16 (2001-12-02) [pr]
-
- // *** registers
-
- fprintf(file, "\nRegisters:");
- if (pContextRec->ContextFlags & CONTEXT_INTEGER)
- {
- // DS the following 4 added V0.9.6 (2000-11-06) [umoeller]
- fprintf(file, "\n DS = %08lX ", pContextRec->ctx_SegDs);
- excDescribePage(file, pContextRec->ctx_SegDs);
- // ES
- fprintf(file, "\n ES = %08lX ", pContextRec->ctx_SegEs);
- excDescribePage(file, pContextRec->ctx_SegEs);
- // FS
- fprintf(file, "\n FS = %08lX ", pContextRec->ctx_SegFs);
- excDescribePage(file, pContextRec->ctx_SegFs);
- // GS
- fprintf(file, "\n GS = %08lX ", pContextRec->ctx_SegGs);
- excDescribePage(file, pContextRec->ctx_SegGs);
-
- // EAX
- fprintf(file, "\n EAX = %08lX ", pContextRec->ctx_RegEax);
- excDescribePage(file, pContextRec->ctx_RegEax);
- // EBX
- fprintf(file, "\n EBX = %08lX ", pContextRec->ctx_RegEbx);
- excDescribePage(file, pContextRec->ctx_RegEbx);
- // ECX
- fprintf(file, "\n ECX = %08lX ", pContextRec->ctx_RegEcx);
- excDescribePage(file, pContextRec->ctx_RegEcx);
- // EDX
- fprintf(file, "\n EDX = %08lX ", pContextRec->ctx_RegEdx);
- excDescribePage(file, pContextRec->ctx_RegEdx);
- // ESI
- fprintf(file, "\n ESI = %08lX ", pContextRec->ctx_RegEsi);
- excDescribePage(file, pContextRec->ctx_RegEsi);
- // EDI
- fprintf(file, "\n EDI = %08lX ", pContextRec->ctx_RegEdi);
- excDescribePage(file, pContextRec->ctx_RegEdi);
- fprintf(file, "\n");
- }
- else
- fprintf(file, " not available\n");
-
- if (pContextRec->ContextFlags & CONTEXT_CONTROL)
- {
-
- // *** instruction
-
- fprintf(file, "Instruction pointer (where exception occured):\n CS:EIP = %04lX:%08lX ",
- pContextRec->ctx_SegCs,
- pContextRec->ctx_RegEip);
- excDescribePage(file, pContextRec->ctx_RegEip);
-
- // *** CPU flags
-
- fprintf(file, "\n EFLAGS = %08lX", pContextRec->ctx_EFlags);
-
- /*
- * stack:
- *
- */
-
- fprintf(file, "\nStack:\n Base: %08lX\n Limit: %08lX",
- (ULONG)(ptib ? ptib->tib_pstack : 0),
- (ULONG)(ptib ? ptib->tib_pstacklimit : 0));
- fprintf(file, "\n SS:ESP = %04lX:%08lX ",
- pContextRec->ctx_SegSs,
- pContextRec->ctx_RegEsp);
- excDescribePage(file, pContextRec->ctx_RegEsp);
-
- fprintf(file, "\n EBP = %08lX ", pContextRec->ctx_RegEbp);
- excDescribePage(file, pContextRec->ctx_RegEbp);
-
- /*
- * stack dump:
- */
-
- if (ptib != 0)
- {
- excDumpStackFrames(file, ptib, pContextRec);
- }
- }
- }
- fprintf(file, "\n");
-
- // reset old priority
- DosSetPriority(PRTYS_THREAD,
- (ulOldPriority & 0x0F00) >> 8,
- (UCHAR)ulOldPriority,
- 0); // current thread
-
- // lower global flag again V0.9.13 (2001-06-19) [umoeller]
- G_ulExplainExceptionRunning--;
-}
-
-/* ******************************************************************
- *
- * Exported routines
- *
- ********************************************************************/
-
-/*
- *@@ excRegisterHooks:
- * this registers hooks which get called for
- * exception handlers. You can set any of the
- * hooks to NULL for safe defaults (see top of
- * except.c for details). You can set none,
- * one, or both of the hooks, and you can call
- * this function several times.
- *
- * Both hooks get called whenever an exception
- * occurs, so there better be no bugs in these
- * routines. ;-) They only get called from
- * within excHandlerLoud (because excHandlerQuiet
- * writes no trap logs).
- *
- * The hooks are as follows:
- *
- * -- pfnExcOpenFileNew gets called to open
- * the trap log file. This must return a FILE*
- * pointer from fopen(). If this is not defined,
- * ?:\TRAP.LOG is used. Use this to specify a
- * different file and have some notes written
- * into it before the actual exception info.
- *
- * -- pfnExcHookNew gets called while the trap log
- * is being written. At this point,
- * the following info has been written into
- * the trap log already:
- * -- exception type/address block
- * -- exception explanation
- * -- process information
- *
- * _After_ the hook, the exception handler
- * continues with the "Registers" information
- * and stack dump/analysis.
- *
- * Use this hook to write additional application
- * info into the trap log, such as the state
- * of your own threads and mutexes.
- *
- * -- pfnExcHookError gets called when the TRY_* macros
- * fail to install an exception handler (when
- * DosSetExceptionHandler fails). I've never seen
- * this happen.
- *
- *@@added V0.9.0 [umoeller]
- *@@changed V0.9.2 (2000-03-10) [umoeller]: pfnExcHookError added
- */
-
-VOID excRegisterHooks(PFNEXCOPENFILE pfnExcOpenFileNew,
- PFNEXCHOOK pfnExcHookNew,
- PFNEXCHOOKERROR pfnExcHookError,
- BOOL fBeepOnExceptionNew)
-{
- // adjust the global variables
- G_pfnExcOpenFile = pfnExcOpenFileNew;
- G_pfnExcHook = pfnExcHookNew;
- G_pfnExcHookError = pfnExcHookError;
- G_fBeepOnException = fBeepOnExceptionNew;
-}
-
-/*
- *@@ excHandlerLoud:
- * this is the "sophisticated" exception handler;
- * which gives forth a loud sequence of beeps thru the
- * speaker, writes a trap log and then returns back
- * to the thread to continue execution, i.e. the
- * default OS/2 exception handler will never get
- * called.
- *
- * This requires a setjmp() call on
- * EXCEPTIONREGISTRATIONRECORD2.jmpThread before
- * being installed. The TRY_LOUD macro will take
- * care of this for you (see except.c).
- *
- * This intercepts the following exceptions (see
- * the OS/2 Control Program Reference for details):
- *
- * -- XCPT_ACCESS_VIOLATION (traps 0x0d, 0x0e)
- * -- XCPT_INTEGER_DIVIDE_BY_ZERO (trap 0)
- * -- XCPT_ILLEGAL_INSTRUCTION (trap 6)
- * -- XCPT_PRIVILEGED_INSTRUCTION
- * -- XCPT_INTEGER_OVERFLOW (trap 4)
- *
- * For these exceptions, we call the functions in debug.c
- * to try to find debug code or SYM file information about
- * what source code corresponds to the error.
- *
- * See excRegisterHooks for the default setup of this.
- *
- * Note that to get meaningful debugging information
- * in this handler's traplog, you need the following:
- *
- * a) have a MAP file created at link time (/MAP)
- *
- * b) convert the MAP to a SYM file using MAPSYM
- *
- * c) put the SYM file in the same directory of
- * the module (EXE or DLL). This must have the
- * same filestem as the module.
- *
- * All other exceptions are passed to the next handler
- * in the exception handler chain. This might be the
- * C/C++ compiler handler or the default OS/2 handler,
- * which will probably terminate the process.
- *
- *@@changed V0.9.0 [umoeller]: added support for thread termination
- *@@changed V0.9.2 (2000-03-10) [umoeller]: switched date format to ISO
- *@@changed V0.9.19 (2002-05-07) [umoeller]: added EXCEPTIONREPORTRECORD info so that catch block can check that
- */
-
-ULONG _System excHandlerLoud(PEXCEPTIONREPORTRECORD pReportRec,
- PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
- PCONTEXTRECORD pContextRec,
- PVOID pv)
-{
- /* From the VAC++3 docs:
- * "The first thing an exception handler should do is check the
- * exception flags. If EH_EXIT_UNWIND is set, meaning
- * the thread is ending, the handler tells the operating system
- * to pass the exception to the next exception handler. It does the
- * same if the EH_UNWINDING flag is set, the flag that indicates
- * this exception handler is being removed.
- * The EH_NESTED_CALL flag indicates whether the exception
- * occurred within an exception handler. If the handler does
- * not check this flag, recursive exceptions could occur until
- * there is no stack remaining."
- * So for all these conditions, we exit immediately.
- */
-
- if (pReportRec->fHandlerFlags & EH_EXIT_UNWIND)
- return (XCPT_CONTINUE_SEARCH);
- if (pReportRec->fHandlerFlags & EH_UNWINDING)
- return (XCPT_CONTINUE_SEARCH);
- if (pReportRec->fHandlerFlags & EH_NESTED_CALL)
- return (XCPT_CONTINUE_SEARCH);
-
- switch (pReportRec->ExceptionNum)
- {
- case XCPT_ACCESS_VIOLATION:
- case XCPT_INTEGER_DIVIDE_BY_ZERO:
- case XCPT_ILLEGAL_INSTRUCTION:
- case XCPT_PRIVILEGED_INSTRUCTION:
- case XCPT_INVALID_LOCK_SEQUENCE:
- case XCPT_INTEGER_OVERFLOW:
- {
- // "real" exceptions:
- FILE *file;
-
- // open traplog file;
- if (G_pfnExcOpenFile)
- // hook defined for this: call it
- file = (*G_pfnExcOpenFile)();
- else
- {
- CHAR szFileName[100];
- // no hook defined: open some
- // default traplog file in root directory of
- // boot drive
- sprintf(szFileName, "%c:\\trap.log", doshQueryBootDrive());
- file = fopen(szFileName, "a");
-
- if (file)
- {
- DATETIME DT;
- DosGetDateTime(&DT);
- fprintf(file,
- "\nTrap message -- Date: %04d-%02d-%02d, Time: %02d:%02d:%02d\n",
- DT.year, DT.month, DT.day,
- DT.hours, DT.minutes, DT.seconds);
- fprintf(file, "------------------------------------------------\n");
-
- }
- }
-
- // write error log
- excExplainException(file,
- "excHandlerLoud",
- pReportRec,
- pContextRec);
- fclose(file);
-
- // copy report rec to user buffer
- // V0.9.19 (2002-05-07) [umoeller]
- memcpy(&pRegRec2->err,
- pReportRec,
- sizeof(EXCEPTIONREPORTRECORD));
-
- // jump back to failing routine
- longjmp(pRegRec2->jmpThread, pReportRec->ExceptionNum);
- break; }
- }
-
- // not handled
- return (XCPT_CONTINUE_SEARCH);
-}
-
-/*
- *@@ excHandlerQuiet:
- * "quiet" xcpt handler, which simply suppresses exceptions;
- * this is useful for certain error-prone functions, where
- * exceptions are likely to appear, for example used by
- * wpshCheckObject to implement a fail-safe SOM object check.
- *
- * This does _not_ write an error log and makes _no_ sound.
- * This simply jumps back to the trapping thread or
- * calls EXCEPTIONREGISTRATIONRECORD2.pfnOnKill.
- *
- * Other than that, this behaves like excHandlerLoud.
- *
- * This is best registered thru the TRY_QUIET macro
- * (new with V0.84, described in except.c), which
- * does the necessary setup.
- *
- *@@changed V0.9.0 [umoeller]: added support for thread termination
- *@@changed V0.9.19 (2002-05-07) [umoeller]: added EXCEPTIONREPORTRECORD info so that catch block can check that
- */
-
-ULONG _System excHandlerQuiet(PEXCEPTIONREPORTRECORD pReportRec,
- PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
- PCONTEXTRECORD pContextRec,
- PVOID pv)
-{
- if (pReportRec->fHandlerFlags & EH_EXIT_UNWIND)
- return (XCPT_CONTINUE_SEARCH);
- if (pReportRec->fHandlerFlags & EH_UNWINDING)
- return (XCPT_CONTINUE_SEARCH);
- if (pReportRec->fHandlerFlags & EH_NESTED_CALL)
- return (XCPT_CONTINUE_SEARCH);
-
- switch (pReportRec->ExceptionNum)
- {
- case XCPT_ACCESS_VIOLATION:
- case XCPT_INTEGER_DIVIDE_BY_ZERO:
- case XCPT_ILLEGAL_INSTRUCTION:
- case XCPT_PRIVILEGED_INSTRUCTION:
- case XCPT_INVALID_LOCK_SEQUENCE:
- case XCPT_INTEGER_OVERFLOW:
- // write excpt explanation only if the
- // resp. debugging #define is set (setup.h)
- #ifdef DEBUG_WRITEQUIETEXCPT
- {
- FILE *file = excOpenTraplogFile();
- excExplainException(file,
- "excHandlerQuiet",
- pReportRec,
- pContextRec);
- fclose(file);
- }
- #endif
-
- // copy report rec to user buffer
- // V0.9.19 (2002-05-07) [umoeller]
- memcpy(&pRegRec2->err,
- pReportRec,
- sizeof(EXCEPTIONREPORTRECORD));
-
- // jump back to failing routine
- longjmp(pRegRec2->jmpThread, pReportRec->ExceptionNum);
- break;
-
- default:
- break;
- }
-
- return (XCPT_CONTINUE_SEARCH);
-}
-
-
diff --git a/sal/osl/os2/helpers/debug.h b/sal/osl/os2/helpers/debug.h
deleted file mode 100644
index f592a04271ed..000000000000
--- a/sal/osl/os2/helpers/debug.h
+++ /dev/null
@@ -1,1775 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/*
- *@@sourcefile debug.h:
- * header file for debug.c (exception handling and debugging).
- * See remarks there.
- *
- * Note: Version numbering in this file relates to XWorkplace version
- * numbering.
- *
- *@@changed V0.9.0: included contents of newexe.h
- *
- *@@include #define INCL_BASE
- *@@include #include <os2.h>
- *@@include #include <stdio.h>
- *@@include #include "helpers\debug.h"
- */
-
-/*
- * This file incorporates code from the following:
- * -- Marc Fiammante, John Currier, Kim Rasmussen,
- * Anthony Cruise (EXCEPT3.ZIP package for a generic
- * exception handling DLL, available at Hobbes).
- *
- * This file Copyright (C) 1992-99 Ulrich M�ller,
- * Kim Rasmussen,
- * Marc Fiammante,
- * John Currier,
- * Anthony Cruise.
- *
- * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
- *
- */
-
-#ifndef DEBUG_HEADER_INCLUDED
- #define DEBUG_HEADER_INCLUDED
-
- /********************************************************************
- *
- * SYM file declarations
- *
- ********************************************************************/
-
- // Pointer means offset from beginning of file or beginning of struct
- #pragma pack(1)
-
- typedef struct
- {
- unsigned short int ppNextMap; // paragraph pointer to next map
- unsigned char bFlags; // symbol types
- unsigned char bReserved1; // reserved
- unsigned short int pSegEntry; // segment entry point value
- unsigned short int cConsts; // count of constants in map
- unsigned short int pConstDef; // pointer to constant chain
- unsigned short int cSegs; // count of segments in map
- unsigned short int ppSegDef; // paragraph pointer to first segment
- unsigned char cbMaxSym; // maximum symbol-name length
- unsigned char cbModName; // length of module name
- char achModName[1]; // cbModName Bytes of module-name member
- } MAPDEF;
-
- typedef struct
- {
- unsigned short int ppNextMap; // always zero
- unsigned char release; // release number (minor version number)
- unsigned char version; // major version number
- } LAST_MAPDEF;
-
- typedef struct
- {
- unsigned short int ppNextSeg; // paragraph pointer to next segment
- unsigned short int cSymbols; // count of symbols in list
- unsigned short int pSymDef; // offset of symbol chain
- unsigned short int wReserved1; // reserved
- unsigned short int wReserved2; // reserved
- unsigned short int wReserved3; // reserved
- unsigned short int wReserved4; // reserved
- unsigned char bFlags; // symbol types; bit 0 signals 32-bit (*UM)
- unsigned char bReserved1; // reserved
- unsigned short int ppLineDef; // offset of line number record
- unsigned char bReserved2; // reserved
- unsigned char bReserved3; // reserved
- unsigned char cbSegName; // length of segment name
- char achSegName[1]; /* cbSegName Bytes of segment-name member*/
- } SEGDEF;
-
- typedef struct
- {
- unsigned short int wSymVal; // symbol address or constant
- unsigned char cbSymName; // length of symbol name
- char achSymName[1]; // cbSymName Bytes of symbol-name member
- } SYMDEF16;
-
- typedef struct
- {
- unsigned int wSymVal; // symbol address or constant
- unsigned char cbSymName; // length of symbol name
- char achSymName[1]; // cbSymName Bytes of symbol-name member
- } SYMDEF32;
-
- typedef struct
- {
- unsigned short int ppNextLine; // ptr to next linedef (0 if last)
- unsigned short int wReserved1; // reserved
- unsigned short int pLines; // pointer to line numbers
- unsigned short int cLines; // reserved
- unsigned char cbFileName; // length of filename
- char achFileName[1];// cbFileName Bytes of filename
- } LINEDEF;
-
- typedef struct
- {
- unsigned short int wCodeOffset; // executable offset
- unsigned short int dwFileOffset; // source offset
- } LINEINF;
-
- #define SEGDEFOFFSET(MapDef) (MapDef.ppSegDef*16)
- #define NEXTSEGDEFOFFSET(SegDef) (SegDef.ppNextSeg*16)
-
- #define ASYMPTROFFSET(SegDefOffset,Segdef) (SegDefOffset+SegDef.pSymDef)
- #define SYMDEFOFFSET(SegDefOffset,SegDef,n) (ASYMPTROFFSET(SegDefOffset,SegDef)+(n)*(sizeof(unsigned short int)))
-
- #define ACONSTPTROFFSET(MapDef) (MapDef.ppConstDef)
- #define CONSTDEFOFFSET(MapDef,n) ((MapDef.ppConstDef)+(n)*(sizeof(unsigned short int)))
-
- #define LINEDEFOFFSET(SegDef) (SegDef.ppLineDef*16)
- #define NEXTLINEDEFOFFSET(LineDef) (LineDef.ppNextLine*16)
- #define LINESOFFSET(LinedefOffset,LineDef) ((LinedefOffset)+LineDef.pLines)
-
- /********************************************************************
- *
- * EXE declarations taken from exe.h
- *
- ********************************************************************/
-
- #ifndef WORD
- typedef unsigned short WORD;
- #endif
-
- typedef WORD bbmask;
-
- struct exe {
- WORD eid; // contains EXEID, below
- WORD elast; // # of bytes in last page
- WORD epagsiz; // # of pages in whole file
- WORD erelcnt; // # of relocation entrys
- WORD ehdrsiz; // size of header, in paragraphs
- WORD eminfre; // min # of free paragraphs needed
- WORD emaxfre; // max # of free paragraphs needed
- WORD eiSS; // initial SS value
- WORD eiSP; // initial SP value
- WORD enegsum; // negative sum of entire file
- WORD eiIP; // initial IP value
- WORD eiCS; // initial CS value
- WORD ereloff; // offset in file of relocation table
- WORD eovlnum; // number of the overlay
-
- /* the following fields may not be present.
- * ereloff = 28 not present
- * = 30 exe.ever present and valid
- * = 32 exe.ever field contains garbage
- * ereloff > 32 exe.ever present and valid
- * = 0 if "don't know"
- */
-
- WORD ever; // version # of producing linker
- WORD dumy; // unused
-
- /* the following fields may not be present - if the exe.ereloff
- * value encompasses the fields then they are present and valid.
- */
-
- bbmask ebb; // behavior bits
- WORD dumy2[7]; // must be 0 until defined
- };
-
-
- #define EXEID 0x5a4d // magic ID value
-
- /********************************************************************
- *
- * Object Module Format (OMF) declarations
- *
- ********************************************************************/
-
- struct exehdr_rec
- {
- BYTE signature[2]; // Must be "MZ"
- USHORT image_len; // Image Length
- USHORT pages; // Pages
- USHORT reloc_items; // Relocation table items
- USHORT min_paragraphs; // Mininum 16-bytes paragraphs
- USHORT max_paragraphs; // Maximum 16-bytes paragraphs
- USHORT stack_pos; // Stack position
- USHORT offset_in_sp; // Offset in SP
- USHORT checksum; // Checksum
- USHORT offset_in_ip; // Offset in IP
- USHORT code_pos; // Code segment pos.
- USHORT reloc_item_pos; // Position of first relocation item
- USHORT overlay_number; // Overlay number
- BYTE unused[8]; // Unused bytes
- USHORT oem_id; // OEM Identifier
- BYTE oem_info[24]; // OEM Info
- ULONG lexe_offset; // Offset to linear header
- };
-
- struct lexehdr_rec
- {
- BYTE signature[2]; // Must be "LX"
- BYTE b_ord; // Byte ordering
- BYTE w_ord; // Word ordering
- ULONG format_level; // Format level
- USHORT cpu_type; // CPU Type
- USHORT os_type; // Operating system
- ULONG module_version; // Module version
- ULONG mod_flags; // Module flags
- ULONG mod_pages; // Module pages
- ULONG EIP_object; // EIP Object no.
- ULONG EIP; // EIP Value
- ULONG ESP_object; // ESP Object no
- ULONG ESP; // ESP Value
- ULONG page_size; // Page size
- ULONG page_ofs_shift; // Page offset shift
- ULONG fixup_sect_size; // Fixup section size
- ULONG fixup_sect_checksum; // Fixup section checksum
- ULONG loader_sect_size; // Loader section size
- ULONG loader_sect_checksum; // Loader section checksum
- ULONG obj_table_ofs; // Object table offset
- ULONG obj_count; // Object count
- ULONG obj_page_tab_ofs; // Object page table offset
- ULONG obj_iter_page_ofs; // Object iteration pages offset
- ULONG res_tab_ofs; // Resource table offset
- ULONG res_table_entries; // Resource table entries
- ULONG res_name_tab_ofs; // Resident name table offset;
- ULONG ent_tab_ofs; // Entry table offset
- ULONG mod_dir_ofs; // Module directives offset
- ULONG mod_dir_count; // Number of module directives
- ULONG fixup_page_tab_ofs; // Fixup page table offset
- ULONG fixup_rec_tab_ofs; // Fixup record table offset
- ULONG imp_tab_ofs; // Import module table offset
- ULONG imp_mod_entries; // Import module entries
- ULONG imp_proc_tab_ofs; // Import proc table offset
- ULONG per_page_check_ofs; // Per page checksum offset
- ULONG data_page_offset; // Data pages offset
- ULONG preload_page_count; // Preload pages count
- ULONG nonres_tab_ofs; // Nonresident name table offset
- ULONG nonres_tab_len; // Nonresident name table len
- ULONG nonres_tab_check; // Nonresident tables checksum
- ULONG auto_ds_objectno; // Auto DS object number
- ULONG debug_info_ofs; // Debug info offset
- ULONG debug_info_len; // Debug info length
- ULONG inst_preload_count; // Instance preload count
- ULONG inst_demand_count; // Instance demand count
- ULONG heapsize; // Heap size
- ULONG stacksize; // Stack size
- };
-
- struct debug_head_rec
- {
- BYTE signature[3]; // Debug signature
- BYTE type; // Debug info type
- };
-
- struct dir_inf_rec
- {
- USHORT dirstruct_size; // Size of directory structure
- USHORT number_of_entries; // Number of dnt_rec's in the array
- USHORT unknown; // Unknown data
- // Followed by an array of dnt_rec structures
- };
-
- struct dnt_rec
- {
- USHORT subsect_type; // sst Subsection type
- USHORT mod_index; // Module index (1-based)
- ULONG offset; // Offset of start of section
- ULONG size; // Size of section
- };
-
- // Modules subsection
- struct modules_rec
- {
- USHORT code_seg_base; // Code segment base
- ULONG code_seg_offset; // Code segment offset
- ULONG code_seg_len; // Code segment length
- USHORT overlay_no; // Overlay number
- USHORT lib_idx; // Index into library section or 0
- BYTE segments; // Number of segments
- BYTE reserved;
- BYTE debug_style[2]; // "HL" for HLL, "CV" or 0 for CodeView
- BYTE debug_version[2]; // 00 01 or 00 03 for HLL, 00 00 for CV
- BYTE name_len; // Length of name (which follows)
- };
-
- // Publics subsection
- struct publics_rec
- {
- ULONG offset; // Offset
- USHORT segment; // Segment
- USHORT type; // Type index
- BYTE name_len; // Length of name (wich follows)
- };
-
- #if 0
- // Linenumbers header
- struct linhead_rec
- {
- BYTE id; // 0x95 for flat mem, 32 bit progs
- USHORT length; // Record length
- USHORT base_group; // Base group
- USHORT base_segment; // Base segment
- };
- #endif
-
- // First linenumber record
- struct linfirst_rec
- {
- USHORT lineno; // Line number (0)
- BYTE entry_type; // Entry type
- BYTE reserved; // Reserved
- USHORT entries_count; // Number of table entries
- USHORT segment_no; // Segment number
- ULONG filename_tabsize; // File names table size
- };
-
- // Source line numbers
- struct linsource_rec
- {
- USHORT source_line; // Source file line number
- USHORT source_idx; // Source file index
- ULONG offset; // Offset into segment
- };
-
- // Listing statement numbers
- struct linlist_rec
- {
- ULONG list_line; // Listing file linenumber
- ULONG statement; // Listing file statement number
- ULONG offset; // Offset into segment
- };
-
- // Source and Listing statement numbers
- struct linsourcelist_rec
- {
- USHORT source_line; // Source file line number
- USHORT source_idx; // Source file index
- ULONG list_line; // Listing file linenumber
- ULONG statement; // Listing file statement number
- ULONG offset; // Offset into segment
- };
-
- // Path table
- struct pathtab_rec
- {
- ULONG offset; // Offset into segment
- USHORT path_code; // Path code
- USHORT source_idx; // Source file index
- };
-
- // File names table
- struct filenam_rec
- {
- ULONG first_char; // First displayable char in list file
- ULONG disp_chars; // Number of displayable chars in list line
- ULONG filecount; // Number of source/listing files
- };
-
- // Symbol types
- #define SYM_BEGIN 0x00 // Begin block
- #define SYM_PROC 0x01 // Function
- #define SYM_END 0x02 // End block of function
- #define SYM_AUTO 0x04 // Auto variable
- #define SYM_STATIC 0x05 // Static variable
- #define SYM_LABEL 0x0B // Label
- #define SYM_WITH 0x0C // With start symbol (not used)
- #define SYM_REG 0x0D // Register variable
- #define SYM_CONST 0x0E // Constant
- #define SYM_ENTRY 0x0F // Secondary entry (not in C)
- #define SYM_SKIP 0x10 // For incremental linking (not used)
- #define SYM_CHANGESEG 0x11 // Change segment (#pragma alloc_text)
- #define SYM_TYPEDEF 0x12 // Typedef variable
- #define SYM_PUBLIC 0x13 // Public reference
- #define SYM_MEMBER 0x14 // Member of minor or major structure
- #define SYM_BASED 0x15 // Based variable
- #define SYM_TAG 0x16 // Tag in struct, union, enum ...
- #define SYM_TABLE 0x17 // Table (used in RPG - not C)
- #define SYM_MAP 0x18 // Map variable (extern in C)
- #define SYM_CLASS 0x19 // Class symbol (C++)
- #define SYM_MEMFUNC 0x1A // Member function
- #define SYM_AUTOSCOPE 0x1B // Scoped auto for C++ (not used)
- #define SYM_STATICSCOPE 0x1C // scoped static for C++ (not used)
- #define SYM_CPPPROC 0x1D // C++ Proc
- #define SYM_CPPSTAT 0x1E // C++ Static var
- #define SYM_COMP 0x40 // Compiler information
-
- // Symbolic begin record
- struct symbegin_rec
- {
- ULONG offset; // Segment offset
- ULONG length; // Length of block
- BYTE name_len; // Length of block name
- // Block name follows
- };
-
- // Symbolic auto var record
- struct symauto_rec
- {
- ULONG stack_offset; // Stack offset
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Var name follows
- };
-
- // Symbolic procedure record
- struct symproc_rec
- {
- ULONG offset; // Segment offset
- USHORT type_idx; // Type index
- ULONG length; // Length of procedure
- USHORT pro_len; // Length of prologue
- ULONG pro_bodylen; // Length of prologue + body
- USHORT class_type; // Class type
- BYTE near_far; // Near or far
- BYTE name_len; // Length of name
- // Function name follows
- };
-
- // Symbolic static var record
- struct symstatic_rec
- {
- ULONG offset; // Segment offset
- USHORT segaddr; // Segment address
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Var name follows
- };
-
- // Symbolic label var record
- struct symlabel_rec
- {
- ULONG offset; // Segment offset
- BYTE near_far; // Near or far
- BYTE name_len; // Length of name
- // Var name follows
- };
-
- // Symbolic register var record
- struct symreg_rec
- {
- USHORT type_idx; // Type index
- BYTE reg_no; // Register number
- BYTE name_len; // Length of name
- // Var name follows
- };
-
- // Symbolic change-segment record
- struct symseg_rec
- {
- USHORT seg_no; // Segment number
- };
-
- // Symbolic typedef record
- struct symtypedef_rec
- {
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Symbolic public record
- struct sympublic_rec
- {
- ULONG offset; // Segment offset
- USHORT segaddr; // Segment address
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Symbolic member record
- struct symmember_rec
- {
- ULONG offset; // Offset to subrecord
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Symbolic based record
- struct symbased_rec
- {
- ULONG offset; // Offset to subrecord
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Symbolic tag record
- struct symtag_rec
- {
- USHORT type_idx; // Type index
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Symbolic table record
- struct symtable_rec
- {
- ULONG offset; // Segment offset
- USHORT segaddr; // Segment address
- USHORT type_idx; // Type index
- ULONG idx_ofs; // Index offset to subrecord
- BYTE name_len; // Length of name
- // Name follows
- };
-
- // Type record
- struct type_rec
- {
- USHORT length; // Length of sub-record
- BYTE type; // Sub-record type
- BYTE type_qual; // Type qualifier
- };
-
- // Types
- #define TYPE_CLASS 0x40 // Class
- #define TYPE_BASECLASS 0x41 // Base class
- #define TYPE_FRIEND 0x42 // Friend
- #define TYPE_CLASSDEF 0x43 // Class definition
- #define TYPE_MEMBERFUNC 0x45 // Member function
- #define TYPE_CLASSMEMBER 0x46 // Class member
- #define TYPE_REF 0x48 // Reference
- #define TYPE_MEMBERPTR 0x49 // Member pointer
- #define TYPE_SCALARS 0x51 // Scalars
- #define TYPE_SET 0x52 // Set
- #define TYPE_ENTRY 0x53 // Entry
- #define TYPE_FUNCTION 0x54 // Function
- #define TYPE_AREA 0x55 // Area
- #define TYPE_LOGICAL 0x56 // Logical
- #define TYPE_STACK 0x57 // Stack
- #define TYPE_MACRO 0x59 // Macro
- #define TYPE_BITSTRING 0x5C // Bit string
- #define TYPE_USERDEF 0x5D // User defined
- #define TYPE_CHARSTR 0x60 // Character string
- #define TYPE_PICTURE 0x61 // Picture
- #define TYPE_GRAPHIC 0x62 // Graphic
- #define TYPE_FORMATLAB 0x65 // Format label
- #define TYPE_FILE 0x67 // File
- #define TYPE_SUBRANGE 0x6F // Subrange
- #define TYPE_CODELABEL 0x72 // Code label
- #define TYPE_PROCEDURE 0x75 // Procedure
- #define TYPE_ARRAY 0x78 // Array
- #define TYPE_STRUCT 0x79 // Structure / Union / Record
- #define TYPE_POINTER 0x7A // Pointer
- #define TYPE_ENUM 0x7B // Enum
- #define TYPE_LIST 0x7F // List
-
- // Type userdef
- struct type_userdefrec
- {
- BYTE FID_index; // Field ID
- USHORT type_index; // Type index
- BYTE FID_string; // String ID
- BYTE name_len; // Length of name which follows
- };
-
- // Type function
- struct type_funcrec
- {
- USHORT params;
- USHORT max_params;
- BYTE FID_index; // Field ID
- USHORT type_index; // Type index of return value
- BYTE FID_index1; // String ID
- USHORT typelist_index; // Index of list of params
- };
-
- // Type struct
- struct type_structrec
- {
- ULONG size; // Size of structure
- USHORT field_count; // Number of fields in structure
- BYTE FID_index; // Field ID
- USHORT type_list_idx; // Index to type list
- BYTE FID_index1; // Field ID
- USHORT type_name_idx; // Index to names / offsets
- BYTE dont_know; // Haven't a clue, but it seems to be needed
- BYTE name_len; // Length of structure name which follows
- };
-
- // Type list, type qualifier 1: contains types for structures
- // This record is repeated for the number of items in the structure definition
- struct type_list1
- {
- BYTE FID_index; // Field identifier for index
- USHORT type_index; // Type index.
- };
-
- // Type list, type qualifier 2: contains names and offsets for structure items
- // This record is repeated for the number of items in the structure definition
- struct type_list2
- {
- BYTE FID_string; // String identifier
- BYTE name_len; // Length of name which follows
- };
-
- // Type list, subrecord to the above, contains offset of variable in the structure
- struct type_list2_1
- {
- BYTE FID_span; // Defines what type of variable follows
- union {
- BYTE b_len;
- USHORT s_len;
- ULONG l_len;
- } u;
- };
-
- // Type pointer
- struct type_pointerrec
- {
- BYTE FID_index; // Index identifier
- USHORT type_index; // Type index
- BYTE FID_string; // String identifier
- BYTE name_len; // Length of name which follows
- };
-
- /********************************************************************
- *
- * Prototypes
- *
- ********************************************************************/
-
- BOOL dbgPrintStackFrame(FILE *LogFile,
- PSZ pszModuleName, // in: module name (fully q'fied)
- ULONG ulObject,
- ULONG ulOffset);
-
- VOID dbgPrintStack(FILE *file,
- PUSHORT StackBottom,
- PUSHORT StackTop,
- PUSHORT Ebp,
- PUSHORT ExceptionAddress);
-
- APIRET APIENTRY DosQueryModFromEIP(HMODULE *phMod, // out: trapping module
- ULONG *pulObjNum, // out: object/segment number
- ULONG ulBuffLen, // in: sizeof(*pszBuff)
- CHAR *pszBuff, // out: module name
- ULONG *pulOffset, // out: offset in module
- ULONG ulAddress); // in: address to be analyzed
-
- APIRET APIENTRY DOSQUERYMODFROMEIP(HMODULE * phMod,
- ULONG * pObjNum,
- ULONG BuffLen,
- PCHAR pBuff,
- ULONG * pOffset,
- PVOID Address);
-
- typedef ULONG *_Seg16 PULONG16;
- APIRET16 APIENTRY16 DOS16SIZESEG(USHORT Seg, PULONG16 Size);
- typedef APIRET16(APIENTRY16 _PFN16) (VOID);
- ULONG APIENTRY DosSelToFlat(ULONG);
-
- APIRET16 APIENTRY16 DOSQPROCSTATUS(ULONG * _Seg16 pBuf, USHORT cbBuf);
-
- #define CONVERT(fp,QSsel) MAKEP((QSsel),OFFSETOF(fp))
-
- #pragma pack() // added V0.9.0
-
-
- /********************************************************************
- *
- * Executable definitions
- *
- ********************************************************************/
-
- #define EXE386 1
-
- #ifndef __NEWEXE__
- #define __NEWEXE__
-
- #pragma pack(1)
-
- /*_________________________________________________________________*
- | |
- | |
- | DOS3 .EXE FILE HEADER DEFINITION |
- | |
- |_________________________________________________________________|
- * */
-
-
- #define EMAGIC 0x5A4D // Old magic number
- #define ENEWEXE sizeof(struct exe_hdr)
- // Value of E_LFARLC for new .EXEs
- #define ENEWHDR 0x003C // Offset in old hdr. of ptr. to new
- #define ERESWDS 0x0010 // No. of reserved words (OLD)
- #define ERES1WDS 0x0004 // No. of reserved words in e_res
- #define ERES2WDS 0x000A // No. of reserved words in e_res2
- #define ECP 0x0004 // Offset in struct of E_CP
- #define ECBLP 0x0002 // Offset in struct of E_CBLP
- #define EMINALLOC 0x000A // Offset in struct of E_MINALLOC
-
- /*
- *@@ exe_hdr:
- * DOS 1, 2, 3 .EXE header.
- */
-
- struct exe_hdr
- {
- unsigned short e_magic; // Magic number
- unsigned short e_cblp; // Bytes on last page of file
- unsigned short e_cp; // Pages in file
- unsigned short e_crlc; // Relocations
- unsigned short e_cparhdr; // Size of header in paragraphs
- unsigned short e_minalloc; // Minimum extra paragraphs needed
- unsigned short e_maxalloc; // Maximum extra paragraphs needed
- unsigned short e_ss; // Initial (relative) SS value
- unsigned short e_sp; // Initial SP value
- unsigned short e_csum; // Checksum
- unsigned short e_ip; // Initial IP value
- unsigned short e_cs; // Initial (relative) CS value
- unsigned short e_lfarlc; // File address of relocation table
- unsigned short e_ovno; // Overlay number
- unsigned short e_res[ERES1WDS];// Reserved words
- unsigned short e_oemid; // OEM identifier (for e_oeminfo)
- unsigned short e_oeminfo; // OEM information; e_oemid specific
- unsigned short e_res2[ERES2WDS];// Reserved words
- long e_lfanew; // File address of new exe header
- };
-
- #define E_MAGIC(x) (x).e_magic
- #define E_CBLP(x) (x).e_cblp
- #define E_CP(x) (x).e_cp
- #define E_CRLC(x) (x).e_crlc
- #define E_CPARHDR(x) (x).e_cparhdr
- #define E_MINALLOC(x) (x).e_minalloc
- #define E_MAXALLOC(x) (x).e_maxalloc
- #define E_SS(x) (x).e_ss
- #define E_SP(x) (x).e_sp
- #define E_CSUM(x) (x).e_csum
- #define E_IP(x) (x).e_ip
- #define E_CS(x) (x).e_cs
- #define E_LFARLC(x) (x).e_lfarlc
- #define E_OVNO(x) (x).e_ovno
- #define E_RES(x) (x).e_res
- #define E_OEMID(x) (x).e_oemid
- #define E_OEMINFO(x) (x).e_oeminfo
- #define E_RES2(x) (x).e_res2
- #define E_LFANEW(x) (x).e_lfanew
-
-
- /*_________________________________________________________________*
- | |
- | |
- | OS/2 & WINDOWS .EXE FILE HEADER DEFINITION - 286 version |
- | |
- |_________________________________________________________________|
- * */
-
- #define NEMAGIC 0x454E // New magic number
- #define NERESBYTES 8 // Eight bytes reserved (now)
- #define NECRC 8 // Offset into new header of NE_CRC
-
- /*
- *@@ new_exe:
- * New Executable (NE) header.
- * Follows DOS header in the executable file.
- */
-
- struct new_exe
- {
- unsigned short ne_magic; // Magic number NE_MAGIC
- unsigned char ne_ver; // Version number
- unsigned char ne_rev; // Revision number
- unsigned short ne_enttab; // Offset of Entry Table
- unsigned short ne_cbenttab; // Number of bytes in Entry Table
- long ne_crc; // Checksum of whole file
- unsigned short ne_flags; // Flag word
- unsigned short ne_autodata; // Automatic data segment number
- unsigned short ne_heap; // Initial heap allocation
- unsigned short ne_stack; // Initial stack allocation
- long ne_csip; // Initial CS:IP setting
- long ne_sssp; // Initial SS:SP setting
- unsigned short ne_cseg; // Count of file segments
- unsigned short ne_cmod; // Entries in Module Reference Table
- unsigned short ne_cbnrestab; // Size of non-resident name table
- unsigned short ne_segtab; // Offset of Segment Table
- unsigned short ne_rsrctab; // Offset of Resource Table
- unsigned short ne_restab; // Offset of resident name table
- unsigned short ne_modtab; // Offset of Module Reference Table
- unsigned short ne_imptab; // Offset of Imported Names Table
- long ne_nrestab; // Offset of Non-resident Names Table
- unsigned short ne_cmovent; // Count of movable entries
- unsigned short ne_align; // Segment alignment shift count
- unsigned short ne_cres; // Count of resource entries
- unsigned char ne_exetyp; // Target operating system
- unsigned char ne_flagsothers; // Other .EXE flags
- char ne_res[NERESBYTES]; // Pad structure to 64 bytes
- };
-
- #pragma pack()
-
- #define NE_MAGIC(x) (x).ne_magic
- #define NE_VER(x) (x).ne_ver
- #define NE_REV(x) (x).ne_rev
- #define NE_ENTTAB(x) (x).ne_enttab
- #define NE_CBENTTAB(x) (x).ne_cbenttab
- #define NE_CRC(x) (x).ne_crc
- #define NE_FLAGS(x) (x).ne_flags
- #define NE_AUTODATA(x) (x).ne_autodata
- #define NE_HEAP(x) (x).ne_heap
- #define NE_STACK(x) (x).ne_stack
- #define NE_CSIP(x) (x).ne_csip
- #define NE_SSSP(x) (x).ne_sssp
- #define NE_CSEG(x) (x).ne_cseg
- #define NE_CMOD(x) (x).ne_cmod
- #define NE_CBNRESTAB(x) (x).ne_cbnrestab
- #define NE_SEGTAB(x) (x).ne_segtab
- #define NE_RSRCTAB(x) (x).ne_rsrctab
- #define NE_RESTAB(x) (x).ne_restab
- #define NE_MODTAB(x) (x).ne_modtab
- #define NE_IMPTAB(x) (x).ne_imptab
- #define NE_NRESTAB(x) (x).ne_nrestab
- #define NE_CMOVENT(x) (x).ne_cmovent
- #define NE_ALIGN(x) (x).ne_align
- #define NE_CRES(x) (x).ne_cres
- #define NE_RES(x) (x).ne_res
- #define NE_EXETYP(x) (x).ne_exetyp
- #define NE_FLAGSOTHERS(x) (x).ne_flagsothers
-
- #define NE_USAGE(x) (WORD)*((WORD *)(x)+1)
- #define NE_PNEXTEXE(x) (WORD)(x).ne_cbenttab
- #define NE_ONEWEXE(x) (WORD)(x).ne_crc
- #define NE_PFILEINFO(x) (WORD)((DWORD)(x).ne_crc >> 16)
-
-
- /*
- * Target operating systems
- */
-
- #define NE_UNKNOWN 0x0 /* Unknown (any "new-format" OS) */
- #define NE_OS2 0x1 /* OS/2 (default) */
- #define NE_WINDOWS 0x2 /* Windows */
- #define NE_DOS4 0x3 /* DOS 4.x */
- #define NE_DEV386 0x4 /* Windows 386 */
-
-
- /*
- * Format of NE_FLAGS(x):
- *
- * p Not-a-process
- * x Unused
- * e Errors in image
- * x Unused
- * b Bound Family/API
- * ttt Application type
- * f Floating-point instructions
- * 3 386 instructions
- * 2 286 instructions
- * 0 8086 instructions
- * P Protected mode only
- * p Per-process library initialization
- * i Instance data
- * s Solo data
- */
- #define NENOTP 0x8000 /* Not a process */
- #define NEIERR 0x2000 /* Errors in image */
- #define NEBOUND 0x0800 /* Bound Family/API */
- #define NEAPPTYP 0x0700 /* Application type mask */
- #define NENOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
- #define NEWINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
- #define NEWINAPI 0x0300 /* Uses P.M. Windowing API */
- #define NEFLTP 0x0080 /* Floating-point instructions */
- #define NEI386 0x0040 /* 386 instructions */
- #define NEI286 0x0020 /* 286 instructions */
- #define NEI086 0x0010 /* 8086 instructions */
- #define NEPROT 0x0008 /* Runs in protected mode only */
- #define NEPPLI 0x0004 /* Per-Process Library Initialization */
- #define NEINST 0x0002 /* Instance data */
- #define NESOLO 0x0001 /* Solo data */
-
- /*
- * Format of NE_FLAGSOTHERS(x):
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | | |
- * | | | +---------------- Support for long file names
- * | | +------------------ Windows 2.x app runs in prot mode
- * | +-------------------- Windows 2.x app gets prop. font
- * +------------------------------ WLO appl on OS/2 (markwlo.exe)
- *
- */
-
- #define NELONGNAMES 0x01
- #define NEWINISPROT 0x02
- #define NEWINGETPROPFON 0x04
- #define NEWLOAPPL 0x80
-
-
-
- struct new_seg /* New .EXE segment table entry */
- {
- unsigned short ns_sector; /* File sector of start of segment */
- unsigned short ns_cbseg; /* Number of bytes in file */
- unsigned short ns_flags; /* Attribute flags */
- unsigned short ns_minalloc; /* Minimum allocation in bytes */
- };
-
- #define NS_SECTOR(x) (x).ns_sector
- #define NS_CBSEG(x) (x).ns_cbseg
- #define NS_FLAGS(x) (x).ns_flags
- #define NS_MINALLOC(x) (x).ns_minalloc
-
-
- /*
- * Format of NS_FLAGS(x)
- *
- * Flag word has the following format:
- *
- * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
- * | | | | | | | | | | | | | | |
- * | | | | | | | | | | | | +-+-+--- Segment type DATA/CODE
- * | | | | | | | | | | | +--------- Iterated segment
- * | | | | | | | | | | +----------- Movable segment
- * | | | | | | | | | +------------- Segment can be shared
- * | | | | | | | | +--------------- Preload segment
- * | | | | | | | +----------------- Execute/read-only for code/data segment
- * | | | | | | +------------------- Segment has relocations
- * | | | | | +--------------------- Code conforming/Data is expand down
- * | | | +--+----------------------- I/O privilege level
- * | | +----------------------------- Discardable segment
- * | +-------------------------------- 32-bit code segment
- * +----------------------------------- Huge segment/GDT allocation requested
- *
- */
-
- #define NSTYPE 0x0007 /* Segment type mask */
-
- #ifdef EXE386
- #define NSCODE 0x0000 /* Code segment */
- #define NSDATA 0x0001 /* Data segment */
- #define NSITER 0x0008 /* Iterated segment flag */
- #define NSMOVE 0x0010 /* Movable segment flag */
- #define NSSHARED 0x0020 /* Shared segment flag */
- #define NSPRELOAD 0x0040 /* Preload segment flag */
- #define NSEXRD 0x0080 /* Execute-only (code segment), or
- * read-only (data segment)
- */
- #define NSRELOC 0x0100 /* Segment has relocations */
- #define NSCONFORM 0x0200 /* Conforming segment */
- #define NSEXPDOWN 0x0200 /* Data segment is expand down */
- #define NSDPL 0x0C00 /* I/O privilege level (286 DPL bits) */
- #define SHIFTDPL 10 /* Left shift count for SEGDPL field */
- #define NSDISCARD 0x1000 /* Segment is discardable */
- #define NS32BIT 0x2000 /* 32-bit code segment */
- #define NSHUGE 0x4000 /* Huge memory segment, length of
- * segment and minimum allocation
- * size are in segment sector units
- */
- #define NSGDT 0x8000 /* GDT allocation requested */
-
- #define NSPURE NSSHARED /* For compatibility */
-
- #define NSALIGN 9 /* Segment data aligned on 512 byte boundaries */
-
- #define NSLOADED 0x0004 /* ns_sector field contains memory addr */
- #endif
-
-
- struct new_segdata /* Segment data */
- {
- union
- {
- struct
- {
- unsigned short ns_niter; /* number of iterations */
- unsigned short ns_nbytes; /* number of bytes */
- char ns_iterdata; /* iterated data bytes */
- } ns_iter;
- struct
- {
- char ns_data; /* data bytes */
- } ns_noniter;
- } ns_union;
- };
-
- struct new_rlcinfo /* Relocation info */
- {
- unsigned short nr_nreloc; /* number of relocation items that */
- }; /* follow */
-
- #pragma pack(1)
-
-
- struct new_rlc /* Relocation item */
- {
- char nr_stype; /* Source type */
- char nr_flags; /* Flag byte */
- unsigned short nr_soff; /* Source offset */
- union
- {
- struct
- {
- char nr_segno; /* Target segment number */
- char nr_res; /* Reserved */
- unsigned short nr_entry; /* Target Entry Table offset */
- } nr_intref; /* Internal reference */
- struct
- {
- unsigned short nr_mod; /* Index into Module Reference Table */
- unsigned short nr_proc; /* Procedure ordinal or name offset */
- } nr_import; /* Import */
- struct
- {
- unsigned short nr_ostype; /* OSFIXUP type */
- unsigned short nr_osres; /* reserved */
- } nr_osfix; /* Operating system fixup */
- } nr_union; /* Union */
- };
-
- #pragma pack()
-
-
- #define NR_STYPE(x) (x).nr_stype
- #define NR_FLAGS(x) (x).nr_flags
- #define NR_SOFF(x) (x).nr_soff
- #define NR_SEGNO(x) (x).nr_union.nr_intref.nr_segno
- #define NR_RES(x) (x).nr_union.nr_intref.nr_res
- #define NR_ENTRY(x) (x).nr_union.nr_intref.nr_entry
- #define NR_MOD(x) (x).nr_union.nr_import.nr_mod
- #define NR_PROC(x) (x).nr_union.nr_import.nr_proc
- #define NR_OSTYPE(x) (x).nr_union.nr_osfix.nr_ostype
- #define NR_OSRES(x) (x).nr_union.nr_osfix.nr_osres
-
-
-
- /*
- * Format of NR_STYPE(x) and R32_STYPE(x):
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | | |
- * +-+-+-+--- source type
- *
- */
-
- #define NRSTYP 0x0f /* Source type mask */
- #define NRSBYT 0x00 /* lo byte (8-bits)*/
- #define NRSSEG 0x02 /* 16-bit segment (16-bits) */
- #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
- #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
- #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
- #define NROFF32 0x07 /* 32-bit offset (32-bits) */
- #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
-
-
- /*
- * Format of NR_FLAGS(x) and R32_FLAGS(x):
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | |
- * | +-+--- Reference type
- * +------- Additive fixup
- */
-
- #define NRADD 0x04 /* Additive fixup */
- #define NRRTYP 0x03 /* Reference type mask */
- #define NRRINT 0x00 /* Internal reference */
- #define NRRORD 0x01 /* Import by ordinal */
- #define NRRNAM 0x02 /* Import by name */
- #define NRROSF 0x03 /* Operating system fixup */
-
-
- #if (EXE386 == 0)
-
- /* Resource type or name string */
- struct rsrc_string
- {
- char rs_len; /* number of bytes in string */
- char rs_string[ 1 ]; /* text of string */
- };
-
- #define RS_LEN( x ) (x).rs_len
- #define RS_STRING( x ) (x).rs_string
-
- /* Resource type information block */
- struct rsrc_typeinfo
- {
- unsigned short rt_id;
- unsigned short rt_nres;
- long rt_proc;
- };
-
- #define RT_ID( x ) (x).rt_id
- #define RT_NRES( x ) (x).rt_nres
- #define RT_PROC( x ) (x).rt_proc
-
- /* Resource name information block */
- struct rsrc_nameinfo
- {
- /* The following two fields must be shifted left by the value of */
- /* the rs_align field to compute their actual value. This allows */
- /* resources to be larger than 64k, but they do not need to be */
- /* aligned on 512 byte boundaries, the way segments are */
- unsigned short rn_offset; /* file offset to resource data */
- unsigned short rn_length; /* length of resource data */
- unsigned short rn_flags; /* resource flags */
- unsigned short rn_id; /* resource name id */
- unsigned short rn_handle; /* If loaded, then global handle */
- unsigned short rn_usage; /* Initially zero. Number of times */
- /* the handle for this resource has */
- /* been given out */
- };
-
- #define RN_OFFSET( x ) (x).rn_offset
- #define RN_LENGTH( x ) (x).rn_length
- #define RN_FLAGS( x ) (x).rn_flags
- #define RN_ID( x ) (x).rn_id
- #define RN_HANDLE( x ) (x).rn_handle
- #define RN_USAGE( x ) (x).rn_usage
-
- #define RSORDID 0x8000 /* if high bit of ID set then integer id */
- /* otherwise ID is offset of string from
- the beginning of the resource table */
-
- /* Ideally these are the same as the */
- /* corresponding segment flags */
- #define RNMOVE 0x0010 /* Moveable resource */
- #define RNPURE 0x0020 /* Pure (read-only) resource */
- #define RNPRELOAD 0x0040 /* Preloaded resource */
- #define RNDISCARD 0xF000 /* Discard priority level for resource */
-
- /* Resource table */
- struct new_rsrc
- {
- unsigned short rs_align; /* alignment shift count for resources */
- struct rsrc_typeinfo rs_typeinfo;
- };
-
- #define RS_ALIGN( x ) (x).rs_align
-
-
- #endif /* NOT EXE386 */
-
- #endif /* __NEWEXE__ */
-
- #ifndef DWORD
- #define DWORD long int
- #endif
-
- #ifndef WORD
- #define WORD short int
- #endif
-
- #ifndef __EXE386__
- #define __EXE386__
-
- #pragma pack(1) /* Force byte alignment */
-
- /*_________________________________________________________________*
- | |
- | |
- | OS/2 .EXE FILE HEADER DEFINITION - 386 version 0:32 |
- | |
- |_________________________________________________________________|
- * */
-
- #define BITPERWORD 16
- #define BITPERBYTE 8
- #define OBJPAGELEN 4096
- #define E32MAGIC1 'L' /* New magic number "LX" */
- #define E32MAGIC2 'X' /* New magic number "LX" */
- #define E32MAGIC 0x584c /* New magic number "LX" */
- #define E32RESBYTES1 0 /* First bytes reserved */
- #define E32RESBYTES2 0 /* Second bytes reserved */
- #define E32RESBYTES3 20 /* Third bytes reserved */
- #define E32LEBO 0x00 /* Little Endian Byte Order */
- #define E32BEBO 0x01 /* Big Endian Byte Order */
- #define E32LEWO 0x00 /* Little Endian Word Order */
- #define E32BEWO 0x01 /* Big Endian Word Order */
- #define E32LEVEL 0L /* 32-bit EXE format level */
- #define E32CPU286 0x001 /* Intel 80286 or upwardly compatibile */
- #define E32CPU386 0x002 /* Intel 80386 or upwardly compatibile */
- #define E32CPU486 0x003 /* Intel 80486 or upwardly compatibile */
-
-
-
- struct e32_exe /* New 32-bit .EXE header */
- {
- unsigned char e32_magic[2]; /* Magic number E32_MAGIC */
- unsigned char e32_border; /* The byte ordering for the .EXE */
- unsigned char e32_worder; /* The word ordering for the .EXE */
- unsigned long e32_level; /* The EXE format level for now = 0 */
- unsigned short e32_cpu; /* The CPU type */
- unsigned short e32_os; /* The OS type */
- unsigned long e32_ver; /* Module version */
- unsigned long e32_mflags; /* Module flags */
- unsigned long e32_mpages; /* Module # pages */
- unsigned long e32_startobj; /* Object # for instruction pointer */
- unsigned long e32_eip; /* Extended instruction pointer */
- unsigned long e32_stackobj; /* Object # for stack pointer */
- unsigned long e32_esp; /* Extended stack pointer */
- unsigned long e32_pagesize; /* .EXE page size */
- unsigned long e32_pageshift; /* Page alignment shift in .EXE */
- unsigned long e32_fixupsize; /* Fixup section size */
- unsigned long e32_fixupsum; /* Fixup section checksum */
- unsigned long e32_ldrsize; /* Loader section size */
- unsigned long e32_ldrsum; /* Loader section checksum */
- unsigned long e32_objtab; /* Object table offset */
- unsigned long e32_objcnt; /* Number of objects in module */
- unsigned long e32_objmap; /* Object page map offset */
- unsigned long e32_itermap; /* Object iterated data map offset */
- unsigned long e32_rsrctab; /* Offset of Resource Table */
- unsigned long e32_rsrccnt; /* Number of resource entries */
- unsigned long e32_restab; /* Offset of resident name table */
- unsigned long e32_enttab; /* Offset of Entry Table */
- unsigned long e32_dirtab; /* Offset of Module Directive Table */
- unsigned long e32_dircnt; /* Number of module directives */
- unsigned long e32_fpagetab; /* Offset of Fixup Page Table */
- unsigned long e32_frectab; /* Offset of Fixup Record Table */
- unsigned long e32_impmod; /* Offset of Import Module Name Table */
- unsigned long e32_impmodcnt; /* Number of entries in Import Module Name Table */
- unsigned long e32_impproc; /* Offset of Import Procedure Name Table */
- unsigned long e32_pagesum; /* Offset of Per-Page Checksum Table */
- unsigned long e32_datapage; /* Offset of Enumerated Data Pages */
- unsigned long e32_preload; /* Number of preload pages */
- unsigned long e32_nrestab; /* Offset of Non-resident Names Table */
- unsigned long e32_cbnrestab; /* Size of Non-resident Name Table */
- unsigned long e32_nressum; /* Non-resident Name Table Checksum */
- unsigned long e32_autodata; /* Object # for automatic data object */
- unsigned long e32_debuginfo; /* Offset of the debugging information */
- unsigned long e32_debuglen; /* The length of the debugging info. in bytes */
- unsigned long e32_instpreload;/* Number of instance pages in preload section of .EXE file */
- unsigned long e32_instdemand; /* Number of instance pages in demand load section of .EXE file */
- unsigned long e32_heapsize; /* Size of heap - for 16-bit apps */
- unsigned long e32_stacksize; /* Size of stack */
- unsigned char e32_res3[E32RESBYTES3];
- /* Pad structure to 196 bytes */
- };
-
-
-
- #define E32_MAGIC1(x) (x).e32_magic[0]
- #define E32_MAGIC2(x) (x).e32_magic[1]
- #define E32_BORDER(x) (x).e32_border
- #define E32_WORDER(x) (x).e32_worder
- #define E32_LEVEL(x) (x).e32_level
- #define E32_CPU(x) (x).e32_cpu
- #define E32_OS(x) (x).e32_os
- #define E32_VER(x) (x).e32_ver
- #define E32_MFLAGS(x) (x).e32_mflags
- #define E32_MPAGES(x) (x).e32_mpages
- #define E32_STARTOBJ(x) (x).e32_startobj
- #define E32_EIP(x) (x).e32_eip
- #define E32_STACKOBJ(x) (x).e32_stackobj
- #define E32_ESP(x) (x).e32_esp
- #define E32_PAGESIZE(x) (x).e32_pagesize
- #define E32_PAGESHIFT(x) (x).e32_pageshift
- #define E32_FIXUPSIZE(x) (x).e32_fixupsize
- #define E32_FIXUPSUM(x) (x).e32_fixupsum
- #define E32_LDRSIZE(x) (x).e32_ldrsize
- #define E32_LDRSUM(x) (x).e32_ldrsum
- #define E32_OBJTAB(x) (x).e32_objtab
- #define E32_OBJCNT(x) (x).e32_objcnt
- #define E32_OBJMAP(x) (x).e32_objmap
- #define E32_ITERMAP(x) (x).e32_itermap
- #define E32_RSRCTAB(x) (x).e32_rsrctab
- #define E32_RSRCCNT(x) (x).e32_rsrccnt
- #define E32_RESTAB(x) (x).e32_restab
- #define E32_ENTTAB(x) (x).e32_enttab
- #define E32_DIRTAB(x) (x).e32_dirtab
- #define E32_DIRCNT(x) (x).e32_dircnt
- #define E32_FPAGETAB(x) (x).e32_fpagetab
- #define E32_FRECTAB(x) (x).e32_frectab
- #define E32_IMPMOD(x) (x).e32_impmod
- #define E32_IMPMODCNT(x) (x).e32_impmodcnt
- #define E32_IMPPROC(x) (x).e32_impproc
- #define E32_PAGESUM(x) (x).e32_pagesum
- #define E32_DATAPAGE(x) (x).e32_datapage
- #define E32_PRELOAD(x) (x).e32_preload
- #define E32_NRESTAB(x) (x).e32_nrestab
- #define E32_CBNRESTAB(x) (x).e32_cbnrestab
- #define E32_NRESSUM(x) (x).e32_nressum
- #define E32_AUTODATA(x) (x).e32_autodata
- #define E32_DEBUGINFO(x) (x).e32_debuginfo
- #define E32_DEBUGLEN(x) (x).e32_debuglen
- #define E32_INSTPRELOAD(x) (x).e32_instpreload
- #define E32_INSTDEMAND(x) (x).e32_instdemand
- #define E32_HEAPSIZE(x) (x).e32_heapsize
- #define E32_STACKSIZE(x) (x).e32_stacksize
-
-
-
- /*
- * Format of E32_MFLAGS(x):
- *
- * Low word has the following format:
- *
- * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
- * | | | | | | | |
- * | | | | | | | +------- Per-Process Library Initialization
- * | | | | | | +--------- SystemDLL (internal fixups discarded)
- * | | | | | +----------- No Internal Fixups for Module in .EXE
- * | | | | +------------- No External Fixups for Module in .EXE
- * | | | +------------------- Incompatible with PM Windowing
- * | | +--------------------- Compatible with PM Windowing
- * | | Uses PM Windowing API
- * | +-------------------------------- Module not Loadable
- * +-------------------------------------- Library Module
- */
-
-
- #define E32NOTP 0x8000L /* Library Module - used as NENOTP */
- #define E32NOLOAD 0x2000L /* Module not Loadable */
- #define E32PMAPI 0x0300L /* Uses PM Windowing API */
- #define E32PMW 0x0200L /* Compatible with PM Windowing */
- #define E32NOPMW 0x0100L /* Incompatible with PM Windowing */
- #define E32NOEXTFIX 0x0020L /* NO External Fixups in .EXE */
- #define E32NOINTFIX 0x0010L /* NO Internal Fixups in .EXE */
- #define E32SYSDLL 0x0008L /* System DLL, Internal Fixups discarded*/
- #define E32LIBINIT 0x0004L /* Per-Process Library Initialization */
- #define E32LIBTERM 0x40000000L /* Per-Process Library Termination */
- #define E32APPMASK 0x0300L /* Application Type Mask */
-
-
- /*
- * Format of E32_MFLAGS(x):
- *
- * High word has the following format:
- *
- * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
- * | |
- * | +--- Protected memory library module
- * +----- Device driver
- */
-
- #define E32PROTDLL 0x10000L /* Protected memory library module */
- #define E32DEVICE 0x20000L /* Device driver */
- #define E32MODEXE 0x00000L /* .EXE module */
- #define E32MODDLL 0x08000L /* .DLL module */
- #define E32MODPROTDLL 0x18000L /* Protected memory library module */
- #define E32MODPDEV 0x20000L /* Physical device driver */
- #define E32MODVDEV 0x28000L /* Virtual device driver */
- #define E32MODMASK 0x38000L /* Module type mask */
-
- /*
- * RELOCATION DEFINITIONS - RUN-TIME FIXUPS
- */
-
- typedef union _RELOC_OFS
- {
- unsigned short offset16;
- unsigned long offset32;
- } RELOC_OFS; /* 16-bit or 32-bit offset */
-
-
- /***ET+ r32_rlc - Relocation item */
-
- struct r32_rlc /* Relocation item */
- {
- unsigned char nr_stype; /* Source type - field shared with new_rlc */
- unsigned char nr_flags; /* Flag byte - field shared with new_rlc */
- short r32_soff; /* Source offset */
- unsigned short r32_objmod; /* Target object number or Module ordinal */
-
- union targetid
- {
- RELOC_OFS intref; /* Internal fixup */
-
- union extfixup
- {
- RELOC_OFS proc; /* Procedure name offset */
- unsigned long ord; /* Procedure odrinal */
- } extref; /* External fixup */
-
- struct addfixup
- {
- unsigned short entry; /* Entry ordinal */
- RELOC_OFS addval; /* Value added to the address */
- } addfix; /* Additive fixup */
- }
- r32_target; /* Target data */
- unsigned short r32_srccount; /* Number of chained fixup records */
- unsigned short r32_chain; /* Chain head */
- };
-
- /*
- * In 32-bit .EXE file run-time relocations are written as varying size
- * records, so we need many size definitions.
- */
-
- #define RINTSIZE16 8
- #define RINTSIZE32 10
- #define RORDSIZE 8
- #define RNAMSIZE16 8
- #define RNAMSIZE32 10
- #define RADDSIZE16 10
- #define RADDSIZE32 12
-
- #if FALSE
- /*
- * Access macros defined in NEWEXE.H !!!
- */
- #define NR_STYPE(x) (x).nr_stype
- #define NR_FLAGS(x) (x).nr_flags
- #endif
-
- #define R32_SOFF(x) (x).r32_soff
- #define R32_OBJNO(x) (x).r32_objmod
- #define R32_MODORD(x) (x).r32_objmod
- #define R32_OFFSET16(x) (x).r32_target.intref.offset16
- #define R32_OFFSET32(x) (x).r32_target.intref.offset32
- #define R32_PROCOFF16(x) (x).r32_target.extref.proc.offset16
- #define R32_PROCOFF32(x) (x).r32_target.extref.proc.offset32
- #define R32_PROCORD(x) (x).r32_target.extref.ord
- #define R32_ENTRY(x) (x).r32_target.addfix.entry
- #define R32_ADDVAL16(x) (x).r32_target.addfix.addval.offset16
- #define R32_ADDVAL32(x) (x).r32_target.addfix.addval.offset32
- #define R32_SRCCNT(x) (x).r32_srccount
- #define R32_CHAIN(x) (x).r32_chain
-
-
-
- /*
- * Format of NR_STYPE(x)
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | | | | |
- * | | +-+-+-+--- Source type
- * | +----------- Fixup to 16:16 alias
- * +------------- List of source offset follows fixup record
- */
-
- #if FALSE
-
- /* DEFINED in newexe.h !!! */
-
- #define NRSTYP 0x0f /* Source type mask */
- #define NRSBYT 0x00 /* lo byte (8-bits)*/
- #define NRSSEG 0x02 /* 16-bit segment (16-bits) */
- #define NRSPTR 0x03 /* 16:16 pointer (32-bits) */
- #define NRSOFF 0x05 /* 16-bit offset (16-bits) */
- #define NRPTR48 0x06 /* 16:32 pointer (48-bits) */
- #define NROFF32 0x07 /* 32-bit offset (32-bits) */
- #define NRSOFF32 0x08 /* 32-bit self-relative offset (32-bits) */
- #endif
-
-
- #define NRSRCMASK 0x0f /* Source type mask */
- #define NRALIAS 0x10 /* Fixup to alias */
- #define NRCHAIN 0x20 /* List of source offset follows */
- /* fixup record, source offset field */
- /* in fixup record contains number */
- /* of elements in list */
-
- /*
- * Format of NR_FLAGS(x) and R32_FLAGS(x):
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | | | | | |
- * | | | | | +-+--- Reference type
- * | | | | +------- Additive fixup
- * | | | +----------- 32-bit Target Offset Flag (1 - 32-bit; 0 - 16-bit)
- * | | +------------- 32-bit Additive Flag (1 - 32-bit; 0 - 16-bit)
- * | +--------------- 16-bit Object/Module ordinal (1 - 16-bit; 0 - 8-bit)
- * +----------------- 8-bit import ordinal (1 - 8-bit;
- * 0 - NR32BITOFF toggles
- * between 16 and 32 bit
- * ordinal)
- */
-
- #ifdef NEVER_INCLUDE_THE_FOLLWING
- /* DEFINED in newexe.h !!! */
- #define NRRTYP 0x03 /* Reference type mask */
- #define NRRINT 0x00 /* Internal reference */
- #define NRRORD 0x01 /* Import by ordinal */
- #define NRRNAM 0x02 /* Import by name */
- #define NRADD 0x04 /* Additive fixup */
- #endif
-
- #define NRRENT 0x03 /* Internal entry table fixup */
-
- #define NR32BITOFF 0x10 /* 32-bit Target Offset */
- #define NR32BITADD 0x20 /* 32-bit Additive fixup */
- #define NR16OBJMOD 0x40 /* 16-bit Object/Module ordinal */
- #define NR8BITORD 0x80 /* 8-bit import ordinal */
- /*end*/
-
- /*
- * Data structures for storing run-time fixups in linker virtual memory.
- *
- * Each object has a list of Object Page Directories which specify
- * fixups for given page. Each page has its own hash table which is
- * used to detect fixups to the same target.
- */
-
- #define PAGEPERDIR 62
- #define LG2DIR 7
-
-
- typedef struct _OBJPAGEDIR
- {
- DWORD next; /* Virtual pointer to next dir on list */
- WORD ht[PAGEPERDIR]; /* Pointers to individual hash tables */
- }
- OBJPAGEDIR;
-
- /*
- * OBJECT TABLE
- */
-
- /***ET+ o32_obj Object Table Entry */
-
- struct o32_obj /* Flat .EXE object table entry */
- {
- unsigned long o32_size; /* Object virtual size */
- unsigned long o32_base; /* Object base virtual address */
- unsigned long o32_flags; /* Attribute flags */
- unsigned long o32_pagemap; /* Object page map index */
- unsigned long o32_mapsize; /* Number of entries in object page map */
- unsigned long o32_reserved; /* Reserved */
- };
-
-
- #define O32_SIZE(x) (x).o32_size
- #define O32_BASE(x) (x).o32_base
- #define O32_FLAGS(x) (x).o32_flags
- #define O32_PAGEMAP(x) (x).o32_pagemap
- #define O32_MAPSIZE(x) (x).o32_mapsize
- #define O32_RESERVED(x) (x).o32_reserved
-
- /*
- * Format of O32_FLAGS(x)
- *
- * High word of dword flag field is not used for now.
- * Low word has the following format:
- *
- * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - bit no
- * | | | | | | | | | | | | | | |
- * | | | | | | | | | | | | | | +--- Readable Object
- * | | | | | | | | | | | | | +----- Writeable Object
- * | | | | | | | | | | | | +------- Executable Object
- * | | | | | | | | | | | +--------- Resource Object
- * | | | | | | | | | | +----------- Object is Discardable
- * | | | | | | | | | +------------- Object is Shared
- * | | | | | | | | +--------------- Object has preload pages
- * | | | | | | | +----------------- Object has invalid pages
- * | | | | | | +------------------- Object is permanent and swappable
- * | | | | | +--------------------- Object is permanent and resident
- * | | | | +----------------------- Object is permanent and long lockable
- * | | | +----------------------------- 16:16 alias required (80x86 specific)
- * | | +-------------------------------- Big/Default bit setting (80x86 specific)
- * | +----------------------------------- Object is conforming for code (80x86 specific)
- * +-------------------------------------- Object I/O privilege level (80x86 specific)
- *
- */
-
- #define OBJREAD 0x0001L /* Readable Object */
- #define OBJWRITE 0x0002L /* Writeable Object */
- #define OBJRSRC 0x0008L /* Resource Object */
- #define OBJINVALID 0x0080L /* Object has invalid pages */
- #define LNKNONPERM 0x0600L /* Object is nonpermanent - should be */
- #define OBJNONPERM 0x0000L /* zero in the .EXE but LINK386 uses 6 */
- #define OBJPERM 0x0100L /* Object is permanent and swappable */
- #define OBJRESIDENT 0x0200L /* Object is permanent and resident */
- #define OBJCONTIG 0x0300L /* Object is resident and contiguous */
- #define OBJDYNAMIC 0x0400L /* Object is permanent and long locable */
- #define OBJTYPEMASK 0x0700L /* Object type mask */
- #define OBJALIAS16 0x1000L /* 16:16 alias required (80x86 specific) */
- #define OBJBIGDEF 0x2000L /* Big/Default bit setting (80x86 specific) */
- #define OBJIOPL 0x8000L /* Object I/O privilege level (80x86 specific) */
- #if FOR_EXEHDR
- /*
- * Name these flags differently for EXEHDR.EXE - avoid conflicts with 286 version
- */
- #define OBJDISCARD 0x0010L /* Object is Discardable */
- #define OBJSHARED 0x0020L /* Object is Shared */
- #define OBJPRELOAD 0x0040L /* Object has preload pages */
- #define OBJEXEC 0x0004L /* Executable Object */
- #define OBJCONFORM 0x4000L /* Object is conforming for code (80x86 specific) */
- #else
- /*
- * Life will be easier, if we keep the same names for the following flags:
- */
- #ifndef NSDISCARD
- #define NSDISCARD 0x0010L /* Object is Discardable */
- #endif
- #ifndef NSMOVE
- #define NSMOVE NSDISCARD /* Moveable object is for sure Discardable */
- #endif
- #ifndef NSSHARED
- #define NSSHARED 0x0020L /* Object is Shared */
- #endif
- #ifndef NSPRELOAD
- #define NSPRELOAD 0x0040L /* Object has preload pages */
- #endif
- #ifndef NSEXRD
- #define NSEXRD 0x0004L /* Executable Object */
- #endif
- #ifndef NSCONFORM
- #define NSCONFORM 0x4000L /* Object is conforming for code (80x86 specific) */
- #endif
- #endif
- /*end*/
-
- /***ET+ o32_map - Object Page Map entry */
-
- struct o32_map /* Object Page Table entry */
- {
- unsigned long o32_pagedataoffset; /* file offset of page */
- unsigned short o32_pagesize; /* # bytes of page data */
- unsigned short o32_pageflags; /* Per-Page attributes */
- };
-
-
- #define GETPAGEIDX(x) ((x).o32_pagedataoffset)
-
- #define PUTPAGEIDX(x,i) ((x).o32_pagedataoffset = ((unsigned long)(i)))
-
- #define PUTPAGESIZ(x,i) ((x).o32_pagesize = ((unsigned int)(i)))
-
- #define GETPAGESIZ(x) ((x).o32_pagesize)
-
- #define PAGEFLAGS(x) (x).o32_pageflags
-
-
- #define VALID 0x0000 /* Valid Physical Page in .EXE */
- #define ITERDATA 0x0001 /* Iterated Data Page */
- #define INVALID 0x0002 /* Invalid Page */
- #define ZEROED 0x0003 /* Zero Filled Page */
- #define RANGE 0x0004 /* Range of pages */
- #define ITERDATA2 0x0005 /* Iterated Data Page Type II */
- /*end*/
-
- /*
- * RESOURCE TABLE
- */
-
- /***ET+ rsrc32 - Resource Table Entry */
-
- struct rsrc32 /* Resource Table Entry */
- {
- unsigned short type; /* Resource type */
- unsigned short name; /* Resource name */
- unsigned long cb; /* Resource size */
- unsigned short obj; /* Object number */
- unsigned long offset; /* Offset within object */
- };
- /*end*/
-
-
- /*
- * Iteration Record format for 'EXEPACK'ed pages.
- */
- struct LX_Iter
- {
- unsigned short LX_nIter; /* number of iterations */
- unsigned short LX_nBytes; /* number of bytes */
- unsigned char LX_Iterdata; /* iterated data byte(s) */
- };
-
-
- /*
- * ENTRY TABLE DEFINITIONS
- */
-
- /***ET+ b32_bundle - Entry Table */
-
- struct b32_bundle
- {
- unsigned char b32_cnt; /* Number of entries in this bundle */
- unsigned char b32_type; /* Bundle type */
- unsigned short b32_obj; /* Object number */
- }; /* Follows entry types */
-
- struct e32_entry
- {
- unsigned char e32_flags; /* Entry point flags */
- union entrykind
- {
- RELOC_OFS e32_offset; /* 16-bit/32-bit offset entry */
- struct callgate
- {
- unsigned short offset; /* Offset in segment */
- unsigned short callgate; /* Callgate selector */
- }
- e32_callgate; /* 286 (16-bit) call gate */
- struct fwd
- {
- unsigned short modord; /* Module ordinal number */
- unsigned long value; /* Proc name offset or ordinal */
- }
- e32_fwd; /* Forwarder */
- }
- e32_variant; /* Entry variant */
- };
-
-
-
- #define B32_CNT(x) (x).b32_cnt
- #define B32_TYPE(x) (x).b32_type
- #define B32_OBJ(x) (x).b32_obj
-
- #define E32_EFLAGS(x) (x).e32_flags
- #define E32_OFFSET16(x) (x).e32_variant.e32_offset.offset16
- #define E32_OFFSET32(x) (x).e32_variant.e32_offset.offset32
- #define E32_GATEOFF(x) (x).e32_variant.e32_callgate.offset
- #define E32_GATE(x) (x).e32_variant.e32_callgate.callgate
- #define E32_MODORD(x) (x).e32_variant.e32_fwd.modord
- #define E32_VALUE(x) (x).e32_variant.e32_fwd.value
-
- #define FIXENT16 3
- #define FIXENT32 5
- #define GATEENT16 5
- #define FWDENT 7
-
- /*
- * BUNDLE TYPES
- */
-
- #define EMPTY 0x00 /* Empty bundle */
- #define ENTRY16 0x01 /* 16-bit offset entry point */
- #define GATE16 0x02 /* 286 call gate (16-bit IOPL) */
- #define ENTRY32 0x03 /* 32-bit offset entry point */
- #define ENTRYFWD 0x04 /* Forwarder entry point */
- #define TYPEINFO 0x80 /* Typing information present flag */
-
-
- /*
- * Format for E32_EFLAGS(x)
- *
- * 7 6 5 4 3 2 1 0 - bit no
- * | | | | | | | |
- * | | | | | | | +--- exported entry
- * | | | | | | +----- uses shared data
- * +-+-+-+-+-+------- parameter word count
- */
-
- #define E32EXPORT 0x01 /* Exported entry */
- #define E32SHARED 0x02 /* Uses shared data */
- #define E32PARAMS 0xf8 /* Parameter word count mask */
-
- /*
- * Flags for forwarders only:
- */
-
- #define FWD_ORDINAL 0x01 /* Imported by ordinal */
-
-
- #pragma pack() /* Restore default alignment */
-
- /*end*/
-
- #endif /* __EXE386__ */
-
-#endif
diff --git a/sal/osl/os2/helpers/dosh.h b/sal/osl/os2/helpers/dosh.h
deleted file mode 100644
index d760085cce55..000000000000
--- a/sal/osl/os2/helpers/dosh.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/* This file Copyright (C) 1997-2006 Ulrich M�ller,
- * Dmitry A. Steklenev.
- * This file is part of the "XWorkplace helpers" source package.
- *
- * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
- *
- */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef DOSH_HEADER_INCLUDED
- #define DOSH_HEADER_INCLUDED
-
- CHAR doshQueryBootDrive(VOID);
-
-#endif
-
-#if __cplusplus
-}
-#endif
diff --git a/sal/osl/os2/helpers/except.h b/sal/osl/os2/helpers/except.h
deleted file mode 100644
index 1a7d380b96af..000000000000
--- a/sal/osl/os2/helpers/except.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/*
- *@@sourcefile except.h:
- * header file for except.c. See remarks there.
- *
- * Note: Version numbering in this file relates to XWorkplace version
- * numbering.
- *
- *@@include #define INCL_DOSEXCEPTIONS
- *@@include #define INCL_DOSPROCESS
- *@@include #include <os2.h>
- *@@include #include <stdio.h>
- *@@include #include <setjmp.h>
- *@@include #include "helpers\except.h"
- */
-
-/*
- * Copyright (C) 1999-2000 Ulrich M�ller.
- *
- * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
- *
- */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-#ifndef EXCEPT_HEADER_INCLUDED
- #define EXCEPT_HEADER_INCLUDED
-
- #if defined __IBMCPP__ || defined __IBMC__
- #ifndef INCL_DOSEXCEPTIONS
- #error except.h requires INCL_DOSEXCEPTIONS to be defined.
- #endif
- #ifndef INCL_DOSPROCESS
- #error except.h requires INCL_DOSPROCESS to be defined.
- #endif
-
- #ifndef __stdio_h
- #error except.h requires stdio.h to be included.
- #endif
- #ifndef __setjmp_h
- #error except.h requires setjmp.h to be included.
- #endif
- #endif
-
- /********************************************************************
- *
- * Declarations
- *
- ********************************************************************/
-
- // forward declaration
- typedef struct _EXCEPTIONREGISTRATIONRECORD2 *PEXCEPTIONREGISTRATIONRECORD2;
-
- // "OnKill" function prototype for EXCEPTIONREGISTRATIONRECORD2
- // added V0.9.0 (99-10-22) [umoeller]
- // removed V0.9.7 (2000-12-08) [umoeller]
- // typedef VOID APIENTRY FNEXCONKILL(PEXCEPTIONREGISTRATIONRECORD2);
- // typedef FNEXCONKILL *PFNEXCONKILL;
-
- /*
- *@@ EXCEPTIONREGISTRATIONRECORD2:
- * replacement EXCEPTIONREGISTRATIONRECORD
- * struct for thread exception handling.
- *
- *@@changed V0.9.0 (99-10-22) [umoeller]: pfnOnKill added
- *@@changed V0.9.0 (99-10-22) [umoeller]: renamed from REGREC2
- */
-
- typedef struct _EXCEPTIONREGISTRATIONRECORD2
- {
- PVOID pNext; // as in EXCEPTIONREGISTRATIONRECORD
- PFN pfnHandler; // as in EXCEPTIONREGISTRATIONRECORD
- jmp_buf jmpThread; // additional buffer for setjmp
- EXCEPTIONREPORTRECORD err; // exception handlers copy the report rec here
- PVOID pvUser; // user ptr
- } EXCEPTIONREGISTRATIONRECORD2;
-
- /*
- *@@ EXCEPTSTRUCT:
- * structure used with TRY_xxx macros.
- */
-
- typedef struct _EXCEPTSTRUCT
- {
- EXCEPTIONREGISTRATIONRECORD2 RegRec2;
- ULONG ulExcpt; // != NULL if exception caught
- APIRET arc; // rc of DosSetExceptionHandler
- } EXCEPTSTRUCT, *PEXCEPTSTRUCT;
-
- // function prototypes for exception hooks (V0.9.0)
-
- // "open traplog file" hook
- typedef FILE* APIENTRY FNEXCOPENFILE(VOID);
- typedef FNEXCOPENFILE *PFNEXCOPENFILE;
-
- // "exception" hook
- typedef VOID APIENTRY FNEXCHOOK(FILE*, PTIB, ULONG); // V0.9.16 (2001-12-02) [pr]
- typedef FNEXCHOOK *PFNEXCHOOK;
-
- // "error" hook
- typedef VOID APIENTRY FNEXCHOOKERROR(const char *pcszFile,
- ULONG ulLine,
- const char *pcszFunction,
- APIRET arc);
- typedef FNEXCHOOKERROR *PFNEXCHOOKERROR;
-
- /********************************************************************
- *
- * Prototypes
- *
- ********************************************************************/
-
- VOID excExplainException(FILE *file,
- PSZ pszHandlerName,
- PEXCEPTIONREPORTRECORD pReportRec,
- PCONTEXTRECORD pContextRec);
-
- VOID excRegisterHooks(PFNEXCOPENFILE pfnExcOpenFileNew,
- PFNEXCHOOK pfnExcHookNew,
- PFNEXCHOOKERROR pfnExcHookError,
- BOOL fBeepOnExceptionNew);
-
- ULONG _System excHandlerLoud(PEXCEPTIONREPORTRECORD pReportRec,
- PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
- PCONTEXTRECORD pContextRec,
- PVOID pv);
-
- ULONG _System excHandlerQuiet(PEXCEPTIONREPORTRECORD pReportRec,
- PEXCEPTIONREGISTRATIONRECORD2 pRegRec2,
- PCONTEXTRECORD pContextRec,
- PVOID pv);
-
- extern PFNEXCHOOKERROR G_pfnExcHookError;
-
- extern ULONG G_ulExplainExceptionRunning;
-
- /********************************************************************
- *
- * Macros
- *
- ********************************************************************/
-
- /* See except.c for explanations how to use these. */
-
- #ifdef __NO_EXCEPTION_HANDLERS__
- // exception handlers can completely be disabled
- #define TRY_LOUD(excptstruct)
- #else
- #ifdef __NO_LOUD_EXCEPTION_HANDLERS__
- #define TRY_LOUD(e) TRY_QUIET(e)
- #else // __NO_LOUD_EXCEPTION_HANDLERS__
- #define TRY_LOUD(excptstruct) \
- { \
- EXCEPTSTRUCT excptstruct = {0}; \
- excptstruct.RegRec2.pfnHandler = (PFN)excHandlerLoud; \
- excptstruct.arc = DosSetExceptionHandler( \
- (PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
- if (excptstruct.arc) \
- if (G_pfnExcHookError) \
- G_pfnExcHookError(__FILE__, __LINE__, __FUNCTION__, excptstruct.arc); \
- else \
- DosBeep(1000, 1000); \
- excptstruct.ulExcpt = setjmp(excptstruct.RegRec2.jmpThread); \
- if (excptstruct.ulExcpt == 0) \
- {
-
- #endif // __NO_LOUD_EXCEPTION_HANDLERS__
- #endif
-
- #ifdef __NO_EXCEPTION_HANDLERS__
- // exception handlers can completely be disabled
- #define TRY_QUIET(excptstruct)
- #else
- #define TRY_QUIET(excptstruct) \
- { \
- EXCEPTSTRUCT excptstruct = {0}; \
- excptstruct.RegRec2.pfnHandler = (PFN)excHandlerQuiet; \
- excptstruct.arc = DosSetExceptionHandler( \
- (PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
- if (excptstruct.arc) \
- if (G_pfnExcHookError) \
- G_pfnExcHookError(__FILE__, __LINE__, __FUNCTION__, excptstruct.arc); \
- else \
- DosBeep(1000, 1000); \
- excptstruct.ulExcpt = setjmp(excptstruct.RegRec2.jmpThread); \
- if (excptstruct.ulExcpt == 0) \
- {
-
- #endif
-
- #ifdef __NO_EXCEPTION_HANDLERS__
- // exception handlers can completely be disabled
- #define CATCH(excptstruct) if (FALSE) {
- #else
- #define CATCH(excptstruct) \
- DosUnsetExceptionHandler( \
- (PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2)); \
- } /* end of TRY block */ \
- else \
- { /* exception occured: */ \
- DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&(excptstruct.RegRec2));
- #endif
-
- #ifdef __NO_EXCEPTION_HANDLERS__
- // exception handlers can completely be disabled
- #define END_CATCH() }
- #else
- #define END_CATCH() \
- } /* end of exception-occured block */ \
- }
- #endif
-
- /*
- * CRASH:
- * this macro is helpful for testing
- * the exception handlers.
- * This is not for general use. ;-)
- */
-
- #define CRASH {PSZ p = NULL; *p = 'a'; }
-
-#endif // EXCEPT_HEADER_INCLUDED
-
-#if __cplusplus
-}
-#endif
-
diff --git a/sal/osl/os2/helpers/setup.h b/sal/osl/os2/helpers/setup.h
deleted file mode 100644
index c1c861abe667..000000000000
--- a/sal/osl/os2/helpers/setup.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-/*
- * setup.h:
- * sample master include file which gets included
- * from all helpers *.c sources.
- */
-
-#ifndef SETUP_HEADER_INCLUDED
- #define SETUP_HEADER_INCLUDED
-
- // XWPEXPORT defines the standard linkage for the
- // XWorkplace helpers.
- #ifdef __EMX__
- #define XWPENTRY
- #elif defined (__IBMCPP__) || defined (__IBMC__)
- #define XWPENTRY _Optlink
- #endif
-
- /*************************************************************
- * *
- * Additional stuff for EMX *
- * *
- *************************************************************/
-
- #ifdef __EMX__
- // EMX doesn't have all these 16-bit typedefs;
- // added (99-10-22) [umoeller]
- #define APIENTRY16 _Far16 _Pascal
- #define PASCAL16 _Far16 _Pascal
- #define CDECL16 _Far16 _Cdecl
-
- typedef unsigned short APIRET16;
- typedef unsigned long APIRET32;
-
-#if 0
-//YD do not use with gcc 3.3.5
- #define _System
- #define APIENTRY
- // with VAC++, this defines _System linkage, which
- // EMX doesn't have, or does it?!?
-#endif // 0
-
- #endif
-
- // the following is a VAC++-specific macro, which doesn't exist
- // with EMX, so we need to implement this... this was one of
- // the "undefined symbols" we got (99-10-23) [umoeller]
- // changed this to prefix underscore, because the STL apparently
- // redefines this V0.9.3 (2000-05-15) [umoeller]
- #define _min(a,b) ( ((a) > (b)) ? b : a )
- #define _max(a,b) ( ((a) > (b)) ? a : b )
-
- // Uncomment the following if you have trouble with the
- // exception handlers in helpers\except.c; WarpIN will
- // then install _no_ additional exception handlers at all
- // (include\helpers\except.h reacts to these defines).
- // I'm not sure if the handlers work well with EMX.
-
- #ifdef __EMX__00
- #define __NO_EXCEPTION_HANDLERS__
- #endif
-
- /*************************************************************
- * *
- * Additional stuff for VAC++ 3.0 *
- * *
- *************************************************************/
-
- // all this added V0.9.2 (2000-03-10) [umoeller]
- #if ( defined ( __IBMCPP__ ) && ( __IBMCPP__ < 400 ) )
- typedef int bool;
- #define true 1
- #define false 0
- #define _BooleanConst // needed for some VAC headers, which define bool also
- #endif
-
- #ifndef __stdlib_h // <stdlib.h>
- #include <stdlib.h>
- #endif
- #ifndef __string_h // <string.h>
- #include <string.h>
- #endif
-
- /*************************************************************
- * *
- * Debugging *
- * *
- *************************************************************/
-
- // All the following redone (99-10-23) [umoeller]:
- // __DEBUG__ is defined as a macro on the compiler
- // command line by the makefiles if DEBUG was enabled
- // in \setup.in
- #ifdef __DEBUG__
-
- // with debug code, disable the exception handlers
- #define __NO_EXCEPTION_HANDLERS__
-
- // If the following is commented out, no PMPRINTF will be
- // used at all. WarpIN uses Dennis Bareis' PMPRINTF
- // package to do this.
-
- // NOTE: We cannot use PmPrintf with EMX,
- // because pmprintf.lib imports the VAC++ runtimes.
- // That's the strange errors I was reporting yesterday.
- #ifndef __EMX__
- #ifdef OS2_INCLUDED
- #define _PMPRINTF_
- #include "helpers/pmprintf.h"
- #endif
- #endif
- #endif
-
- #ifndef _PMPRINTF_
- // not defined: define empty macro so we don't
- // get compiler errors
- #define _Pmpf(x)
- #endif
-
-#endif
-
diff --git a/sal/osl/os2/makefile.mk b/sal/osl/os2/makefile.mk
index b16a8fa00d1c..4b0e8ad80163 100644
--- a/sal/osl/os2/makefile.mk
+++ b/sal/osl/os2/makefile.mk
@@ -72,8 +72,6 @@ SLOFILES= $(SLO)$/conditn.obj \
$(SLO)$/file_url.obj \
$(SLO)$/file_error_transl.obj \
$(SLO)$/file_path_helper.obj \
- $(SLO)$/debug.obj \
- $(SLO)$/except.obj \
$(SLO)$/debug_printf.obj \
$(SLO)$/salinit.obj
@@ -101,8 +99,6 @@ OBJFILES= $(OBJ)$/conditn.obj \
$(OBJ)$/file_url.obj \
$(OBJ)$/file_error_transl.obj \
$(OBJ)$/file_path_helper.obj \
- $(OBJ)$/debug.obj \
- $(OBJ)$/except.obj \
$(OBJ)$/debug_printf.obj \
$(OBJ)$/salinit.obj
diff --git a/sal/osl/os2/process.c b/sal/osl/os2/process.c
index 7df540188f6d..185a6ca6a57f 100644
--- a/sal/osl/os2/process.c
+++ b/sal/osl/os2/process.c
@@ -44,7 +44,6 @@
// for exception logging
#include <stdio.h>
#include <setjmp.h>
-#include "helpers/except.h"
#define MAX_ARGS 255
diff --git a/sal/osl/os2/salinit.cxx b/sal/osl/os2/salinit.cxx
index af375848b0f3..0412f9336922 100644
--- a/sal/osl/os2/salinit.cxx
+++ b/sal/osl/os2/salinit.cxx
@@ -35,7 +35,6 @@
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
-#include "helpers/except.h"
extern "C" {
@@ -80,13 +79,15 @@ static FILE* APIENTRY _oslExceptOpenLogFile(VOID)
/*----------------------------------------------------------------------------*/
+#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
static EXCEPTSTRUCT g_excptstruct = {0};
+#endif
void SAL_CALL sal_detail_initialize(int argc, char ** argv)
{
APIRET rc = -1;
-#if OSL_DEBUG_LEVEL == 0
+#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
excRegisterHooks(_oslExceptOpenLogFile, NULL, NULL, FALSE);
g_excptstruct.RegRec2.pfnHandler = (PFN)excHandlerLoud;
@@ -108,7 +109,7 @@ void SAL_CALL sal_detail_deinitialize()
{
APIRET rc = -1;
-#if OSL_DEBUG_LEVEL == 0
+#if 0 // until exceptions restored OSL_DEBUG_LEVEL == 0
rc = DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD)&(g_excptstruct.RegRec2));
#endif
}