...

Text file src/debug/dwarf/testdata/issue57046_part1.c

Documentation: debug/dwarf/testdata

     1// Copyright 2025 The Go Authors. All rights reserved.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5// Part 1 of the sources for issue 57046 test case.
     6
     7// Build instructions:
     8//
     9// clang-16 -O -g -gdwarf-5 -c issue57046_part1.c
    10// clang-16 -O -g -gdwarf-5 -c issue57046_part2.c
    11// clang-16 -o issue57046-clang.elf5 issue57046_part1.o issue57046_part2.o
    12
    13#include <stdio.h>
    14#include <stdlib.h>
    15#include <string.h>
    16
    17extern const char *mom();
    18
    19int gadgety() {
    20  const char *ev = getenv("PATH");
    21  int n = strlen(ev);
    22  int s1 = (int)ev[0];
    23  int s2 = (int)ev[1];
    24  int s3 = (int)ev[2];
    25  for (int i = 0; i < strlen(ev); i++) {
    26    if (s1 == 101) {
    27	int t = s1;
    28	s1 = s3;
    29	s3 = t;
    30    }
    31    if (ev[i] == 99) {
    32      printf("%d\n", i);
    33    }
    34  }
    35  s2 *= 2;
    36  return n + s1 + s2;
    37}
    38
    39int main(int argc, char **argv) {
    40  printf("Hi %s %d\n", mom(), gadgety());
    41  return 0;
    42}

View as plain text