1# 2# Copyright (C) 2020 Google, Inc. 3# 4# Permission is hereby granted, free of charge, to any person obtaining a 5# copy of this software and associated documentation files (the "Software"), 6# to deal in the Software without restriction, including without limitation 7# the rights to use, copy, modify, merge, publish, distribute, sublicense, 8# and/or sell copies of the Software, and to permit persons to whom the 9# Software is furnished to do so, subject to the following conditions: 10# 11# The above copyright notice and this permission notice (including the next 12# paragraph) shall be included in all copies or substantial portions of the 13# Software. 14# 15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21# IN THE SOFTWARE. 22# 23 24import argparse 25import sys 26 27# 28# TODO can we do this with less boilerplate? 29# 30parser = argparse.ArgumentParser() 31parser.add_argument('-p', '--import-path', required=True) 32parser.add_argument('-C', '--src') 33parser.add_argument('-H', '--hdr') 34args = parser.parse_args() 35sys.path.insert(0, args.import_path) 36 37 38from u_trace import Header 39from u_trace import Tracepoint 40from u_trace import TracepointArg as Arg 41from u_trace import TracepointArgStruct as ArgStruct 42from u_trace import utrace_generate 43 44# 45# Tracepoint definitions: 46# 47 48Header('pipe/p_state.h') 49Header('util/format/u_format.h') 50 51Tracepoint('surface', 52 args=[ArgStruct(type='const struct pipe_surface *', var='psurf')], 53 tp_struct=[Arg(type='uint16_t', name='width', var='psurf->width', c_format='%u'), 54 Arg(type='uint16_t', name='height', var='psurf->height', c_format='%u'), 55 Arg(type='uint8_t', name='nr_samples', var='psurf->nr_samples', c_format='%u'), 56 Arg(type='const char *', name='format', var='util_format_short_name(psurf->format)', c_format='%s')], 57 tp_print=['%ux%u@%u, fmt=%s', 58 '__entry->width', 59 '__entry->height', 60 '__entry->nr_samples', 61 '__entry->format'], 62) 63 64# Note: called internally from trace_framebuffer_state() 65Tracepoint('framebuffer', 66 args=[ArgStruct(type='const struct pipe_framebuffer_state *', var='pfb')], 67 tp_struct=[Arg(type='uint16_t', name='width', var='pfb->width', c_format='%u'), 68 Arg(type='uint16_t', name='height', var='pfb->height', c_format='%u'), 69 Arg(type='uint8_t', name='layers', var='pfb->layers', c_format='%u'), 70 Arg(type='uint8_t', name='samples', var='pfb->samples', c_format='%u'), 71 Arg(type='uint8_t', name='nr_cbufs', var='pfb->nr_cbufs', c_format='%u')], 72 tp_print=['%ux%ux%u@%u, nr_cbufs: %u', 73 '__entry->width', 74 '__entry->height', 75 '__entry->layers', 76 '__entry->samples', 77 '__entry->nr_cbufs'], 78) 79 80Tracepoint('grid_info', 81 args=[ArgStruct(type='const struct pipe_grid_info *', var='pgrid')], 82 tp_struct=[Arg(type='uint8_t', name='work_dim', var='pgrid->work_dim', c_format='%u'), 83 Arg(type='uint16_t', name='block_x', var='pgrid->block[0]', c_format='%u'), 84 Arg(type='uint16_t', name='block_y', var='pgrid->block[1]', c_format='%u'), 85 Arg(type='uint16_t', name='block_z', var='pgrid->block[2]', c_format='%u'), 86 Arg(type='uint16_t', name='grid_x', var='pgrid->grid[0]', c_format='%u'), 87 Arg(type='uint16_t', name='grid_y', var='pgrid->grid[1]', c_format='%u'), 88 Arg(type='uint16_t', name='grid_z', var='pgrid->grid[2]', c_format='%u')], 89 tp_print=['work_dim=%u, block=%ux%ux%u, grid=%ux%ux%u', '__entry->work_dim', 90 '__entry->block_x', '__entry->block_y', '__entry->block_z', 91 '__entry->grid_x', '__entry->grid_y', '__entry->grid_z'], 92) 93 94utrace_generate(cpath=args.src, hpath=args.hdr, ctx_param='struct pipe_context *pctx') 95