"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

ptrace.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include "host.h"
#include "misc.h"
#include "machine.h"
#include "range.h"
#include "ptrace.h"

Include dependency graph for ptrace.c:

Include dependency graph

Go to the source code of this file.

Functions

Variables


Function Documentation

void __ptrace_endinst unsigned int    iseq
 

Definition at line 170 of file ptrace.c.

References ptrace_outfd.

00171 {
00172   fprintf(ptrace_outfd, "- %u\n", iseq);
00173 
00174   if (ptrace_outfd == stderr || ptrace_outfd == stdout)
00175     fflush(ptrace_outfd);
00176 }

void __ptrace_newcycle tick_t    cycle
 

Definition at line 180 of file ptrace.c.

References ptrace_outfd, and tick_t.

00181 {
00182   fprintf(ptrace_outfd, "@ %.0f\n", (double)cycle);
00183 
00184   if (ptrace_outfd == stderr || ptrace_outfd == stdout)
00185     fflush(ptrace_outfd);
00186 }

void __ptrace_newinst unsigned int    iseq,
md_inst_t    inst,
md_addr_t    pc,
md_addr_t    addr
 

Definition at line 141 of file ptrace.c.

References md_print_insn(), myfprintf(), and ptrace_outfd.

00145 {
00146   myfprintf(ptrace_outfd, "+ %u 0x%08p 0x%08p ", iseq, pc, addr);
00147   md_print_insn(inst, addr, ptrace_outfd);
00148   fprintf(ptrace_outfd, "\n");
00149 
00150   if (ptrace_outfd == stderr || ptrace_outfd == stdout)
00151     fflush(ptrace_outfd);
00152 }

void __ptrace_newstage unsigned int    iseq,
char *    pstage,
unsigned int    pevents
 

Definition at line 190 of file ptrace.c.

References ptrace_outfd.

00193 {
00194   fprintf(ptrace_outfd, "* %u %s 0x%08x\n", iseq, pstage, pevents);
00195 
00196   if (ptrace_outfd == stderr || ptrace_outfd == stdout)
00197     fflush(ptrace_outfd);
00198 }

void __ptrace_newuop unsigned int    iseq,
char *    uop_desc,
md_addr_t    pc,
md_addr_t    addr
 

Definition at line 156 of file ptrace.c.

References myfprintf(), and ptrace_outfd.

00160 {
00161   myfprintf(ptrace_outfd,
00162             "+ %u 0x%08p 0x%08p [%s]\n", iseq, pc, addr, uop_desc);
00163 
00164   if (ptrace_outfd == stderr || ptrace_outfd == stdout)
00165     fflush(ptrace_outfd);
00166 }

void ptrace_close void   
 

Definition at line 133 of file ptrace.c.

References ptrace_outfd.

Referenced by sim_uninit().

00134 {
00135   if (ptrace_outfd != NULL && ptrace_outfd != stderr && ptrace_outfd != stdout)
00136     fclose(ptrace_outfd);
00137 }

void ptrace_open char *    fname,
char *    range
 

Definition at line 93 of file ptrace.c.

References range_range_t::end, FALSE, fatal(), panic(), ptrace_active, ptrace_outfd, range_pos_t::ptype, range_parse_range(), range_range_t::start, and TRUE.

Referenced by sim_load_prog().

00095 {
00096   char *errstr;
00097 
00098   /* parse the output range */
00099   if (!range)
00100     {
00101       /* no range */
00102       errstr = range_parse_range(":", &ptrace_range);
00103       if (errstr)
00104         panic("cannot parse pipetrace range, use: {<start>}:{<end>}");
00105       ptrace_active = TRUE;
00106     }
00107   else
00108     {
00109       errstr = range_parse_range(range, &ptrace_range);
00110       if (errstr)
00111         fatal("cannot parse pipetrace range, use: {<start>}:{<end>}");
00112       ptrace_active = FALSE;
00113     }
00114 
00115   if (ptrace_range.start.ptype != ptrace_range.end.ptype)
00116     fatal("range endpoints are not of the same type");
00117 
00118   /* open output trace file */
00119   if (!fname || !strcmp(fname, "-") || !strcmp(fname, "stderr"))
00120     ptrace_outfd = stderr;
00121   else if (!strcmp(fname, "stdout"))
00122     ptrace_outfd = stdout;
00123   else
00124     {
00125       ptrace_outfd = fopen(fname, "w");
00126       if (!ptrace_outfd)
00127         fatal("cannot open pipetrace output file `%s'", fname);
00128     }
00129 }


Variable Documentation

int ptrace_active = FALSE
 

Definition at line 83 of file ptrace.c.

Referenced by ptrace_open().

int ptrace_oneshot = FALSE
 

Definition at line 89 of file ptrace.c.

FILE* ptrace_outfd = NULL
 

Definition at line 80 of file ptrace.c.

Referenced by __ptrace_endinst(), __ptrace_newcycle(), __ptrace_newinst(), __ptrace_newstage(), __ptrace_newuop(), ptrace_close(), and ptrace_open().

struct range_range_t ptrace_range
 

Definition at line 86 of file ptrace.c.



UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214