Path: blob/21.2-virgl/src/gallium/auxiliary/driver_trace/tr_dump.h
4565 views
/**************************************************************************1*2* Copyright 2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/**28* @file29* Trace data dumping primitives.30*/3132#ifndef TR_DUMP_H33#define TR_DUMP_H343536#include "pipe/p_compiler.h"37#include "pipe/p_format.h"3839struct pipe_resource;40struct pipe_surface;41struct pipe_transfer;42struct pipe_box;4344/*45* Low level dumping controls.46*47* Opening the trace file and checking if that is opened.48*/49bool trace_dump_trace_begin(void);50bool trace_dump_trace_enabled(void);51void trace_dump_trace_flush(void);5253/*54* Lock and unlock the call mutex.55*56* It used by the none locked version of dumping control57* and begin/end call dump functions.58*59* Begin takes the lock while end unlocks it. Use the _locked60* version to avoid locking/unlocking it.61*/62void trace_dump_call_lock(void);63void trace_dump_call_unlock(void);6465/*66* High level dumping control.67*/68void trace_dumping_start_locked(void);69void trace_dumping_stop_locked(void);70bool trace_dumping_enabled_locked(void);71void trace_dumping_start(void);72void trace_dumping_stop(void);73bool trace_dumping_enabled(void);7475void trace_dump_call_begin_locked(const char *klass, const char *method);76void trace_dump_call_end_locked(void);77void trace_dump_call_begin(const char *klass, const char *method);78void trace_dump_call_end(void);7980void trace_dump_arg_begin(const char *name);81void trace_dump_arg_end(void);82void trace_dump_ret_begin(void);83void trace_dump_ret_end(void);84void trace_dump_bool(int value);85void trace_dump_int(long long int value);86void trace_dump_uint(long long unsigned value);87void trace_dump_float(double value);88void trace_dump_bytes(const void *data, size_t size);89void trace_dump_box_bytes(const void *data,90struct pipe_resource *resource,91const struct pipe_box *box,92unsigned stride,93unsigned slice_stride);94void trace_dump_string(const char *str);95void trace_dump_enum(const char *value);96void trace_dump_array_begin(void);97void trace_dump_array_end(void);98void trace_dump_elem_begin(void);99void trace_dump_elem_end(void);100void trace_dump_struct_begin(const char *name);101void trace_dump_struct_end(void);102void trace_dump_member_begin(const char *name);103void trace_dump_member_end(void);104void trace_dump_null(void);105void trace_dump_ptr(const void *value);106/* will turn a wrapped object into the real one and dump ptr */107void trace_dump_surface_ptr(struct pipe_surface *_surface);108void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);109110void trace_dump_trigger_active(bool active);111void trace_dump_check_trigger(void);112bool trace_dump_is_triggered(void);113114/*115* Code saving macros.116*/117118#define trace_dump_arg(_type, _arg) \119do { \120trace_dump_arg_begin(#_arg); \121trace_dump_##_type(_arg); \122trace_dump_arg_end(); \123} while(0)124125#define trace_dump_arg_struct(_type, _arg) \126do { \127trace_dump_arg_begin(#_arg); \128trace_dump_##_type(&_arg); \129trace_dump_arg_end(); \130} while(0)131132#define trace_dump_ret(_type, _arg) \133do { \134trace_dump_ret_begin(); \135trace_dump_##_type(_arg); \136trace_dump_ret_end(); \137} while(0)138139#define trace_dump_array(_type, _obj, _size) \140do { \141if (_obj) { \142size_t idx; \143trace_dump_array_begin(); \144for(idx = 0; idx < (_size); ++idx) { \145trace_dump_elem_begin(); \146trace_dump_##_type((_obj)[idx]); \147trace_dump_elem_end(); \148} \149trace_dump_array_end(); \150} else { \151trace_dump_null(); \152} \153} while(0)154155#define trace_dump_struct_array(_type, _obj, _size) \156do { \157if (_obj) { \158size_t idx; \159trace_dump_array_begin(); \160for(idx = 0; idx < (_size); ++idx) { \161trace_dump_elem_begin(); \162trace_dump_##_type(&(_obj)[idx]); \163trace_dump_elem_end(); \164} \165trace_dump_array_end(); \166} else { \167trace_dump_null(); \168} \169} while(0)170171#define trace_dump_member(_type, _obj, _member) \172do { \173trace_dump_member_begin(#_member); \174trace_dump_##_type((_obj)->_member); \175trace_dump_member_end(); \176} while(0)177178#define trace_dump_arg_array(_type, _arg, _size) \179do { \180trace_dump_arg_begin(#_arg); \181trace_dump_array(_type, _arg, _size); \182trace_dump_arg_end(); \183} while(0)184185#define trace_dump_member_array(_type, _obj, _member) \186do { \187trace_dump_member_begin(#_member); \188trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \189trace_dump_member_end(); \190} while(0)191192193#endif /* TR_DUMP_H */194195196