trace2name.pl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Author James Laird-Wah <james@laird-wah.net>
  2. # This is free and unencumbered software released into the public domain.
  3. #
  4. # Anyone is free to copy, modify, publish, use, compile, sell, or
  5. # distribute this software, either in source code form or as a compiled
  6. # binary, for any purpose, commercial or non-commercial, and by any
  7. # means.
  8. #
  9. # In jurisdictions that recognize copyright laws, the author or authors
  10. # of this software dedicate any and all copyright interest in the
  11. # software to the public domain. We make this dedication for the benefit
  12. # of the public at large and to the detriment of our heirs and
  13. # successors. We intend this dedication to be an overt act of
  14. # relinquishment in perpetuity of all present and future rights to this
  15. # software under copyright law.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21. # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22. # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23. # OTHER DEALINGS IN THE SOFTWARE.
  24. # For more information, please refer to <http://unlicense.org/>
  25. open HDR, '<trace.h';
  26. $next = 0;
  27. $enum = 0;
  28. for (<HDR>) {
  29. chomp;
  30. /^enum trace_event/ || $enum or next;
  31. $enum++;
  32. /}/ && break;
  33. /trace_(\S+)(\s*=\s*(\S+))?\s*,\s*$/ or next;
  34. ($name, $valmatch, $val) = ($1, $2, $3);
  35. $next = hex $val if defined $val;
  36. $names{$next} = $name;
  37. $next++;
  38. }
  39. while (!eof STDIN) {
  40. $ch = ord getc;
  41. if ($ch==1 || $ch==9) {
  42. $data = ord getc;
  43. print "ISR: " if $ch==9;
  44. $name = $names{$data} // sprintf "unk: 0x%X", $data;
  45. print $names{$data}, "\n"
  46. } else {
  47. print "<dropped>\n";
  48. }
  49. }