mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	tracing/eprobes: Fix reading of string fields
Currently when an event probe (eprobe) hooks to a string field, it does
not display it as a string, but instead as a number. This makes the field
rather useless. Handle the different kinds of strings, dynamic, static,
relational/dynamic etc.
Now when a string field is used, the ":string" type can be used to display
it:
  echo "e:sw sched/sched_switch comm=$next_comm:string" > dynamic_events
Link: https://lkml.kernel.org/r/20220820134400.959640191@goodmis.org
Cc: stable@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Cc: Tom Zanussi <zanussi@kernel.org>
Fixes: 7491e2c442 ("tracing: Add a probe that attaches to trace events")
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
			
			
This commit is contained in:
		
							parent
							
								
									02333de90e
								
							
						
					
					
						commit
						f04dec9346
					
				
					 1 changed files with 21 additions and 0 deletions
				
			
		| 
						 | 
					@ -311,6 +311,27 @@ static unsigned long get_event_field(struct fetch_insn *code, void *rec)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	addr = rec + field->offset;
 | 
						addr = rec + field->offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (is_string_field(field)) {
 | 
				
			||||||
 | 
							switch (field->filter_type) {
 | 
				
			||||||
 | 
							case FILTER_DYN_STRING:
 | 
				
			||||||
 | 
								val = (unsigned long)(rec + (*(unsigned int *)addr & 0xffff));
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case FILTER_RDYN_STRING:
 | 
				
			||||||
 | 
								val = (unsigned long)(addr + (*(unsigned int *)addr & 0xffff));
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case FILTER_STATIC_STRING:
 | 
				
			||||||
 | 
								val = (unsigned long)addr;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case FILTER_PTR_STRING:
 | 
				
			||||||
 | 
								val = (unsigned long)(*(char *)addr);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								WARN_ON_ONCE(1);
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return val;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (field->size) {
 | 
						switch (field->size) {
 | 
				
			||||||
	case 1:
 | 
						case 1:
 | 
				
			||||||
		if (field->is_signed)
 | 
							if (field->is_signed)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue