summaryrefslogtreecommitdiffstats
path: root/lldb/test/global_variables
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/global_variables')
-rw-r--r--lldb/test/global_variables/Makefile142
-rw-r--r--lldb/test/global_variables/a.c10
-rw-r--r--lldb/test/global_variables/cmds.txt3
-rw-r--r--lldb/test/global_variables/main.c21
4 files changed, 176 insertions, 0 deletions
diff --git a/lldb/test/global_variables/Makefile b/lldb/test/global_variables/Makefile
new file mode 100644
index 00000000000..fdf381403b5
--- /dev/null
+++ b/lldb/test/global_variables/Makefile
@@ -0,0 +1,142 @@
+#----------------------------------------------------------------------
+# Fill in the source files to build
+#----------------------------------------------------------------------
+C_SOURCES :=main.c
+CXX_SOURCES :=
+OBJC_SOURCES :=
+OBJCXX_SOURCES :=
+
+# Uncomment line below for debugging shell commands
+# SHELL = /bin/sh -x
+
+#----------------------------------------------------------------------
+# Change any build/tool options needed
+#----------------------------------------------------------------------
+DS := dsymutil
+DSFLAGS =
+CFLAGS ?=-arch x86_64 -gdwarf-2 -O0
+CPLUSPLUSFLAGS +=$(CFLAGS)
+CPPFLAGS +=$(CFLAGS)
+LD = gcc
+LDFLAGS = $(CFLAGS)
+OBJECTS =
+EXE=a.out
+DSYM=$(EXE).dSYM
+
+#----------------------------------------------------------------------
+# dylib settings
+#----------------------------------------------------------------------
+DYLIB_NAME=a
+DYLIB_BASENAME=lib$(DYLIB_NAME).dylib
+DYLIB_C_SOURCES :=a.c
+ifneq "$(strip $(DYLIB_C_SOURCES))" ""
+ DYLIB_OBJECTS +=$(strip $(DYLIB_C_SOURCES:.c=.o))
+endif
+
+
+#----------------------------------------------------------------------
+# Check if we have any C source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(C_SOURCES))" ""
+ OBJECTS +=$(strip $(C_SOURCES:.c=.o))
+endif
+
+
+#----------------------------------------------------------------------
+# Check if we have any C++ source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(CXX_SOURCES))" ""
+ OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o))
+ LD = g++
+endif
+
+#----------------------------------------------------------------------
+# Check if we have any ObjC source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(OBJC_SOURCES))" ""
+ OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o))
+ LDFLAGS +=-lobjc
+endif
+
+#----------------------------------------------------------------------
+# Check if we have any ObjC++ source files
+#----------------------------------------------------------------------
+ifneq "$(strip $(OBJCXX_SOURCES))" ""
+ OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o))
+ LD = g++
+ ifeq $(findstring lobjc,$(LDFLAGS)) ""
+ LDFLAGS +=-lobjc
+ endif
+endif
+
+
+#----------------------------------------------------------------------
+# Make the dSYM file from the executable
+#----------------------------------------------------------------------
+$(DSYM) : $(EXE)
+ $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)"
+
+#----------------------------------------------------------------------
+# Compile the executable from all the objects (default rule) with no
+# dsym file.
+#----------------------------------------------------------------------
+$(EXE) : $(OBJECTS) $(DYLIB_BASENAME)
+ $(LD) $(LDFLAGS) $(OBJECTS) -L. -l$(DYLIB_NAME) -o "$(EXE)"
+
+#----------------------------------------------------------------------
+# Make the dylib
+#----------------------------------------------------------------------
+$(DYLIB_BASENAME) : $(DYLIB_OBJECTS)
+ $(LD) $(LDFLAGS) $(DYLIB_OBJECTS) -install_name "@executable_path/$(DYLIB_BASENAME)" -dynamiclib -o "$(DYLIB_BASENAME)"
+
+#----------------------------------------------------------------------
+# Automatic variables based on items already entered. Below we create
+# an objects lists from the list of sources by replacing all entries
+# that end with .c with .o, and we also create a list of prerequisite
+# files by replacing all .c files with .d.
+#----------------------------------------------------------------------
+PREREQS := $(OBJECTS:.o=.d)
+
+#----------------------------------------------------------------------
+# Rule for Generating Prerequisites Automatically using .d files and
+# the compiler -MM option. The -M option will list all system headers,
+# and the -MM option will list all non-system dependencies.
+#----------------------------------------------------------------------
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.cpp
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.m
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+%.d: %.mm
+ @set -e; rm -f $@; \
+ $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
+#----------------------------------------------------------------------
+# Include all of the makefiles for each source file so we don't have
+# to manually track all of the prerequisites for each source file.
+#----------------------------------------------------------------------
+sinclude $(PREREQS)
+
+.PHONY: clean
+dsym: $(DSYM)
+all: $(EXE) $(DSYM)
+clean:
+ rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(DYLIB_OBJECTS) $(DYLIB_BASENAME) $(DYLIB_BASENAME).dSYM
+
+
+
diff --git a/lldb/test/global_variables/a.c b/lldb/test/global_variables/a.c
new file mode 100644
index 00000000000..0a9b4f61871
--- /dev/null
+++ b/lldb/test/global_variables/a.c
@@ -0,0 +1,10 @@
+//===-- a.c -----------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+int g_a = 123;
+
diff --git a/lldb/test/global_variables/cmds.txt b/lldb/test/global_variables/cmds.txt
new file mode 100644
index 00000000000..6906a0729ae
--- /dev/null
+++ b/lldb/test/global_variables/cmds.txt
@@ -0,0 +1,3 @@
+break main.c:5
+continue
+var -global g_a -global g_global_int
diff --git a/lldb/test/global_variables/main.c b/lldb/test/global_variables/main.c
new file mode 100644
index 00000000000..13778c29377
--- /dev/null
+++ b/lldb/test/global_variables/main.c
@@ -0,0 +1,21 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+int g_file_global_int = 42;
+const char *g_file_global_cstr = "g_file_global_cstr";
+static const char *g_file_static_cstr = "g_file_static_cstr";
+
+extern int g_a;
+int main (int argc, char const *argv[])
+{
+ static const char *g_func_static_cstr = "g_func_static_cstr";
+ printf ("%s\n", g_file_global_cstr);
+ return g_file_global_int + g_a; //// break $source:$line; continue; var -global g_a -global g_global_int
+}
OpenPOWER on IntegriCloud