Commit e4b27b12 by Per Bothner Committed by Per Bothner

jcf-dump.c (flag_print_constant_pool): Default to off.


	* jcf-dump.c (flag_print_constant_pool):  Default to off.
	(print_constant_terse_with_index):  New helper function.
	(various places):  Check flag_print_constant_pool where missing.
	(main):  If verbose set flag_print_constant_pool.
	(HANDLE_INNERCLASSES_ATTRIBUTE):  Null inner class name is anonymous.

From-SVN: r79555
parent ec835fb2
2004-03-16 Per Bothner <per@bothner.com>
* jcf-dump.c (flag_print_constant_pool): Default to off.
(print_constant_terse_with_index): New helper function.
(various places): Check flag_print_constant_pool where missing.
(main): If verbose set flag_print_constant_pool.
(HANDLE_INNERCLASSES_ATTRIBUTE): Null inner class name is anonymous.
2004-03-15 Andrew Haley <aph@redhat.com> 2004-03-15 Andrew Haley <aph@redhat.com>
PR java/14581 PR java/14581
......
...@@ -74,7 +74,7 @@ int verbose = 0; ...@@ -74,7 +74,7 @@ int verbose = 0;
int flag_disassemble_methods = 0; int flag_disassemble_methods = 0;
int flag_print_class_info = 1; int flag_print_class_info = 1;
int flag_print_constant_pool = 1; int flag_print_constant_pool = 0;
int flag_print_fields = 1; int flag_print_fields = 1;
int flag_print_methods = 1; int flag_print_methods = 1;
int flag_print_attributes = 1; int flag_print_attributes = 1;
...@@ -152,9 +152,7 @@ utf8_equal_string (JCF *jcf, int index, const char * value) ...@@ -152,9 +152,7 @@ utf8_equal_string (JCF *jcf, int index, const char * value)
print_access_flags (out, ACCESS_FLAGS, 'c'); \ print_access_flags (out, ACCESS_FLAGS, 'c'); \
fputc ('\n', out); \ fputc ('\n', out); \
fprintf (out, "This class: "); \ fprintf (out, "This class: "); \
if (flag_print_constant_pool) \ print_constant_terse_with_index (out, jcf, THIS, CONSTANT_Class); \
fprintf (out, "%d=", THIS); \
print_constant_terse (out, jcf, THIS, CONSTANT_Class); \
if (flag_print_constant_pool || SUPER != 0) \ if (flag_print_constant_pool || SUPER != 0) \
fprintf (out, ", super: "); \ fprintf (out, ", super: "); \
if (flag_print_constant_pool) \ if (flag_print_constant_pool) \
...@@ -173,8 +171,8 @@ utf8_equal_string (JCF *jcf, int index, const char * value) ...@@ -173,8 +171,8 @@ utf8_equal_string (JCF *jcf, int index, const char * value)
#define HANDLE_CLASS_INTERFACE(INDEX) \ #define HANDLE_CLASS_INTERFACE(INDEX) \
if (flag_print_class_info) \ if (flag_print_class_info) \
{ fprintf (out, "- Implements: %d=", INDEX); \ { fprintf (out, "- Implements: "); \
print_constant_terse (out, jcf, INDEX, CONSTANT_Class); \ print_constant_terse_with_index (out, jcf, INDEX, CONSTANT_Class); \
fputc ('\n', out); } fputc ('\n', out); }
#define HANDLE_START_FIELDS(FIELDS_COUNT) \ #define HANDLE_START_FIELDS(FIELDS_COUNT) \
...@@ -287,9 +285,13 @@ utf8_equal_string (JCF *jcf, int index, const char * value) ...@@ -287,9 +285,13 @@ utf8_equal_string (JCF *jcf, int index, const char * value)
int name_index = JCF_readu2 (jcf); \ int name_index = JCF_readu2 (jcf); \
int signature_index = JCF_readu2 (jcf); \ int signature_index = JCF_readu2 (jcf); \
int slot = JCF_readu2 (jcf); \ int slot = JCF_readu2 (jcf); \
fprintf (out, " slot#%d: name: %d=", slot, name_index); \ fprintf (out, " slot#%d: name: ", slot); \
if (flag_print_constant_pool) \
fprintf (out, "%d=", name_index); \
print_name (out, jcf, name_index); \ print_name (out, jcf, name_index); \
fprintf (out, ", type: %d=", signature_index); \ fprintf (out, ", type: "); \
if (flag_print_constant_pool) \
fprintf (out, "%d=", signature_index); \
print_signature (out, jcf, signature_index, 0); \ print_signature (out, jcf, signature_index, 0); \
fprintf (out, " (pc: %d length: %d)\n", start_pc, length); }} fprintf (out, " (pc: %d length: %d)\n", start_pc, length); }}
...@@ -317,19 +319,22 @@ utf8_equal_string (JCF *jcf, int index, const char * value) ...@@ -317,19 +319,22 @@ utf8_equal_string (JCF *jcf, int index, const char * value)
\ \
if (flag_print_class_info) \ if (flag_print_class_info) \
{ \ { \
fprintf (out, "\n class: "); \ fprintf (out, "\n inner: "); \
if (flag_print_constant_pool) \ print_constant_terse_with_index (out, jcf, \
fprintf (out, "%d=", inner_class_info_index); \
print_constant_terse (out, jcf, \
inner_class_info_index, CONSTANT_Class); \ inner_class_info_index, CONSTANT_Class); \
fprintf (out, " (%d=", inner_name_index); \ if (inner_name_index == 0) \
print_constant_terse (out, jcf, inner_name_index, CONSTANT_Utf8); \ fprintf (out, " (anonymous)"); \
fprintf (out, "), access flags: 0x%x", inner_class_access_flags); \ else if (verbose || flag_print_constant_pool) \
{ \
fprintf (out, " ("); \
print_constant_terse_with_index (out, jcf, inner_name_index, \
CONSTANT_Utf8); \
fputc (')', out); \
} \
fprintf (out, ", access flags: 0x%x", inner_class_access_flags); \
print_access_flags (out, inner_class_access_flags, 'c'); \ print_access_flags (out, inner_class_access_flags, 'c'); \
fprintf (out, ", outer class: "); \ fprintf (out, ", outer class: "); \
if (flag_print_constant_pool) \ print_constant_terse_with_index (out, jcf, \
fprintf (out, "%d=", outer_class_info_index); \
print_constant_terse (out, jcf, \
outer_class_info_index, CONSTANT_Class); \ outer_class_info_index, CONSTANT_Class); \
} \ } \
} \ } \
...@@ -350,12 +355,16 @@ utf8_equal_string (JCF *jcf, int index, const char * value) ...@@ -350,12 +355,16 @@ utf8_equal_string (JCF *jcf, int index, const char * value)
static void static void
print_constant_ref (FILE *stream, JCF *jcf, int index) print_constant_ref (FILE *stream, JCF *jcf, int index)
{ {
fprintf (stream, "#%d=<", index);
if (index <= 0 || index >= JPOOL_SIZE(jcf)) if (index <= 0 || index >= JPOOL_SIZE(jcf))
fprintf (stream, "out of range"); fprintf (stream, "<out of range>");
else else
print_constant (stream, jcf, index, 1); {
fprintf (stream, ">"); if (flag_print_constant_pool)
fprintf (stream, "#%d=", index);
fputc ('<', stream);
print_constant (stream, jcf, index, 1);
fputc ('>', stream);
}
} }
/* Print the access flags given by FLAGS. /* Print the access flags given by FLAGS.
...@@ -414,6 +423,14 @@ print_constant_terse (FILE *out, JCF *jcf, int index, int expected) ...@@ -414,6 +423,14 @@ print_constant_terse (FILE *out, JCF *jcf, int index, int expected)
print_constant (out, jcf, index, 0); print_constant (out, jcf, index, 0);
} }
static void
print_constant_terse_with_index (FILE *out, JCF *jcf, int index, int expected)
{
if (flag_print_constant_pool)
fprintf (out, "%d=", index);
print_constant_terse (out, jcf, index, expected);
}
/* Print the constant at INDEX in JCF's constant pool. /* Print the constant at INDEX in JCF's constant pool.
If verbosity==0, print very tersely (no extraneous text). If verbosity==0, print very tersely (no extraneous text).
If verbosity==1, prefix the type of the constant. If verbosity==1, prefix the type of the constant.
...@@ -775,15 +792,13 @@ print_exception_table (JCF *jcf, const unsigned char *entries, int count) ...@@ -775,15 +792,13 @@ print_exception_table (JCF *jcf, const unsigned char *entries, int count)
int end_pc = GET_u2 (ptr+2); int end_pc = GET_u2 (ptr+2);
int handler_pc = GET_u2 (ptr+4); int handler_pc = GET_u2 (ptr+4);
int catch_type = GET_u2 (ptr+6); int catch_type = GET_u2 (ptr+6);
fprintf (out, " start: %d, end: %d, handler: %d, type: %d", fprintf (out, " start: %d, end: %d, handler: %d, type: ",
start_pc, end_pc, handler_pc, catch_type); start_pc, end_pc, handler_pc);
if (catch_type == 0) if (catch_type == 0)
fputs (" /* finally */", out); fputs ("0 /* finally */", out);
else else
{ print_constant_terse_with_index (out, jcf,
fputc('=', out); catch_type, CONSTANT_Class);
print_constant_terse (out, jcf, catch_type, CONSTANT_Class);
}
fputc ('\n', out); fputc ('\n', out);
} }
} }
...@@ -976,6 +991,9 @@ main (int argc, char** argv) ...@@ -976,6 +991,9 @@ main (int argc, char** argv)
} }
} }
if (verbose && ! flag_javap_compatible)
flag_print_constant_pool = 1;
if (optind == argc) if (optind == argc)
{ {
fprintf (stderr, _("jcf-dump: no classes specified\n")); fprintf (stderr, _("jcf-dump: no classes specified\n"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment