1 /* 2 * Copyright (c) Tony Bybell 1999-2012. 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 #ifndef WAVE_DEBUG_H 11 #define WAVE_DEBUG_H 12 13 #include <gtk/gtk.h> 14 #include <stdlib.h> 15 #include <stdio.h> 16 #include <string.h> 17 18 #ifndef _MSC_VER 19 #ifndef __MINGW32__ 20 #include <stdint.h> 21 #else 22 #include <windows.h> 23 #endif 24 #endif 25 26 #define WAVE_MAX_CLIST_LENGTH 15000 27 28 29 /* 30 * If you have problems viewing traces (mangled timevalues), 31 * make sure that you use longs rather than the glib 64-bit 32 * types... 33 */ 34 #ifdef G_HAVE_GINT64 35 typedef gint64 TimeType; 36 typedef guint64 UTimeType; 37 38 #ifndef _MSC_VER 39 #define LLDescriptor(x) x##LL 40 #define ULLDescriptor(x) x##ULL 41 #ifdef __MINGW32__ 42 #define TTFormat "%I64d" 43 #define UTTFormat "%I64u" 44 #else 45 #if __WORDSIZE == 64 46 #define TTFormat "%ld" 47 #define UTTFormat "%lu" 48 #else 49 #define TTFormat "%lld" 50 #define UTTFormat "%llu" 51 #endif 52 #endif 53 #else 54 #define LLDescriptor(x) x##i64 55 #define ULLDescriptor(x) x##i64 56 #define TTFormat "%I64d" 57 #define UTTFormat "%I64u" 58 #endif 59 60 #define WAVE_MINZOOM (LLDescriptor(-4000000000)) 61 #else 62 typedef long TimeType; 63 typedef unsigned long UTimeType; 64 #define TTFormat "%d" 65 #define UTTFormat "%u" 66 67 #define LLDescriptor(x) x 68 #define ULLDescriptor(x) x 69 70 #define WAVE_MINZOOM (LLDescriptor(-20000000)) 71 #endif 72 73 74 #ifdef _MSC_VER 75 #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) 76 #define popen _popen 77 #define pclose _pclose 78 #endif 79 80 81 #ifdef DEBUG_PRINTF 82 #define DEBUG(x) x 83 #else 84 #define DEBUG(x) 85 #endif 86 87 88 #ifdef DEBUG_MALLOC_LINES 89 void free_2(void *ptr, char *filename, int lineno); 90 #define free_2(x) free_2((x),__FILE__,__LINE__) 91 92 void *malloc_2(size_t size, char *filename, int lineno); 93 #define malloc_2(x) malloc_2((x),__FILE__,__LINE__) 94 95 void *realloc_2(void *ptr, size_t size, char *filename, int lineno); 96 #define realloc_2(x, y) realloc_2((x),(y),__FILE__,__LINE__) 97 98 void *calloc_2(size_t nmemb, size_t size, char *filename, int lineno); 99 #define calloc_2(x, y) calloc_2((x),(y),__FILE__,__LINE__) 100 101 #else 102 void free_2(void *ptr); 103 void *malloc_2(size_t size); 104 void *realloc_2(void *ptr, size_t size); 105 void *calloc_2(size_t nmemb, size_t size); 106 #endif 107 108 109 void free_outstanding(void); 110 111 char *strdup_2(const char *s); 112 char *strdup_2s(const char *s); 113 114 char *tmpnam_2(char *s, int *fd); /* mimic functionality of tmpnam() */ 115 116 TimeType atoi_64(const char *str); 117 118 void gtk_tooltips_set_tip_2(GtkTooltips *tooltips, GtkWidget *widget, 119 const gchar *tip_text, const gchar *tip_private); 120 void gtk_tooltips_set_delay_2(GtkTooltips *tooltips, guint delay); 121 GtkTooltips* gtk_tooltips_new_2(void); 122 123 char *realpath_2(const char *path, char *resolved_path); 124 125 enum WaveLoadingTitleType { WAVE_SET_TITLE_NONE, WAVE_SET_TITLE_MODIFIED, WAVE_SET_TITLE_LOADING }; 126 127 void wave_gtk_window_set_title(GtkWindow *window, const gchar *title, int typ, int pct); 128 129 130 #undef WAVE_USE_SIGCMP_INFINITE_PRECISION /* define this for slow sigcmp with infinite digit accuracy */ 131 #define WAVE_OPT_SKIP 1 /* make larger for more accel on traces */ 132 133 /* for source code annotation helper app */ 134 135 #ifndef PATH_MAX 136 #define PATH_MAX (4096) 137 #endif 138 139 #define WAVE_MATCHWORD "WAVE" 140 enum AnnotateAetType { WAVE_ANNO_NONE, WAVE_ANNO_AE2, WAVE_ANNO_VZT, WAVE_ANNO_LXT2, WAVE_ANNO_FST, WAVE_ANNO_MAX }; 141 142 143 #if !defined _MSC_VER && !defined __MINGW32__ 144 145 #include <sys/ipc.h> 146 #include <sys/shm.h> 147 148 struct gtkwave_annotate_ipc_t 149 { 150 char matchword[4]; /* match against WAVE_MATCHWORD string */ 151 char time_string[40]; /* formatted marker time */ 152 153 pid_t gtkwave_process; 154 pid_t browser_process; 155 156 TimeType marker; 157 unsigned marker_set : 1; 158 unsigned cygwin_remote_kill : 1; 159 160 int aet_type; 161 char aet_name[PATH_MAX+1]; 162 char stems_name[PATH_MAX+1]; 163 }; 164 165 #else 166 167 struct gtkwave_annotate_ipc_t 168 { 169 char matchword[4]; /* match against WAVE_MATCHWORD string */ 170 char time_string[40]; /* formatted marker time */ 171 172 #ifdef __MINGW32__ 173 HANDLE browser_process; 174 #endif 175 176 TimeType marker; 177 unsigned marker_set : 1; 178 unsigned cygwin_remote_kill : 1; 179 180 int aet_type; 181 char aet_name[PATH_MAX+1]; 182 char stems_name[PATH_MAX+1]; 183 }; 184 185 #endif 186 187 #define DUAL_MATCHWORD "DUAL" 188 189 struct gtkwave_dual_ipc_t 190 { 191 char matchword[4]; /* match against DUAL_MATCHWORD string */ 192 193 TimeType left_margin_time; 194 TimeType marker, baseline; 195 gdouble zoom; 196 unsigned use_new_times : 1; 197 unsigned viewer_is_initialized : 1; 198 }; 199 200 201 enum GtkwaveFileTypes { G_FT_UNKNOWN, G_FT_LXT, G_FT_LXT2, G_FT_VZT, G_FT_FST }; 202 203 int determine_gtkwave_filetype(const char *path); 204 205 206 #endif 207 208