1. Print only 16 bytes per line
2. Print the address of each line
3. Put an extra space halfway (i.e. after the 8th byte) for readability
It looks like this:
TRACE: jvm/ObjectCreationAndManipulationTest.main([Ljava/lang/String;)V
Length: 52
Code:
[ 0000 ] b8 00 61 b8 00 63 b8 00 65 b8 00 67 b8 00 69 b8
[ 0016 ] 00 6b b8 00 6d b8 00 6f b8 00 71 b8 00 73 b8 00
[ 0032 ] 75 b8 00 77 b8 00 79 b8 00 7b b8 00 7d b8 00 7f
[ 0048 ] b8 00 81 b1
Signed-off-by: Vegard Nossum <[email protected]>
---
jit/trace-jit.c | 28 ++++++++++++++++++++++++----
1 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/jit/trace-jit.c b/jit/trace-jit.c
index 3e649a6..b0c21c8 100644
--- a/jit/trace-jit.c
+++ b/jit/trace-jit.c
@@ -51,17 +51,37 @@ void trace_method(struct compilation_unit *cu)
{
struct vm_method *method = cu->method;
unsigned char *p;
- unsigned int i;
+ unsigned int i, j;
printf("\nTRACE: %s.%s%s\n",
method->class->name, method->name, method->type);
printf("Length: %d\n", method->code_attribute.code_length);
- printf("Code: ");
+ printf("Code:\n");
p = method->code_attribute.code;
- for (i = 0; i < method->code_attribute.code_length; i++) {
- printf("%02x ", p[i]);
+
+ unsigned int n = method->code_attribute.code_length;
+ unsigned int rows = n / 16;
+ unsigned int cols = 16;
+
+ for (i = 0; i <= rows; ++i) {
+ if (i == rows) {
+ cols = n % 16;
+ if (!cols)
+ break;
+ }
+
+ printf("[ %04u ] ", i * 16);
+
+ for (j = 0; j < cols; ++j) {
+ printf("%02x%s",
+ p[i * 16 + j],
+ j == 7 ? " " : " ");
+ }
+
+ printf("\n");
}
+
printf("\n\n");
}
--
1.6.0.6
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel