diff mbox

Best way to inspect the parse tree from Sparse

Message ID CANeU7QmDs0Dbdd=-ceD55rD9fHuz53Vy2=a==8J1OjV1d7RVHg@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Christopher Li Aug. 10, 2017, 7:59 p.m. UTC
On Wed, Aug 9, 2017 at 4:03 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> On 9 August 2017 at 12:57, Christopher Li <sparse@chrisli.org> wrote:
>> Can you do a "ldd test-inspect"?
>>
>> Which version of Ubuntu are you using? I think I need to get one of those to
>> test it.
>>
>
> I am using ubuntu 16.04 LTS.
>


OK. I have install ubuntu 16.04 LTS and writing this email
on ubuntu now.

The first patch I send you should be correct. But I think
there is a bug in the updated version of ubuntu 16.04
libgtk2.0-dev. I am not able to reproduce it with the
fresh install libgtk2 but I can't go back now.

I can duplicate the crash with update to latest version.

It seems to me that, when I click on one sub item,
it is passing iter == NULL. That seems wrong.
It shouldn't pass iter == NULL for sub list item.

Again, I am not GUI developer at all. This
test-inspect is all my GUI skill at best already.

With the patch I send earlier, this cause the gtk
go into infinity loop of asking about the child
of the child. It is asking for child with iter==NULL.
So I get it the root node, gtk seems get confused
after that.

The patch I send out before obvious should be applied.

The good news is that, in Ubuntu 16.04. GTK3.0 does
not have this problem. I am able to run gtk3 and
test-inspect will not crash.

I attach the patch here. You can try it out.
Please let me know how it work out for you.

I am writing a patch for RC5 to compile with gtk3
if available.

Chris
diff mbox

Patch

From 002cb50499ca64539d677e46f035a0d62ab981e1 Mon Sep 17 00:00:00 2001
From: Chris Li <chris@cool>
Date: Thu, 10 Aug 2017 15:34:14 -0400
Subject: [PATCH] switch to gtk3

---
 Makefile    | 6 +++---
 ast-model.c | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 96e81c4..db410eb 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@  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')
+HAVE_GTK2:=$(shell $(PKG_CONFIG) --exists gtk+-3.0 2>/dev/null && echo 'yes')
 LLVM_CONFIG:=llvm-config
 HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes')
 
@@ -67,8 +67,8 @@  $(warning Your system does not have libxml, disabling c2xml)
 endif
 
 ifeq ($(HAVE_GTK2),yes)
-GTK2_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-2.0)
-GTK2_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0)
+GTK2_CFLAGS := $(shell $(PKG_CONFIG) --cflags gtk+-3.0)
+GTK2_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-3.0)
 PROGRAMS += test-inspect
 INST_PROGRAMS += test-inspect
 test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o
diff --git a/ast-model.c b/ast-model.c
index 704c487..d7f0c3a 100644
--- a/ast-model.c
+++ b/ast-model.c
@@ -401,7 +401,8 @@  static gint
 ast_iter_n_children (GtkTreeModel *tree_model,
                           GtkTreeIter  *iter)
 {
-	AstNode  *node = iter->user_data;
+	AstNode  *node = iter ? iter->user_data
+				: AST_NODE(tree_model);
 
 	inspect_child_node(node);
 	return node->childnodes->len;
-- 
2.7.4