2003-09-09
2003-09-09 14:30:17 by Martin Stjernholm <mast@lysator.liu.se>
-
5a484d1c4479d9ba6a231988689ae1af92ee3190
(224 lines)
(+184/-40)
[
Show
| Annotate
]
Branch: 7.9
Improved descriptions of objects and programs.
Rev: src/gc.c:1.230
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: gc.c,v 1.229 2003/09/08 21:31:32 mast Exp $
+ || $Id: gc.c,v 1.230 2003/09/09 14:30:17 mast Exp $
*/
#include "global.h"
33:
#include "block_alloc.h"
- RCSID("$Id: gc.c,v 1.229 2003/09/08 21:31:32 mast Exp $");
+ RCSID("$Id: gc.c,v 1.230 2003/09/09 14:30:17 mast Exp $");
int gc_enabled = 1;
702: Inside #if defined(PIKE_DEBUG)
describe_location(gc_found_in , gc_found_in_type, gc_svalue_location,0,1,0);
else {
fputc('\n', stderr);
- describe_something(gc_found_in, gc_found_in_type, 2, 0, DESCRIBE_MEM, 0);
+ describe_something(gc_found_in, gc_found_in_type, 0, 0, DESCRIBE_MEM, 0);
}
}
else
769: Inside #if defined(PIKE_DEBUG)
fprintf(stderr,"%*s**The object is destructed.\n",indent,"");
p=id_to_program(((struct object *)a)->program_id);
}
+
if (p) {
-
+ size_t inh_idx, var_idx, var_count = 0;
+
+ fprintf (stderr, "%*s**Object variables:\n", indent, "");
+
+ for (inh_idx = 0; inh_idx < p->num_inherits; inh_idx++) {
+ struct inherit *inh = p->inherits + inh_idx;
+ struct program *p2 = inh->prog;
+
+ if (inh->inherit_level) {
+ if (inh->name) {
+ fprintf (stderr, "%*s**%*s=== In inherit ",
+ indent, "", inh->inherit_level + 1, "");
+ push_string (inh->name);
+ print_svalue (stderr, --Pike_sp);
+ fprintf (stderr, ", program %d:\n", inh->prog->id);
+ }
+ else
+ fprintf (stderr, "%*s**%*s=== In nameless inherit, program %d:\n",
+ indent, "", inh->inherit_level + 1, "", inh->prog->id);
+ }
+
+ for (var_idx = 0; var_idx < p2->num_variable_index; var_idx++) {
+ struct identifier *id = p2->identifiers + p2->variable_index[var_idx];
+ void *ptr;
+
+ fprintf (stderr, "%*s**%*srtt: %-8s name: ",
+ indent, "", inh->inherit_level + 1, "",
+ get_name_of_type (id->run_time_type));
+
+ if (id->name->size_shift) {
+ push_string (id->name);
+ print_svalue (stderr, --Pike_sp);
+ }
+ else
+ fprintf (stderr, "%-20s", id->name->str);
+
+ fprintf (stderr, " off: %4"PRINTPTRDIFFT"d value: ",
+ inh->storage_offset + id->func.offset);
+
+ ptr = PIKE_OBJ_STORAGE ((struct object *) a) +
+ inh->storage_offset + id->func.offset;
+ if (id->run_time_type == T_MIXED)
+ push_svalue ((struct svalue *) ptr);
+ else
+ assign_from_short_svalue_no_free (
+ Pike_sp++, (union anything *) ptr, id->run_time_type);
+ print_svalue (stderr, Pike_sp - 1);
+ pop_stack();
+
+ fputc ('\n', stderr);
+ var_count++;
+ }
+ }
+
+ if (!var_count)
+ fprintf (stderr, "%*s** (none)\n", indent, "");
+
fprintf(stderr,"%*s**Describing program %p of object:\n",indent,"", p);
#ifdef DEBUG_MALLOC
if ((int) p == 0x55555555)
777: Inside #if defined(PIKE_DEBUG)
else
#endif
low_describe_something(p, T_PROGRAM, indent, depth, flags, 0);
- }
+
- if(p &&
- (p->flags & PROGRAM_USES_PARENT) &&
+ if((p->flags & PROGRAM_USES_PARENT) &&
LOW_PARENT_INFO(((struct object *)a),p)->parent)
{
-
+ if (depth) {
fprintf(stderr,"%*s**Describing parent of object:\n",indent,"");
describe_something( PARENT_INFO((struct object *)a)->parent, T_OBJECT,
indent+2, depth-1,
(flags | DESCRIBE_SHORT | DESCRIBE_NO_REFS )
& ~ (DESCRIBE_MEM),
0);
-
+ }
+ else
+ fprintf (stderr, "%*s**Object got a parent.\n", indent, "");
}else{
fprintf(stderr,"%*s**There is no parent (any longer?)\n",indent,"");
}
-
+ }
break;
case T_PROGRAM:
{
char *tmp;
INT32 line;
- int foo=0;
+ ptrdiff_t id_idx, id_count = 0;
+ struct inherit *inh = p->inherits, *next_inh = p->inherits + 1;
+ ptrdiff_t inh_id_end = p->num_identifier_references;
fprintf(stderr,"%*s**Program id: %ld, flags: %x, parent id: %d\n",
indent,"", (long)(p->id), p->flags,
809: Inside #if defined(PIKE_DEBUG)
fprintf(stderr,"%*s**The program was written in C.\n",indent,"");
}
- #if 0
- dump_program_tables (p, indent + 2);
- #endif
-
+
tmp = low_get_program_line_plain(p, &line, 1);
if (tmp) {
fprintf(stderr,"%*s**Location: %s:%ld\n",
indent, "", tmp, (long)line);
- foo=1;
+
free (tmp);
- break;
+
}
- #if 0
- if(!foo && p->num_linenumbers>1 && EXTRACT_UCHAR(p->linenumbers)=='\177')
- {
- fprintf(stderr,"%*s**From file: %s\n",indent,"",p->linenumbers+1);
- foo=1;
+
+ fprintf (stderr, "%*s**Identifiers:\n", indent, "");
+
+ for (id_idx = 0; id_idx < p->num_identifier_references; id_idx++) {
+ struct reference *id_ref = p->identifier_references + id_idx;
+ struct inherit *id_inh;
+ struct identifier *id;
+ const char *type;
+ char prot[100], descr[120];
+
+ while (next_inh < p->inherits + p->num_inherits &&
+ id_idx == next_inh->identifier_level) {
+ inh = next_inh++;
+ inh_id_end = inh->identifier_level + inh->prog->num_identifier_references;
+ if (inh->name) {
+ fprintf (stderr, "%*s**%*s=== In inherit ",
+ indent, "", inh->inherit_level + 1, "");
+ push_string (inh->name);
+ print_svalue (stderr, --Pike_sp);
+ fprintf (stderr, ", program %d:\n", inh->prog->id);
}
- #endif
+ else
+ fprintf (stderr, "%*s**%*s=== In nameless inherit, program %d:\n",
+ indent, "", inh->inherit_level + 1, "", inh->prog->id);
+ }
- if(!foo)
- {
- int e;
- fprintf(stderr,"%*s**identifiers:\n",indent,"");
- for(e=0;e<p->num_identifier_references;e++)
- fprintf(stderr,"%*s**** %s\n",indent,"",ID_FROM_INT(p,e)->name->str);
+ while (id_idx == inh_id_end) {
+ int cur_lvl = inh->inherit_level;
+ if (inh->name) {
+ fprintf (stderr, "%*s**%*s=== End of inherit ",
+ indent, "", inh->inherit_level + 1, "");
+ push_string (inh->name);
+ print_svalue (stderr, --Pike_sp);
+ fputc ('\n', stderr);
+ }
+ else
+ fprintf (stderr, "%*s**%*s=== End of nameless inherit\n",
+ indent, "", inh->inherit_level + 1, "");
+ while (inh > p->inherits) { /* Paranoia. */
+ if ((--inh)->inherit_level < cur_lvl) break;
+ }
+ inh_id_end = inh->identifier_level + inh->prog->num_identifier_references;
+ }
- fprintf(stderr,"%*s**num inherits: %d\n",indent,"",p->num_inherits);
+ if (id_ref->id_flags & ID_HIDDEN ||
+ (id_ref->id_flags & (ID_INHERITED|ID_PRIVATE)) ==
+ (ID_INHERITED|ID_PRIVATE)) continue;
+
+ id_inh = INHERIT_FROM_PTR (p, id_ref);
+ id = id_inh->prog->identifiers + id_ref->identifier_offset;
+
+ if (IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags)) type = "fun";
+ else if (IDENTIFIER_IS_FUNCTION (id->identifier_flags)) type = "cfun";
+ else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags)) type = "const";
+ else if (IDENTIFIER_IS_ALIAS (id->identifier_flags)) type = "alias";
+ else if (IDENTIFIER_IS_VARIABLE (id->identifier_flags)) type = "var";
+ else type = "???";
+
+ prot[0] = prot[1] = 0;
+ if (id_ref->id_flags & ID_PRIVATE) {
+ strcat (prot, ",pri");
+ if (!(id_ref->id_flags & ID_STATIC)) strcat (prot, ",!sta");
}
-
+ else
+ if (id_ref->id_flags & ID_STATIC) strcat (prot, ",sta");
+ if (id_ref->id_flags & ID_NOMASK) strcat (prot, ",nom");
+ if (id_ref->id_flags & ID_PUBLIC) strcat (prot, ",pub");
+ if (id_ref->id_flags & ID_PROTECTED) strcat (prot, ",pro");
+ if (id_ref->id_flags & ID_INLINE) strcat (prot, ",inl");
+ if (id_ref->id_flags & ID_OPTIONAL) strcat (prot, ",opt");
+ if (id_ref->id_flags & ID_EXTERN) strcat (prot, ",ext");
+ if (id_ref->id_flags & ID_VARIANT) strcat (prot, ",var");
+ if (id_ref->id_flags & ID_ALIAS) strcat (prot, ",ali");
-
+ sprintf (descr, "%s: %s", type, prot + 1);
+ fprintf (stderr, "%*s**%*s%-18s name: ",
+ indent, "", id_inh->inherit_level + 1, "", descr);
+
+ if (id->name->size_shift) {
+ push_string (id->name);
+ print_svalue (stderr, --Pike_sp);
+ }
+ else
+ fprintf (stderr, "%-20s", id->name->str);
+
+ if (id->identifier_flags & IDENTIFIER_C_FUNCTION)
+ fprintf (stderr, " addr: %p", id->func.c_fun);
+ else if (IDENTIFIER_IS_VARIABLE (id->identifier_flags))
+ fprintf (stderr, " rtt: %s off: %"PRINTPTRDIFFT"d",
+ get_name_of_type (id->run_time_type), id->func.offset);
+ else if (IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags))
+ fprintf (stderr, " pc: %"PRINTPTRDIFFT"d", id->func.offset);
+ else if (IDENTIFIER_IS_CONSTANT (id->identifier_flags)) {
+ fputs (" value: ", stderr);
+ print_svalue (stderr, &id_inh->prog->constants[id->func.offset].sval);
+ }
+
+ fputc ('\n', stderr);
+ id_count++;
+ }
+
+ if (!id_count)
+ fprintf (stderr, "%*s** (none)\n", indent, "");
+
if(flags & DESCRIBE_MEM)
{
#define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
1005:
{
void *inblock;
int type = attempt_to_identify(x, &inblock);
- describe_something(x, type, 0, 2, 0, inblock);
+ describe_something(x, type, 0, 0, 0, inblock);
}
void debug_describe_svalue(struct svalue *s)
1040:
}
}
}
- describe_something(s->u.refs,s->type,0,2,0,0);
+ describe_something(s->u.refs,s->type,0,0,0,0);
}
void gc_watch(void *a)