printgprof.c (7c478bd9) | printgprof.c (92ed1782) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * --- 5 unchanged lines hidden (view full) --- 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ |
22 |
|
22/* | 23/* |
23 * Copyright (c) 1990-1998 by Sun Microsystems, Inc. 24 * All rights reserved. | 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. |
25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <ctype.h> 30#include <string.h> 31#include <sys/param.h> 32#include <stdlib.h> 33#include "gprof.h" 34 35extern int find_run_directory(char *, char *, char *, char **, char *); 36void print_demangled_name(int, nltype *); 37void striped_name(char *, nltype **); 38 | 26 */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 30#include <ctype.h> 31#include <string.h> 32#include <sys/param.h> 33#include <stdlib.h> 34#include "gprof.h" 35 36extern int find_run_directory(char *, char *, char *, char **, char *); 37void print_demangled_name(int, nltype *); 38void striped_name(char *, nltype **); 39 |
39 40extern char *demangle(); 41char *strstr(); 42char *parsename(); 43char name_buffer[512]; | |
44extern long hz; 45 46/* 47 * Symbols that must never be printed, no matter what. 48 */ 49char *splsym[] = { 50 PRF_ETEXT, 51 PRF_EXTSYM, 52 PRF_MEMTERM, | 40extern long hz; 41 42/* 43 * Symbols that must never be printed, no matter what. 44 */ 45char *splsym[] = { 46 PRF_ETEXT, 47 PRF_EXTSYM, 48 PRF_MEMTERM, |
53 0 | 49 NULL |
54}; 55 | 50}; 51 |
52static bool is_special_sym(nltype *nlp); 53 |
|
56char * 57demangled_name(nltype *selfp) 58{ 59 char *name; 60 if (!Cflag) 61 return (selfp->name); 62 | 54char * 55demangled_name(nltype *selfp) 56{ 57 char *name; 58 if (!Cflag) 59 return (selfp->name); 60 |
63 name = (char *) sgs_demangle(selfp->name); | 61 name = (char *)sgs_demangle(selfp->name); |
64 return (name); 65} 66 67void | 62 return (name); 63} 64 65void |
68printprof() | 66printprof(void) |
69{ 70 nltype *np; 71 nltype **sortednlp; 72 int i, index; 73 int print_count = number_funcs_toprint; 74 bool print_flag = TRUE; 75 mod_info_t *mi; 76 77 actime = 0.0; | 67{ 68 nltype *np; 69 nltype **sortednlp; 70 int i, index; 71 int print_count = number_funcs_toprint; 72 bool print_flag = TRUE; 73 mod_info_t *mi; 74 75 actime = 0.0; |
78 printf("\f\n"); | 76 (void) printf("\f\n"); |
79 flatprofheader(); 80 81 /* 82 * Sort the symbol table in by time 83 */ 84 sortednlp = (nltype **) calloc(total_names, sizeof (nltype *)); 85 if (sortednlp == (nltype **) 0) { | 77 flatprofheader(); 78 79 /* 80 * Sort the symbol table in by time 81 */ 82 sortednlp = (nltype **) calloc(total_names, sizeof (nltype *)); 83 if (sortednlp == (nltype **) 0) { |
86 fprintf(stderr, | 84 (void) fprintf(stderr, |
87 "[printprof] ran out of memory for time sorting\n"); 88 } 89 90 index = 0; 91 for (mi = &modules; mi; mi = mi->next) { 92 for (i = 0; i < mi->nname; i++) 93 sortednlp[index++] = &(mi->nl[i]); 94 } 95 | 85 "[printprof] ran out of memory for time sorting\n"); 86 } 87 88 index = 0; 89 for (mi = &modules; mi; mi = mi->next) { 90 for (i = 0; i < mi->nname; i++) 91 sortednlp[index++] = &(mi->nl[i]); 92 } 93 |
96 qsort(sortednlp, total_names, sizeof (nltype *), 97 (int(*)(const void *, const void *))timecmp); | 94 qsort(sortednlp, total_names, sizeof (nltype *), timecmp); |
98 99 for (index = 0; (index < total_names) && print_flag; index += 1) { 100 np = sortednlp[index]; 101 flatprofline(np); 102 if (nflag) { 103 if (--print_count == 0) 104 print_flag = FALSE; 105 } 106 } 107 actime = 0.0; 108 free(sortednlp); 109} 110 111int | 95 96 for (index = 0; (index < total_names) && print_flag; index += 1) { 97 np = sortednlp[index]; 98 flatprofline(np); 99 if (nflag) { 100 if (--print_count == 0) 101 print_flag = FALSE; 102 } 103 } 104 actime = 0.0; 105 free(sortednlp); 106} 107 108int |
112timecmp(nltype **npp1, nltype **npp2) | 109timecmp(const void *arg1, const void *arg2) |
113{ | 110{ |
111 nltype **npp1 = (nltype **)arg1; 112 nltype **npp2 = (nltype **)arg2; |
|
114 double timediff; 115 long calldiff; 116 117 timediff = (*npp2)->time - (*npp1)->time; 118 119 if (timediff > 0.0) 120 return (1); 121 --- 17 unchanged lines hidden (view full) --- 139void 140flatprofheader() 141{ 142 143 if (bflag) 144 printblurb(FLAT_BLURB); 145 146 if (old_style) { | 113 double timediff; 114 long calldiff; 115 116 timediff = (*npp2)->time - (*npp1)->time; 117 118 if (timediff > 0.0) 119 return (1); 120 --- 17 unchanged lines hidden (view full) --- 138void 139flatprofheader() 140{ 141 142 if (bflag) 143 printblurb(FLAT_BLURB); 144 145 if (old_style) { |
147 printf("\ngranularity: each sample hit covers %d byte(s)", 148 (long)scale * sizeof (UNIT)); | 146 (void) printf( 147 "\ngranularity: each sample hit covers %d byte(s)", 148 (long)scale * sizeof (UNIT)); |
149 if (totime > 0.0) { | 149 if (totime > 0.0) { |
150 printf(" for %.2f%% of %.2f seconds\n\n", | 150 (void) printf(" for %.2f%% of %.2f seconds\n\n", |
151 100.0/totime, totime / hz); 152 } else { | 151 100.0/totime, totime / hz); 152 } else { |
153 printf(" no time accumulated\n\n"); | 153 (void) printf(" no time accumulated\n\n"); |
154 /* 155 * this doesn't hurt since all the numerators will 156 * be zero. 157 */ 158 totime = 1.0; 159 } 160 } 161 | 154 /* 155 * this doesn't hurt since all the numerators will 156 * be zero. 157 */ 158 totime = 1.0; 159 } 160 } 161 |
162 printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", | 162 (void) printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", |
163 "% ", "cumulative", "self ", "", "self ", "total ", ""); | 163 "% ", "cumulative", "self ", "", "self ", "total ", ""); |
164 printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", | 164 (void) printf("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", |
165 "time", "seconds ", "seconds", "calls", 166 "ms/call", "ms/call", "name"); 167} 168 169void 170flatprofline(nltype *np) 171{ 172 if (zflag == 0 && np->ncall == 0 && np->time == 0) 173 return; 174 175 /* 176 * Do not print certain special symbols, like PRF_EXTSYM, etc. 177 * even if zflag was on. 178 */ 179 if (is_special_sym(np)) 180 return; 181 182 actime += np->time; 183 | 165 "time", "seconds ", "seconds", "calls", 166 "ms/call", "ms/call", "name"); 167} 168 169void 170flatprofline(nltype *np) 171{ 172 if (zflag == 0 && np->ncall == 0 && np->time == 0) 173 return; 174 175 /* 176 * Do not print certain special symbols, like PRF_EXTSYM, etc. 177 * even if zflag was on. 178 */ 179 if (is_special_sym(np)) 180 return; 181 182 actime += np->time; 183 |
184 printf("%5.1f %10.2f %8.2f", | 184 (void) printf("%5.1f %10.2f %8.2f", |
185 100 * np->time / totime, actime / hz, np->time / hz); 186 187 if (np->ncall != 0) { | 185 100 * np->time / totime, actime / hz, np->time / hz); 186 187 if (np->ncall != 0) { |
188 printf(" %8lld %8.2f %8.2f ", np->ncall, | 188 (void) printf(" %8lld %8.2f %8.2f ", np->ncall, |
189 1000 * np->time / hz / np->ncall, 190 1000 * (np->time + np->childtime) / hz / np->ncall); 191 } else { 192 if (!Cflag) | 189 1000 * np->time / hz / np->ncall, 190 1000 * (np->time + np->childtime) / hz / np->ncall); 191 } else { 192 if (!Cflag) |
193 printf(" %8.8s %8.8s %8.8s ", "", "", ""); | 193 (void) printf(" %8.8s %8.8s %8.8s ", "", "", ""); |
194 else | 194 else |
195 printf(" %8.8s %8.8s %8.8s ", "", "", ""); | 195 (void) printf(" %8.8s %8.8s %8.8s ", "", "", ""); |
196 } 197 198 printname(np); 199 200 if (Cflag) 201 print_demangled_name(55, np); 202 | 196 } 197 198 printname(np); 199 200 if (Cflag) 201 print_demangled_name(55, np); 202 |
203 printf("\n"); | 203 (void) printf("\n"); |
204} 205 206void 207gprofheader() 208{ 209 210 if (bflag) 211 printblurb(CALLG_BLURB); 212 213 if (old_style) { 214 | 204} 205 206void 207gprofheader() 208{ 209 210 if (bflag) 211 printblurb(CALLG_BLURB); 212 213 if (old_style) { 214 |
215 printf("\ngranularity: each sample hit covers %d byte(s)", 216 (long)scale * sizeof (UNIT)); | 215 (void) printf( 216 "\ngranularity: each sample hit covers %d byte(s)", 217 (long)scale * sizeof (UNIT)); |
217 218 if (printtime > 0.0) { | 218 219 if (printtime > 0.0) { |
219 printf(" for %.2f%% of %.2f seconds\n\n", | 220 (void) printf(" for %.2f%% of %.2f seconds\n\n", |
220 100.0/printtime, printtime / hz); 221 } else { | 221 100.0/printtime, printtime / hz); 222 } else { |
222 printf(" no time propagated\n\n"); | 223 (void) printf(" no time propagated\n\n"); |
223 /* 224 * this doesn't hurt, since all the numerators 225 * will be 0.0 226 */ 227 printtime = 1.0; 228 } 229 } else { | 224 /* 225 * this doesn't hurt, since all the numerators 226 * will be 0.0 227 */ 228 printtime = 1.0; 229 } 230 } else { |
230 printf("\ngranularity: each pc-hit is considered 1 tick"); | 231 (void) printf( 232 "\ngranularity: each pc-hit is considered 1 tick"); |
231 if (hz != 1) { | 233 if (hz != 1) { |
232 printf(" (@ %4.3f seconds per tick)", 233 (double) 1.0 / hz); | 234 (void) printf(" (@ %4.3f seconds per tick)", 235 (double)1.0 / hz); |
234 } | 236 } |
235 puts("\n\n"); | 237 (void) puts("\n\n"); |
236 } 237 | 238 } 239 |
238 printf("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n", | 240 (void) printf("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n", |
239 "", "", "", "", "called", "total", "parents"); | 241 "", "", "", "", "called", "total", "parents"); |
240 printf("%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n", | 242 (void) printf("%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n", |
241 "index", "%time", "self", "descendents", 242 "called", "self", "name", "index"); | 243 "index", "%time", "self", "descendents", 244 "called", "self", "name", "index"); |
243 printf("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n", | 245 (void) printf("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n", |
244 "", "", "", "", "called", "total", "children"); | 246 "", "", "", "", "called", "total", "children"); |
245 printf("\n"); | 247 (void) printf("\n"); |
246} 247 248void 249gprofline(nltype *np) 250{ 251 char kirkbuffer[BUFSIZ]; 252 | 248} 249 250void 251gprofline(nltype *np) 252{ 253 char kirkbuffer[BUFSIZ]; 254 |
253 sprintf(kirkbuffer, "[%d]", np->index); 254 printf("%-6.6s %5.1f %7.2f %11.2f", kirkbuffer, | 255 (void) sprintf(kirkbuffer, "[%d]", np->index); 256 (void) printf("%-6.6s %5.1f %7.2f %11.2f", kirkbuffer, |
255 100 * (np->propself + np->propchild) / printtime, 256 np->propself / hz, np->propchild / hz); 257 258 if ((np->ncall + np->selfcalls) != 0) { | 257 100 * (np->propself + np->propchild) / printtime, 258 np->propself / hz, np->propchild / hz); 259 260 if ((np->ncall + np->selfcalls) != 0) { |
259 printf(" %7lld", np->ncall); | 261 (void) printf(" %7lld", np->ncall); |
260 261 if (np->selfcalls != 0) | 262 263 if (np->selfcalls != 0) |
262 printf("+%-7lld ", np->selfcalls); | 264 (void) printf("+%-7lld ", np->selfcalls); |
263 else | 265 else |
264 printf(" %7.7s ", ""); | 266 (void) printf(" %7.7s ", ""); |
265 } else { | 267 } else { |
266 printf(" %7.7s %7.7s ", "", ""); | 268 (void) printf(" %7.7s %7.7s ", "", ""); |
267 } 268 269 printname(np); 270 271 if (Cflag) 272 print_demangled_name(50, np); 273 | 269 } 270 271 printname(np); 272 273 if (Cflag) 274 print_demangled_name(50, np); 275 |
274 printf("\n"); | 276 (void) printf("\n"); |
275} 276 277static bool 278is_special_sym(nltype *nlp) 279{ 280 int i; 281 282 if (nlp->name == NULL) --- 43 unchanged lines hidden (view full) --- 326 printcycle(parentp); 327 printmembers(parentp); 328 } else { 329 printparents(parentp); 330 gprofline(parentp); 331 printchildren(parentp); 332 } 333 | 277} 278 279static bool 280is_special_sym(nltype *nlp) 281{ 282 int i; 283 284 if (nlp->name == NULL) --- 43 unchanged lines hidden (view full) --- 328 printcycle(parentp); 329 printmembers(parentp); 330 } else { 331 printparents(parentp); 332 gprofline(parentp); 333 printchildren(parentp); 334 } 335 |
334 printf("\n"); 335 printf("-----------------------------------------------\n"); 336 printf("\n"); | 336 (void) printf("\n"); 337 (void) printf( 338 "-----------------------------------------------\n"); 339 (void) printf("\n"); |
337 338 if (nflag) { 339 --print_count; 340 if (print_count == 0) 341 count_flag = FALSE; 342 } 343 } 344 free(timesortnlp); 345} 346 347/* 348 * sort by decreasing propagated time 349 * if times are equal, but one is a cycle header, 350 * say that's first (e.g. less, i.e. -1). 351 * if one's name doesn't have an underscore and the other does, 352 * say the one is first. 353 * all else being equal, sort by names. 354 */ 355int | 340 341 if (nflag) { 342 --print_count; 343 if (print_count == 0) 344 count_flag = FALSE; 345 } 346 } 347 free(timesortnlp); 348} 349 350/* 351 * sort by decreasing propagated time 352 * if times are equal, but one is a cycle header, 353 * say that's first (e.g. less, i.e. -1). 354 * if one's name doesn't have an underscore and the other does, 355 * say the one is first. 356 * all else being equal, sort by names. 357 */ 358int |
356totalcmp(nltype **npp1, nltype **npp2) | 359totalcmp(const void *arg1, const void *arg2) |
357{ | 360{ |
361 nltype **npp1 = (nltype **)arg1; 362 nltype **npp2 = (nltype **)arg2; |
|
358 nltype *np1 = *npp1; 359 nltype *np2 = *npp2; 360 double diff; 361 362 diff = (np1->propself + np1->propchild) - 363 (np2->propself + np2->propchild); 364 365 if (diff < 0.0) --- 28 unchanged lines hidden (view full) --- 394 nltype *cycleheadp; 395 396 if (childp->cyclehead != 0) 397 cycleheadp = childp -> cyclehead; 398 else 399 cycleheadp = childp; 400 401 if (childp->parents == 0) { | 363 nltype *np1 = *npp1; 364 nltype *np2 = *npp2; 365 double diff; 366 367 diff = (np1->propself + np1->propchild) - 368 (np2->propself + np2->propchild); 369 370 if (diff < 0.0) --- 28 unchanged lines hidden (view full) --- 399 nltype *cycleheadp; 400 401 if (childp->cyclehead != 0) 402 cycleheadp = childp -> cyclehead; 403 else 404 cycleheadp = childp; 405 406 if (childp->parents == 0) { |
402 printf("%6.6s %5.5s %7.7s %11.11s %7.7s %7.7s" | 407 (void) printf("%6.6s %5.5s %7.7s %11.11s %7.7s %7.7s" |
403 " <spontaneous>\n", "", "", "", "", "", ""); 404 return; 405 } 406 407 sortparents(childp); 408 409 for (arcp = childp->parents; arcp; arcp = arcp->arc_parentlist) { 410 parentp = arcp -> arc_parentp; 411 if (childp == parentp || (childp->cycleno != 0 && 412 parentp->cycleno == childp->cycleno)) { 413 /* 414 * selfcall or call among siblings 415 */ | 408 " <spontaneous>\n", "", "", "", "", "", ""); 409 return; 410 } 411 412 sortparents(childp); 413 414 for (arcp = childp->parents; arcp; arcp = arcp->arc_parentlist) { 415 parentp = arcp -> arc_parentp; 416 if (childp == parentp || (childp->cycleno != 0 && 417 parentp->cycleno == childp->cycleno)) { 418 /* 419 * selfcall or call among siblings 420 */ |
416 printf("%6.6s %5.5s %7.7s %11.11s %7lld %7.7s ", | 421 (void) printf( 422 "%6.6s %5.5s %7.7s %11.11s %7lld %7.7s ", |
417 "", "", "", "", arcp->arc_count, ""); 418 printname(parentp); 419 420 if (Cflag) 421 print_demangled_name(54, parentp); 422 | 423 "", "", "", "", arcp->arc_count, ""); 424 printname(parentp); 425 426 if (Cflag) 427 print_demangled_name(54, parentp); 428 |
423 printf("\n"); | 429 (void) printf("\n"); |
424 } else { 425 /* 426 * regular parent of child 427 */ | 430 } else { 431 /* 432 * regular parent of child 433 */ |
428 printf("%6.6s %5.5s %7.2f %11.2f %7lld/%-7lld ", "", | 434 (void) printf( 435 "%6.6s %5.5s %7.2f %11.2f %7lld/%-7lld ", "", |
429 "", arcp->arc_time / hz, arcp->arc_childtime / hz, 430 arcp->arc_count, cycleheadp->ncall); 431 printname(parentp); 432 433 if (Cflag) 434 print_demangled_name(54, parentp); 435 | 436 "", arcp->arc_time / hz, arcp->arc_childtime / hz, 437 arcp->arc_count, cycleheadp->ncall); 438 printname(parentp); 439 440 if (Cflag) 441 print_demangled_name(54, parentp); 442 |
436 printf("\n"); | 443 (void) printf("\n"); |
437 } 438 } 439} 440 441void 442printchildren(nltype *parentp) 443{ 444 nltype *childp; 445 arctype *arcp; 446 447 sortchildren(parentp); 448 449 for (arcp = parentp->children; arcp; arcp = arcp->arc_childlist) { 450 childp = arcp->arc_childp; 451 if (childp == parentp || (childp->cycleno != 0 && 452 childp->cycleno == parentp->cycleno)) { 453 /* 454 * self call or call to sibling 455 */ | 444 } 445 } 446} 447 448void 449printchildren(nltype *parentp) 450{ 451 nltype *childp; 452 arctype *arcp; 453 454 sortchildren(parentp); 455 456 for (arcp = parentp->children; arcp; arcp = arcp->arc_childlist) { 457 childp = arcp->arc_childp; 458 if (childp == parentp || (childp->cycleno != 0 && 459 childp->cycleno == parentp->cycleno)) { 460 /* 461 * self call or call to sibling 462 */ |
456 printf("%6.6s %5.5s %7.7s %11.11s %7lld %7.7s ", | 463 (void) printf( 464 "%6.6s %5.5s %7.7s %11.11s %7lld %7.7s ", |
457 "", "", "", "", arcp->arc_count, ""); 458 printname(childp); 459 460 if (Cflag) 461 print_demangled_name(54, childp); 462 | 465 "", "", "", "", arcp->arc_count, ""); 466 printname(childp); 467 468 if (Cflag) 469 print_demangled_name(54, childp); 470 |
463 printf("\n"); | 471 (void) printf("\n"); |
464 } else { 465 /* 466 * regular child of parent 467 */ 468 if (childp->cyclehead) | 472 } else { 473 /* 474 * regular child of parent 475 */ 476 if (childp->cyclehead) |
469 printf("%6.6s %5.5s %7.2f %11.2f " | 477 (void) printf("%6.6s %5.5s %7.2f %11.2f " |
470 "%7lld/%-7lld ", "", "", 471 arcp->arc_time / hz, 472 arcp->arc_childtime / hz, arcp->arc_count, 473 childp->cyclehead->ncall); 474 else | 478 "%7lld/%-7lld ", "", "", 479 arcp->arc_time / hz, 480 arcp->arc_childtime / hz, arcp->arc_count, 481 childp->cyclehead->ncall); 482 else |
475 printf("%6.6s %5.5s %7.2f %11.2f " | 483 (void) printf("%6.6s %5.5s %7.2f %11.2f " |
476 "%7lld %7.7s ", 477 "", "", arcp->arc_time / hz, 478 arcp->arc_childtime / hz, arcp->arc_count, 479 ""); 480 481 printname(childp); 482 483 if (Cflag) 484 print_demangled_name(54, childp); 485 | 484 "%7lld %7.7s ", 485 "", "", arcp->arc_time / hz, 486 arcp->arc_childtime / hz, arcp->arc_count, 487 ""); 488 489 printname(childp); 490 491 if (Cflag) 492 print_demangled_name(54, childp); 493 |
486 printf("\n"); | 494 (void) printf("\n"); |
487 } 488 } 489} 490 491void 492printname(nltype *selfp) 493{ 494 char *c; 495 c = demangled_name(selfp); 496 497 if (selfp->name != 0) { 498 if (!Cflag) | 495 } 496 } 497} 498 499void 500printname(nltype *selfp) 501{ 502 char *c; 503 c = demangled_name(selfp); 504 505 if (selfp->name != 0) { 506 if (!Cflag) |
499 printf("%s", selfp->name); | 507 (void) printf("%s", selfp->name); |
500 else | 508 else |
501 printf("%s", c); | 509 (void) printf("%s", c); |
502 503#ifdef DEBUG 504 if (debug & DFNDEBUG) | 510 511#ifdef DEBUG 512 if (debug & DFNDEBUG) |
505 printf("{%d} ", selfp->toporder); | 513 (void) printf("{%d} ", selfp->toporder); |
506 507 if (debug & PROPDEBUG) | 514 515 if (debug & PROPDEBUG) |
508 printf("%5.2f%% ", selfp->propfraction); 509#endif DEBUG | 516 (void) printf("%5.2f%% ", selfp->propfraction); 517#endif /* DEBUG */ |
510 } 511 512 if (selfp->cycleno != 0) | 518 } 519 520 if (selfp->cycleno != 0) |
513 printf("\t<cycle %d>", selfp->cycleno); | 521 (void) printf("\t<cycle %d>", selfp->cycleno); |
514 515 if (selfp->index != 0) { 516 if (selfp->printflag) | 522 523 if (selfp->index != 0) { 524 if (selfp->printflag) |
517 printf(" [%d]", selfp->index); | 525 (void) printf(" [%d]", selfp->index); |
518 else | 526 else |
519 printf(" (%d)", selfp->index); | 527 (void) printf(" (%d)", selfp->index); |
520 } 521} 522 523void 524print_demangled_name(int n, nltype *selfp) 525{ 526 char *c; 527 int i; 528 529 c = selfp->name; 530 531 if (strcmp(c, demangled_name(selfp)) == 0) 532 return; 533 else { | 528 } 529} 530 531void 532print_demangled_name(int n, nltype *selfp) 533{ 534 char *c; 535 int i; 536 537 c = selfp->name; 538 539 if (strcmp(c, demangled_name(selfp)) == 0) 540 return; 541 else { |
534 printf("\n"); | 542 (void) printf("\n"); |
535 for (i = 1; i < n; i++) | 543 for (i = 1; i < n; i++) |
536 printf(" "); 537 printf("[%s]", selfp->name); | 544 (void) printf(" "); 545 (void) printf("[%s]", selfp->name); |
538 } 539} 540 | 546 } 547} 548 |
541char *exotic(); 542 | |
543void 544sortchildren(nltype *parentp) 545{ 546 arctype *arcp; 547 arctype *detachedp; 548 arctype sorted; 549 arctype *prevp; 550 551 /* 552 * unlink children from parent, 553 * then insertion sort back on to sorted's children. 554 * *arcp the arc you have detached and are inserting. 555 * *detachedp the rest of the arcs to be sorted. 556 * sorted arc list onto which you insertion sort. 557 * *prevp arc before the arc you are comparing. 558 */ 559 sorted.arc_childlist = 0; 560 | 549void 550sortchildren(nltype *parentp) 551{ 552 arctype *arcp; 553 arctype *detachedp; 554 arctype sorted; 555 arctype *prevp; 556 557 /* 558 * unlink children from parent, 559 * then insertion sort back on to sorted's children. 560 * *arcp the arc you have detached and are inserting. 561 * *detachedp the rest of the arcs to be sorted. 562 * sorted arc list onto which you insertion sort. 563 * *prevp arc before the arc you are comparing. 564 */ 565 sorted.arc_childlist = 0; 566 |
567 /* LINTED: warning: assignment operator */ |
|
561 for ((arcp = parentp->children) && (detachedp = arcp->arc_childlist); 562 arcp; | 568 for ((arcp = parentp->children) && (detachedp = arcp->arc_childlist); 569 arcp; |
570 /* LINTED: warning: assignment operator */ |
|
563 (arcp = detachedp) && (detachedp = detachedp->arc_childlist)) { 564 /* 565 * consider *arcp as disconnected 566 * insert it into sorted 567 */ 568 for (prevp = &sorted; prevp->arc_childlist; 569 prevp = prevp->arc_childlist) { 570 if (arccmp(arcp, prevp->arc_childlist) != LESSTHAN) --- 23 unchanged lines hidden (view full) --- 594 * then insertion sort back on to sorted's parents. 595 * *arcp the arc you have detached and are inserting. 596 * *detachedp the rest of the arcs to be sorted. 597 * sorted arc list onto which you insertion sort. 598 * *prevp arc before the arc you are comparing. 599 */ 600 sorted.arc_parentlist = 0; 601 | 571 (arcp = detachedp) && (detachedp = detachedp->arc_childlist)) { 572 /* 573 * consider *arcp as disconnected 574 * insert it into sorted 575 */ 576 for (prevp = &sorted; prevp->arc_childlist; 577 prevp = prevp->arc_childlist) { 578 if (arccmp(arcp, prevp->arc_childlist) != LESSTHAN) --- 23 unchanged lines hidden (view full) --- 602 * then insertion sort back on to sorted's parents. 603 * *arcp the arc you have detached and are inserting. 604 * *detachedp the rest of the arcs to be sorted. 605 * sorted arc list onto which you insertion sort. 606 * *prevp arc before the arc you are comparing. 607 */ 608 sorted.arc_parentlist = 0; 609 |
610 /* LINTED: warning: assignment operator */ |
|
602 for ((arcp = childp->parents) && (detachedp = arcp->arc_parentlist); 603 arcp; | 611 for ((arcp = childp->parents) && (detachedp = arcp->arc_parentlist); 612 arcp; |
613 /* LINTED: warning: assignment operator */ |
|
604 (arcp = detachedp) && (detachedp = detachedp->arc_parentlist)) { 605 /* 606 * consider *arcp as disconnected 607 * insert it into sorted 608 */ 609 for (prevp = &sorted; prevp->arc_parentlist; 610 prevp = prevp->arc_parentlist) { 611 if (arccmp(arcp, prevp->arc_parentlist) != GREATERTHAN) --- 9 unchanged lines hidden (view full) --- 621 childp->parents = sorted.arc_parentlist; 622} 623 624void 625printcycle(nltype *cyclep) 626{ 627 char kirkbuffer[BUFSIZ]; 628 | 614 (arcp = detachedp) && (detachedp = detachedp->arc_parentlist)) { 615 /* 616 * consider *arcp as disconnected 617 * insert it into sorted 618 */ 619 for (prevp = &sorted; prevp->arc_parentlist; 620 prevp = prevp->arc_parentlist) { 621 if (arccmp(arcp, prevp->arc_parentlist) != GREATERTHAN) --- 9 unchanged lines hidden (view full) --- 631 childp->parents = sorted.arc_parentlist; 632} 633 634void 635printcycle(nltype *cyclep) 636{ 637 char kirkbuffer[BUFSIZ]; 638 |
629 sprintf(kirkbuffer, "[%d]", cyclep->index); 630 printf("%-6.6s %5.1f %7.2f %11.2f %7lld", kirkbuffer, | 639 (void) sprintf(kirkbuffer, "[%d]", cyclep->index); 640 (void) printf("%-6.6s %5.1f %7.2f %11.2f %7lld", kirkbuffer, |
631 100 * (cyclep->propself + cyclep->propchild) / printtime, 632 cyclep -> propself / hz, cyclep -> propchild / hz, 633 cyclep -> ncall); 634 635 if (cyclep->selfcalls != 0) | 641 100 * (cyclep->propself + cyclep->propchild) / printtime, 642 cyclep -> propself / hz, cyclep -> propchild / hz, 643 cyclep -> ncall); 644 645 if (cyclep->selfcalls != 0) |
636 printf("+%-7lld", cyclep->selfcalls); | 646 (void) printf("+%-7lld", cyclep->selfcalls); |
637 else | 647 else |
638 printf(" %7.7s", ""); | 648 (void) printf(" %7.7s", ""); |
639 | 649 |
640 printf(" <cycle %d as a whole>\t[%d]\n", cyclep->cycleno, | 650 (void) printf(" <cycle %d as a whole>\t[%d]\n", cyclep->cycleno, |
641 cyclep->index); 642} 643 644/* 645 * print the members of a cycle 646 */ 647void 648printmembers(nltype *cyclep) 649{ 650 nltype *memberp; 651 652 sortmembers(cyclep); 653 654 for (memberp = cyclep->cnext; memberp; memberp = memberp->cnext) { | 651 cyclep->index); 652} 653 654/* 655 * print the members of a cycle 656 */ 657void 658printmembers(nltype *cyclep) 659{ 660 nltype *memberp; 661 662 sortmembers(cyclep); 663 664 for (memberp = cyclep->cnext; memberp; memberp = memberp->cnext) { |
655 printf("%6.6s %5.5s %7.2f %11.2f %7lld", "", "", | 665 (void) printf("%6.6s %5.5s %7.2f %11.2f %7lld", "", "", |
656 memberp->propself / hz, memberp->propchild / hz, 657 memberp->ncall); 658 659 if (memberp->selfcalls != 0) | 666 memberp->propself / hz, memberp->propchild / hz, 667 memberp->ncall); 668 669 if (memberp->selfcalls != 0) |
660 printf("+%-7lld", memberp->selfcalls); | 670 (void) printf("+%-7lld", memberp->selfcalls); |
661 else | 671 else |
662 printf(" %7.7s", ""); | 672 (void) printf(" %7.7s", ""); |
663 | 673 |
664 printf(" "); | 674 (void) printf(" "); |
665 printname(memberp); 666 if (Cflag) 667 print_demangled_name(54, memberp); | 675 printname(memberp); 676 if (Cflag) 677 print_demangled_name(54, memberp); |
668 printf("\n"); | 678 (void) printf("\n"); |
669 } 670} 671 672/* 673 * sort members of a cycle 674 */ 675void 676sortmembers(nltype *cyclep) --- 4 unchanged lines hidden (view full) --- 681 682 /* 683 * detach cycle members from cyclehead, 684 * and insertion sort them back on. 685 */ 686 todo = cyclep->cnext; 687 cyclep->cnext = 0; 688 | 679 } 680} 681 682/* 683 * sort members of a cycle 684 */ 685void 686sortmembers(nltype *cyclep) --- 4 unchanged lines hidden (view full) --- 691 692 /* 693 * detach cycle members from cyclehead, 694 * and insertion sort them back on. 695 */ 696 todo = cyclep->cnext; 697 cyclep->cnext = 0; 698 |
699 /* LINTED: warning: assignment operator */ |
|
689 for ((doing = todo) && (todo = doing->cnext); | 700 for ((doing = todo) && (todo = doing->cnext); |
690 doing; (doing = todo) && (todo = doing->cnext)) { | 701 doing; 702 /* LINTED: warning: assignment operator */ 703 (doing = todo) && (todo = doing->cnext)) { |
691 for (prev = cyclep; prev->cnext; prev = prev->cnext) { 692 if (membercmp(doing, prev->cnext) == GREATERTHAN) 693 break; 694 } 695 doing->cnext = prev->cnext; 696 prev->cnext = doing; 697 } 698} --- 41 unchanged lines hidden (view full) --- 740 nltype *thischildp = thisp->arc_childp; 741 nltype *thatparentp = thatp->arc_parentp; 742 nltype *thatchildp = thatp->arc_childp; 743 double thistime; 744 double thattime; 745 746#ifdef DEBUG 747 if (debug & TIMEDEBUG) { | 704 for (prev = cyclep; prev->cnext; prev = prev->cnext) { 705 if (membercmp(doing, prev->cnext) == GREATERTHAN) 706 break; 707 } 708 doing->cnext = prev->cnext; 709 prev->cnext = doing; 710 } 711} --- 41 unchanged lines hidden (view full) --- 753 nltype *thischildp = thisp->arc_childp; 754 nltype *thatparentp = thatp->arc_parentp; 755 nltype *thatchildp = thatp->arc_childp; 756 double thistime; 757 double thattime; 758 759#ifdef DEBUG 760 if (debug & TIMEDEBUG) { |
748 printf("[arccmp] "); | 761 (void) printf("[arccmp] "); |
749 printname(thisparentp); | 762 printname(thisparentp); |
750 printf(" calls "); | 763 (void) printf(" calls "); |
751 printname(thischildp); | 764 printname(thischildp); |
752 printf(" %f + %f %lld/%lld\n", thisp->arc_time, | 765 (void) printf(" %f + %f %lld/%lld\n", thisp->arc_time, |
753 thisp->arc_childtime, thisp->arc_count, 754 thischildp->ncall); | 766 thisp->arc_childtime, thisp->arc_count, 767 thischildp->ncall); |
755 printf("[arccmp] "); | 768 (void) printf("[arccmp] "); |
756 printname(thatparentp); | 769 printname(thatparentp); |
757 printf(" calls "); | 770 (void) printf(" calls "); |
758 printname(thatchildp); | 771 printname(thatchildp); |
759 printf(" %f + %f %lld/%lld\n", thatp->arc_time, | 772 (void) printf(" %f + %f %lld/%lld\n", thatp->arc_time, |
760 thatp->arc_childtime, thatp->arc_count, 761 thatchildp->ncall); | 773 thatp->arc_childtime, thatp->arc_count, 774 thatchildp->ncall); |
762 printf("\n"); | 775 (void) printf("\n"); |
763 } | 776 } |
764#endif DEBUG | 777#endif /* DEBUG */ |
765 766 if (thisparentp == thischildp) { 767 /* 768 * this is a self call 769 */ 770 return (LESSTHAN); 771 } 772 --- 72 unchanged lines hidden (view full) --- 845 cwd[0] = '.'; 846 cwd[1] = '\0'; 847 848 if (find_run_directory(prog_name, cwd, blurb_directory, 849 NULL, getenv("PATH")) != 0) { 850 (void) fprintf(stderr, "Error in finding run directory."); 851 return; 852 } else { | 778 779 if (thisparentp == thischildp) { 780 /* 781 * this is a self call 782 */ 783 return (LESSTHAN); 784 } 785 --- 72 unchanged lines hidden (view full) --- 858 cwd[0] = '.'; 859 cwd[1] = '\0'; 860 861 if (find_run_directory(prog_name, cwd, blurb_directory, 862 NULL, getenv("PATH")) != 0) { 863 (void) fprintf(stderr, "Error in finding run directory."); 864 return; 865 } else { |
853 strcat(blurb_directory, blurbname); | 866 (void) strcat(blurb_directory, blurbname); |
854 } 855 856 blurbfile = fopen(blurb_directory, "r"); 857 if (blurbfile == NULL) { 858 perror(blurb_directory); 859 return; 860 } 861 862 while ((input = getc(blurbfile)) != EOF) | 867 } 868 869 blurbfile = fopen(blurb_directory, "r"); 870 if (blurbfile == NULL) { 871 perror(blurb_directory); 872 return; 873 } 874 875 while ((input = getc(blurbfile)) != EOF) |
863 putchar(input); | 876 (void) putchar(input); |
864 | 877 |
865 fclose(blurbfile); | 878 (void) fclose(blurbfile); |
866} 867 868char *s1, *s2; 869 | 879} 880 881char *s1, *s2; 882 |
870int 871namecmp(nltype **npp1, nltype **npp2) | 883static int 884namecmp(const void *arg1, const void *arg2) |
872{ | 885{ |
886 nltype **npp1 = (nltype **)arg1; 887 nltype **npp2 = (nltype **)arg2; 888 |
|
873 if (!Cflag) 874 return (strcmp((*npp1)->name, (*npp2)->name)); 875 else { 876 striped_name(s1, npp1); 877 striped_name(s2, npp2); 878 return (strcmp(s1, s2)); 879 } 880} --- 39 unchanged lines hidden (view full) --- 920 return (FALSE); 921} 922 923void 924printmodules() 925{ 926 mod_info_t *mi; 927 | 889 if (!Cflag) 890 return (strcmp((*npp1)->name, (*npp2)->name)); 891 else { 892 striped_name(s1, npp1); 893 striped_name(s2, npp2); 894 return (strcmp(s1, s2)); 895 } 896} --- 39 unchanged lines hidden (view full) --- 936 return (FALSE); 937} 938 939void 940printmodules() 941{ 942 mod_info_t *mi; 943 |
928 printf("\f\nObject modules\n\n"); | 944 (void) printf("\f\nObject modules\n\n"); |
929 for (mi = &modules; mi; mi = mi->next) | 945 for (mi = &modules; mi; mi = mi->next) |
930 printf(" %d: %s\n", mi->id, mi->name); | 946 (void) printf(" %d: %s\n", mi->id, mi->name); |
931} 932 933#define IDFMT(id) ((id) < 10 ? 1 : 2) 934#define NMFMT(id) ((id) < 10 ? 17 : 16) 935 936void 937printindex() 938{ --- 5 unchanged lines hidden (view full) --- 944 945 /* 946 * Now, sort regular function name alphabetically 947 * to create an index. 948 */ 949 namesortnlp = calloc(total_names + ncycle, sizeof (nltype *)); 950 951 if (namesortnlp == NULL) | 947} 948 949#define IDFMT(id) ((id) < 10 ? 1 : 2) 950#define NMFMT(id) ((id) < 10 ? 17 : 16) 951 952void 953printindex() 954{ --- 5 unchanged lines hidden (view full) --- 960 961 /* 962 * Now, sort regular function name alphabetically 963 * to create an index. 964 */ 965 namesortnlp = calloc(total_names + ncycle, sizeof (nltype *)); 966 967 if (namesortnlp == NULL) |
952 fprintf(stderr, "%s: ran out of memory for sorting\n", whoami); | 968 (void) fprintf(stderr, "%s: ran out of memory for sorting\n", 969 whoami); |
953 954 nnames = 0; 955 for (mi = &modules; mi; mi = mi->next) { 956 for (index = 0; index < mi->nname; index++) { 957 if (zflag == 0 && (mi->nl[index]).ncall == 0 && 958 (mi->nl[index]).time == 0) { 959 continue; 960 } --- 9 unchanged lines hidden (view full) --- 970 } 971 } 972 973 if (Cflag) { 974 s1 = malloc(500 * sizeof (char)); 975 s2 = malloc(500 * sizeof (char)); 976 } 977 | 970 971 nnames = 0; 972 for (mi = &modules; mi; mi = mi->next) { 973 for (index = 0; index < mi->nname; index++) { 974 if (zflag == 0 && (mi->nl[index]).ncall == 0 && 975 (mi->nl[index]).time == 0) { 976 continue; 977 } --- 9 unchanged lines hidden (view full) --- 987 } 988 } 989 990 if (Cflag) { 991 s1 = malloc(500 * sizeof (char)); 992 s2 = malloc(500 * sizeof (char)); 993 } 994 |
978 qsort(namesortnlp, nnames, sizeof (nltype *), 979 (int(*)(const void *, const void *))namecmp); | 995 qsort(namesortnlp, nnames, sizeof (nltype *), namecmp); |
980 981 for (index = 1, todo = nnames; index <= ncycle; index++) 982 namesortnlp[todo++] = &cyclenl[index]; 983 | 996 997 for (index = 1, todo = nnames; index <= ncycle; index++) 998 namesortnlp[todo++] = &cyclenl[index]; 999 |
984 printf("\f\nIndex by function name\n\n"); | 1000 (void) printf("\f\nIndex by function name\n\n"); |
985 986 if (!Cflag) 987 index = (todo + 2) / 3; 988 else 989 index = todo; 990 991 for (i = 0; i < index; i++) { 992 if (!Cflag) { 993 for (j = i; j < todo; j += index) { 994 nlp = namesortnlp[j]; 995 996 if (nlp->printflag) { | 1001 1002 if (!Cflag) 1003 index = (todo + 2) / 3; 1004 else 1005 index = todo; 1006 1007 for (i = 0; i < index; i++) { 1008 if (!Cflag) { 1009 for (j = i; j < todo; j += index) { 1010 nlp = namesortnlp[j]; 1011 1012 if (nlp->printflag) { |
997 sprintf(peterbuffer, | 1013 (void) sprintf(peterbuffer, |
998 "[%d]", nlp->index); 999 } else { | 1014 "[%d]", nlp->index); 1015 } else { |
1000 sprintf(peterbuffer, | 1016 (void) sprintf(peterbuffer, |
1001 "(%d)", nlp->index); 1002 } 1003 1004 if (j < nnames) { 1005 if (does_clash(namesortnlp, 1006 j, nnames)) { | 1017 "(%d)", nlp->index); 1018 } 1019 1020 if (j < nnames) { 1021 if (does_clash(namesortnlp, 1022 j, nnames)) { |
1007 printf("%6.6s %*d:%-*.*s", | 1023 (void) printf( 1024 "%6.6s %*d:%-*.*s", |
1008 peterbuffer, 1009 IDFMT(nlp->module->id), 1010 nlp->module->id, 1011 NMFMT(nlp->module->id), 1012 NMFMT(nlp->module->id), 1013 nlp->name); 1014 } else { | 1025 peterbuffer, 1026 IDFMT(nlp->module->id), 1027 nlp->module->id, 1028 NMFMT(nlp->module->id), 1029 NMFMT(nlp->module->id), 1030 nlp->name); 1031 } else { |
1015 printf("%6.6s %-19.19s", | 1032 (void) printf("%6.6s %-19.19s", |
1016 peterbuffer, nlp->name); 1017 } 1018 } else { | 1033 peterbuffer, nlp->name); 1034 } 1035 } else { |
1019 printf("%6.6s ", peterbuffer); 1020 sprintf(peterbuffer, | 1036 (void) printf("%6.6s ", peterbuffer); 1037 (void) sprintf(peterbuffer, |
1021 "<cycle %d>", nlp->cycleno); | 1038 "<cycle %d>", nlp->cycleno); |
1022 printf("%-19.19s", peterbuffer); | 1039 (void) printf("%-19.19s", peterbuffer); |
1023 } 1024 } 1025 } else { 1026 nlp = namesortnlp[i]; 1027 1028 if (nlp->printflag) | 1040 } 1041 } 1042 } else { 1043 nlp = namesortnlp[i]; 1044 1045 if (nlp->printflag) |
1029 sprintf(peterbuffer, "[%d]", nlp->index); | 1046 (void) sprintf(peterbuffer, "[%d]", nlp->index); |
1030 else | 1047 else |
1031 sprintf(peterbuffer, "(%d)", nlp->index); | 1048 (void) sprintf(peterbuffer, "(%d)", nlp->index); |
1032 1033 if (i < nnames) { 1034 char *d = demangled_name(nlp); 1035 1036 if (does_clash(namesortnlp, i, nnames)) { | 1049 1050 if (i < nnames) { 1051 char *d = demangled_name(nlp); 1052 1053 if (does_clash(namesortnlp, i, nnames)) { |
1037 printf("%6.6s %d:%s\n", peterbuffer, 1038 nlp->module->id, d); | 1054 (void) printf("%6.6s %d:%s\n", 1055 peterbuffer, nlp->module->id, d); |
1039 } else | 1056 } else |
1040 printf("%6.6s %s\n", peterbuffer, d); | 1057 (void) printf("%6.6s %s\n", peterbuffer, 1058 d); |
1041 1042 if (d != nlp->name) | 1059 1060 if (d != nlp->name) |
1043 printf("%6.6s [%s]", "", nlp->name); | 1061 (void) printf("%6.6s [%s]", "", 1062 nlp->name); |
1044 } else { | 1063 } else { |
1045 printf("%6.6s ", peterbuffer); 1046 sprintf(peterbuffer, "<cycle %d>", | 1064 (void) printf("%6.6s ", peterbuffer); 1065 (void) sprintf(peterbuffer, "<cycle %d>", |
1047 nlp->cycleno); | 1066 nlp->cycleno); |
1048 printf("%-33.33s", peterbuffer); | 1067 (void) printf("%-33.33s", peterbuffer); |
1049 } 1050 } | 1068 } 1069 } |
1051 printf("\n"); | 1070 (void) printf("\n"); |
1052 } 1053 free(namesortnlp); 1054} | 1071 } 1072 free(namesortnlp); 1073} |
1055 1056 1057char dname[500]; 1058 1059char * 1060exotic(char *s) 1061{ 1062 char *name; 1063 int i = 0, j; 1064 char *p, *s1 = "static constructor function for "; 1065 1066 name = malloc(500 * sizeof (char)); 1067 1068 if (strncmp(s, "__sti__", 7) == 0) { 1069 i = 0; 1070 s += 7; 1071 1072 if ((p = strstr(s, "_c_")) == NULL) { 1073 if ((p = strstr(s, "_C_")) == NULL) { 1074 if ((p = strstr(s, "_cc_")) == NULL) { 1075 if ((p = strstr(s, "_cxx_")) == NULL) { 1076 if ((p = 1077 strstr(s, "_h_")) == NULL) 1078 return (NULL); 1079 } 1080 } 1081 } 1082 } else { 1083 p += 3; 1084 *p = '\0'; 1085 } 1086 1087 for (i = 0; s1[i] != '\0'; i++) 1088 dname[i] = s1[i]; 1089 j = i; 1090 1091 for (i = 0; s[i] != '\0'; i++) 1092 dname[j + i] = s[i]; 1093 dname[j + i] = '\0'; 1094 1095 free(name); 1096 return (dname); 1097 } 1098 1099 if (strncmp(s, "__std__", 7) == 0) { 1100 char *s1 = "static destructor function for "; 1101 i = 0; 1102 s += 7; 1103 1104 if ((p = strstr(s, "_c_")) == NULL) { 1105 if ((p = strstr(s, "_C_")) == NULL) { 1106 if ((p = strstr(s, "_cc_")) == NULL) { 1107 if ((p = strstr(s, "_cxx_")) == NULL) { 1108 if ((p = 1109 strstr(s, "_h_")) == NULL) 1110 return (NULL); 1111 } 1112 } 1113 } 1114 } else { 1115 p += 3; 1116 *p = '\0'; 1117 } 1118 1119 for (i = 0; s1[i] != '\0'; i++) 1120 dname[i] = s1[i]; 1121 j = i; 1122 1123 for (i = 0; s[i] != '\0'; i++) 1124 dname[j + i] = s[i]; 1125 dname[j + i] = '\0'; 1126 1127 free(name); 1128 return (dname); 1129 } 1130 1131 if (strncmp(s, "__vtbl__", 8) == 0) { 1132 char *s1 = "virtual table for "; 1133 char *printname, *return_p = dname; 1134 1135 s += 8; 1136 printname = parsename(s); 1137 return_p = '\0'; 1138 strcat(return_p, s1); 1139 strcat(return_p, printname); 1140 1141 free(name); 1142 return (dname); 1143 } 1144 1145 if (strncmp(s, "__ptbl__", 8) == 0) { 1146 char *s1 = "pointer to the virtual table for "; 1147 char *printname, *return_p = dname; 1148 1149 s += 8; 1150 printname = parsename(s); 1151 return_p = '\0'; 1152 strcat(return_p, s1); 1153 strcat(return_p, printname); 1154 1155 free(name); 1156 return (return_p); 1157 } 1158 1159 free(name); 1160 return (s); 1161} 1162 1163char * 1164parsename(char *s) 1165{ 1166 char *d = name_buffer; 1167 int len; 1168 char c_init; 1169 char *len_pointer = s; 1170 1171 *d = '\0'; 1172 1173 strcat(d, "class "); 1174 1175 while (isdigit(*s)) 1176 s++; 1177 c_init = *s; 1178 *s = '\0'; 1179 1180 len = atoi(len_pointer); 1181 *s = c_init; 1182 1183 /* 1184 * only one class name 1185 */ 1186 if (*(s + len) == '\0') { 1187 strcat(d, s); 1188 return (d); 1189 } else { 1190 /* 1191 * two classname %drootname__%dchildname 1192 */ 1193 char *child; 1194 char *root; 1195 int child_len; 1196 char *child_len_p; 1197 root = s; 1198 child = s + len + 2; 1199 child_len_p = child; 1200 1201 if (!isdigit(*child)) { /* ptbl file name */ 1202 c_init = *(root + len); 1203 *(root + len) = '\0'; 1204 strcat(d, root); 1205 *(root + len) = c_init; 1206 strcat(d, " in "); 1207 strcat(d, child); 1208 return (d); 1209 } 1210 1211 while (isdigit(*child)) 1212 child++; 1213 c_init = *child; 1214 *child = '\0'; 1215 child_len = atoi(child_len_p); 1216 *child = c_init; 1217 if (*(child + child_len) == '\0') { 1218 strcat(d, child); 1219 strcat(d, " derived from "); 1220 c_init = *(root + len); 1221 *(root + len) = '\0'; 1222 strcat(d, root); 1223 *(root + len) = c_init; 1224 return (d); 1225 } else { /* %drootname__%dchildname__filename */ 1226 c_init = *(child + child_len); 1227 *(child + child_len) = '\0'; 1228 strcat(d, child); 1229 *(child+ child_len) = c_init; 1230 strcat(d, " derived from "); 1231 c_init = *(root + len); 1232 *(root + len) = '\0'; 1233 strcat(d, root); 1234 *(root + len) = c_init; 1235 strcat(d, " in "); 1236 strcat(d, child + child_len + 2); 1237 return (d); 1238 } 1239 } 1240} | |