From: "RCX" <lrogers42@yahoo.com>
Subject: Instrumentation error
Date: 7 Apr 2005 08:54:44 -0700 [thread overview]
Message-ID: <1112889284.007353.52610@l41g2000cwc.googlegroups.com> (raw)
I am new to Compaq's Atom tools and am trying to get familiar with
them. I have taken one of the example programs and added some code to
see if I can understand the process.
By taking the "ptrace" example program:
// ptrace.inst.c
#include <stdio.h>
#include <cmplrs/atom.inst.h>
static const char * SafeProcName(Proc *);
Instrument(int argc, char **argv, Obj *obj)
{
Proc *p;
AddCallProto("ProcTrace(char *)");
for (p = GetFirstObjProc(obj); p != NULL; p = GetNextProc(p)) {
AddCallProc(p,ProcBefore,"ProcTrace",SafeProcName(p));
}
}
static const char *SafeProcName(Proc *p)
{
const char * name;
static char buf[128];
name = ProcName(p);
if (name)
return(name);
sprintf(buf, "proc_at_0x%lx", ProcPC(p));
return(buf);
}
// ptrace.anal.c
#include <stdio.h>
#include <cmplrs/atom.anal.h>
void ProcTrace(char *name)
{
fprintf(stderr,"%s\n",name);
}
...and adding a few lines of code in order to get a sense of what the
Atom program is doing:
// ptrace2.inst.c
#include <stdio.h>
#include <cmplrs/atom.inst.h>
static const char* SafeProcName(Proc*);
Instrument(int argc, char* argv[], Obj* obj)
{
Proc* p;
AddCallProto("ProcTraceB(char*)");
AddCallProto("ProcTraceA(char*)");
for (p = GetFirstObjProc(obj); p != NULL; p = GetNextProc(p))
{
AddCallProc(p, ProcBefore, "ProcTraceB", SafeProcName(p));
AddCallProc(p, ProcAfter, "ProcTraceA", SafeProcName(p));
}
}
static const char* SafeProcName(Proc* p)
{
const char* name;
static char buf[128];
name = ProcName(p);
if (name)
{
return(name);
}
sprintf(buf, "proc_at_0x%lx", ProcPC(p));
return(buf);
}
// ptrace2.anal.c
#include <stdio.h>
#include <cmplrs/atom.anal.h>
void ProcTraceB(char* name)
{
fprintf(stderr,"Entering '%s'\n", name);
}
void ProcTraceA(char* name)
{
fprintf(stderr,"Leaving '%s'\n", name);
}
When I run the modified files against a VERY basic "Hello World"
application, the resulting executable is much larger than the original
and it produces the expected output.
When I run the modified instrumentation files against a production
application, I get an executable that is one third the size of the
original and I receive an error message that states,
"atom: Warning: Branch instruction overflowed. Executable may not
work."
Admittedly, the production application is huge. When compiled with
debugging turned on, the executable is 44 Meg in size. It is also a
threaded application which my "Hello World" application is not. Other
than the few lines of code that I added to the instrumentation and
analysis files, I also changed the code structure to conform to our
coding standards. (I changed it back to see if that would make any
difference and it did not.)
The original "ptrace" example program runs against the production
application without warnings or errors. It produces gigabytes of
output. My ultimate goal is to further modify the instrumentation file
using Atom's "GetProcInfo()" method to only output the local procedure
names (GetProcInfo(p, ProcSymRes) != SYMRESEXTERN), but I can't even
begin to attempt that until I get the simpler version working.
Any help in getting a better understanding of why I'm getting a warning
message would be appreciated.
OS: OSF1
OS version: Tru64 V5.1B
Command line: $> atom prog1 ptrace2.inst.c ptrace2.anal.c -L../libs
BTW - I have read through "Program Analysis Using Atom Tools" without
getting any information as to what might be happening.
reply other threads:[~2005-04-07 15:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox