github.com/undoio/delve@v1.9.0/_fixtures/testvariablescgo/test.c (about)

     1  #include <stdlib.h>
     2  #include <string.h>
     3  #include <stdio.h>
     4  
     5  #ifdef __amd64__
     6  #define BREAKPOINT asm("int3;")
     7  #elif __i386__
     8  #define BREAKPOINT asm("int3;")
     9  #elif __aarch64__
    10  #define BREAKPOINT asm("brk 0;")
    11  #endif
    12  
    13  #define N 100
    14  
    15  struct align_check {
    16  	int a;
    17  	char b;
    18  };
    19  
    20  void testfn(void) {
    21  	const char *s0 = "a string";
    22  	const char *longstring = "averylongstring0123456789a0123456789b0123456789c0123456789d0123456789e0123456789f0123456789g0123456789h0123456789";
    23  	int *v = malloc(sizeof(int) * N);
    24  	struct align_check *v_align_check = malloc(sizeof(struct align_check) * N);
    25  
    26  	for (int i = 0; i < N; i++) {
    27  		v[i] = i;
    28  		v_align_check[i].a = i;
    29  		v_align_check[i].b = i;
    30  	}
    31  
    32  	char *s = malloc(strlen(s0) + 1);
    33  	strcpy(s, s0);
    34  
    35  	BREAKPOINT;
    36  	
    37  	printf("%s %s %p %p\n", s, longstring, v, v_align_check);
    38  }