SUGGESTED FIX
Name: dd4877 Date: 09/19/2002
daniel.daugherty@Sun 2002-09-19
Here are the context diffs for the suggested fix:
------- src/share/tools/hprof/hprof_heapdump.c -------
*** /tmp/sccs.dSaW0J Thu Sep 19 17:08:48 2002
--- hprof_heapdump.c Thu Sep 19 17:08:28 2002
***************
*** 614,623 ****
unsigned int num_elements = hprof_dump_read_u4();
void *class_id = hprof_dump_read_id();
hprof_objmap_t *classmap = hprof_fetch_object_info(class_id);
- hprof_class_t *class;
unsigned int trace_serial_num = 0;
int size = 0;
- const char *class_name;
if (objmap != NULL) {
trace_serial_num = objmap->site->trace_serial_num;
--- 614,621 ----
***************
*** 624,636 ****
size = objmap->size;
}
- class = hprof_lookup_class_objmap(classmap);
- if (class == NULL || class->name == NULL) {
- CALL(RequestEvent)(JVMPI_EVENT_CLASS_LOAD, class_id);
- class = hprof_lookup_class_objmap(classmap);
- }
- class_name = (class == NULL || class->name == NULL) ? "<Unknown>" :
class->name->name;
-
if (output_format == 'b') {
hprof_write_id(objmap);
hprof_write_u4(trace_serial_num);
--- 622,627 ----
***************
*** 637,642 ****
--- 628,643 ----
hprof_write_u4(num_elements);
hprof_write_id(classmap);
} else {
+ hprof_class_t *class = hprof_lookup_class_objmap(classmap);
+ const char *class_name;
+
+ if (class == NULL || class->name == NULL) {
+ CALL(RequestEvent)(JVMPI_EVENT_CLASS_LOAD, class_id);
+ class = hprof_lookup_class_objmap(classmap);
+ }
+ class_name = (class == NULL || class->name == NULL) ?
+ "<Unknown>" : class->name->name;
+
hprof_printf("ARR %x (sz=%u, trace=%u, nelems=%u, elem
type=%s@%x)\n",
objmap, size, trace_serial_num, num_elements,
class_name, classmap);
======================================================================
|
EVALUATION
Copied from 4747238:
###@###.### 2002-09-13
As usual, Mandy is right! The fix for 4508003 modified the logic used
during construction of the HPROF_GC_OBJ_ARRAY_DUMP record type to
request a CLASS_LOAD event when needed. The change allows the class
name to be displayed in text output format, but it scrambles the
output stream in binary output format (format=b).
The logic that Mandy changed is only needed in the text output code
path so it should be possible to rearrange the code to only make the
CLASS_LOAD event request when doing text output as opposed to binary
format. While this would solve the immediate HPROF_GC_OBJ_ARRAY_DUMP
record corruption problem, it may introduce another problem. The
HPROF_GC_OBJ_ARRAY_DUMP record will contain a reference to a class
that hasn't been "defined" yet. However, it appears from perusing
the hprof output that CLS entries quite often come after objects
that refer to them.
|