Changeset 2727
- Timestamp:
- Jul 18, 2006, 1:26:14 AM (19 years ago)
- Location:
- trunk/libc
- Files:
-
- 1 added
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/Makefile.kmk
r2718 r2727 56 56 $(TARGET_libc_libsyslog) \ 57 57 $(TARGET_libc_libc_sys) 58 libc_SOURCES.win32 = $(TARGET_kNIX.nt) 58 59 59 60 ifdef CFG_LIBC_LOGSTRICT_LIBS … … 69 70 $(TARGET_libc_libsyslog_l) \ 70 71 $(TARGET_libc_libc_sys_l) 72 libc_SOURCES.win32 = $(TARGET_kNIX.nt_l) 71 73 endif 72 74 … … 83 85 $(TARGET_libc_libsyslog_p) 84 86 $(TARGET_libc_libc_p) 87 libc_SOURCES.win32 = $(TARGET_kNIX.nt_p) 85 88 endif 86 89 -
trunk/libc/include/klibc/nt/fib.h
r2726 r2727 132 132 } u1; /* 10 20 */ 133 133 void *ArbitraryUserPointer; /* 14 28 */ 134 struct _ NT_TIB*Self; /* 18 30 */134 struct __LIBC_TEB *Self; /* 18 30 */ 135 135 void *EnvironmentPointer; /* 1c 38 */ 136 136 struct … … 323 323 324 324 /** 325 * Gets the pointer to the thread information block. 326 */ 327 #define fibGetTEB() ((__LIBC_PTEB)__libc_fibGetTEB_PV(Self)) 328 329 /** 325 330 * Gets the pointer to the process information block. 326 331 */ … … 390 395 } 391 396 397 /** 398 * Checks if we're being debugged. 399 */ 400 #define fibIsBeingDebugged() (fibGetPEB()->BeingDebugged) 392 401 393 402 __END_DECLS -
trunk/libc/include/klibc/nt/nt.h
r2723 r2727 33 33 #undef PAGE_SHIFT 34 34 35 NTOSAPI 36 NTSTATUS NTAPI RtlQueryEnvironmentVariable_U( 37 IN PVOID Environment OPTIONAL, 38 IN PUNICODE_STRING VariableName, 39 OUT PUNICODE_STRING VariableValue); 40 35 41 #endif 36 42 -
trunk/libc/src/kNIX.nt/b_panic.c
r2722 r2727 4 4 * LIBC SYS Backend - panic. 5 5 * 6 * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net>7 * 8 * 9 * This file is part of InnoTekLIBC.10 * 11 * InnoTekLIBC is free software; you can redistribute it and/or modify6 * Copyright (c) 2005-2006 knut st. osmundsen <bird@anduin.net> 7 * 8 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 12 12 * it under the terms of the GNU General Public License as published by 13 13 * the Free Software Foundation; either version 2 of the License, or 14 14 * (at your option) any later version. 15 15 * 16 * InnoTekLIBC is distributed in the hope that it will be useful,16 * kLIBC is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 20 20 * 21 21 * You should have received a copy of the GNU General Public License 22 * along with InnoTekLIBC; if not, write to the Free Software22 * along with kLIBC; if not, write to the Free Software 23 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 24 * … … 31 31 *******************************************************************************/ 32 32 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_NOGROUP 33 #define INCL_BASE34 #define INCL_ERRORS35 #define INCL_FSMACROS36 #define INCL_DOSUNDOCUEMENTED37 33 #define _GNU_SOURCE 34 #include <klibc/nt/nt.h> 35 #include <klibc/fib.h> 38 36 #include <string.h> 39 37 #include <InnotekLIBC/backend.h> 40 38 #include <InnotekLIBC/sharedpm.h> 41 39 #include <InnotekLIBC/logstrict.h> 42 #include <os2emx.h>43 44 45 /*******************************************************************************46 * Defined Constants And Macros *47 *******************************************************************************/48 /** OS/2 default standard error handle. */49 #define HFILE_STDERR ((HFILE)2)50 40 51 41 … … 63 53 } 64 54 55 56 65 57 /** 66 58 * Compare and advance if found. … … 69 61 * @returns 0 if no match. 70 62 */ 71 static int panicStrICmp(const char **ppsz, const char *pszLower, const char *pszUpper)72 { 73 const char *psz = *ppsz;74 while (*p sz == *pszLower || *psz == *pszUpper)75 { 76 p sz++;63 static int panicStrICmp(const WCHAR **ppwsz, const char *pszLower, const char *pszUpper) 64 { 65 const WCHAR *pwsz = *ppwsz; 66 while (*pwsz == *pszLower || *pwsz == *pszUpper) 67 { 68 pwsz++; 77 69 pszUpper++; 78 70 if (!*pszUpper) 79 71 { 80 *pp sz = psz;72 *ppwsz = pwsz; 81 73 return 1; 82 74 } … … 137 129 138 130 /** 131 * Write panic text to the panic message / log. 132 * 133 * @param psz The text. 134 * @param cch The length. 135 */ 136 static void panicWrite(const char *psz, unsigned cch) 137 { 138 /** @todo find somewhere to write the panic! */ 139 } 140 141 142 /** 139 143 * Print a panic message and dump/kill the process. 140 144 * … … 168 172 * First, terminate the exception handler chain to avoid recursive trouble. 169 173 */ 170 FS_VAR(); 171 FS_SAVE_LOAD(); 172 PTIB pTib; 173 PPIB pPib; 174 DosGetInfoBlocks(&pTib, &pPib); 175 pTib->tib_pexchain = END_OF_CHAIN; 174 __LIBC_PTEB pTeb = fibGetTEB(); 175 pTeb->ExceptionList = (void *)-1; 176 176 177 177 /* 178 178 * Set the exit reason in SPM. 179 179 */ 180 if (!(fFlags & __LIBC_PANIC_NO_SPM_TERM))181 __libc_spmTerm(__LIBC_EXIT_REASON_KILL, 127);180 //later if (!(fFlags & __LIBC_PANIC_NO_SPM_TERM)) 181 //later __libc_spmTerm(__LIBC_EXIT_REASON_KILL, 127); 182 182 183 183 /* … … 186 186 BOOL fQuiet = FALSE; 187 187 BOOL fVerbose = TRUE; 188 BOOL fBreakpoint = DosSysCtl(DOSSYSCTL_AM_I_DEBUGGED, NULL) == TRUE;188 BOOL fBreakpoint = fibIsBeingDebugged(); 189 189 BOOL fDumpProcess = TRUE; 190 const char *pszPanicCfg = NULL; 191 int rc = DosScanEnv((PCSZ)"LIBC_PANIC", (PSZ *)(void *)&pszPanicCfg); 192 if (!rc && pszPanicCfg && strnlen(pszPanicCfg, 512) < 512) 193 { 194 int c = 512; 195 while (c-- > 0 && *pszPanicCfg) 190 /* the variable name */ 191 static WCHAR s_wszEnvVar[] = { 'L','I','B','C','_','P','A','N','I','C','\0' }; 192 UNICODE_STRING s_EnvVar = 193 { 194 .Length = sizeof(s_wszEnvVar) - 2, 195 .MaximumLength = sizeof(s_wszEnvVar), 196 .Buffer = (PWSTR)&s_wszEnvVar[0] 197 }; 198 /* the value buffer. */ 199 static WCHAR s_wszEnvValue[512]; 200 UNICODE_STRING EnvValue; 201 EnvValue.Length = EnvValue.MaximumLength = sizeof(s_wszEnvValue); 202 EnvValue.Buffer = &s_wszEnvValue[0]; 203 /* do the query. */ 204 NTSTATUS rc = RtlQueryEnvironmentVariable_U(NULL, &s_EnvVar, &EnvValue); 205 if (NT_SUCCESS(rc)) 206 { 207 int c = EnvValue.Length; 208 const WCHAR *pwszPanicCfg = EnvValue.Buffer; 209 while (c-- > 0) 196 210 { 197 if (panicStrICmp(&p szPanicCfg, "quiet", "QUIET"))211 if (panicStrICmp(&pwszPanicCfg, "quiet", "QUIET")) 198 212 fQuiet = TRUE; 199 //else if (panicStrICmp(&p szPanicCfg, "noquiet", "NOQUIET"))213 //else if (panicStrICmp(&pwszPanicCfg, "noquiet", "NOQUIET")) 200 214 // fQuiet = FALSE; 201 else if (panicStrICmp(&p szPanicCfg, "terse", "TERSE"))215 else if (panicStrICmp(&pwszPanicCfg, "terse", "TERSE")) 202 216 fVerbose = FALSE; 203 //else if (panicStrICmp(&p szPanicCfg, "verbose", "VERBOSE"))217 //else if (panicStrICmp(&pwszPanicCfg, "verbose", "VERBOSE")) 204 218 // fVerbose = TRUE; 205 else if (panicStrICmp(&p szPanicCfg, "breakpoint", "BREAKPOINT"))219 else if (panicStrICmp(&pwszPanicCfg, "breakpoint", "BREAKPOINT")) 206 220 fBreakpoint = TRUE; 207 else if (panicStrICmp(&p szPanicCfg, "nobreakpoint", "NOBREAKPOINT"))221 else if (panicStrICmp(&pwszPanicCfg, "nobreakpoint", "NOBREAKPOINT")) 208 222 fBreakpoint = FALSE; 209 //else if (panicStrICmp(&p szPanicCfg, "dump", "DUMP"))223 //else if (panicStrICmp(&pwszPanicCfg, "dump", "DUMP")) 210 224 // fDumpProcess = TRUE; 211 else if (panicStrICmp(&p szPanicCfg, "nodump", "NODUMP"))225 else if (panicStrICmp(&pwszPanicCfg, "nodump", "NODUMP")) 212 226 fDumpProcess = FALSE; 213 227 else 214 p szPanicCfg++;228 pwszPanicCfg++; 215 229 } 216 230 } … … 223 237 * Write user message to stderr. 224 238 */ 225 #define PRINT_CHAR(ch) DosWrite(HFILE_STDERR, &ch, 1, &cb)226 #define PRINT_C(msg) DosWrite(HFILE_STDERR, msg, sizeof(msg) - 1, &cb)227 #define PRINT_P(msg) DosWrite(HFILE_STDERR, msg, panicStrLen(msg), &cb)228 #define PRINT_H(hex) DosWrite(HFILE_STDERR, szHexNum, panicHex(szHexNum, hex, 0), &cb)229 #define PRINT_H16(hex) DosWrite(HFILE_STDERR, szHexNum, panicHex(szHexNum, hex, 4), &cb)230 #define PRINT_H32(hex) DosWrite(HFILE_STDERR, szHexNum, panicHex(szHexNum, hex, 8), &cb)239 #define PRINT_CHAR(ch) panicWrite(&ch, 1) 240 #define PRINT_C(msg) panicWrite(msg, sizeof(msg) - 1) 241 #define PRINT_P(msg) panicWrite(msg, panicStrLen(msg)) 242 #define PRINT_H(hex) panicWrite(szHexNum, panicHex(szHexNum, hex, 0)) 243 #define PRINT_H16(hex) panicWrite(szHexNum, panicHex(szHexNum, hex, 4)) 244 #define PRINT_H32(hex) panicWrite(szHexNum, panicHex(szHexNum, hex, 8)) 231 245 if (!(fFlags & __LIBC_PANIC_SIGNAL) && fVerbose) 232 246 PRINT_C("\r\nLIBC PANIC!!\r\n"); … … 312 326 313 327 /* pid, tid and stuff */ 314 PRINT_C("pid=0x"); PRINT_H16(pPib->pib_ulpid); 315 PRINT_C(" ppid=0x"); PRINT_H16(pPib->pib_ulppid); 316 PRINT_C(" tid=0x"); PRINT_H16(pTib->tib_ptib2->tib2_ultid); 317 PRINT_C(" slot=0x"); PRINT_H16(pTib->tib_ordinal); 318 PRINT_C(" pri=0x"); PRINT_H16(pTib->tib_ptib2->tib2_ulpri); 319 PRINT_C(" mc=0x"); PRINT_H16(pTib->tib_ptib2->tib2_usMCCount); 320 328 PRINT_C("pid=0x"); PRINT_H16((uintptr_t)pTeb->ClientId.UniqueProcess); 329 PRINT_C(" tid=0x"); PRINT_H16((uintptr_t)pTeb->ClientId.UniqueThread); 330 331 #if 0 321 332 /* executable name. */ 322 333 static char szExeName[CCHMAXPATH]; … … 327 338 PRINT_P(szExeName); 328 339 } 340 #endif 329 341 330 342 /* … … 333 345 if (pvCtx) 334 346 { 335 PCONTEXTRECORD pCtx = (PCONTEXTRECORD)pvCtx; 336 347 PCONTEXT pCtx = (PCONTEXT)pvCtx; 348 349 #if 0 337 350 /* the module name */ 338 if (pCtx-> ctx_RegEip >= 0x10000)351 if (pCtx->Eip >= 0x10000) 339 352 { 340 353 HMODULE hmod; 341 354 ULONG iObj = 0; 342 355 ULONG offObj = 0; 343 if (!DosQueryModFromEIP(&hmod, &iObj, sizeof(szExeName), szExeName, &offObj, pCtx-> ctx_RegEip))356 if (!DosQueryModFromEIP(&hmod, &iObj, sizeof(szExeName), szExeName, &offObj, pCtx->Eip)) 344 357 { 345 358 PRINT_C("\r\n"); … … 352 365 } 353 366 } 367 #endif 354 368 355 369 /* registers */ 356 370 PRINT_C("\r\ncs:eip="); 357 PRINT_H16(pCtx-> ctx_SegCs);371 PRINT_H16(pCtx->SegCs); 358 372 PRINT_C(":"); 359 PRINT_H32(pCtx-> ctx_RegEip);373 PRINT_H32(pCtx->Eip); 360 374 361 375 PRINT_C(" ss:esp="); 362 PRINT_H16(pCtx-> ctx_SegSs);376 PRINT_H16(pCtx->SegSs); 363 377 PRINT_C(":"); 364 PRINT_H32(pCtx-> ctx_RegEsp);378 PRINT_H32(pCtx->Esp); 365 379 366 380 PRINT_C(" ebp="); 367 PRINT_H32(pCtx-> ctx_RegEbp);381 PRINT_H32(pCtx->Ebp); 368 382 369 383 PRINT_C("\r\n ds="); 370 PRINT_H16(pCtx-> ctx_SegDs);384 PRINT_H16(pCtx->SegDs); 371 385 PRINT_C(" es="); 372 PRINT_H16(pCtx-> ctx_SegEs);386 PRINT_H16(pCtx->SegEs); 373 387 PRINT_C(" fs="); 374 PRINT_H16(pCtx-> ctx_SegFs);388 PRINT_H16(pCtx->SegFs); 375 389 PRINT_C(" gs="); 376 PRINT_H16(pCtx-> ctx_SegGs);390 PRINT_H16(pCtx->SegGs); 377 391 PRINT_C(" efl="); 378 PRINT_H32(pCtx-> ctx_EFlags);392 PRINT_H32(pCtx->EFlags); 379 393 380 394 PRINT_C("\r\neax="); 381 PRINT_H32(pCtx-> ctx_RegEax);395 PRINT_H32(pCtx->Eax); 382 396 PRINT_C(" ebx="); 383 PRINT_H32(pCtx-> ctx_RegEbx);397 PRINT_H32(pCtx->Ebx); 384 398 PRINT_C(" ecx="); 385 PRINT_H32(pCtx-> ctx_RegEcx);399 PRINT_H32(pCtx->Ecx); 386 400 PRINT_C(" edx="); 387 PRINT_H32(pCtx-> ctx_RegEdx);401 PRINT_H32(pCtx->Edx); 388 402 PRINT_C(" edi="); 389 PRINT_H32(pCtx-> ctx_RegEdi);403 PRINT_H32(pCtx->Edi); 390 404 PRINT_C(" esi="); 391 PRINT_H32(pCtx-> ctx_RegEsi);405 PRINT_H32(pCtx->Esi); 392 406 /** @todo fpu */ 393 407 } … … 408 422 } 409 423 424 #if 0 410 425 /* 411 426 * Attempt dumping the process. … … 413 428 if (fDumpProcess) 414 429 { 430 /// @todo Use MiniDumpWriteDump() if we're in a process which support dbghelp and such. 415 431 LIBCLOG_MSG("Calling DosDumpProcess()\n"); 416 432 rc = DosDumpProcess(DDP_PERFORMPROCDUMP, 0, 0); … … 429 445 } 430 446 } 447 #endif 431 448 432 449 /* 433 450 * Terminate the process. 434 451 */ 435 LIBCLOG_MSG("Calling DosKillProcess()\n");452 LIBCLOG_MSG("Calling ZwTerminateProcess()\n"); 436 453 for (;;) 437 454 { 438 DosKillProcess(DKP_PROCESS, pPib->pib_ulpid);439 DosExit(EXIT_PROCESS, 127);440 } 441 } 442 455 ZwTerminateProcess(NtCurrentProcess(), 127); 456 ZwYieldExecution(); 457 } 458 } 459
Note:
See TracChangeset
for help on using the changeset viewer.