tests/c/breakpoints1.c
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 07 Feb 2019 15:18:41 +0000
changeset 175 a04e1a36e888
parent 120 73877848ea7f
permissions -rw-r--r--
Fix for multi-location breakpoints created initially as pending If the breakpoint has been created as pending breakpoint it is unknown whether it is a multi-location breakpoint or not so it has no locations. If, once the object is loaded abd breakpoint can be installed, it turns out there are multiple locations, we get an an =breakpoint-modified event listing all locations. Therefore, we have to update existing breakpoint and add locations.

/*
 * CFLAGS=-ggdb3 -O2 -W -Wall -Wno-unused-parameter -I.
 */
#include <stdio.h>
#include <stdlib.h>

static inline int 
add(int a, int b)  {
    return a + b;
}

int my_rand_1(void) {
    return add(rand(), rand());
}

int my_rand_2(void) {
    int r = my_rand_1();
    return add(r, r);
}

int main (int argc, char **argv)
{
  int i = my_rand_1();
  printf("%d\n", i);
  return 1; /* next-line */
}