Merge commit 'origin/gallium-0.1' into gallium-0.2
This commit is contained in:
commit
205e0e3e38
|
@ -119,6 +119,7 @@ __inline double __cdecl atan2(double val)
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
||||||
#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
|
#if _MSC_VER < 1400 && !defined(__cplusplus) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
|
||||||
|
|
||||||
static INLINE float cosf( float f )
|
static INLINE float cosf( float f )
|
||||||
|
@ -161,12 +162,6 @@ static INLINE float logf( float f )
|
||||||
return (float) log( (double) f );
|
return (float) log( (double) f );
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE double log2( double x )
|
|
||||||
{
|
|
||||||
const double invln2 = 1.442695041;
|
|
||||||
return log( x ) * invln2;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Work-around an extra semi-colon in VS 2005 logf definition */
|
/* Work-around an extra semi-colon in VS 2005 logf definition */
|
||||||
#ifdef logf
|
#ifdef logf
|
||||||
|
@ -174,6 +169,13 @@ static INLINE double log2( double x )
|
||||||
#define logf(x) ((float)log((double)(x)))
|
#define logf(x) ((float)log((double)(x)))
|
||||||
#endif /* logf */
|
#endif /* logf */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static INLINE double log2( double x )
|
||||||
|
{
|
||||||
|
const double invln2 = 1.442695041;
|
||||||
|
return log( x ) * invln2;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
|
|
||||||
%include "typemaps.i"
|
%include "typemaps.i"
|
||||||
|
|
||||||
|
%include "cstring.i"
|
||||||
|
|
||||||
%include "carrays.i"
|
%include "carrays.i"
|
||||||
%array_class(unsigned char, ByteArray);
|
%array_class(unsigned char, ByteArray);
|
||||||
%array_class(int, IntArray);
|
%array_class(int, IntArray);
|
||||||
|
|
|
@ -179,7 +179,35 @@ struct st_buffer {
|
||||||
st_buffer_destroy($self);
|
st_buffer_destroy($self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write( const char *STRING, unsigned LENGTH, unsigned offset = 0) {
|
unsigned __len__(void)
|
||||||
|
{
|
||||||
|
assert($self->buffer->refcount);
|
||||||
|
return $self->buffer->size;
|
||||||
|
}
|
||||||
|
|
||||||
|
%cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
|
||||||
|
void read(char **STRING, int *LENGTH)
|
||||||
|
{
|
||||||
|
struct pipe_screen *screen = $self->st_dev->screen;
|
||||||
|
const char *map;
|
||||||
|
|
||||||
|
assert($self->buffer->refcount);
|
||||||
|
|
||||||
|
*LENGTH = $self->buffer->size;
|
||||||
|
*STRING = (char *) malloc($self->buffer->size);
|
||||||
|
if(!*STRING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
map = pipe_buffer_map(screen, $self->buffer, PIPE_BUFFER_USAGE_CPU_READ);
|
||||||
|
if(map) {
|
||||||
|
memcpy(*STRING, map, $self->buffer->size);
|
||||||
|
pipe_buffer_unmap(screen, $self->buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%cstring_input_binary(const char *STRING, unsigned LENGTH);
|
||||||
|
void write(const char *STRING, unsigned LENGTH, unsigned offset = 0)
|
||||||
|
{
|
||||||
struct pipe_screen *screen = $self->st_dev->screen;
|
struct pipe_screen *screen = $self->st_dev->screen;
|
||||||
char *map;
|
char *map;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
#!/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.
|
||||||
|
#
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
|
class Formatter:
|
||||||
|
'''Plain formatter'''
|
||||||
|
|
||||||
|
def __init__(self, stream):
|
||||||
|
self.stream = stream
|
||||||
|
|
||||||
|
def text(self, text):
|
||||||
|
self.stream.write(text)
|
||||||
|
|
||||||
|
def newline(self):
|
||||||
|
self.text('\n')
|
||||||
|
|
||||||
|
def function(self, name):
|
||||||
|
self.text(name)
|
||||||
|
|
||||||
|
def variable(self, name):
|
||||||
|
self.text(name)
|
||||||
|
|
||||||
|
def literal(self, value):
|
||||||
|
self.text(str(value))
|
||||||
|
|
||||||
|
def address(self, addr):
|
||||||
|
self.text(str(addr))
|
||||||
|
|
||||||
|
|
||||||
|
class AnsiFormatter(Formatter):
|
||||||
|
'''Formatter for plain-text files which outputs ANSI escape codes. See
|
||||||
|
http://en.wikipedia.org/wiki/ANSI_escape_code for more information
|
||||||
|
concerning ANSI escape codes.
|
||||||
|
'''
|
||||||
|
|
||||||
|
_csi = '\33['
|
||||||
|
|
||||||
|
_normal = '0m'
|
||||||
|
_bold = '1m'
|
||||||
|
_italic = '3m'
|
||||||
|
_red = '31m'
|
||||||
|
_green = '32m'
|
||||||
|
_blue = '34m'
|
||||||
|
|
||||||
|
def _escape(self, code):
|
||||||
|
self.text(self._csi + code)
|
||||||
|
|
||||||
|
def function(self, name):
|
||||||
|
self._escape(self._bold)
|
||||||
|
Formatter.function(self, name)
|
||||||
|
self._escape(self._normal)
|
||||||
|
|
||||||
|
def variable(self, name):
|
||||||
|
self._escape(self._italic)
|
||||||
|
Formatter.variable(self, name)
|
||||||
|
self._escape(self._normal)
|
||||||
|
|
||||||
|
def literal(self, value):
|
||||||
|
self._escape(self._blue)
|
||||||
|
Formatter.literal(self, value)
|
||||||
|
self._escape(self._normal)
|
||||||
|
|
||||||
|
def address(self, value):
|
||||||
|
self._escape(self._green)
|
||||||
|
Formatter.address(self, value)
|
||||||
|
self._escape(self._normal)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def DefaultFormatter(stream):
|
||||||
|
if stream.isatty():
|
||||||
|
return AnsiFormatter(stream)
|
||||||
|
else:
|
||||||
|
return Formatter(stream)
|
||||||
|
|
|
@ -1,25 +1,35 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#############################################################################
|
##########################################################################
|
||||||
#
|
#
|
||||||
# Copyright 2008 Tungsten Graphics, Inc.
|
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
# under the terms of the GNU Lesser General Public License as published
|
# copy of this software and associated documentation files (the
|
||||||
# by the Free Software Foundation, either version 3 of the License, or
|
# "Software"), to deal in the Software without restriction, including
|
||||||
# (at your option) any later version.
|
# 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:
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# The above copyright notice and this permission notice (including the
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# next paragraph) shall be included in all copies or substantial portions
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# of the Software.
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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 sys
|
||||||
|
import struct
|
||||||
|
|
||||||
import gallium
|
import gallium
|
||||||
import model
|
import model
|
||||||
import parser
|
import parser
|
||||||
|
@ -198,7 +208,8 @@ class Winsys(Object):
|
||||||
4,
|
4,
|
||||||
gallium.PIPE_BUFFER_USAGE_CPU_READ |
|
gallium.PIPE_BUFFER_USAGE_CPU_READ |
|
||||||
gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
|
gallium.PIPE_BUFFER_USAGE_CPU_WRITE )
|
||||||
buffer.write(data, size)
|
assert size == len(data)
|
||||||
|
buffer.write(data)
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
def buffer_create(self, alignment, usage, size):
|
def buffer_create(self, alignment, usage, size):
|
||||||
|
@ -208,7 +219,8 @@ class Winsys(Object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def buffer_write(self, buffer, data, size):
|
def buffer_write(self, buffer, data, size):
|
||||||
buffer.write(data, size)
|
assert size == len(data)
|
||||||
|
buffer.write(data)
|
||||||
|
|
||||||
def fence_finish(self, fence, flags):
|
def fence_finish(self, fence, flags):
|
||||||
pass
|
pass
|
||||||
|
@ -361,6 +373,15 @@ class Context(Object):
|
||||||
if state is not None:
|
if state is not None:
|
||||||
self.real.set_constant_buffer(shader, index, state.buffer)
|
self.real.set_constant_buffer(shader, index, state.buffer)
|
||||||
|
|
||||||
|
if 1:
|
||||||
|
data = state.buffer.read()
|
||||||
|
format = '4f'
|
||||||
|
index = 0
|
||||||
|
for offset in range(0, len(data), struct.calcsize(format)):
|
||||||
|
x, y, z, w = struct.unpack_from(format, data, offset)
|
||||||
|
sys.stdout.write('\tCONST[%2u] = {%10.4f, %10.4f, %10.4f, %10.4f}\n' % (index, x, y, z, w))
|
||||||
|
index += 1
|
||||||
|
|
||||||
def set_framebuffer_state(self, state):
|
def set_framebuffer_state(self, state):
|
||||||
_state = gallium.Framebuffer()
|
_state = gallium.Framebuffer()
|
||||||
_state.width = state.width
|
_state.width = state.width
|
||||||
|
@ -432,10 +453,16 @@ class Context(Object):
|
||||||
show_image(self.cbufs[0])
|
show_image(self.cbufs[0])
|
||||||
|
|
||||||
|
|
||||||
class Interpreter(parser.TraceParser):
|
class Interpreter(parser.TraceDumper):
|
||||||
|
|
||||||
|
ignore_calls = set((
|
||||||
|
('pipe_screen', 'is_format_supported'),
|
||||||
|
('pipe_screen', 'get_param'),
|
||||||
|
('pipe_screen', 'get_paramf'),
|
||||||
|
))
|
||||||
|
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
parser.TraceParser.__init__(self, stream)
|
parser.TraceDumper.__init__(self, stream)
|
||||||
self.objects = {}
|
self.objects = {}
|
||||||
self.result = None
|
self.result = None
|
||||||
self.globl = Global(self, None)
|
self.globl = Global(self, None)
|
||||||
|
@ -455,7 +482,11 @@ class Interpreter(parser.TraceParser):
|
||||||
self.interpret_call(call)
|
self.interpret_call(call)
|
||||||
|
|
||||||
def handle_call(self, call):
|
def handle_call(self, call):
|
||||||
sys.stderr.write("%s\n" % call)
|
|
||||||
|
if (call.klass, call.method) in self.ignore_calls:
|
||||||
|
return
|
||||||
|
|
||||||
|
parser.TraceDumper.handle_call(self, call)
|
||||||
|
|
||||||
args = [self.interpret_arg(arg) for name, arg in call.args]
|
args = [self.interpret_arg(arg) for name, arg in call.args]
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,57 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#############################################################################
|
##########################################################################
|
||||||
#
|
#
|
||||||
# Copyright 2008 Tungsten Graphics, Inc.
|
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
# under the terms of the GNU Lesser General Public License as published
|
# copy of this software and associated documentation files (the
|
||||||
# by the Free Software Foundation, either version 3 of the License, or
|
# "Software"), to deal in the Software without restriction, including
|
||||||
# (at your option) any later version.
|
# 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:
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# The above copyright notice and this permission notice (including the
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# next paragraph) shall be included in all copies or substantial portions
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# of the Software.
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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.
|
||||||
#
|
#
|
||||||
#############################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
||||||
'''Trace data model.'''
|
'''Trace data model.'''
|
||||||
|
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import string
|
||||||
|
import format
|
||||||
|
|
||||||
|
try:
|
||||||
|
from cStringIO import StringIO
|
||||||
|
except ImportError:
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
|
|
||||||
class Node:
|
class Node:
|
||||||
|
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
stream = StringIO()
|
||||||
|
formatter = format.DefaultFormatter(stream)
|
||||||
|
pretty_printer = PrettyPrinter(formatter)
|
||||||
|
self.visit(pretty_printer)
|
||||||
|
return stream.getvalue()
|
||||||
|
|
||||||
|
|
||||||
class Literal(Node):
|
class Literal(Node):
|
||||||
|
|
||||||
|
@ -36,12 +61,6 @@ class Literal(Node):
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_literal(self)
|
visitor.visit_literal(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
if isinstance(self.value, str) and len(self.value) > 32:
|
|
||||||
return '...'
|
|
||||||
else:
|
|
||||||
return repr(self.value)
|
|
||||||
|
|
||||||
|
|
||||||
class NamedConstant(Node):
|
class NamedConstant(Node):
|
||||||
|
|
||||||
|
@ -51,9 +70,6 @@ class NamedConstant(Node):
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_named_constant(self)
|
visitor.visit_named_constant(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class Array(Node):
|
class Array(Node):
|
||||||
|
|
||||||
|
@ -63,9 +79,6 @@ class Array(Node):
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_array(self)
|
visitor.visit_array(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '{' + ', '.join([str(value) for value in self.elements]) + '}'
|
|
||||||
|
|
||||||
|
|
||||||
class Struct(Node):
|
class Struct(Node):
|
||||||
|
|
||||||
|
@ -76,9 +89,6 @@ class Struct(Node):
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_struct(self)
|
visitor.visit_struct(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '{' + ', '.join([name + ' = ' + str(value) for name, value in self.members]) + '}'
|
|
||||||
|
|
||||||
|
|
||||||
class Pointer(Node):
|
class Pointer(Node):
|
||||||
|
|
||||||
|
@ -88,9 +98,6 @@ class Pointer(Node):
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_pointer(self)
|
visitor.visit_pointer(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.address
|
|
||||||
|
|
||||||
|
|
||||||
class Call:
|
class Call:
|
||||||
|
|
||||||
|
@ -103,15 +110,6 @@ class Call:
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_call(self)
|
visitor.visit_call(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
s = self.method
|
|
||||||
if self.klass:
|
|
||||||
s = self.klass + '::' + s
|
|
||||||
s += '(' + ', '.join([name + ' = ' + str(value) for name, value in self.args]) + ')'
|
|
||||||
if self.ret is not None:
|
|
||||||
s += ' = ' + str(self.ret)
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
class Trace:
|
class Trace:
|
||||||
|
|
||||||
|
@ -121,9 +119,6 @@ class Trace:
|
||||||
def visit(self, visitor):
|
def visit(self, visitor):
|
||||||
visitor.visit_trace(self)
|
visitor.visit_trace(self)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return '\n'.join([str(call) for call in self.calls])
|
|
||||||
|
|
||||||
|
|
||||||
class Visitor:
|
class Visitor:
|
||||||
|
|
||||||
|
@ -149,3 +144,68 @@ class Visitor:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
class PrettyPrinter:
|
||||||
|
|
||||||
|
def __init__(self, formatter):
|
||||||
|
self.formatter = formatter
|
||||||
|
|
||||||
|
def visit_literal(self, node):
|
||||||
|
if isinstance(node.value, basestring):
|
||||||
|
if len(node.value) >= 4096 or node.value.strip(string.printable):
|
||||||
|
self.formatter.text('...')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.formatter.literal('"' + node.value + '"')
|
||||||
|
return
|
||||||
|
|
||||||
|
self.formatter.literal(repr(node.value))
|
||||||
|
|
||||||
|
def visit_named_constant(self, node):
|
||||||
|
self.formatter.literal(node.name)
|
||||||
|
|
||||||
|
def visit_array(self, node):
|
||||||
|
self.formatter.text('{')
|
||||||
|
sep = ''
|
||||||
|
for value in node.elements:
|
||||||
|
self.formatter.text(sep)
|
||||||
|
value.visit(self)
|
||||||
|
sep = ', '
|
||||||
|
self.formatter.text('}')
|
||||||
|
|
||||||
|
def visit_struct(self, node):
|
||||||
|
self.formatter.text('{')
|
||||||
|
sep = ''
|
||||||
|
for name, value in node.members:
|
||||||
|
self.formatter.text(sep)
|
||||||
|
self.formatter.variable(name)
|
||||||
|
self.formatter.text(' = ')
|
||||||
|
value.visit(self)
|
||||||
|
sep = ', '
|
||||||
|
self.formatter.text('}')
|
||||||
|
|
||||||
|
def visit_pointer(self, node):
|
||||||
|
self.formatter.address(node.address)
|
||||||
|
|
||||||
|
def visit_call(self, node):
|
||||||
|
if node.klass is not None:
|
||||||
|
self.formatter.function(node.klass + '::' + node.method)
|
||||||
|
else:
|
||||||
|
self.formatter.function(node.method)
|
||||||
|
self.formatter.text('(')
|
||||||
|
sep = ''
|
||||||
|
for name, value in node.args:
|
||||||
|
self.formatter.text(sep)
|
||||||
|
self.formatter.variable(name)
|
||||||
|
self.formatter.text(' = ')
|
||||||
|
value.visit(self)
|
||||||
|
sep = ', '
|
||||||
|
self.formatter.text(')')
|
||||||
|
if node.ret is not None:
|
||||||
|
self.formatter.text(' = ')
|
||||||
|
node.ret.visit(self)
|
||||||
|
|
||||||
|
def visit_trace(self, node):
|
||||||
|
for call in node.calls:
|
||||||
|
call.visit(self)
|
||||||
|
self.formatter.newline()
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#############################################################################
|
##########################################################################
|
||||||
#
|
#
|
||||||
# Copyright 2008 Tungsten Graphics, Inc.
|
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
# All Rights Reserved.
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
# under the terms of the GNU Lesser General Public License as published
|
# copy of this software and associated documentation files (the
|
||||||
# by the Free Software Foundation, either version 3 of the License, or
|
# "Software"), to deal in the Software without restriction, including
|
||||||
# (at your option) any later version.
|
# 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:
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# The above copyright notice and this permission notice (including the
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# next paragraph) shall be included in all copies or substantial portions
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# of the Software.
|
||||||
# GNU Lesser General Public License for more details.
|
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# 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 sys
|
||||||
|
@ -319,15 +327,19 @@ class TraceParser(XmlParser):
|
||||||
return Pointer(address)
|
return Pointer(address)
|
||||||
|
|
||||||
def handle_call(self, call):
|
def handle_call(self, call):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TraceDumper(TraceParser):
|
class TraceDumper(TraceParser):
|
||||||
|
|
||||||
|
def __init__(self, fp):
|
||||||
|
TraceParser.__init__(self, fp)
|
||||||
|
self.formatter = format.DefaultFormatter(sys.stdout)
|
||||||
|
self.pretty_printer = PrettyPrinter(self.formatter)
|
||||||
|
|
||||||
def handle_call(self, call):
|
def handle_call(self, call):
|
||||||
print call
|
call.visit(self.pretty_printer)
|
||||||
|
self.formatter.newline()
|
||||||
|
|
||||||
|
|
||||||
def main(ParserFactory):
|
def main(ParserFactory):
|
||||||
|
|
Loading…
Reference in New Issue