shell:
grep -Inr --color "XXX" --include="*.c" . 2>/dev/null # Grep specific and just show c file
============================
vim tool:
:%! perl -pne '$random=int(rand 10000000000); s/XYZ123/$random/' # For replace XYZ123 to random number
%s/.*pattern.*//ec # For delete whole line when search specific pattern
============================
kernel Space :
#define DPRINTK(format,args…) if (debug) printk(format,##args)
printk (KERN_ERR "GOGO - Debug - dbridge_main.c - function name - XYZ123 \n");
============================
User Space :
fprintf(stderr,"GOGO - Debug - C code name - function name - XYZ123 \n");
static bool verbose = 1;
#define dbg_print(fmt, args...) do { if (verbose) fprintf(stdout, "%s " fmt, __func__, ##args); } while(0)
#define print_err(fmt, args...) do { if (verbose) fprintf(stderr, "Error: %s " fmt, __func__, ##args); } while(0)
void error(char *msg)
{
perror(msg);
exit(1);
}
Reference:
- Linux/Documentation/printk-formats.txt
- [VIM] Substitute a debug message with random number
- Use argdo with search pattern to delete line while suppressing errors and requiring confirmation in Vim
0 意見:
張貼留言