| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  | # -*- coding: utf-8 -*- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2014-02-23 20:37:30 +01:00
										 |  |  | trace/generated-ust-provider.h | 
					
						
							| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | __author__     = "Mohamad Gebai <mohamad.gebai@polymtl.ca>" | 
					
						
							|  |  |  | __copyright__  = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>" | 
					
						
							|  |  |  | __license__    = "GPL version 2 or (at your option) any later version" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | __maintainer__ = "Stefan Hajnoczi" | 
					
						
							|  |  |  | __email__      = "stefanha@redhat.com" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from tracetool import out | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-04 14:35:59 +01:00
										 |  |  | def generate(events, backend, group): | 
					
						
							| 
									
										
										
										
											2014-02-23 20:37:40 +01:00
										 |  |  |     events = [e for e in events | 
					
						
							|  |  |  |               if "disabled" not in e.properties] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-25 16:14:15 +00:00
										 |  |  |     if group == "all": | 
					
						
							|  |  |  |         include = "trace-ust-all.h" | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         include = "trace-ust.h" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  |     out('/* This file is autogenerated by tracetool, do not edit. */', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '#undef TRACEPOINT_PROVIDER', | 
					
						
							|  |  |  |         '#define TRACEPOINT_PROVIDER qemu', | 
					
						
							|  |  |  |         '', | 
					
						
							| 
									
										
										
										
											2022-03-28 12:47:13 +04:00
										 |  |  |         '#undef TRACEPOINT_INCLUDE', | 
					
						
							|  |  |  |         '#define TRACEPOINT_INCLUDE "./%s"' % include, | 
					
						
							| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  |         '', | 
					
						
							| 
									
										
										
										
											2016-10-04 14:35:59 +01:00
										 |  |  |         '#if !defined (TRACE_%s_GENERATED_UST_H) || \\'  % group.upper(), | 
					
						
							|  |  |  |         '     defined(TRACEPOINT_HEADER_MULTI_READ)', | 
					
						
							|  |  |  |         '#define TRACE_%s_GENERATED_UST_H' % group.upper(), | 
					
						
							| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  |         '', | 
					
						
							|  |  |  |         '#include <lttng/tracepoint.h>', | 
					
						
							|  |  |  |         '', | 
					
						
							|  |  |  |         '/*', | 
					
						
							|  |  |  |         ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints', | 
					
						
							|  |  |  |         ' * requiring no arguments. We define these macros introduced in more recent' | 
					
						
							|  |  |  |         ' * versions of LTTng ust as a workaround', | 
					
						
							|  |  |  |         ' */', | 
					
						
							|  |  |  |         '#ifndef _TP_EXPROTO1', | 
					
						
							|  |  |  |         '#define _TP_EXPROTO1(a)               void', | 
					
						
							|  |  |  |         '#endif', | 
					
						
							|  |  |  |         '#ifndef _TP_EXDATA_PROTO1', | 
					
						
							|  |  |  |         '#define _TP_EXDATA_PROTO1(a)          void *__tp_data', | 
					
						
							|  |  |  |         '#endif', | 
					
						
							|  |  |  |         '#ifndef _TP_EXDATA_VAR1', | 
					
						
							|  |  |  |         '#define _TP_EXDATA_VAR1(a)            __tp_data', | 
					
						
							|  |  |  |         '#endif', | 
					
						
							|  |  |  |         '#ifndef _TP_EXVAR1', | 
					
						
							|  |  |  |         '#define _TP_EXVAR1(a)', | 
					
						
							|  |  |  |         '#endif', | 
					
						
							|  |  |  |         '') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-23 20:37:40 +01:00
										 |  |  |     for e in events: | 
					
						
							|  |  |  |         if len(e.args) > 0: | 
					
						
							|  |  |  |             out('TRACEPOINT_EVENT(', | 
					
						
							|  |  |  |                 '   qemu,', | 
					
						
							|  |  |  |                 '   %(name)s,', | 
					
						
							|  |  |  |                 '   TP_ARGS(%(args)s),', | 
					
						
							|  |  |  |                 '   TP_FIELDS(', | 
					
						
							|  |  |  |                 name=e.name, | 
					
						
							|  |  |  |                 args=", ".join(", ".join(i) for i in e.args)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-01 17:08:56 +01:00
										 |  |  |             types = e.args.types() | 
					
						
							|  |  |  |             names = e.args.names() | 
					
						
							| 
									
										
										
										
											2014-08-18 15:02:07 +02:00
										 |  |  |             fmts = e.formats() | 
					
						
							| 
									
										
										
										
											2014-08-01 17:08:56 +01:00
										 |  |  |             for t,n,f in zip(types, names, fmts): | 
					
						
							|  |  |  |                 if ('char *' in t) or ('char*' in t): | 
					
						
							|  |  |  |                     out('       ctf_string(' + n + ', ' + n + ')') | 
					
						
							|  |  |  |                 elif ("%p" in f) or ("x" in f) or ("PRIx" in f): | 
					
						
							|  |  |  |                     out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')') | 
					
						
							|  |  |  |                 elif ("ptr" in t) or ("*" in t): | 
					
						
							|  |  |  |                     out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')') | 
					
						
							| 
									
										
										
										
											2018-01-29 05:16:48 +01:00
										 |  |  |                 elif ('int' in t) or ('long' in t) or ('unsigned' in t) \ | 
					
						
							|  |  |  |                         or ('size_t' in t) or ('bool' in t): | 
					
						
							| 
									
										
										
										
											2014-02-23 20:37:40 +01:00
										 |  |  |                     out('       ctf_integer(' + t + ', ' + n + ', ' + n + ')') | 
					
						
							|  |  |  |                 elif ('double' in t) or ('float' in t): | 
					
						
							|  |  |  |                     out('       ctf_float(' + t + ', ' + n + ', ' + n + ')') | 
					
						
							|  |  |  |                 elif ('void *' in t) or ('void*' in t): | 
					
						
							|  |  |  |                     out('       ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             out('   )', | 
					
						
							|  |  |  |                 ')', | 
					
						
							|  |  |  |                 '') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             out('TRACEPOINT_EVENT(', | 
					
						
							|  |  |  |                 '   qemu,', | 
					
						
							|  |  |  |                 '   %(name)s,', | 
					
						
							|  |  |  |                 '   TP_ARGS(void),', | 
					
						
							|  |  |  |                 '   TP_FIELDS()', | 
					
						
							|  |  |  |                 ')', | 
					
						
							|  |  |  |                 '', | 
					
						
							|  |  |  |                 name=e.name) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-04 14:35:59 +01:00
										 |  |  |     out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(), | 
					
						
							| 
									
										
										
										
											2014-01-29 22:47:55 -05:00
										 |  |  |         '', | 
					
						
							|  |  |  |         '/* This part must be outside ifdef protection */', | 
					
						
							|  |  |  |         '#include <lttng/tracepoint-event.h>') |