SHARE
TWEET

Untitled

a guest Nov 15th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/gawk -f
  2.  
  3. # Prepare file list
  4. $1 ~ /[0-9]+/ {
  5.    pid = $1
  6.    fname = "/proc/" pid "/stack";
  7.    stack_level = 0
  8.    # Read file and count stack depth
  9.    getline_ret = getline < fname
  10.    while (getline_ret == 1) {
  11.       getline_ret = getline < fname
  12.       stack_level++
  13.    }
  14.    stack_levels[stack_level] = pid " " stack_levels[stack_level]
  15. }
  16.  
  17. END {
  18.    print "\\documentclass{article}"
  19.    print "\\begin{document}"
  20.    # TODO: add sane latex code
  21.    print "\\begin{tabular}[c]{|r| p{7.5cm}|}"
  22.    print "\\hline"
  23.    print "Stack Level & PIDs \\\\ \\hline"
  24.    for (stack_level in stack_levels) {
  25.       print stack_level " & " stack_levels[stack_level] " \\\\ \\hline"
  26. #      split(stack_levels[stack_level], pids)
  27. #      for (pid in pids) {
  28. #         print "  " pids[pid]
  29. #      }
  30.    }
  31.    print "\\end{tabular}"
  32.    print "\\end{document}"
  33. }
RAW Paste Data
Top