@@ -319,15 +319,6 @@ static void DbugExit(const char *why);
319319static const char * DbugStrTok (const char * s );
320320static void DbugVfprintf (FILE * stream , const char * format , va_list args );
321321
322- #ifndef THREAD
323- /* Open profile output stream */
324- static FILE * OpenProfile (CODE_STATE * cs , const char * name );
325- /* Profile if asked for it */
326- static BOOLEAN DoProfile (CODE_STATE * );
327- /* Return current user time (ms) */
328- static unsigned long Clock (void );
329- #endif
330-
331322/*
332323 * Miscellaneous printf format strings.
333324 */
@@ -355,7 +346,6 @@ static unsigned long Clock(void);
355346** Macros to allow dbugging with threads
356347*/
357348
358- #ifdef THREAD
359349#include <my_pthread.h>
360350static pthread_mutex_t THR_LOCK_dbug ;
361351
@@ -394,30 +384,6 @@ static CODE_STATE *code_state(void)
394384 return cs ;
395385}
396386
397- #else /* !THREAD */
398-
399- static CODE_STATE static_code_state =
400- {
401- "dbug" , "?func" , "?file" , NULL , & init_settings ,
402- NullS , NullS , 0 ,0 ,0 ,0 ,0 ,NullS
403- };
404-
405- static CODE_STATE * code_state (void )
406- {
407- if (!init_done )
408- {
409- bzero (& init_settings , sizeof (init_settings ));
410- init_settings .out_file = stderr ;
411- init_settings .flags = OPEN_APPEND ;
412- init_done = TRUE;
413- }
414- return & static_code_state ;
415- }
416-
417- #define pthread_mutex_lock (A ) {}
418- #define pthread_mutex_unlock (A ) {}
419- #endif
420-
421387/*
422388 * Translate some calls among different systems.
423389 */
@@ -601,15 +567,6 @@ int DbugParse(CODE_STATE *cs, const char *control)
601567 else
602568 stack -> flags |= PID_ON ;
603569 break ;
604- #ifndef THREAD
605- case 'g' :
606- if (OpenProfile (cs , PROF_FILE ))
607- {
608- stack -> flags |= PROFILE_ON ;
609- stack -> p_functions = ListAdd (stack -> p_functions , control , end );
610- }
611- break ;
612- #endif
613570 case 'L' :
614571 if (sign < 0 )
615572 stack -> flags &= ~LINE_ON ;
@@ -1154,23 +1111,7 @@ void _db_enter_(const char *_func_, const char *_file_,
11541111 _stack_frame_ -> prev = cs -> framep ;
11551112 _stack_frame_ -> level = ++ cs -> level | framep_trace_flag (cs , cs -> framep );
11561113 cs -> framep = _stack_frame_ ;
1157- #ifndef THREAD
1158- if (DoProfile (cs ))
1159- {
1160- long stackused ;
1161- if (cs -> framep -> prev == NULL )
1162- stackused = 0 ;
1163- else
1164- {
1165- stackused = (char * )(cs -> framep -> prev ) - (char * )(cs -> framep );
1166- stackused = stackused > 0 ? stackused : - stackused ;
1167- }
1168- (void ) fprintf (cs -> stack -> prof_file , PROF_EFMT , Clock (), cs -> func );
1169- (void ) fprintf (cs -> stack -> prof_file , PROF_SFMT , (ulong ) cs -> framep , stackused ,
1170- AUTOS_REVERSE ? _stack_frame_ -> func : cs -> func );
1171- (void ) fflush (cs -> stack -> prof_file );
1172- }
1173- #endif
1114+
11741115 switch (DoTrace (cs )) {
11751116 case ENABLE_TRACE :
11761117 cs -> framep -> level |= TRACE_ON ;
@@ -1229,10 +1170,7 @@ void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_)
12291170 my_snprintf (buf , sizeof (buf ), ERR_MISSING_RETURN , cs -> func );
12301171 DbugExit (buf );
12311172 }
1232- #ifndef THREAD
1233- if (DoProfile (cs ))
1234- (void ) fprintf (cs -> stack -> prof_file , PROF_XFMT , Clock (), cs -> func );
1235- #endif
1173+
12361174 if (DoTrace (cs ) & DO_TRACE )
12371175 {
12381176 if (TRACING )
@@ -1744,36 +1682,6 @@ static int DoTrace(CODE_STATE *cs)
17441682 return DONT_TRACE ;
17451683}
17461684
1747-
1748- /*
1749- * FUNCTION
1750- *
1751- * DoProfile check to see if profiling is current enabled
1752- *
1753- * SYNOPSIS
1754- *
1755- * static BOOLEAN DoProfile()
1756- *
1757- * DESCRIPTION
1758- *
1759- * Checks to see if profiling is enabled based on whether the
1760- * user has specified profiling, the maximum trace depth has
1761- * not yet been reached, the current function is selected,
1762- * and the current process is selected. Returns TRUE if
1763- * profiling is enabled, FALSE otherwise.
1764- *
1765- */
1766-
1767- #ifndef THREAD
1768- static BOOLEAN DoProfile (CODE_STATE * cs )
1769- {
1770- return PROFILING &&
1771- cs -> level <= cs -> stack -> maxdepth &&
1772- InList (cs -> stack -> p_functions , cs -> func ) & (INCLUDE |MATCHED ) &&
1773- InList (cs -> stack -> processes , cs -> process ) & (INCLUDE |MATCHED );
1774- }
1775- #endif
1776-
17771685FILE * _db_fp_ (void )
17781686{
17791687 CODE_STATE * cs ;
@@ -1900,11 +1808,7 @@ static void DoPrefix(CODE_STATE *cs, uint _line_)
19001808 cs -> lineno ++ ;
19011809 if (cs -> stack -> flags & PID_ON )
19021810 {
1903- #ifdef THREAD
19041811 (void ) fprintf (cs -> stack -> out_file , "%-7s: " , my_thread_name ());
1905- #else
1906- (void ) fprintf (cs -> stack -> out_file , "%5d: " , (int ) getpid ());
1907- #endif
19081812 }
19091813 if (cs -> stack -> flags & NUMBER_ON )
19101814 (void ) fprintf (cs -> stack -> out_file , "%5d: " , cs -> lineno );
@@ -2014,63 +1918,6 @@ static void DBUGOpenFile(CODE_STATE *cs,
20141918 }
20151919}
20161920
2017-
2018- /*
2019- * FUNCTION
2020- *
2021- * OpenProfile open new output stream for profiler output
2022- *
2023- * SYNOPSIS
2024- *
2025- * static FILE *OpenProfile(name)
2026- * char *name;
2027- *
2028- * DESCRIPTION
2029- *
2030- * Given name of a new file, opens the file
2031- * and sets the profiler output stream to the new file.
2032- *
2033- * It is currently unclear whether the prefered behavior is
2034- * to truncate any existing file, or simply append to it.
2035- * The latter behavior would be desirable for collecting
2036- * accumulated runtime history over a number of separate
2037- * runs. It might take some changes to the analyzer program
2038- * though, and the notes that Binayak sent with the profiling
2039- * diffs indicated that append was the normal mode, but this
2040- * does not appear to agree with the actual code. I haven't
2041- * investigated at this time [fnf; 24-Jul-87].
2042- */
2043-
2044- #ifndef THREAD
2045- static FILE * OpenProfile (CODE_STATE * cs , const char * name )
2046- {
2047- REGISTER FILE * fp ;
2048- REGISTER BOOLEAN newfile ;
2049-
2050- fp = 0 ;
2051- if (!Writable (name ))
2052- {
2053- (void ) fprintf (cs -> stack -> out_file , ERR_OPEN , cs -> process , name );
2054- perror ("" );
2055- (void ) Delay (cs -> stack -> delay );
2056- }
2057- else
2058- {
2059- newfile = !EXISTS (name );
2060- if (!(fp = fopen (name , "w" )))
2061- {
2062- (void ) fprintf (cs -> stack -> out_file , ERR_OPEN , cs -> process , name );
2063- perror ("" );
2064- }
2065- else
2066- {
2067- cs -> stack -> prof_file = fp ;
2068- }
2069- }
2070- return fp ;
2071- }
2072- #endif
2073-
20741921/*
20751922 * FUNCTION
20761923 *
@@ -2419,80 +2266,6 @@ const char* _db_get_func_(void)
24192266 return cs -> func ;
24202267}
24212268
2422- /*
2423- * Here we need the definitions of the clock routine. Add your
2424- * own for whatever system that you have.
2425- */
2426-
2427- #ifndef THREAD
2428- #if defined(HAVE_GETRUSAGE )
2429-
2430- #include <sys/param.h>
2431- #include <sys/resource.h>
2432-
2433- /* extern int getrusage(int, struct rusage *); */
2434-
2435- /*
2436- * Returns the user time in milliseconds used by this process so
2437- * far.
2438- */
2439-
2440- static unsigned long Clock ()
2441- {
2442- struct rusage ru ;
2443-
2444- (void ) getrusage (RUSAGE_SELF , & ru );
2445- return ru .ru_utime .tv_sec * 1000 + ru .ru_utime .tv_usec /1000 ;
2446- }
2447-
2448- #elif defined(__WIN__ )
2449-
2450- static ulong Clock ()
2451- {
2452- return clock ()* (1000 /CLOCKS_PER_SEC );
2453- }
2454- #elif defined(amiga )
2455-
2456- struct DateStamp { /* Yes, this is a hack, but doing it right */
2457- long ds_Days ; /* is incredibly ugly without splitting this */
2458- long ds_Minute ; /* off into a separate file */
2459- long ds_Tick ;
2460- };
2461-
2462- static int first_clock = TRUE;
2463- static struct DateStamp begin ;
2464- static struct DateStamp elapsed ;
2465-
2466- static unsigned long Clock ()
2467- {
2468- register struct DateStamp * now ;
2469- register unsigned long millisec = 0 ;
2470- extern VOID * AllocMem ();
2471-
2472- now = (struct DateStamp * ) AllocMem ((long ) sizeof (struct DateStamp ), 0L );
2473- if (now != NULL )
2474- {
2475- if (first_clock == TRUE)
2476- {
2477- first_clock = FALSE;
2478- (void ) DateStamp (now );
2479- begin = * now ;
2480- }
2481- (void ) DateStamp (now );
2482- millisec = 24 * 3600 * (1000 / HZ ) * (now -> ds_Days - begin .ds_Days );
2483- millisec += 60 * (1000 / HZ ) * (now -> ds_Minute - begin .ds_Minute );
2484- millisec += (1000 / HZ ) * (now -> ds_Tick - begin .ds_Tick );
2485- (void ) FreeMem (now , (long ) sizeof (struct DateStamp ));
2486- }
2487- return millisec ;
2488- }
2489- #else
2490- static unsigned long Clock ()
2491- {
2492- return 0 ;
2493- }
2494- #endif /* RUSAGE */
2495- #endif /* THREADS */
24962269
24972270#else
24982271
0 commit comments