/usr/share/gfxboot/bin/trace_context is in gfxboot-dev 4.5.2-1.1-5build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116  | #! /usr/bin/perl
#
# trace 16/32 bit context switches and warn if we messed things up
#
use Getopt::Long;
$opt_verbose = 0;
GetOptions(
  'verbose|v' => \$opt_verbose
);
$ctx = 16;
$line = 0;
$err = 0;
while(<>) {
  chomp;
  $line++;
  $macro = 1 if /^\s*%macro/;
  $macro = 0 if /^\s*%endmacro/;
  s/\s*;.*$//;
  $_ = "" if $macro || /^\s*%endmacro/;
  push @line, [ $ctx, $_, $line ];
  $ctx_cnt{$ctx}++;
  if(!$macro) {
    if(/^\s*(\S+):/) {
      $label{$1}{ctx} = $ctx;
      $label{$1}{line} = $line;
    }
    $ctx = $2 if /^\s*(switch_to_)?bits\s+(16|32)\s*$/;
    $ctx = 32 if /^\s*pm_enter\s*$/;
    $ctx = 16 if /^\s*pm_leave\s*$/;
    $ctx = 32 if /^\s*gfx_enter\s*$/;
    $ctx = 16 if /^\s*gfx_leave\s*$/;
  }
}
$macro = 0;
for $l (@line) {
  $_ = $l->[1];
  if(/^\s*(\S+:)?\s*(call|j[a-z]+)(\s+far)?\s+(\S+)/) {
    $op = $2;
    $dst = $4;
    next if $dst eq '$';
    if($label{$dst}) {
      if($label{$dst}{ctx} != $l->[0]) {
        printf "%5d: wrong context (%d -> %d): %s\n", $l->[2], $l->[0], $label{$dst}{ctx}, $_;
        $err = 1;
      }
    }
    else {
      printf "%5d: no target: %s\n", $l->[2], $_ if $opt_verbose;
    }
    next;
  }
  if(/^\s*(\S+:)?\s*([rp]m32_call)\s+(\S+)/) {
    $op = $2;
    $dst = $3;
    ($c0, $c1) = $op eq 'pm32_call' ? (16, 32) : (32, 16);
    if($label{$dst}) {
      if($label{$dst}{ctx} != $c1 || $l->[0] != $c0) {
        printf "%5d: wrong context (%d -> %d): %s\n", $l->[2], $l->[0], $label{$dst}{ctx}, $_;
        $err = 1
      }
    }
    else {
      printf "%5d: no target: %s\n", $l->[2], $_ if $opt_verbose;
    }
    next;
  }
  if(/^\s*(\S+:)?\s*(pm_enter|pm_leave)\s*$/) {
    $op = $2;
    $c = $op eq 'pm_enter' ? 16 : 32;
    if($l->[0] != $c) {
      printf "%5d: wrong context (%d): %s\n", $l->[2], $l->[0], $_;
      $err = 1
    }
    next;
  }
}
for (sort keys %label) {
  if(/^prim_/ && $label{$_}{ctx} != 32) {
    printf "%s: wrong context (16)\n", $_;
    $err = 1;
  }
}
printf "  32 bit: %d (of %d)\n", $ctx_cnt{32}, scalar(@line);
exit $err;
 |