summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mklib269
-rwxr-xr-xbin/win32kprof.py309
2 files changed, 156 insertions, 422 deletions
diff --git a/bin/mklib b/bin/mklib
index db97087c0a6..9799a4ed277 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -25,6 +25,124 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# Given a list of files, look for .a archives and unpack them.
+# Return the original list of files minus the .a files plus the unpacked files.
+expand_archives() {
+ DIR=$1
+ shift
+ FILES=$@
+ NEWFILES=""
+ ORIG_DIR=`pwd`
+ mkdir -p "$DIR"
+ cd "$DIR"
+ for FILE in $FILES ; do
+ case $FILE in
+ *.a)
+ # extract the .o files from this .a archive
+ case $FILE in
+ /*) ;;
+ *) FILE="$ORIG_DIR/$FILE" ;;
+ esac
+ MEMBERS=`ar t $FILE`
+ ar x $FILE
+ for MEMBER in $MEMBERS ; do
+ NEWFILES="$NEWFILES $DIR/$MEMBER"
+ done
+ ;;
+ *)
+ # other file type, just add to list
+ NEWFILES="$NEWFILES $FILE"
+ ;;
+ esac
+ done
+ cd "$ORIG_DIR"
+ echo $NEWFILES
+}
+
+
+# Given a list of files, look for .a archives and return a list of all objects
+# in the .a archives.
+contents_of_archives() {
+ FILES=$@
+ NEWFILES=""
+ for FILE in $FILES ; do
+ case $FILE in
+ *.a)
+ # get list of members in this .a archive
+ MEMBERS=`ar t $FILE`
+ NEWFILES="$NEWFILES $MEMBERS"
+ ;;
+ *)
+ # skip other file types
+ ;;
+ esac
+ done
+ echo $NEWFILES
+}
+
+
+# Make static library with 'ar'
+# params:
+# options to ar
+# 1 or 0 to indicate if ranlib should be run
+# libname to make
+# list of object files
+# Return name of library we made
+# Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
+make_ar_static_lib() {
+ OPTS=$1
+ shift;
+ RANLIB=$1
+ shift;
+ LIBNAME=$1
+ shift;
+ OBJECTS=$@
+
+ # remove existing lib, if present
+ rm -f ${LIBNAME}
+
+ # make static lib
+ ar ${OPTS} ${LIBNAME} ${OBJECTS}
+
+ # run ranlib
+ if [ ${RANLIB} = 1 ] ; then
+ ranlib ${LIBNAME}
+ fi
+
+ echo ${LIBNAME}
+}
+
+
+# Print usage info.
+usage() {
+ echo 'Usage: mklib [options] objects'
+ echo 'Create a shared library from object files.'
+ echo ' -o LIBRARY specifies the name of the resulting library, without'
+ echo ' the leading "lib" or any suffix.'
+ echo ' (eg: "-o GL" might result in "libGL.so" being made)'
+ echo ' -major N specifies major version number (default is 1)'
+ echo ' -minor N specifies minor version number (default is 0)'
+ echo ' -patch N specifies patch version number (default is 0)'
+ echo ' -lLIBRARY specifies a dependency on LIBRARY'
+ echo ' -LDIR search in DIR for library dependencies at build time'
+ echo ' -RDIR search in DIR for library dependencies at run time'
+ echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
+ echo ' Not observed on all systems at this time.'
+ echo ' -ldflags OPT specify any additional linker flags in OPT'
+ echo ' -cplusplus link with C++ runtime'
+ echo ' -static make a static library (default is dynamic/shared)'
+ echo ' -dlopen make a shared library suitable for dynamic loading'
+ echo ' -install DIR put resulting library file(s) in DIR'
+ echo ' -arch ARCH override using `uname` to determine host system'
+ echo ' -archopt OPT specify an extra achitecture-specific option OPT'
+ echo ' -altopts OPTS alternate options to override all others'
+ echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
+ echo ' -exports FILE only export the symbols listed in FILE'
+ echo ' -id NAME Sets the id of the dylib (Darwin)'
+ echo ' -h, --help display this information and exit'
+}
+
+
#
# Option defaults
#
@@ -52,31 +170,7 @@ while true
do
case $1 in
'-h' | '--help')
- echo 'Usage: mklib [options] objects'
- echo 'Create a shared library from object files.'
- echo ' -o LIBRARY specifies the name of the resulting library, without'
- echo ' the leading "lib" or any suffix.'
- echo ' (eg: "-o GL" might result in "libGL.so" being made)'
- echo ' -major N specifies major version number (default is 1)'
- echo ' -minor N specifies minor version number (default is 0)'
- echo ' -patch N specifies patch version number (default is 0)'
- echo ' -lLIBRARY specifies a dependency on LIBRARY'
- echo ' -LDIR search in DIR for library dependencies at build time'
- echo ' -RDIR search in DIR for library dependencies at run time'
- echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
- echo ' Not observed on all systems at this time.'
- echo ' -ldflags OPT specify any additional linker flags in OPT'
- echo ' -cplusplus link with C++ runtime'
- echo ' -static make a static library (default is dynamic/shared)'
- echo ' -dlopen make a shared library suitable for dynamic loading'
- echo ' -install DIR put resulting library file(s) in DIR'
- echo ' -arch ARCH override using `uname` to determine host system'
- echo ' -archopt OPT specify an extra achitecture-specific option OPT'
- echo ' -altopts OPTS alternate options to override all others'
- echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
- echo ' -exports FILE only export the symbols listed in FILE'
- echo ' -id NAME Sets the id of the dylib (Darwin)'
- echo ' -h, --help display this information and exit'
+ usage
exit 1
;;
'-o')
@@ -197,11 +291,11 @@ fi
# Error checking
#
if [ "x${LIBNAME}" = "x" ] ; then
- echo "mklib: Error: no library name specified"
+ echo "mklib: Error: no library name specified (-h for help)"
exit 1
fi
if [ "x${OBJECTS}" = "x" ] ; then
- echo "mklib: Error: no object files specified"
+ echo "mklib: Error: no object files specified (-h for help)"
exit 1
fi
@@ -269,45 +363,24 @@ case $ARCH in
# finish up
FINAL_LIBS="${LIBNAME}"
elif [ $STATIC = 1 ] ; then
+ # make a static .a library
LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
- LINK="ar"
OPTS="-ru"
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
fi
- rm -f ${LIBNAME}
- # expand any .a objects into constituent .o files.
- NEWOBJECTS=""
- DELETIA=""
- for OBJ in $OBJECTS ; do
- case $OBJ in
- *.a)
- # extract the .o files from this .a archive
- FILES=`ar t $OBJ`
- ar x $OBJ
- NEWOBJECTS="$NEWOBJECTS $FILES"
- # keep track of temporary .o files and delete them below
- DELETIA="$DELETIA $FILES"
- ;;
- *)
- # ordinary .o file
- NEWOBJECTS="$NEWOBJECTS $OBJ"
- ;;
- esac
- done
+ # expand .a into .o files
+ NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
- # make lib
- ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
- ranlib ${LIBNAME}
+ # make static lib
+ FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
# remove temporary extracted .o files
- rm -f ${DELETIA}
-
- # finish up
- FINAL_LIBS=${LIBNAME}
+ rm -rf ${LIBNAME}.obj
else
+ # make dynamic library
LIBNAME="lib${LIBNAME}" # prefix with "lib"
case $ARCH in 'Linux' | 'GNU' | GNU/*)
OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
@@ -368,9 +441,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making SunOS static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar -ruv ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
else
if [ $NOPREFIX = 0 ] ; then
LIBNAME="lib${LIBNAME}.so"
@@ -489,13 +560,19 @@ case $ARCH in
${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
FINAL_LIBS=${LIBNAME}
elif [ $STATIC = 1 ] ; then
+ # make a static .a library
STLIB="lib${LIBNAME}.a"
echo "mklib: Making FreeBSD static library: " ${STLIB}
- rm -f ${STLIB}
- ar cq ${STLIB} ${OBJECTS}
- ranlib ${STLIB}
- FINAL_LIBS=${STLIB}
+
+ # expand .a into .o files
+ NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS`
+
+ FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
+
+ # remove temporary extracted .o files
+ rm -rf ${STLIB}.obj
else
+ # make dynamic library
SHLIB="lib${LIBNAME}.so.${MAJOR}"
OPTS="-shared -Wl,-soname,${SHLIB}"
if [ "${ALTOPTS}" ] ; then
@@ -513,10 +590,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}_pic.a"
echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar cq ${LIBNAME} ${OBJECTS}
- ranlib ${LIBNAME}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
else
LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
@@ -529,9 +603,7 @@ case $ARCH in
'IRIX' | 'IRIX64')
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
- rm -f ${LIBNAME}
- ar rc ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
else
LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
@@ -582,9 +654,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making HP-UX static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar -ruv ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
else
# HP uses a .2 for their current GL/GLU libraries
if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
@@ -614,8 +684,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making AIX static library: " ${LIBNAME}
- ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
else
EXPFILE="lib${LIBNAME}.exp"
LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
@@ -666,9 +735,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making OSF/1 static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar -ruv ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
else
VERSION="${MAJOR}.${MINOR}"
LIBNAME="lib${LIBNAME}.so"
@@ -724,22 +791,10 @@ case $ARCH in
# examine first object to determine ABI
set ${OBJECTS}
- ABI_PPC=`file $1 | grep ' ppc'`
- ABI_I386=`file $1 | grep ' i386'`
- ABI_PPC64=`file $1 | grep ' ppc64'`
- ABI_X86_64=`file $1 | grep ' x86_64'`
- if [ "${ABI_PPC}" ] ; then
- OPTS="${OPTS} -arch ppc"
- fi
- if [ "${ABI_I386}" ] ; then
- OPTS="${OPTS} -arch i386"
- fi
- if [ "${ABI_PPC64}" ] ; then
- OPTS="${OPTS} -arch ppc64"
- fi
- if [ "${ABI_X86_64}" ] ; then
- OPTS="${OPTS} -arch x86_64"
- fi
+ ABIS=`lipo -info $1 | sed s/.*://`
+ for ABI in $ABIS; do
+ OPTS="${OPTS} -arch ${ABI}"
+ done
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
@@ -767,16 +822,14 @@ case $ARCH in
'LynxOS')
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making LynxOS static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar ru ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
;;
'BeOS')
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making BeOS static library: " ${LIBNAME}
- ar -cru "${LIBNAME}" ${OBJECTS}
+ FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
else
LIBNAME="lib${LIBNAME}.so"
echo "mklib: Making BeOS shared library: " ${LIBNAME}
@@ -855,9 +908,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making AIX GCC static library: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar ru ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
+ FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
else
LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
@@ -878,9 +929,7 @@ case $ARCH in
fi
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making static library for Ultrix: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar ru ${LIBNAME} ${OBJECTS}
- FINAL_LIBS="${LIBNAME}"
+ FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
;;
CYGWIN*)
@@ -900,17 +949,13 @@ case $ARCH in
LIBNAME="lib${LIBNAME}" # prefix with "lib"
if [ $STATIC = 1 ] ; then
- echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
- LINK="ar"
+ LIBNAME=${LIBNAME}.a
+ echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
OPTS="-ru"
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
fi
- # make lib
- ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
- ranlib ${LIBNAME}.a
- # finish up
- FINAL_LIBS=${LIBNAME}.a
+ FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${OBJECTS}`
else
OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
if [ "${ALTOPTS}" ] ; then
@@ -948,9 +993,7 @@ case $ARCH in
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making static library for example arch: " ${LIBNAME}
- rm -f ${LIBNAME}
- ar rv ${LIBNAME} ${OBJECTS}
- FINAL_LIBS="${LIBNAME}"
+ FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
else
LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
echo "mklib: Making shared library for example arch: " ${LIBNAME}
diff --git a/bin/win32kprof.py b/bin/win32kprof.py
deleted file mode 100755
index c36317d23ae..00000000000
--- a/bin/win32kprof.py
+++ /dev/null
@@ -1,309 +0,0 @@
-#!/usr/bin/env python
-##########################################################################
-#
-# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
-# All Rights Reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sub license, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice (including the
-# next paragraph) shall be included in all copies or substantial portions
-# of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
-# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-##########################################################################
-
-
-import sys
-import optparse
-import re
-import struct
-
-from gprof2dot import Call, Function, Profile
-from gprof2dot import CALLS, SAMPLES, TIME, TIME_RATIO, TOTAL_TIME, TOTAL_TIME_RATIO
-from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
-
-
-__version__ = '0.1'
-
-
-class ParseError(Exception):
- pass
-
-
-class MsvcDemangler:
- # http://www.kegel.com/mangle.html
-
- def __init__(self, symbol):
- self._symbol = symbol
- self._pos = 0
-
- def lookahead(self):
- return self._symbol[self._pos]
-
- def consume(self):
- ret = self.lookahead()
- self._pos += 1
- return ret
-
- def match(self, c):
- if self.lookahead() != c:
- raise ParseError
- self.consume()
-
- def parse(self):
- self.match('?')
- name = self.parse_name()
- qualifications = self.parse_qualifications()
- return '::'.join(qualifications + [name])
-
- def parse_name(self):
- if self.lookahead() == '?':
- return self.consume() + self.consume()
- else:
- name = self.parse_id()
- self.match('@')
- return name
-
- def parse_qualifications(self):
- qualifications = []
- while self.lookahead() != '@':
- name = self.parse_id()
- qualifications.append(name)
- self.match('@')
- return qualifications
-
- def parse_id(self):
- s = ''
- while True:
- c = self.lookahead()
- if c.isalnum() or c in '_':
- s += c
- self.consume()
- else:
- break
- return s
-
-
-def demangle(name):
- if name.startswith('_'):
- name = name[1:]
- idx = name.rfind('@')
- if idx != -1 and name[idx+1:].isdigit():
- name = name[:idx]
- return name
- if name.startswith('?'):
- demangler = MsvcDemangler(name)
- return demangler.parse()
- return name
-
-
-class Reader:
-
- def __init__(self):
- self.symbols = []
- self.symbol_cache = {}
- self.base_addr = None
-
- def read_map(self, mapfile):
- # See http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
- last_addr = 0
- last_name = 0
- for line in file(mapfile, "rt"):
- fields = line.split()
- try:
- section_offset, name, addr, type, lib_object = fields
- except ValueError:
- continue
- if type != 'f':
- continue
- section, offset = section_offset.split(':')
- addr = int(offset, 16)
- self.symbols.append((addr, name))
- last_addr = addr
- last_name = name
-
- # sort symbols
- self.symbols.sort(key = lambda (addr, name): addr)
-
- def lookup_addr(self, addr):
- try:
- return self.symbol_cache[addr]
- except KeyError:
- pass
-
- tolerance = 4196
- s, e = 0, len(self.symbols)
- while s != e:
- i = (s + e)//2
- start_addr, name = self.symbols[i]
- try:
- end_addr, next_name = self.symbols[i + 1]
- except IndexError:
- end_addr = start_addr + tolerance
- if addr < start_addr:
- e = i
- continue
- if addr == end_addr:
- return next_name, addr - start_addr
- if addr > end_addr:
- s = i
- continue
- return name, addr - start_addr
- raise ValueError
-
- def lookup_symbol(self, name):
- for symbol_addr, symbol_name in self.symbols:
- if name == symbol_name:
- return symbol_addr
- return 0
-
- def read_data(self, data):
- profile = Profile()
-
- fp = file(data, "rb")
- entry_format = "IIII"
- entry_size = struct.calcsize(entry_format)
- caller = None
- caller_stack = []
- while True:
- entry = fp.read(entry_size)
- if len(entry) < entry_size:
- break
- caller_addr, callee_addr, samples_lo, samples_hi = struct.unpack(entry_format, entry)
- if caller_addr == 0 and callee_addr == 0:
- continue
-
- if self.base_addr is None:
- ref_addr = self.lookup_symbol('___debug_profile_reference@0')
- if ref_addr:
- self.base_addr = (caller_addr - ref_addr) & ~(options.align - 1)
- else:
- self.base_addr = 0
- sys.stderr.write('Base addr: %08x\n' % self.base_addr)
-
- samples = (samples_hi << 32) | samples_lo
-
- try:
- caller_raddr = caller_addr - self.base_addr
- caller_sym, caller_ofs = self.lookup_addr(caller_raddr)
-
- try:
- caller = profile.functions[caller_sym]
- except KeyError:
- caller_name = demangle(caller_sym)
- caller = Function(caller_sym, caller_name)
- profile.add_function(caller)
- caller[CALLS] = 0
- caller[SAMPLES] = 0
- except ValueError:
- caller = None
-
- if not callee_addr:
- if caller:
- caller[SAMPLES] += samples
- else:
- callee_raddr = callee_addr - self.base_addr
- callee_sym, callee_ofs = self.lookup_addr(callee_raddr)
-
- try:
- callee = profile.functions[callee_sym]
- except KeyError:
- callee_name = demangle(callee_sym)
- callee = Function(callee_sym, callee_name)
- profile.add_function(callee)
- callee[CALLS] = samples
- callee[SAMPLES] = 0
- else:
- callee[CALLS] += samples
-
- if caller is not None:
- try:
- call = caller.calls[callee.id]
- except KeyError:
- call = Call(callee.id)
- call[CALLS] = samples
- caller.add_call(call)
- else:
- call[CALLS] += samples
-
- if options.verbose:
- if not callee_addr:
- sys.stderr.write('%s+%u: %u\n' % (caller_sym, caller_ofs, samples))
- else:
- sys.stderr.write('%s+%u -> %s+%u: %u\n' % (caller_sym, caller_ofs, callee_sym, callee_ofs, samples))
-
- # compute derived data
- profile.validate()
- profile.find_cycles()
- profile.aggregate(SAMPLES)
- profile.ratio(TIME_RATIO, SAMPLES)
- profile.call_ratios(CALLS)
- profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
-
- return profile
-
-
-def main():
- parser = optparse.OptionParser(
- usage="\n\t%prog [options] [file] ...",
- version="%%prog %s" % __version__)
- parser.add_option(
- '-a', '--align', metavar='NUMBER',
- type="int", dest="align", default=16,
- help="section alignment")
- parser.add_option(
- '-m', '--map', metavar='FILE',
- type="string", dest="map",
- help="map file")
- parser.add_option(
- '-b', '--base', metavar='FILE',
- type="string", dest="base",
- help="base addr")
- parser.add_option(
- '-n', '--node-thres', metavar='PERCENTAGE',
- type="float", dest="node_thres", default=0.5,
- help="eliminate nodes below this threshold [default: %default]")
- parser.add_option(
- '-e', '--edge-thres', metavar='PERCENTAGE',
- type="float", dest="edge_thres", default=0.1,
- help="eliminate edges below this threshold [default: %default]")
- parser.add_option(
- '-v', '--verbose',
- action="count",
- dest="verbose", default=0,
- help="verbose output")
-
- global options
- (options, args) = parser.parse_args(sys.argv[1:])
-
- reader = Reader()
- if options.base is not None:
- reader.base_addr = int(options.base, 16)
- if options.map is not None:
- reader.read_map(options.map)
- for arg in args:
- profile = reader.read_data(arg)
- profile.prune(options.node_thres/100.0, options.edge_thres/100.0)
- output = sys.stdout
- dot = DotWriter(output)
- colormap = TEMPERATURE_COLORMAP
- dot.graph(profile, colormap)
-
-
-if __name__ == '__main__':
- main()
-