Overview
Comment: | Updated debugging messages to be written in a single fprintf() call in an attempt to avoid having them intermingled when written from multiple threads |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
402217513a8843acd53a30fc9cc6fdf4 |
User & Date: | rkeene on 2013-01-15 14:11:52 |
Other Links: | manifest | tags |
Context
2013-01-15
| ||
14:20 | Updated to make "leakcheck" more tolerant of %p formats check-in: 33a93aab41 user: rkeene tags: trunk | |
14:12 | Merged in trunk check-in: 8f27214611 user: rkeene tags: piv | |
14:11 | Updated debugging messages to be written in a single fprintf() call in an attempt to avoid having them intermingled when written from multiple threads check-in: 402217513a user: rkeene tags: trunk | |
2012-07-30
| ||
16:02 | Updated email address in CACKey for OSX Build Script check-in: 003e5de0f0 user: kvanals tags: trunk | |
Changes
Modified cackey.c from [3db9c71bd5] to [6307d2f89c].
︙ | ︙ | |||
173 174 175 176 177 178 179 | #define MAX_ATR_SIZE 1024 #endif #ifdef CACKEY_DEBUG # ifdef HAVE_TIME_H # include <time.h> static time_t cackey_debug_start_time = 0; | > > > > | > > | > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > | > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | #define MAX_ATR_SIZE 1024 #endif #ifdef CACKEY_DEBUG # ifdef HAVE_TIME_H # include <time.h> static time_t cackey_debug_start_time = 0; static unsigned long CACKEY_DEBUG_GETTIME(void) { if (cackey_debug_start_time == 0) { cackey_debug_start_time = time(NULL); } return(time(NULL) - cackey_debug_start_time); } # else static unsigned long CACKEY_DEBUG_GETTIME(void) { return(0); } # endif # define CACKEY_DEBUG_PRINTF(x...) { \ static char buf_user[4096] = {0}; \ snprintf(buf_user, sizeof(buf_user), x); \ buf_user[sizeof(buf_user) - 1] = '\0'; \ fprintf(cackey_debug_fd(), "[%lu]: %s():%i: %s\n", CACKEY_DEBUG_GETTIME(), __func__, __LINE__, buf_user); \ fflush(cackey_debug_fd()); \ } # define CACKEY_DEBUG_PRINTBUF(f, x, y) { \ static char buf_user[4096] = {0}, *buf_user_p; \ unsigned long buf_user_size; \ unsigned char *TMPBUF; \ unsigned long idx; \ int snprintf_ret; \ TMPBUF = (unsigned char *) (x); \ buf_user_p = buf_user; \ buf_user_size = sizeof(buf_user); \ for (idx = 1; idx < (y); idx++) { \ if (buf_user_size <= 0) { \ break; \ }; \ snprintf_ret = snprintf(buf_user_p, buf_user_size, ", %02x", TMPBUF[idx]); \ if (snprintf_ret <= 0) { \ break; \ }; \ buf_user_p += snprintf_ret; \ buf_user_size -= snprintf_ret; \ }; \ buf_user[sizeof(buf_user) - 1] = '\0'; \ fprintf(cackey_debug_fd(), "[%lu]: %s():%i: %s (%s/%lu = {%02x%s})\n", CACKEY_DEBUG_GETTIME(), __func__, __LINE__, f, #x, (unsigned long) (y), TMPBUF[0], buf_user); \ fflush(cackey_debug_fd()); \ } # define free(x) { CACKEY_DEBUG_PRINTF("FREE(%p) (%s)", (void *) x, #x); free(x); } static FILE *cackey_debug_fd(void) { static FILE *fd = NULL; char *logfile; if (fd != NULL) { |
︙ | ︙ | |||
233 234 235 236 237 238 239 | } static void *CACKEY_DEBUG_FUNC_MALLOC(size_t size, const char *func, int line) { void *retval; retval = malloc(size); | < < < | < < < | < < < | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | } static void *CACKEY_DEBUG_FUNC_MALLOC(size_t size, const char *func, int line) { void *retval; retval = malloc(size); fprintf(cackey_debug_fd(), "[%lu]: %s():%i: MALLOC() = %p\n", CACKEY_DEBUG_GETTIME(), func, line, retval); fflush(cackey_debug_fd()); return(retval); } static void *CACKEY_DEBUG_FUNC_REALLOC(void *ptr, size_t size, const char *func, int line) { void *retval; retval = realloc(ptr, size); if (retval != ptr) { fprintf(cackey_debug_fd(), "[%lu]: %s():%i: REALLOC(%p) = %p\n", CACKEY_DEBUG_GETTIME(), func, line, ptr, retval); fflush(cackey_debug_fd()); } if (retval == NULL) { CACKEY_DEBUG_PRINTF(" *** ERROR *** realloc returned NULL (size = %lu)", (unsigned long) size); } return(retval); } static char *CACKEY_DEBUG_FUNC_STRDUP(const char *ptr, const char *func, int line) { char *retval; retval = strdup(ptr); fprintf(cackey_debug_fd(), "[%lu]: %s():%i: STRDUP_MALLOC() = %p\n", CACKEY_DEBUG_GETTIME(), func, line, retval); fflush(cackey_debug_fd()); return(retval); } static const char *CACKEY_DEBUG_FUNC_TAG_TO_STR(unsigned char tag) { switch (tag) { |
︙ | ︙ | |||
652 653 654 655 656 657 658 | # ifdef strdup # undef strdup # endif # define strdup(x) CACKEY_DEBUG_FUNC_STRDUP(x, __func__, __LINE__) #else # define CACKEY_DEBUG_PRINTF(x...) /**/ # define CACKEY_DEBUG_PRINTBUF(f, x, y) /**/ | < | 679 680 681 682 683 684 685 686 687 688 689 690 691 692 | # ifdef strdup # undef strdup # endif # define strdup(x) CACKEY_DEBUG_FUNC_STRDUP(x, __func__, __LINE__) #else # define CACKEY_DEBUG_PRINTF(x...) /**/ # define CACKEY_DEBUG_PRINTBUF(f, x, y) /**/ # define CACKEY_DEBUG_FUNC_TAG_TO_STR(x) "DEBUG_DISABLED" # define CACKEY_DEBUG_FUNC_SCARDERR_TO_STR(x) "DEBUG_DISABLED" # define CACKEY_DEBUG_FUNC_OBJID_TO_STR(x) "DEBUG_DISABLED" # define CACKEY_DEBUG_FUNC_APPTYPE_TO_STR(x) "DEBUG_DISABLED" # define CACKEY_DEBUG_FUNC_ATTRIBUTE_TO_STR(x) "DEBUG_DISABLED" #endif |
︙ | ︙ |