location-example.txt 8.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Consider compiling test.c, with this content:
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
#include "test.h"

int
main (int argc, char **argv)
{
  int a = PLUS (1,2);
  int b = PLUS (3,4);
  return 0;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...where test.h has this content:
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
extern int foo ();

#define PLUS(A, B) A + B
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


The undocumented -fdump-internal-locations option outputs this information
23 24 25
to stderr, showing what each location_t value means.  Source code
lines are quoted, showing both per-line location_t values and
per-line&column location_t values (written vertically under the
26 27 28 29
corresponding character of source code).

VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
RESERVED LOCATIONS
30
  location_t interval: 0 <= loc < 2
31 32

ORDINARY MAP: 0
33
  location_t interval: 32 <= loc < 64
34 35
  file: test.c
  starting at line: 1
36 37
  column and range bits: 12
  column bits: 7
38
  range bits: 5
39 40
  reason: 0 (LC_ENTER)
  included from location: 0
41 42 43
test.c:  1|loc:   32|#include "test.h"
                    |69269258258148147
                    |46802468024680246
44 45

ORDINARY MAP: 1
46
  location_t interval: 64 <= loc < 96
47 48
  file: <built-in>
  starting at line: 0
49
  column and range bits: 0
50
  column bits: 0
51
  range bits: 0
52 53
  reason: 2 (LC_RENAME)
  included from location: 0
54 55

ORDINARY MAP: 2
56
  location_t interval: 96 <= loc < 128
57 58
  file: <command-line>
  starting at line: 0
59
  column and range bits: 0
60
  column bits: 0
61
  range bits: 0
62 63
  reason: 2 (LC_RENAME)
  included from location: 0
64 65

ORDINARY MAP: 3
66
  location_t interval: 128 <= loc < 250240
67 68
  file: /usr/include/stdc-predef.h
  starting at line: 1
69 70
  column and range bits: 12
  column bits: 7
71
  range bits: 5
72 73
  reason: 0 (LC_ENTER)
  included from location: 127 (in ordinary map 2)
74 75 76
(contents of /usr/include/stdc-predef.h snipped for brevity)

ORDINARY MAP: 4
77
  location_t interval: 250240 <= loc < 250272
78
  file: <command-line>
79
  starting at line: 32
80 81
  column and range bits: 12
  column bits: 7
82
  range bits: 5
83 84
  reason: 1 (LC_LEAVE)
  included from location: 0
85 86

ORDINARY MAP: 5
87
  location_t interval: 250272 <= loc < 254368
88 89
  file: test.c
  starting at line: 1
90 91
  column and range bits: 12
  column bits: 7
92
  range bits: 5
93 94 95 96 97 98 99
  reason: 2 (LC_RENAME)
  included from location: 0
test.c:  1|loc:250272|#include "test.h"
                     |00000000000000000
                     |33344445556667778
                     |03603692692582581
                     |46802468024680246
100 101

ORDINARY MAP: 6
102
  location_t interval: 254368 <= loc < 266720
103 104
  file: test.h
  starting at line: 1
105 106
  column and range bits: 12
  column bits: 7
107
  range bits: 5
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
  reason: 0 (LC_ENTER)
  included from location: 250272 (in ordinary map 5)
test.h:  1|loc:254368|extern int foo ();
                     |444444444444444444
                     |444455566677788899
                     |036926925825814814
                     |024680246802468024
test.h:  2|loc:258464|
                     |
                     |
                     |
                     |
test.h:  3|loc:262560|#define PLUS(A, B) A + B
                     |222222222222233333333333
                     |566677788899900011122223
                     |925825814814704703603692
                     |246802468024680246802468
test.h:  4|loc:266656|
                     |
                     |
                     |
                     |
130 131

ORDINARY MAP: 7
132
  location_t interval: 266720 <= loc < 299520
133 134
  file: test.c
  starting at line: 2
135 136
  column and range bits: 12
  column bits: 7
137
  range bits: 5
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
  reason: 1 (LC_LEAVE)
  included from location: 0
test.c:  2|loc:266720|
                     |
                     |
                     |
                     |
test.c:  3|loc:270816|int
                     |000
                     |889
                     |481
                     |802
test.c:  4|loc:274912|main (int argc, char **argv)
                     |4455555555555555555555555555
                     |9900011122223334445556667778
                     |4704703603692692582581481470
                     |4680246802468024680246802468
test.c:  5|loc:279008|{
                     |9
                     |0
                     |4
                     |0
test.c:  6|loc:283104|  int a = PLUS (1,2);
                     |333333333333333333333
                     |112222333444555666777
                     |360369269258258148147
                     |680246802468024680246
test.c:  7|loc:287200|  int b = PLUS (3,4);
                     |777777777777777777777
                     |222333444555666777888
                     |369269258258148147047
                     |246802468024680246802
test.c:  8|loc:291296|  return 0;
                     |11111111111
                     |33344455566
                     |26925825814
                     |80246802468
test.c:  9|loc:295392|}
                     |5
                     |4
                     |2
                     |4
test.c: 10|loc:299488|
                     |
                     |
                     |
                     |
185 186

UNALLOCATED LOCATIONS
187
  location_t interval: 299520 <= loc < 2147483632
188

189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
MACRO 3: PLUS (7 tokens)
  location_t interval: 2147483632 <= loc < 2147483639
test.c:7:11: note: expansion point is location 287555
    7 |   int b = PLUS (3,4);
      |           ^~~~
  map->start_location: 2147483632
  macro_locations:
    0: 287744, 263200
test.c:7:17: note: token 0 has x-location == 287744
    7 |   int b = PLUS (3,4);
      |                 ^
test.c:7:17: note: token 0 has y-location == 263200
    1: 263264, 263264
In file included from test.c:1:
test.h:3:22: note: token 1 has x-location == y-location == 263264
    3 | #define PLUS(A, B) A + B
      |                      ^
    2: 287808, 263328
test.c:7:19: note: token 2 has x-location == 287808
    7 |   int b = PLUS (3,4);
      |                   ^
test.c:7:19: note: token 2 has y-location == 263328
    3: 0, 0
cc1: note: token 3 has x-location == y-location == 0
    4: 0, 0
cc1: note: token 4 has x-location == y-location == 0
    5: 0, 0
cc1: note: token 5 has x-location == y-location == 0
    6: 0, 0
cc1: note: token 6 has x-location == y-location == 0

MACRO 2: PLUS (7 tokens)
  location_t interval: 2147483639 <= loc < 2147483646
test.c:6:11: note: expansion point is location 283459
    6 |   int a = PLUS (1,2);
      |           ^~~~
  map->start_location: 2147483639
  macro_locations:
    0: 283648, 263200
test.c:6:17: note: token 0 has x-location == 283648
    6 |   int a = PLUS (1,2);
      |                 ^
test.c:6:17: note: token 0 has y-location == 263200
    1: 263264, 263264
In file included from test.c:1:
test.h:3:22: note: token 1 has x-location == y-location == 263264
    3 | #define PLUS(A, B) A + B
      |                      ^
    2: 283712, 263328
test.c:6:19: note: token 2 has x-location == 283712
    6 |   int a = PLUS (1,2);
      |                   ^
test.c:6:19: note: token 2 has y-location == 263328
    3: 0, 0
cc1: note: token 3 has x-location == y-location == 0
    4: 0, 0
cc1: note: token 4 has x-location == y-location == 0
    5: 0, 0
cc1: note: token 5 has x-location == y-location == 0
    6: 0, 0
cc1: note: token 6 has x-location == y-location == 0
250

251 252 253 254 255 256 257
MACRO 1: __GCC_IEC_559_COMPLEX (1 tokens)
  location_t interval: 2147483646 <= loc < 2147483647
In file included from <command-line>:31:
/usr/include/stdc-predef.h:45:6: note: expansion point is location 180564
   45 | # if __GCC_IEC_559_COMPLEX > 0
      |      ^~~~~~~~~~~~~~~~~~~~~
  map->start_location: 2147483646
258
  macro_locations:
259 260 261 262 263 264 265 266 267
    0: 1, 1
<built-in>: note: token 0 has x-location == y-location == 1

MACRO 0: __GCC_IEC_559 (1 tokens)
  location_t interval: 2147483647 <= loc < 2147483648
/usr/include/stdc-predef.h:37:6: note: expansion point is location 147788
   37 | # if __GCC_IEC_559 > 0
      |      ^~~~~~~~~~~~~
  map->start_location: 2147483647
268
  macro_locations:
269 270
    0: 1, 1
<built-in>: note: token 0 has x-location == y-location == 1
271

272 273
MAX_LOCATION_T
  location_t interval: 2147483647 <= loc < 2147483648
274 275

AD-HOC LOCATIONS
276
  location_t interval: 2147483648 <= loc < 4294967295
277
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^