# REQUIRES: lld
# RUN: %clang -target x86_64-pc-linux -g -O0 %S/Inputs/subprogram_ranges.s -o %t.o -c
# RUN: ld.lld %t.o -o %t
# RUN: %lldb -b -s %s %t 2>&1 | FileCheck %s
# Test breaking on symbols and printing variables when a DW_TAG_subprogram uses
# DW_AT_ranges instead of DW_AT_low_pc/DW_AT_high_pc. While the assembly here
# is a bit unrealistic - it's a single-entry range using DWARFv4 which isn't
# useful for anything (a single-entry range with DWARFv5 can reduce address
# relocations, and multi-entry ranges can be used for function sections), but
# it's the simplest thing to test. If anyone's updating this test at some
# point, feel free to replace it with another equivalent test if it's
# especially useful, but don't dismiss it as pointless just because it's a bit
# weird.
# * Using volatile writes to create instructions the location may be valid over
# * Using two values for the variable so it is described by a location list,
# not a single location description
# * Not using function calls, so that the function has no frame pointer
# initialization/no prologue instructions, so the location of "var" is valid
# at the start of the function, so 'image lookup -v -s main' will include it.
#
# Source:
# __attribute__((nodebug)) volatile int i;
# int main() {
# int var = 3;
# i = 1;
# var = 5;
# i = 2;
# }
b main
# CHECK: (lldb) b main
# CHECK-NEXT: Breakpoint 1: where = {{.*}}`main at subprogram_ranges.c:4:5
image lookup -v -s main
# CHECK: 1 symbols match 'main'
# CHECK: Variable: {{.*}}, name = "var", type = "int", {{.*}}, decl = subprogram_ranges.c:3