diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-05-30 12:32:31 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-05-30 12:32:31 +0300 |
commit | a14a6881538229cd938282bd56c7f0d12a089be6 (patch) | |
tree | 89cfa47078460e7505c1a80ce71488eef29dfc63 /src | |
parent | 07caec236e3af48973874f2c0e19bafec4d13f78 (diff) | |
download | gdbm-a14a6881538229cd938282bd56c7f0d12a089be6.tar.gz gdbm-a14a6881538229cd938282bd56c7f0d12a089be6.tar.bz2 |
Drop debugging hooks
The hooks were introduced as a temporary tool in de7834e9. They did
their job and are not necessary any more.
Diffstat (limited to 'src')
-rw-r--r-- | src/bucket.c | 17 | ||||
-rw-r--r-- | src/debug.c | 137 | ||||
-rw-r--r-- | src/falloc.c | 18 | ||||
-rw-r--r-- | src/findkey.c | 12 | ||||
-rw-r--r-- | src/gdbmdefs.h | 14 | ||||
-rw-r--r-- | src/gdbmopen.c | 8 | ||||
-rw-r--r-- | src/gdbmstore.c | 10 | ||||
-rw-r--r-- | src/lex.l | 2 | ||||
-rw-r--r-- | src/update.c | 12 |
9 files changed, 26 insertions, 204 deletions
diff --git a/src/bucket.c b/src/bucket.c index c75db42..2289594 100644 --- a/src/bucket.c +++ b/src/bucket.c | |||
@@ -112,8 +112,7 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index) | |||
112 | /* It is not in the cache, read it from the disk. */ | 112 | /* It is not in the cache, read it from the disk. */ |
113 | 113 | ||
114 | /* Position the file pointer */ | 114 | /* Position the file pointer */ |
115 | file_pos = GDBM_DEBUG_OVERRIDE ("_gdbm_get_bucket:seek-failure", | 115 | file_pos = __lseek (dbf, bucket_adr, SEEK_SET); |
116 | __lseek (dbf, bucket_adr, SEEK_SET)); | ||
117 | if (file_pos != bucket_adr) | 116 | if (file_pos != bucket_adr) |
118 | { | 117 | { |
119 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); | 118 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); |
@@ -131,9 +130,8 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index) | |||
131 | _gdbm_cache_entry_invalidate (dbf, lru); | 130 | _gdbm_cache_entry_invalidate (dbf, lru); |
132 | 131 | ||
133 | /* Read the bucket. */ | 132 | /* Read the bucket. */ |
134 | rc = GDBM_DEBUG_OVERRIDE ("_gdbm_get_bucket:read-failure", | 133 | rc = _gdbm_full_read (dbf, dbf->bucket_cache[lru].ca_bucket, |
135 | _gdbm_full_read (dbf, dbf->bucket_cache[lru].ca_bucket, | 134 | dbf->header->bucket_size); |
136 | dbf->header->bucket_size)); | ||
137 | if (rc) | 135 | if (rc) |
138 | { | 136 | { |
139 | GDBM_DEBUG (GDBM_DEBUG_ERR, | 137 | GDBM_DEBUG (GDBM_DEBUG_ERR, |
@@ -302,8 +300,7 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert) | |||
302 | dir_adr = _gdbm_alloc (dbf, dir_size); | 300 | dir_adr = _gdbm_alloc (dbf, dir_size); |
303 | if (dir_adr == 0) | 301 | if (dir_adr == 0) |
304 | return -1; | 302 | return -1; |
305 | new_dir = GDBM_DEBUG_ALLOC ("_gdbm_split_bucket:malloc-failure", | 303 | new_dir = malloc (dir_size); |
306 | malloc (dir_size)); | ||
307 | if (new_dir == NULL) | 304 | if (new_dir == NULL) |
308 | { | 305 | { |
309 | GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE); | 306 | GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE); |
@@ -435,16 +432,14 @@ _gdbm_write_bucket (GDBM_FILE dbf, cache_elem *ca_entry) | |||
435 | int rc; | 432 | int rc; |
436 | off_t file_pos; /* The return value for lseek. */ | 433 | off_t file_pos; /* The return value for lseek. */ |
437 | 434 | ||
438 | file_pos = GDBM_DEBUG_OVERRIDE ("_gdbm_write_bucket:seek-failure", | 435 | file_pos = __lseek (dbf, ca_entry->ca_adr, SEEK_SET); |
439 | __lseek (dbf, ca_entry->ca_adr, SEEK_SET)); | ||
440 | if (file_pos != ca_entry->ca_adr) | 436 | if (file_pos != ca_entry->ca_adr) |
441 | { | 437 | { |
442 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); | 438 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); |
443 | _gdbm_fatal (dbf, _("lseek error")); | 439 | _gdbm_fatal (dbf, _("lseek error")); |
444 | return -1; | 440 | return -1; |
445 | } | 441 | } |
446 | rc = GDBM_DEBUG_OVERRIDE ("_gdbm_write_bucket:write-failure", | 442 | rc = _gdbm_full_write (dbf, ca_entry->ca_bucket, dbf->header->bucket_size); |
447 | _gdbm_full_write (dbf, ca_entry->ca_bucket, dbf->header->bucket_size)); | ||
448 | if (rc) | 443 | if (rc) |
449 | { | 444 | { |
450 | GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, | 445 | GDBM_DEBUG (GDBM_DEBUG_STORE|GDBM_DEBUG_ERR, |
diff --git a/src/debug.c b/src/debug.c index 00f568c..08957ed 100644 --- a/src/debug.c +++ b/src/debug.c | |||
@@ -136,140 +136,3 @@ gdbm_debug_datum (datum dat, char const *pfx) | |||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | |||
140 | struct hook_list | ||
141 | { | ||
142 | struct hook_list *next; | ||
143 | struct hook_list *prev; | ||
144 | char *id; | ||
145 | gdbm_debug_hook hook; | ||
146 | void *data; | ||
147 | int retval; | ||
148 | }; | ||
149 | |||
150 | static struct hook_list *hook_head, *hook_tail; | ||
151 | static struct hook_list *hook_recent; | ||
152 | |||
153 | static struct hook_list * | ||
154 | hook_lookup_or_install (char const *id, int install) | ||
155 | { | ||
156 | struct hook_list *p; | ||
157 | |||
158 | for (p = hook_head; p; p = p->next) | ||
159 | { | ||
160 | int res = strcmp (p->id, id); | ||
161 | if (res == 0) | ||
162 | return p; | ||
163 | if (res > 0) | ||
164 | break; | ||
165 | } | ||
166 | |||
167 | if (install) | ||
168 | { | ||
169 | struct hook_list *elt = malloc (sizeof *elt); | ||
170 | if (!elt) | ||
171 | return NULL; | ||
172 | elt->id = strdup (id); | ||
173 | if (!elt->id) | ||
174 | { | ||
175 | SAVE_ERRNO (free (elt)); | ||
176 | return NULL; | ||
177 | } | ||
178 | elt->hook = NULL; | ||
179 | elt->next = p; | ||
180 | if (p) | ||
181 | { | ||
182 | if (p->prev) | ||
183 | p->prev->next = elt; | ||
184 | else | ||
185 | hook_head = elt; | ||
186 | elt->prev = p->prev; | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | elt->prev = hook_tail; | ||
191 | if (hook_tail) | ||
192 | hook_tail->next = elt; | ||
193 | else | ||
194 | hook_head = elt; | ||
195 | hook_tail = elt; | ||
196 | } | ||
197 | return elt; | ||
198 | } | ||
199 | |||
200 | return NULL; | ||
201 | } | ||
202 | |||
203 | static struct hook_list * | ||
204 | hook_lookup (char const *id) | ||
205 | { | ||
206 | if (!(hook_recent && strcmp (hook_recent->id, id) == 0)) | ||
207 | hook_recent = hook_lookup_or_install (id, FALSE); | ||
208 | return hook_recent; | ||
209 | } | ||
210 | |||
211 | static void | ||
212 | hook_remove (char const *id) | ||
213 | { | ||
214 | struct hook_list *p; | ||
215 | |||
216 | p = hook_lookup (id); | ||
217 | if (!p) | ||
218 | return; | ||
219 | |||
220 | hook_recent = NULL; | ||
221 | |||
222 | if (p->prev) | ||
223 | p->prev->next = p->next; | ||
224 | else | ||
225 | hook_head = p->next; | ||
226 | |||
227 | if (p->next) | ||
228 | p->next->prev = p->prev; | ||
229 | else | ||
230 | hook_tail = p->prev; | ||
231 | |||
232 | free (p->id); | ||
233 | free (p); | ||
234 | } | ||
235 | |||
236 | static int | ||
237 | default_hook (char const *file, int line, char const *id, void *data) | ||
238 | { | ||
239 | fprintf (stderr, "%s:%d: hit debug hook %s\n", file, line, id); | ||
240 | return 1; | ||
241 | } | ||
242 | |||
243 | void | ||
244 | _gdbm_debug_hook_install (char const *id, gdbm_debug_hook hook, void *data) | ||
245 | { | ||
246 | struct hook_list *p; | ||
247 | |||
248 | p = hook_lookup_or_install (id, TRUE); | ||
249 | p->hook = hook ? hook : default_hook; | ||
250 | p->data = data; | ||
251 | } | ||
252 | |||
253 | void | ||
254 | _gdbm_debug_hook_remove (char const *id) | ||
255 | { | ||
256 | hook_remove (id); | ||
257 | } | ||
258 | |||
259 | int | ||
260 | _gdbm_debug_hook_check (char const *file, int line, char const *id) | ||
261 | { | ||
262 | struct hook_list *p = hook_lookup (id); | ||
263 | if (p) | ||
264 | return p->retval = p->hook (file, line, id, p->data); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | int | ||
269 | _gdbm_debug_hook_val (char const *id) | ||
270 | { | ||
271 | struct hook_list *p = hook_lookup (id); | ||
272 | if (p) | ||
273 | return p->retval; | ||
274 | return 0; | ||
275 | } | ||
diff --git a/src/falloc.c b/src/falloc.c index c3bd145..13ee0ed 100644 --- a/src/falloc.c +++ b/src/falloc.c | |||
@@ -182,8 +182,7 @@ pop_avail_block (GDBM_FILE dbf) | |||
182 | + sizeof (avail_block)); | 182 | + sizeof (avail_block)); |
183 | 183 | ||
184 | /* Allocate space for the block. */ | 184 | /* Allocate space for the block. */ |
185 | new_blk = GDBM_DEBUG_ALLOC ("pop_avail_block:malloc-failure", | 185 | new_blk = malloc (new_el.av_size); |
186 | malloc (new_el.av_size)); | ||
187 | if (new_blk == NULL) | 186 | if (new_blk == NULL) |
188 | { | 187 | { |
189 | GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE); | 188 | GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE); |
@@ -192,8 +191,7 @@ pop_avail_block (GDBM_FILE dbf) | |||
192 | } | 191 | } |
193 | 192 | ||
194 | /* Read the block. */ | 193 | /* Read the block. */ |
195 | file_pos = GDBM_DEBUG_OVERRIDE ("pop_avail_block:lseek-failure", | 194 | file_pos = __lseek (dbf, new_el.av_adr, SEEK_SET); |
196 | __lseek (dbf, new_el.av_adr, SEEK_SET)); | ||
197 | if (file_pos != new_el.av_adr) | 195 | if (file_pos != new_el.av_adr) |
198 | { | 196 | { |
199 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); | 197 | GDBM_SET_ERRNO (dbf, GDBM_FILE_SEEK_ERROR, TRUE); |
@@ -202,8 +200,7 @@ pop_avail_block (GDBM_FILE dbf) | |||
202 | return -1; | 200 | return -1; |
203 | } | 201 | } |
204 |