FreeCalypso > hg > freecalypso-reveng
comparison leo-obj/tool/richsym.c @ 150:df01a4f4c272
tiobjd disasm -g: dump of function locals implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 29 Apr 2014 07:51:28 +0000 |
parents | fdf3137c703a |
children | 6fe08feee018 |
comparison
equal
deleted
inserted
replaced
149:fdf3137c703a | 150:df01a4f4c272 |
---|---|
201 struct internal_syment *sym; | 201 struct internal_syment *sym; |
202 { | 202 { |
203 char *buf; | 203 char *buf; |
204 int isund, len; | 204 int isund, len; |
205 | 205 |
206 isund = (sym->name[0] == '_'); | 206 switch (sym->name[0]) { |
207 case '_': | |
208 isund = 1; | |
209 break; | |
210 case '$': | |
211 if ((sym->type & 0x30) == 0x20) | |
212 isund = 1; | |
213 else | |
214 isund = 0; | |
215 break; | |
216 default: | |
217 isund = 0; | |
218 } | |
207 len = strlen(sym->name) + 1; | 219 len = strlen(sym->name) + 1; |
208 if (isund) | 220 if (isund) |
209 len--; | 221 len--; |
210 else | 222 else |
211 len += 2; | 223 len += 2; |
394 continue; | 406 continue; |
395 } | 407 } |
396 } | 408 } |
397 exit(0); | 409 exit(0); |
398 } | 410 } |
411 | |
412 static int | |
413 localsym_sanity_check(sym) | |
414 struct internal_syment *sym; | |
415 { | |
416 if (!sym->aux) { | |
417 printf("; symbol #%u of class %s has no aux record\n", | |
418 sym->number, storage_class_to_string(sym->class, 0)); | |
419 return(-1); | |
420 } | |
421 if (sym->scnum != -1) { | |
422 printf("; symbol #%u of class %s: section != ABS\n", | |
423 sym->number, storage_class_to_string(sym->class, 0)); | |
424 return(-1); | |
425 } | |
426 return(0); | |
427 } | |
428 | |
429 void | |
430 richsym_function_locals(headsym) | |
431 struct internal_syment *headsym; | |
432 { | |
433 unsigned n; | |
434 struct internal_syment *sym; | |
435 char classbuf[8]; | |
436 | |
437 for (n = headsym->number + 1; n < nsymtab; n++) { | |
438 sym = symtab[n]; | |
439 if (!sym) | |
440 continue; | |
441 switch (sym->class) { | |
442 case C_REG: | |
443 case C_REGPARM: | |
444 if (localsym_sanity_check(sym) < 0) | |
445 continue; | |
446 if (sym->value > 0xF) { | |
447 printf( | |
448 "; symbol #%u of class %s: value is not a valid register number\n", | |
449 sym->number, | |
450 storage_class_to_string(sym->class, 0)); | |
451 continue; | |
452 } | |
453 printf("; %s r%u: ", | |
454 storage_class_to_string(sym->class, 0), | |
455 sym->value); | |
456 richsym_print_in_c("", sym, 0); | |
457 continue; | |
458 case C_ARG: | |
459 case C_AUTO: | |
460 if (localsym_sanity_check(sym) < 0) | |
461 continue; | |
462 printf("; %s at 0x%x: ", | |
463 storage_class_to_string(sym->class, 0), | |
464 sym->value); | |
465 richsym_print_in_c("", sym, 0); | |
466 continue; | |
467 case C_FCN: | |
468 return; | |
469 default: | |
470 printf( | |
471 "; presumed local symbol #%u: unexpected class %s\n", | |
472 sym->number, | |
473 storage_class_to_string(sym->class, classbuf)); | |
474 return; | |
475 } | |
476 } | |
477 } |