#Colin O'Flynns magic SIG_ tester for the AVR, super-alpha release #released under the GPL and all that good stuff #if you actually using this right now you are clearly crazy BEGIN{print "\n\n"} #Uses preprocessed source code #if line contains a interrupt, get the signal name /([(][(]naked[)][)])|([(][(]interrupt[)][)])|([(][(]signal[)][)])/{ #get the C source file name split(FILENAME, sourcefile, ".") csourcename = (sourcefile[1])(".c") if ($2 !~ /__vector_/){ #grep for the bad interrupt name to find offending line #NOTE: Writes output to a temporary file cause I don't know of a better way to do this printf "grep -nH %s %s > interrupt_temp_name_NEVERNAMEAFILETHIS.out", $2, csourcename | "/bin/sh" close("/bin/sh") #Read the file to get the line information getline fileandline < "interrupt_temp_name_NEVERNAMEAFILETHIS.out" close("interrupt_temp_name_NEVERNAMEAFILETHIS.out") #Check we did find the information... if (match(fileandline, $2) == 0){ #oh crap, that line wasn't found in the C file #grep for the bad interrupt name to find offending line in all .h files in directory now #incase user #define'd interrupt name... I just hope not in a file in another directory :| #NOTE: Writes output to a temporary file cause I don't know of a better way to do this printf "grep -nH %s *.h > interrupt_temp_name_NEVERNAMEAFILETHIS.out", $2, csourcename | "/bin/sh" close("/bin/sh") #Read the file to get the line information getline fileandline < "interrupt_temp_name_NEVERNAMEAFILETHIS.out" close("interrupt_temp_name_NEVERNAMEAFILETHIS.out") #tell the user where the include was from printf "In file probably included from %s:\n", csourcename } #just get the filename and line from the grep output split(fileandline, lineinfo, ":") #tell the user! printf "%s:%s: ERROR: %s is NOT a valid interrupt name for your device\n", lineinfo[1], lineinfo[2], $2 #Delete temp file print "rm -f interrupt_temp_name_NEVERNAMEAFILETHIS.out" | "/bin/sh" close("/bin/sh") } else{ printf "%s: Interrupt %s found OK\n",csourcename ,$2 } } END{print "\n\n"}