Files
arti 46417f53ec m7.2: strengthen Task 3 debug/oracle/cinit gates
- debug.sh: add a pointer/array runtime-GEP function (debug_ptr) with
  asserted line rows/low PC, and build the same TU with tms-clang -g -O2
  through --bitptr/opt/--scale/--lower-bitptr/instcombine; require the
  -O2 object's .debug_* sections and dwarfdump its debug.c/function/low PC.
  Read .debug_addr entries by index and assert the CU low/high PC and
  .debug_line file index.
- oracle.sh: load both the GSPLNK and tms-link images in MAME with the same
  markers; require a minimum count and the names the checks depend on, and
  document the absolute/undefined C_EXT exclusion.
- cinit.sh: assert the object relocation (0x10, .bss/_cinit_target base,
  addend 0), compare the 28-byte optional header with GSPLNK, and link
  CINIT.O alone to exercise the synthesized public cinit symbol.
- tmscoff.py: point the order-relaxation comment at the Task 1 lit test that
  still pins the llc section order.
2026-11-14 22:54:19 +00:00

38 lines
1.2 KiB
C

int debug_mul(void) {
int product = 42;
return product + 1;
}
int debug_add(void) {
int sum = 7;
return sum + 7;
}
int debug_array[4] = {10, 20, 30, 40};
int debug_index = 2;
int debug_ptr(void) {
int *p = debug_array;
p += debug_index;
return *p;
}
/* M7.2 debug-info gate driver.
*
* Three functions, so the linked `.debug_info` has three subprograms and the
* second/third `.text` offsets are nonzero. debug_mul returns 43,
* debug_add returns 14 and debug_ptr returns debug_array[2] = 30; the entry
* stores them at 018A8000/018A8020/018A8040 after the stripped link is loaded
* in MAME.
*
* debug_ptr is the bit-pointer barrier coverage: `p += debug_index` is a
* runtime `getelementptr` that --bitptr rewrites, so the -O0 gate proves the
* line row survives that rewrite; debug.sh also builds this TU at -O2 -g to
* exercise opt/--scale/--lower-bitptr/instcombine.
*
* The declarations are on lines 1, 6 and 14; the first local-variable /
* pointer-update lines are 2, 7, 15 and 16; debug.sh asserts those
* `.debug_line` rows and the DW_AT_decl_line values. The comment is
* deliberately after the code so the line numbers stay stable.
*/