1 //===-- main.c --------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #include <stdio.h> 9 #include <stdint.h> 10 11 int32_t global = 0; // Watchpoint variable declaration. 12 13 static void modify(int32_t &var) { 14 ++var; 15 } 16 17 int main(int argc, char** argv) { 18 int local = 0; 19 printf("&global=%p\n", &global); 20 printf("about to write to 'global'...\n"); // Set break point at this line. 21 // When stopped, watch 'global', 22 // for the condition "global == 5". 23 for (int i = 0; i < 10; ++i) 24 modify(global); 25 26 printf("global=%d\n", global); 27 } 28