Skip to content
Permalink
Browse files
Merge branch 'improve_logging' into 'ibm-trunk'
Improve logging

See merge request !28
  • Loading branch information
ngmr committed Apr 23, 2015
2 parents 9bf2be6 + 333ecfe commit a6e72c3f6c82cfadd3e3176affa68df95a2adad8
Show file tree
Hide file tree
Showing 3 changed files with 456 additions and 413 deletions.
@@ -84,7 +84,10 @@ private org.omg.CORBA.TypeCode readTypeCodeImpl(
java.util.Hashtable history, boolean isTopLevel) {
int kind = read_ulong();
int oldPos = buf_.pos_ - 4;
logger.finest("Reading a TypeCode of kind " + kind + " from position " + oldPos);
if (logger.isLoggable(Level.FINEST))
logger.finest(String.format(
"Reading a TypeCode of kind %d from position 0x%x",
kind, oldPos));

TypeCode tc = null;
if (kind == -1) {
@@ -490,7 +493,10 @@ private org.omg.CORBA.TypeCode readTypeCodeImpl(

String id = read_string();

logger.fine("Abstract interface typecode encapsulaton length=" + length + " id=" + id);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format(
"Abstract interface typecode encapsulaton length=0x%x id=%s",
length, id));

if (isTopLevel && cache_ != null)
tc = checkCache(id, typePos, length); // may advance pos
@@ -941,7 +947,8 @@ private String _OB_read_wstring_new() {
// GIOP 1.0/1.1 and in octets for GIOP 1.2+)
//
int len = read_ulong();
logger.fine("Reading wstring of length " + len);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("Reading wstring of length 0x%x", len));

switch (GIOPVersion_) {

@@ -1134,7 +1141,10 @@ public boolean read_boolean() {
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
}

logger.finest("Boolean value is " + buf_.data_[buf_.pos_] + " from position " + buf_.pos_);
if (logger.isLoggable(Level.FINEST))
logger.finest(String.format(
"Boolean value is %b from position 0x%x",
buf_.data_[buf_.pos_], buf_.pos_));
return buf_.data_[buf_.pos_++] != (byte) 0;
}

@@ -1282,7 +1292,10 @@ public String read_string() {

int newPos = buf_.pos_ + length;
if (newPos < buf_.pos_ || newPos > buf_.len_) {
logger.fine("String length=" + length + " newPos=" + newPos + " buf_.pos=" + buf_.pos_ + " buf_.len=" + buf_.len_);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format(
"String length=0x%x newPos=0x%x buf_.pos=0x%x buf_.len=0x%x",
length, newPos, buf_.pos_, buf_.len_));
throw new org.omg.CORBA.MARSHAL(
org.apache.yoko.orb.OB.MinorCodes
.describeMarshal(org.apache.yoko.orb.OB.MinorCodes.MinorReadStringOverflow),
@@ -20,6 +20,22 @@
import org.omg.IOP.TaggedComponent;

public final class IORUtil {
public static void main(String...args) {
final byte[] ba = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f
};

System.out.println("----");
StringBuilder sb = new StringBuilder(200);
for (int i = 0; i < 0x10; i++) {
IORUtil.dump_octets(ba, i, 0x20, sb);
System.out.println(sb.toString());
System.out.println("----");
sb.setLength(0);
}
}

private static void describeCSISecMechList(org.omg.IOP.TaggedComponent component, StringBuilder sb) {
byte[] coct = component.component_data;
@@ -294,6 +310,8 @@ public static void dump_octets(byte[] oct, StringBuilder sb) {
}

private static final char[] HEX_DIGIT = "0123456789abcdef".toCharArray();
private static final int PRINTABLE_CHAR_LOW = 31;
private static final int PRINTABLE_CHAR_HIGH = 127;
//
// Convert an octet buffer into human-friendly data dump
//
@@ -302,25 +320,48 @@ public static void dump_octets(final byte[] oct, final int offset, final int cou
return;
}

final StringBuilder ascii = new StringBuilder(16);
for (int i = 0; i < count; i++) {
final int b = oct[i + offset] & 0xff;
final StringBuilder ascii = new StringBuilder(18);
switch (offset%0x10) {
case 0:
break;
case 0xf: sb.append(" "); ascii.append(" ");
case 0xe: sb.append(" "); ascii.append(" ");
case 0xd: sb.append(" "); ascii.append(" ");
case 0xc: sb.append(" "); ascii.append(" ");
case 0xb: sb.append(" "); ascii.append(" ");
case 0xa: sb.append(" "); ascii.append(" ");
case 0x9: sb.append(" "); ascii.append(" ");
case 0x8: sb.append(" "); ascii.append(" ");
case 0x7: sb.append(" "); ascii.append(" ");
case 0x6: sb.append(" "); ascii.append(" ");
case 0x5: sb.append(" "); ascii.append(" ");
case 0x4: sb.append(" "); ascii.append(" ");
case 0x3: sb.append(" "); ascii.append(" ");
case 0x2: sb.append(" "); ascii.append(" ");
case 0x1: sb.append(" "); ascii.append(" ");
}

ascii.append(" \"");

for (int i = offset; i < (offset + count); i++) {
final int b = oct[i] & 0xff;

// build up the ascii string for the end of the line
ascii.append((31 < b && b < 127)? (char)b : '.');
ascii.append((PRINTABLE_CHAR_LOW < b && b < PRINTABLE_CHAR_HIGH)? (char)b : '.');

// print the high hex nybble
sb.append(HEX_DIGIT[b>>4]);
// and the low hex nybble
sb.append(HEX_DIGIT[b&0xf]);

if (i%4 == (4-1)) {
if (i%0x4 == (0x4-1)) {
// space the columns on every 4-byte boundary
sb.append(' ');
if (i%0x10 == (0x10-1)) {
// write the ascii interpretation on the end of every line
sb.append(" \"").append(ascii).append("\"\n");
sb.append(ascii).append("\"\n");
ascii.setLength(0);
ascii.append(" \"");
if (i%0x100 == (0x100-1)) {
// separating line every 0x100 bytes
// 00000000 00000000 00000000 00000000 "................"
@@ -330,7 +371,7 @@ public static void dump_octets(final byte[] oct, final int offset, final int cou
}
}

switch (count%16) {
switch ((offset+count)%0x10) {
case 0:
break;
case 0x1: sb.append(" ");
@@ -347,7 +388,7 @@ public static void dump_octets(final byte[] oct, final int offset, final int cou
case 0xc: sb.append(" ");
case 0xd: sb.append(" ");
case 0xe: sb.append(" ");
case 0xf: sb.append(" \"").append(ascii).append("\"\n");
case 0xf: sb.append(" ").append(ascii).append("\"\n");
}
}

0 comments on commit a6e72c3

Please sign in to comment.