From 172ae0719964eea130f9fb8dd98971d83692d330 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= <henrik@tjaders.com>
Date: Thu, 8 Mar 2018 14:32:09 +0100
Subject: [PATCH] Use functions and neater comments. Wrap call in try-except

---
 klee_stm_gdb.py | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/klee_stm_gdb.py b/klee_stm_gdb.py
index 57fa79e..e98a316 100644
--- a/klee_stm_gdb.py
+++ b/klee_stm_gdb.py
@@ -310,8 +310,11 @@ def posted_event_init():
         gdb.write('Task to call: %s \n' % (
                   tasks[task_to_test] + "()"))
         # gdb.prompt_hook = prompt
-        gdb.execute('call %s' % "stub_" +
-                    tasks[task_to_test] + "()")
+        try:
+            gdb.execute('call %s' % "stub_" +
+                        tasks[task_to_test] + "()")
+        except gdb.error:
+            print("GDB ERROR")
 
         task_to_test = -1
         do_continue()
@@ -403,8 +406,10 @@ def ktest_setdata(file_index):
 
 
 def ktest_iterate():
-    """ Get the list of folders in current directory, sort and then grab the
-        last one.
+    """
+    Get the list of folders in current directory, sort and then grab the
+    last one.
+
     """
     global debug
     global autobuild
@@ -606,16 +611,6 @@ else:
 gdb.execute("file %s" % (stm_out_folder + example_name))
 gdb.execute("load %s" % (stm_out_folder + example_name))
 
-# gdb.execute("step")
-
-""" Run KLEE on the generated files """
-# print(klee_run())
-
-""" Break at main to set variable values """
-# AddBreakpoint("main")
-# MainBP("main")
-# MainBP("init")
-
 
 """ Tell gdb-dashboard to hide """
 # gdb.execute("dashboard -enabled off")
@@ -626,7 +621,8 @@ MainBP("idle")
 
 """ Save all ktest files into an array """
 file_list = ktest_iterate()
-# print(file_list)
+if debug:
+    print(file_list)
 
 """ Get all the tasks to jump to """
 tasks = tasklist_get()
@@ -641,4 +637,4 @@ and skip the stubs
 gdb.events.stop.connect(stop_event_ignore)
 
 """ Run until the next breakpoint """
-gdb.execute("c")
+do_continue()
-- 
GitLab