forked from mirrors/linux
		
	bug: Factor out a getter for a bug's file line
There is some non-trivial config-based logic to get the file name and line number associated with a bug. Factor this out to a getter that can be resused. Signed-off-by: Andrew Scull <ascull@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210318143311.839894-3-ascull@google.com
This commit is contained in:
		
							parent
							
								
									3ad1a6cb0a
								
							
						
					
					
						commit
						26dbc7e299
					
				
					 2 changed files with 20 additions and 10 deletions
				
			
		| 
						 | 
					@ -36,6 +36,9 @@ static inline int is_warning_bug(const struct bug_entry *bug)
 | 
				
			||||||
	return bug->flags & BUGFLAG_WARNING;
 | 
						return bug->flags & BUGFLAG_WARNING;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void bug_get_file_line(struct bug_entry *bug, const char **file,
 | 
				
			||||||
 | 
							       unsigned int *line);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct bug_entry *find_bug(unsigned long bugaddr);
 | 
					struct bug_entry *find_bug(unsigned long bugaddr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
 | 
					enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										27
									
								
								lib/bug.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								lib/bug.c
									
									
									
									
									
								
							| 
						 | 
					@ -127,6 +127,22 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void bug_get_file_line(struct bug_entry *bug, const char **file,
 | 
				
			||||||
 | 
							       unsigned int *line)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						*file = NULL;
 | 
				
			||||||
 | 
						*line = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef CONFIG_DEBUG_BUGVERBOSE
 | 
				
			||||||
 | 
					#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
 | 
				
			||||||
 | 
						*file = bug->file;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						*file = (const char *)bug + bug->file_disp;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						*line = bug->line;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct bug_entry *find_bug(unsigned long bugaddr)
 | 
					struct bug_entry *find_bug(unsigned long bugaddr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct bug_entry *bug;
 | 
						struct bug_entry *bug;
 | 
				
			||||||
| 
						 | 
					@ -153,17 +169,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	disable_trace_on_warning();
 | 
						disable_trace_on_warning();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	file = NULL;
 | 
						bug_get_file_line(bug, &file, &line);
 | 
				
			||||||
	line = 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_DEBUG_BUGVERBOSE
 | 
					 | 
				
			||||||
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
 | 
					 | 
				
			||||||
	file = bug->file;
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	file = (const char *)bug + bug->file_disp;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	line = bug->line;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	warning = (bug->flags & BUGFLAG_WARNING) != 0;
 | 
						warning = (bug->flags & BUGFLAG_WARNING) != 0;
 | 
				
			||||||
	once = (bug->flags & BUGFLAG_ONCE) != 0;
 | 
						once = (bug->flags & BUGFLAG_ONCE) != 0;
 | 
				
			||||||
	done = (bug->flags & BUGFLAG_DONE) != 0;
 | 
						done = (bug->flags & BUGFLAG_DONE) != 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue