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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
120
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
/*
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
 * CFLAGS=-ggdb3 -O2 -W -Wall -Wno-unused-parameter -I.
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
 */
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
#include <stdio.h>
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
#include <stdlib.h>
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
static inline int 
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
add(int a, int b)  {
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
    return a + b;
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
}
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
int my_rand_1(void) {
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
    return add(rand(), rand());
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
}
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
int my_rand_2(void) {
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
    int r = my_rand_1();
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
    return add(r, r);
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
}
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
int main (int argc, char **argv)
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
{
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
  int i = my_rand_1();
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
  printf("%d\n", i);
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
  return 1; /* next-line */
73877848ea7f Added support for breakpoints with multiple locations
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
}