1 /*
2  * Copyright (c) Tony Bybell 1999-2010.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  */
9 
10 #include "globals.h"
11 
12 #ifndef GTKWAVE_STRACE_H
13 #define GTKWAVE_STRACE_H
14 
15 #include <gtk/gtk.h>
16 #include <string.h>
17 #include <stdarg.h>
18 #include "debug.h"
19 #include "analyzer.h"
20 #include "currenttime.h"
21 #include "bsearch.h"
22 
23 #if WAVE_USE_GTK2
24 #define WAVE_NUM_STRACE_WINDOWS (2)
25 #else
26 #define WAVE_NUM_STRACE_WINDOWS (1)
27 #endif
28 
29 #define WAVE_STRACE_ITERATOR(x) for((x)=((WAVE_NUM_STRACE_WINDOWS)-1); (x)>=0 ; (x)--)
30 #define WAVE_STRACE_ITERATOR_FWD(x) for((x)=0;(x)<(WAVE_NUM_STRACE_WINDOWS);(x)++)
31 
32 enum strace_directions
33 { STRACE_BACKWARD, STRACE_FORWARD };
34 
35 enum st_stype
36         {ST_DC, ST_HIGH, ST_MID, ST_X, ST_LOW, ST_STRING,
37          ST_RISE, ST_FALL, ST_ANY, WAVE_STYPE_COUNT};
38 
39 struct strace_defer_free
40 {
41 struct strace_defer_free *next;
42 Trptr defer;
43 };
44 
45 struct strace_back
46 {
47 struct strace *parent;
48 int which;
49 };
50 
51 struct strace
52 {
53 struct strace *next;
54 char *string;           /* unmalloc this when all's done! */
55 Trptr trace;
56 char value;
57 char search_result;
58 
59 union
60 	{
61         hptr    h;             /* what makes up this trace */
62         vptr    v;
63       	} his;
64 
65 struct strace_back *back[WAVE_STYPE_COUNT];    /* dealloc these too! */
66 };
67 
68 
69 struct timechain
70 {
71 struct timechain *next;
72 TimeType t;
73 };
74 
75 
76 struct mprintf_buff_t
77 {
78 struct mprintf_buff_t *next;
79 char *str;
80 };
81 
82 struct item_mark_string {
83    char *str;
84    unsigned char idx;
85 };
86 
87 
88 /* for being able to handle multiple strace sessions at once, context is moved here */
89 struct strace_ctx_t
90 {
91 GtkWidget *ptr_mark_count_label_strace_c_1;
92 struct strace *straces;
93 struct strace *shadow_straces;
94 struct strace_defer_free *strace_defer_free_head;
95 GtkWidget *window_strace_c_10;
96 void (*cleanup_strace_c_7)(void);
97 
98 struct mprintf_buff_t *mprintf_buff_head;
99 struct mprintf_buff_t *mprintf_buff_current;
100 char *shadow_string;
101 
102 TimeType *timearray;
103 int timearray_size;
104 
105 char logical_mutex[6];
106 char shadow_logical_mutex[6];
107 char shadow_active;
108 char shadow_encountered_parsewavline;
109 char shadow_type;
110 signed char mark_idx_start;
111 signed char mark_idx_end;
112 signed char shadow_mark_idx_start;
113 signed char shadow_mark_idx_end;
114 };
115 
116 
117 void strace_search(int direction);
118 void strace_maketimetrace(int mode); /* 1=create, zero=delete */
119 TimeType strace_adjust(TimeType a, TimeType b);
120 
121 void swap_strace_contexts(void);
122 void delete_strace_context(void);
123 void cache_actual_pattern_mark_traces(void);
124 
125 void edge_search(int direction); /* from edgebuttons.c */
126 
127 int mprintf(const char *fmt, ... );
128 void delete_mprintf(void);
129 
130 void tracesearchbox(const char *title, GtkSignalFunc func, gpointer data);
131 
132 #endif
133 
134