@@ -75,10 +75,10 @@ def get_flags_val(arg, builder, local_sym_tab):
7575 return arg .value
7676
7777 raise NotImplementedError (
78- "Only simple variable names or integer constants are supported as flags in map helpers." )
78+ "Only var names or int consts are supported as map helpers flags ." )
7979
8080
81- def _simple_string_print (string_value , module , builder , func ):
81+ def simple_string_print (string_value , module , builder , func ):
8282 """Emit code for a simple string print statement."""
8383 fmt_str = string_value + "\n \0 "
8484 fmt_ptr = _create_format_string_global (fmt_str , func , module , builder )
@@ -87,9 +87,9 @@ def _simple_string_print(string_value, module, builder, func):
8787 return args
8888
8989
90- def _handle_fstring_print (joined_str , module , builder , func ,
91- local_sym_tab = None , struct_sym_tab = None ,
92- local_var_metadata = None ):
90+ def handle_fstring_print (joined_str , module , builder , func ,
91+ local_sym_tab = None , struct_sym_tab = None ,
92+ local_var_metadata = None ):
9393 """Handle f-string formatting for bpf_printk emitter."""
9494 fmt_parts = []
9595 exprs = []
@@ -108,12 +108,12 @@ def _handle_fstring_print(joined_str, module, builder, func,
108108 f"Unsupported f-string value type: { type (value )} " )
109109
110110 fmt_str = "" .join (fmt_parts )
111- args = _simple_string_print (fmt_str , module , builder , func )
111+ args = simple_string_print (fmt_str , module , builder , func )
112112
113113 # NOTE: Process expressions (limited to 3 due to BPF constraints)
114114 if len (exprs ) > 3 :
115115 logger .warn (
116- "bpf_printk supports up to 3 arguments , extra arguments will be ignored." )
116+ "bpf_printk supports up to 3 args , extra args will be ignored." )
117117
118118 for expr in exprs [:3 ]:
119119 arg_value = _prepare_expr_args (expr , func , module , builder ,
@@ -150,7 +150,7 @@ def _process_fval(fval, fmt_parts, exprs,
150150 local_var_metadata )
151151 else :
152152 raise NotImplementedError (
153- f"Unsupported formatted value type in f-string: { type (fval .value )} " )
153+ f"Unsupported formatted value in f-string: { type (fval .value )} " )
154154
155155
156156def _process_name_in_fval (name_node , fmt_parts , exprs , local_sym_tab ):
@@ -171,12 +171,12 @@ def _process_attr_in_fval(attr_node, fmt_parts, exprs,
171171
172172 if not local_var_metadata or var_name not in local_var_metadata :
173173 raise ValueError (
174- f"Variable metadata for '{ var_name } ' not found in local variable metadata" )
174+ f"Metadata for '{ var_name } ' not found in local var metadata" )
175175
176176 var_type = local_var_metadata [var_name ]
177177 if var_type not in struct_sym_tab :
178178 raise ValueError (
179- f"Struct type '{ var_type } ' for variable '{ var_name } ' not found in struct symbol table" )
179+ f"Struct '{ var_type } ' for '{ var_name } ' not in symbol table" )
180180
181181 struct_info = struct_sym_tab [var_type ]
182182 if field_name not in struct_info .fields :
@@ -187,7 +187,7 @@ def _process_attr_in_fval(attr_node, fmt_parts, exprs,
187187 _populate_fval (field_type , attr_node , fmt_parts , exprs )
188188 else :
189189 raise NotImplementedError (
190- "Only simple attribute access on local variables is supported in f-strings." )
190+ "Only simple attribute on local vars is supported in f-strings." )
191191
192192
193193def _populate_fval (ftype , node , fmt_parts , exprs ):
@@ -233,7 +233,7 @@ def _create_format_string_global(fmt_str, func, module, builder):
233233def _prepare_expr_args (expr , func , module , builder ,
234234 local_sym_tab , struct_sym_tab ,
235235 local_var_metadata ):
236- """Evaluate and prepare an expression to be used as an argument for bpf_printk."""
236+ """Evaluate and prepare an expression to use as an arg for bpf_printk."""
237237 print (f"{ ast .dump (expr )} " )
238238 val , _ = eval_expr (func , module , builder , expr ,
239239 local_sym_tab , None , struct_sym_tab ,
@@ -247,17 +247,19 @@ def _prepare_expr_args(expr, func, module, builder,
247247 val = builder .sext (val , ir .IntType (64 ))
248248 else :
249249 logger .warn (
250- "Only int and ptr supported in bpf_printk arguments. Others default to 0." )
250+ "Only int and ptr supported in bpf_printk args. "
251+ "Others default to 0." )
251252 val = ir .Constant (ir .IntType (64 ), 0 )
252253 return val
253254 else :
254255 logger .warn (
255- "Failed to evaluate expression for bpf_printk argument. It will be converted to 0." )
256+ "Failed to evaluate expression for bpf_printk argument. "
257+ "It will be converted to 0." )
256258 return ir .Constant (ir .IntType (64 ), 0 )
257259
258260
259- def _get_data_ptr_and_size (data_arg , local_sym_tab , struct_sym_tab ,
260- local_var_metadata ):
261+ def get_data_ptr_and_size (data_arg , local_sym_tab , struct_sym_tab ,
262+ local_var_metadata ):
261263 """Extract data pointer and size information for perf event output."""
262264 if isinstance (data_arg , ast .Name ):
263265 data_name = data_arg .id
@@ -276,10 +278,12 @@ def _get_data_ptr_and_size(data_arg, local_sym_tab, struct_sym_tab,
276278 return data_ptr , size_val
277279 else :
278280 raise ValueError (
279- f"Struct type { data_type } for variable { data_name } not found in struct symbol table." )
281+ f"Struct { data_type } for { data_name } not in symbol table." )
280282 else :
281283 raise ValueError (
282- f"Metadata for variable { data_name } not found in local variable metadata." )
284+ f"Metadata for variable { data_name } "
285+ "not found in local variable metadata." )
283286 else :
284287 raise NotImplementedError (
285- "Only simple object names are supported as data in perf event output." )
288+ "Only simple object names are supported "
289+ "as data in perf event output." )
0 commit comments