Changeset 1881 for trunk/src


Ignore:
Timestamp:
Apr 24, 2005, 1:06:47 AM (21 years ago)
Author:
bird
Message:

Display cs:eip and module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/signals.c

    • Property cvs2svn:cvs-rev changed from 1.24 to 1.25
    r1880 r1881  
    206206    __LIBC_PTHREAD  pThrd;
    207207} SIGSCHEDENUMPARAM, *PSIGSCHEDENUMPARAM;
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
    208220
    209221
     
    555567static int              signalDeliver(__LIBC_PTHREAD pThrd, int iSignalNo, void *pvXcptParams);
    556568static void             signalTerminate(int iSignalNo) __dead2;
    557 static void             signalTerminateAbnormal(int iSignalNo) __dead2;
    558 static int              signalTerminateHex(char *pszBuf, unsigned u);
     569static void             signalTerminateAbnormal(int iSignalNo, void *pvXcptParams) __dead2;
    559570static int              signalJobStop(int iSignalNo);
    560571static int              signalJobResume(void);
     
    10121023        LIBCLOG_MSG("we're toast!\n");
    10131024        DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb);
    1014         signalTerminateAbnormal(iSignalNo);
     1025        signalTerminateAbnormal(iSignalNo);
    10151026    }
    10161027
     
    17781789 * @param   iSignalNo           Deliver the first signal of this type no matter if it's
    17791790 *                              blocked or not. This is for use with hardware signals only!
    1780  * @param   pvXcptParams        sPointer to exception parameter list is any.
     1791 * @param   pvXcptParams        Pointer to exception parameter list is any.
    17811792 */
    17821793static int signalDeliver(__LIBC_PTHREAD pThrd, int iSignalNo, void *pvXcptParams)
     
    18831894                case SPA_CORE:
    18841895                case SPA_NEXT_CORE:
    1885                     signalTerminateAbnormal(iSignalNo);
     1896                    signalTerminateAbnormal(iSignalNo);
    18861897                    break;
    18871898
     
    20372048}
    20382049
     2050
    20392051/**
    20402052 * Cause immediate process termination because of the given signal.
     
    20502062     */
    20512063    __libc_spmTerm(__LIBC_EXIT_REASON_SIGNAL_BASE + iSignalNo, 127);
    2052     LIBCLOG_MSG("Calling DosExit(,127)\n");
     2064    LIBCLOG_MSG("Calling Dos)\n");
    20532065    for (;;)
    20542066    {
    20552067        DosKillProcess(DKP_PROCESS, 0);
    2056         DosExit(EXIT_THREAD, 127);
    2057     }
    2058 }
    2059 
    2060 /**
    2061  * Cause immediate process termination because of the given signal.
    2062  *
    2063  * @param   iSignalNo   Signal causing the termination.
    2064  */
    2065 static void signalTerminateAbnormal(int iSignalNo)
    2066 {
    2067     LIBCLOG_ENTER("iSignalNo=%d\n", iSignalNo);
    2068     /*
    2069      * Set the exit reason in SPM.
    2070      */
    2071     __libc_spmTerm(__LIBC_EXIT_REASON_SIGNAL_BASE + iSignalNo, 127);
    2072 
    2073     /*
    2074      * Before we go crazy here, let's release the semaphore.
    2075      *
    2076      * If possible we'll stay in the must complete section to
    2077      * be sure we get to the exit. If not we'll have to mess with
    2078      * exception handlers and such now.
    2079      */
    2080     //if (__libc_back_signalSemIsOwner())
    2081     //    DosReleaseMutexSem(ghmtxSignals);
    2082 
    2083     /*
    2084      * Terminate the exception handler chain to avoid recursive trouble.
    2085      */
    2086     FS_VAR();
    2087     FS_SAVE_LOAD();
    2088     PTIB pTib;
    2089     PPIB pPib;
    2090     DosGetInfoBlocks(&pTib, &pPib);
    2091     pTib->tib_pexchain = END_OF_CHAIN;
    2092 
    2093     /*
    2094      * Write message to stderr.
    2095      */
    2096     ULONG   cb;
    2097     if (iSignalNo == SIGABRT)
    2098     {
    2099         static const char szMsg[] = "\n\rAbnormal program termination";
    2100         DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb);
    2101     }
    2102     else
    2103     {
    2104         static const char szMsg[] = "\n\rProcess terminated by ";
    2105         DosWrite(HFILE_STDERR, szMsg, sizeof(szMsg) - 1, &cb);
    2106 
    2107         const char *psz = "unknown signal";
    2108         if (iSignalNo < sizeof(gaszSignalNames) / sizeof(gaszSignalNames[0]))
    2109             psz = gaszSignalNames[iSignalNo];
    2110         for (cb = 0; psz[cb];)
    2111             cb++;
    2112         DosWrite(HFILE_STDERR, psz, cb, &cb);
    2113     }
    2114 
    2115     /* pid */
    2116     static const char szMsgPid[] = " - pid=0x";
    2117     DosWrite(HFILE_STDERR, szMsgPid, sizeof(szMsgPid) - 1, &cb);
    2118     char szHexNum[12];
    2119     cb = signalTerminateHex(szHexNum, pPib->pib_ulpid);
    2120     DosWrite(HFILE_STDERR, szHexNum, cb, &cb);
    2121 
    2122     /* tid */
    2123     static const char szMsgTid[] = " - tid=0x";
    2124     DosWrite(HFILE_STDERR, szMsgTid, sizeof(szMsgTid) - 1, &cb);
    2125     cb = signalTerminateHex(szHexNum, pTib->tib_ptib2->tib2_ultid);
    2126     DosWrite(HFILE_STDERR, szHexNum, cb, &cb);
    2127 
    2128     /* executable name. */
    2129     static char szExeName[CCHMAXPATH];
    2130     if (!DosQueryModuleName(pPib->pib_hmte, sizeof(szExeName), &szExeName[0]))
    2131     {
    2132         static const char szHypen[] = " - ";
    2133         DosWrite(HFILE_STDERR, szHypen, sizeof(szHypen) - 1, &cb);
    2134 
    2135         for (cb = 0; szExeName[cb];)
    2136             cb++;
    2137         DosWrite(HFILE_STDERR, szExeName, cb, &cb);
    2138     }
    2139 
    2140     /* final newline */
    2141     static const char szNewLine[] = "\r\n";
    2142     DosWrite(HFILE_STDERR, szNewLine, sizeof(szNewLine) - 1, &cb);
    2143 
    2144     /*
    2145      * Terminate the process.
    2146      */
    2147     LIBCLOG_MSG("Calling DosExit(,127)\n");
    2148     for (;;)
    2149     {
    2150         DosKillProcess(DKP_PROCESS, 0);
    2151         DosExit(EXIT_THREAD, 127);
    2152     }
    2153 }
     2068        DosExit(EXIT_PROCESS, 127);
     2069    }
     2070}
     2071
     2072
     2073/**
     2074 * Calculates the length of a string.
     2075 * @returns String length in bytes.
     2076 * @param   psz     Pointer to the string.
     2077 */
     2078static size_t signalTerminateStrLen(const char *psz)
     2079{
     2080    const char *pszEnd = psz;
     2081    while (*pszEnd)
     2082        pszEnd++;
     2083    return pszEnd - psz;
     2084}
     2085
    21542086
    21552087/**
     
    21592091 * @param   pszBuf  Where to store the formatted number.
    21602092 * @param   u       Number to format.
    2161  */
    2162 static int signalTerminateHex(char *pszBuf, unsigned u)
     2093 * @param   cDigits Minimum number of digits in the output. Use 0 for whatever fits.
     2094 */
     2095static int signalTerminateHex(char *pszBuf, unsigned u, unsigned cDigits)
    21632096{
    21642097    static const char szHex[17] = "0123456789abcdef";
    2165     if (u <= 0xff)
     2098    if (u <= 0xf && cDigits <= 1)
     2099    {
     2100        pszBuf[0] = szHex[u & 0xf];
     2101        pszBuf[1] = '\0';
     2102        return 1;
     2103    }
     2104    if (u <= 0xff && cDigits <= 2)
    21662105    {
    21672106        pszBuf[0] = szHex[u >> 4];
     
    21702109        return 2;
    21712110    }
    2172     else if (u <= 0xffff)
     2111    else if (u <= 0xffff)
    21732112    {
    21742113        pszBuf[0] = szHex[u >> 12];
     
    21942133}
    21952134
     2135
     2136
     2137
     2138
     2139
     2140
     2141
     2142
     2143
     2144
     2145
     2146
     2147
     2148
     2149
     2150
     2151
     2152
     2153
     2154
     2155
     2156
     2157
     2158
     2159
     2160
     2161
     2162
     2163
     2164
     2165
     2166
     2167
     2168
     2169
     2170
     2171
     2172
     2173
     2174
     2175
     2176
     2177
     2178
     2179
     2180
     2181
     2182
     2183
     2184
     2185
     2186
     2187
     2188
     2189
     2190
     2191
     2192
     2193
     2194
     2195
     2196
     2197
     2198
     2199
     2200
     2201
     2202
     2203
     2204
     2205
     2206
     2207
     2208
     2209
     2210
     2211
     2212
     2213
     2214
     2215
     2216
     2217
     2218
     2219
     2220
     2221
     2222
     2223
     2224
     2225
     2226
     2227
     2228
     2229
     2230
     2231
     2232
     2233
     2234
     2235
     2236
     2237
     2238
     2239
     2240
     2241
     2242
     2243
     2244
     2245
     2246
     2247
     2248
     2249
     2250
     2251
     2252
     2253
     2254
    21962255/**
    21972256 * Stop the process (job control emulation).
     
    22222281    return __libc_back_signalSemRequest();
    22232282}
     2283
    22242284
    22252285/**
Note: See TracChangeset for help on using the changeset viewer.