Ignore:
Timestamp:
Dec 18, 2011, 10:28:22 PM (14 years ago)
Author:
dmik
Message:

Merge branch gcc-kmk to trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 bin
        2 Makefile.inc
         1env.cmd
         2LocalConfig.kmk
    • Property svn:mergeinfo set to
      /branches/gcc-kmkmergedeligible
  • trunk/src/kernel32/dbglog.cpp

    r21343 r21916  
    2626#include <string.h>
    2727#include <stdarg.h>
     28#include <process.h>
    2829#include <win32type.h>
    2930#include <win32api.h>
     
    9394/* arguments.                                                        */
    9495/* ----------------------------------------------------------------- */
    95 int SYSTEM WriteLog(char *f, ...)
     96int SYSTEM WriteLog(const char *f, ...)
    9697  {
    9798  TIB    *ptib;                    /* process/thread id structures */
     
    257258static BOOL fLogging = TRUE;
    258259static int  dwEnableLogging = 1;
     260#ifdef __IBMC__
    259261static int  oldcrtmsghandle = 0;
     262#endif
    260263
    261264static BOOL fDisableThread[5] = {0};
    262265static BOOL fFlushLines = TRUE;
    263266
    264 static char *pszLastLogEntry = NULL;
     267static const char *pszLastLogEntry = NULL;
    265268
    266269//#define CHECK_ODINHEAP
     
    305308}
    306309
    307 int SYSTEM WriteLog(char *tekst, ...)
     310int SYSTEM WriteLog(const char *tekst, ...)
    308311{
    309312  USHORT  sel = RestoreOS2FS();
     
    330333#ifdef WIN32_IP_LOGGING
    331334        char *logserver = getenv("WIN32LOG_IPSERVER");
    332         if(logserver && loadNr == 0) {
     335        if(logserver) {
    333336             sock_init();
    334337
     
    346349            pszLogBase = "odin32_";
    347350
    348         sprintf(szLogFile, "%s%d.log", pszLogBase, loadNr);
     351        sprintf(szLogFile, "%s%d.log", pszLogBase, getpid());
    349352        flog = fopen(szLogFile, "w");
    350         if(flog == NULL) 
     353        if(flog == NULL)
    351354        {//probably running exe on readonly device
    352             sprintf(szLogFile, "%sodin32_%d.log", kernel32Path, loadNr);
     355            sprintf(szLogFile, "%sodin32_%d.log", kernel32Path, getpid());
    353356            flog = fopen(szLogFile, "w");
    354357        }
     358#ifdef __IBMC__
    355359        oldcrtmsghandle = _set_crt_msg_handle(fileno(flog));
     360#endif
    356361    }
    357362    else
     
    385390    if(logSocket == -1) {
    386391#endif
    387     if(teb) 
     392    if(teb)
    388393    {
    389394      ULONG ulCallDepth;
     
    393398      ulCallDepth = 0;
    394399#endif
    395      
     400
    396401      teb->o.odin.logfile = (DWORD)flog;
    397      
     402
    398403#ifdef LOG_TIME
    399404      if(sel == 0x150b && fSwitchTIBSel)
    400         fprintf(flog, 
     405        fprintf(flog,
    401406                "t%02d (%3d): (%x) (FS=150B) ",
    402407                LOWORD(teb->o.odin.threadId),
    403408                ulCallDepth,
    404409                GetTickCount());
    405       else 
    406         fprintf(flog, 
     410      else
     411        fprintf(flog,
    407412                "t%02d (%3d): (%x) ",
    408413                LOWORD(teb->o.odin.threadId),
     
    410415                GetTickCount());
    411416#else
    412       if(sel == 0x150b && fSwitchTIBSel) 
    413         fprintf(flog, 
     417      if(sel == 0x150b && fSwitchTIBSel)
     418        fprintf(flog,
    414419#ifdef SHOW_FPU_CONTROLREG
    415420                "t%02d (%3d)(%3x): ",
     
    422427                ulCallDepth);
    423428#endif
    424       else 
    425         fprintf(flog, 
     429      else
     430        fprintf(flog,
    426431#ifdef SHOW_FPU_CONTROLREG
    427432                "t%02d (%3d)(%3x): ",
     
    450455        int  prefixlen = 0;
    451456
    452         if(teb) 
     457        if(teb)
    453458        {
    454459            ULONG ulCallDepth;
     
    459464#endif
    460465#ifdef LOG_TIME
    461             if(sel == 0x150b && fSwitchTIBSel) 
     466            if(sel == 0x150b && fSwitchTIBSel)
    462467                sprintf(logbuffer, "t%02d (%3d): %x (FS=150B) ",
    463468                        LOWORD(teb->o.odin.threadId), ulCallDepth, GetTickCount());
    464             else 
     469            else
    465470                sprintf(logbuffer, "t%02d (%3d): %x ",
    466471                        LOWORD(teb->o.odin.threadId), ulCallDepth, GetTickCount());
    467472#else
    468             if(sel == 0x150b && fSwitchTIBSel) 
     473            if(sel == 0x150b && fSwitchTIBSel)
    469474                sprintf(logbuffer, "t%02d (%3d): (FS=150B) ",
    470475                        LOWORD(teb->o.odin.threadId), ulCallDepth);
    471             else 
     476            else
    472477                sprintf(logbuffer, "t%02d (%3d): ",
    473478                        LOWORD(teb->o.odin.threadId), ulCallDepth);
     
    497502        if(tekst[strlen(tekst)-1] != '\n')
    498503            fprintf(flog, "\n");
    499 #if 0       
     504#if 0
    500505if (teb && LOWORD(teb->o.odin.threadId) > 1)
    501506{
     
    514519            break;
    515520        }
    516        
     521
    517522        if ((ULONG)pframe < getESP())
    518523        {
     
    554559//******************************************************************************
    555560//******************************************************************************
    556 int SYSTEM WriteLogNoEOL(char *tekst, ...)
     561int SYSTEM WriteLogNoEOL(const char *tekst, ...)
    557562{
    558563  USHORT  sel = RestoreOS2FS();
     
    572577        char logname[CCHMAXPATH];
    573578
    574         sprintf(logname, "odin32_%d.log", loadNr);
     579        sprintf(logname, "odin32_%d.log", getpid());
    575580        flog = fopen(logname, "w");
    576581        if(flog == NULL) {//probably running exe on readonly device
    577             sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr);
     582            sprintf(logname, "%sodin32_%d.log", kernel32Path, getpid());
    578583            flog = fopen(logname, "w");
    579584        }
     
    612617//******************************************************************************
    613618//******************************************************************************
    614 int SYSTEM WritePrivateLog(void *logfile, char *tekst, ...)
     619int SYSTEM WritePrivateLog(void *logfile, const char *tekst, ...)
    615620{
    616621  USHORT  sel = RestoreOS2FS();
     
    717722void CloseLogFile()
    718723{
     724#ifdef __IBMC__
    719725  if(oldcrtmsghandle)
    720726    _set_crt_msg_handle(oldcrtmsghandle);
     727#endif
    721728
    722729#ifdef WIN32_IP_LOGGING
     
    789796              "int 3"
    790797#endif
     798extern "C"
    791799void WIN32API DebugBreak()
    792800{
Note: See TracChangeset for help on using the changeset viewer.