comparison src/debug.c @ 125:23a36ac0514d

recover dropped pragma pack line, use int64_t rather than off_t to avoid forcing users of the shared library to enable large file support.
author Carl Byington <carl@five-ten-sg.com>
date Tue, 03 Feb 2009 15:01:47 -0800
parents ab2a11e72250
children fc11b1d1ad34
comparison
equal deleted inserted replaced
124:cbf63dd3f109 125:23a36ac0514d
46 46
47 if (!out) return; // no file 47 if (!out) return; // no file
48 if (col == -1) col = NUM_COL; 48 if (col == -1) col = NUM_COL;
49 fprintf(out, "\n"); 49 fprintf(out, "\n");
50 while (off < size) { 50 while (off < size) {
51 fprintf(out, "%06"PRIx64"\t:", (uint64_t)(off+delta)); 51 fprintf(out, "%06"PRIx64"\t:", (int64_t)(off+delta));
52 toff = off; 52 toff = off;
53 while (count < col && off < size) { 53 while (count < col && off < size) {
54 fprintf(out, "%02hhx ", (unsigned char)buf[off]); 54 fprintf(out, "%02hhx ", (unsigned char)buf[off]);
55 off++; count++; 55 off++; count++;
56 } 56 }
249 249
250 void pst_debug_write() { 250 void pst_debug_write() {
251 size_t size, ptr, funcname, filename, text, end; 251 size_t size, ptr, funcname, filename, text, end;
252 char *buf = NULL, rec_type; 252 char *buf = NULL, rec_type;
253 if (!debug_fp) return; // no file 253 if (!debug_fp) return; // no file
254 uint64_t index_pos = ftello(debug_fp); 254 int64_t index_pos = ftello(debug_fp);
255 uint64_t file_pos = index_pos; 255 int64_t file_pos = index_pos;
256 // add 2. One for the pointer to the next index, 256 // add 2. One for the pointer to the next index,
257 // one for the count of this index 257 // one for the count of this index
258 int index_size = ((curr_items+2) * sizeof(uint64_t)); 258 int index_size = ((curr_items+2) * sizeof(int64_t));
259 uint64_t *index; 259 int64_t *index;
260 int index_ptr = 0; 260 int index_ptr = 0;
261 struct pst_debug_file_rec_m mfile_rec; 261 struct pst_debug_file_rec_m mfile_rec;
262 struct pst_debug_file_rec_l lfile_rec; 262 struct pst_debug_file_rec_l lfile_rec;
263 263
264 if (curr_items == 0) return; // no items to write. 264 if (curr_items == 0) return; // no items to write.
265 265
266 index = (uint64_t*)xmalloc(index_size); 266 index = (int64_t*)xmalloc(index_size);
267 memset(index, 0, index_size); // valgrind, avoid writing uninitialized data 267 memset(index, 0, index_size); // valgrind, avoid writing uninitialized data
268 file_pos += index_size; 268 file_pos += index_size;
269 // write the index first, we will re-write it later, but 269 // write the index first, we will re-write it later, but
270 // we want to allocate the space 270 // we want to allocate the space
271 pst_debug_fwrite(index, index_size, 1, debug_fp); 271 pst_debug_fwrite(index, index_size, 1, debug_fp);
333 333
334 void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) { 334 void pst_debug_write_msg(struct pst_debug_item *item, const char *fmt, va_list *ap, int size) {
335 struct pst_debug_file_rec_l lfile_rec; 335 struct pst_debug_file_rec_l lfile_rec;
336 struct pst_debug_file_rec_m mfile_rec; 336 struct pst_debug_file_rec_m mfile_rec;
337 unsigned char rec_type; 337 unsigned char rec_type;
338 int index_size = 3 * sizeof(uint64_t); 338 int index_size = 3 * sizeof(int64_t);
339 uint64_t index[3]; 339 int64_t index[3];
340 uint64_t index_pos, file_pos; 340 int64_t index_pos, file_pos;
341 char zero = '\0'; 341 char zero = '\0';
342 unsigned int end; 342 unsigned int end;
343 if (!debug_fp) return; // no file 343 if (!debug_fp) return; // no file
344 index[0] = 1; // only one item in this index 344 index[0] = 1; // only one item in this index
345 index[1] = 0; // valgrind, avoid writing uninitialized data 345 index[1] = 0; // valgrind, avoid writing uninitialized data
395 395
396 396
397 void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col) { 397 void pst_debug_write_hex(struct pst_debug_item *item, char *buf, size_t size, int col) {
398 struct pst_debug_file_rec_l lfile_rec; 398 struct pst_debug_file_rec_l lfile_rec;
399 unsigned char rec_type; 399 unsigned char rec_type;
400 int index_size = 3 * sizeof(uint64_t); 400 int index_size = 3 * sizeof(int64_t);
401 uint64_t index_pos, file_pos, index[3]; 401 int64_t index_pos, file_pos, index[3];
402 char zero='\0'; 402 char zero='\0';
403 if (!debug_fp) return; // no file 403 if (!debug_fp) return; // no file
404 index[0] = 1; // only one item in this index run 404 index[0] = 1; // only one item in this index run
405 index[1] = 0; // valgrind, avoid writing uninitialized data 405 index[1] = 0; // valgrind, avoid writing uninitialized data
406 index[2] = 0; // "" 406 index[2] = 0; // ""