From: Christopher Li <sparse@chrisli.org>
To: Linux-Sparse <linux-sparse@vger.kernel.org>
Cc: Kamil Dudka <kdudka@redhat.com>, Josh Triplett <josh@joshtriplett.org>
Subject: [PATCH 3/4] inspect: Add test-inspect program
Date: Fri, 2 Apr 2010 11:43:40 -0700 [thread overview]
Message-ID: <m2i70318cbf1004021143lfb587e90zd66d9de22535a6d6@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 98 bytes --]
The test program will launch a gtk treeview windows to
display the symbol node in the AST.
Chris
[-- Attachment #2: 0003-inspect-Add-test-inspect-program.patch --]
[-- Type: application/octet-stream, Size: 3092 bytes --]
From 5488960162b85e4bace29d20ac44dcea19b94888 Mon Sep 17 00:00:00 2001
From: Christopher Li <sparse@chrisli.org>
Date: Tue, 30 Mar 2010 15:49:16 -0700
Subject: [PATCH 3/4] inspect: Add test-inspect program
The test program will launch a gtk treeview windows to
display the symbol node in the AST.
---
Makefile | 17 ++++++++++++++---
test-inspect.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 3 deletions(-)
create mode 100644 test-inspect.c
diff --git a/Makefile b/Makefile
index b07f472..2825e58 100644
--- a/Makefile
+++ b/Makefile
@@ -15,10 +15,11 @@ AR = ar
# CFLAGS += -O0 -DDEBUG -g3 -gdwarf-2
#
-HAVE_LIBXML=$(shell pkg-config --exists libxml-2.0 2>/dev/null && echo 'yes')
-HAVE_GCC_DEP=$(shell touch .gcc-test.c && \
+HAVE_LIBXML:=$(shell pkg-config --exists libxml-2.0 2>/dev/null && echo 'yes')
+HAVE_GCC_DEP:=$(shell touch .gcc-test.c && \
$(CC) -c -Wp,-MD,.gcc-test.d .gcc-test.c 2>/dev/null && \
echo 'yes'; rm -f .gcc-test.d .gcc-test.o .gcc-test.c)
+HAVE_GTK2:=$(shell pkg-config --exists gtk+-2.0 2>/dev/null && echo 'yes')
CFLAGS += -DGCC_BASE=\"$(shell $(CC) --print-file-name=)\"
@@ -46,6 +47,16 @@ INST_PROGRAMS+=c2xml
c2xml_EXTRA_OBJS = `pkg-config --libs libxml-2.0`
endif
+ifeq ($(HAVE_GTK2),yes)
+GTK2_CFLAGS := $(shell pkg-config --cflags gtk+-2.0)
+GTK2_LIBS := $(shell pkg-config --libs gtk+-2.0)
+PROGRAMS += test-inspect
+INST_PROGRAMS += test-inspect
+test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o
+test-inspect.o $(test-inspect_EXTRA_DEPS): CFLAGS += $(GTK2_CFLAGS)
+test-inspect_EXTRA_OBJS := $(GTK2_LIBS)
+endif
+
LIB_H= token.h parse.h lib.h symbol.h scope.h expression.h target.h \
linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
storage.h ptrlist.h dissect.h
@@ -141,7 +152,7 @@ compat-solaris.o: compat/mmap-blob.c $(LIB_H)
compat-mingw.o: $(LIB_H)
compat-cygwin.o: $(LIB_H)
-.c.o:
+%.o: %.c
$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
clean: clean-check
diff --git a/test-inspect.c b/test-inspect.c
new file mode 100644
index 0000000..e437e11
--- /dev/null
+++ b/test-inspect.c
@@ -0,0 +1,43 @@
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "lib.h"
+#include "allocate.h"
+#include "token.h"
+#include "parse.h"
+#include "symbol.h"
+#include "expression.h"
+
+#include "ast-view.h"
+
+static void expand_symbols(struct symbol_list *list)
+{
+ struct symbol *sym;
+ FOR_EACH_PTR(list, sym) {
+ expand_symbol(sym);
+ } END_FOR_EACH_PTR(sym);
+}
+
+int main(int argc, char **argv)
+{
+ struct string_list *filelist = NULL;
+ char *file;
+ struct symbol_list *view_syms = NULL;
+
+ gtk_init(&argc,&argv);
+ expand_symbols(sparse_initialize(argc, argv, &filelist));
+ FOR_EACH_PTR_NOTAG(filelist, file) {
+ struct symbol_list *syms = sparse(file);
+ expand_symbols(syms);
+ concat_symbol_list(syms, &view_syms);
+ } END_FOR_EACH_PTR_NOTAG(file);
+ treeview_main(view_syms);
+ return 0;
+}
+
--
1.6.6.1
reply other threads:[~2010-04-02 18:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2i70318cbf1004021143lfb587e90zd66d9de22535a6d6@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=josh@joshtriplett.org \
--cc=kdudka@redhat.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).