public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Re: [SCM]  master: Add frysk.rsl loggin.
       [not found] <20080212200324.2256.qmail@sourceware.org>
@ 2008-02-12 21:33 ` Andrew Cagney
  2008-02-13 10:18   ` Phil Muldoon
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2008-02-12 21:33 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: frysk

Phil,

There's a less leaky way to write this (if a specific sequence is 
missing in Log, just add it).


>    {
>  
> +
> +    finest.log(this,"peek() address 0x" + Long.toHexString(address));
>   
finest.log(this, "peak() address", address);
>      byte[] buffer = new byte[1];
>      MapAddressHeader metaLine = findMetaData(address);
>  
> @@ -120,6 +125,10 @@ public class CorefileByteBuffer
>  	      StatelessFile temp = new StatelessFile(new File(metaLine.name));
>  	      long offset = metaLine.solibOffset  + (address - metaLine.vaddr);
>  	      temp.pread(offset, buffer,0,1);
> +	      finest.log(this,"peek'ed() 0x"+Integer.toHexString(buffer[0] & 0xff) +
> +			 " from address 0x"+Long.toHexString(address) +  
> +			 " offset 0x"+Long.toHexString(offset) +
> +			 " from file: " +metaLine.name);
>   
finest.log(this, "peek'ed ", (long)(buffer[0]&0xff), "from address", 
address, "offset", offset, "file", metaLine.name);

and so on.  All log functions take the consistent form:
    log(SELF, MESSAGE, OBJECT, MESSAGE, OBJECT, ....)

Andrew


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [SCM]  master: Add frysk.rsl loggin.
  2008-02-12 21:33 ` [SCM] master: Add frysk.rsl loggin Andrew Cagney
@ 2008-02-13 10:18   ` Phil Muldoon
  2008-02-13 16:48     ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Muldoon @ 2008-02-13 10:18 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: frysk

Andrew Cagney wrote:
> Phil,
>
> There's a less leaky way to write this (if a specific sequence is 
> missing in Log, just add it).

Ok on the adding part, this will not work. Will add later:

          finest.log(this,
             "peek'ed() 0x", ((long) (buffer[0] & 0xff)),
             " from address 0x", address,  
             " offset 0x",  offset,
             " from file: " , metaLine.name);

gets:

gcj -C -fsource=1.4 -d classes -g -O -g -classpath 
../../frysk/frysk-core:.:../frysk-sys/frysk-sys.jar:../frysk-imports/jline.jar:../frysk-imports/antlr.jar:../frysk-imports/junit.jar:../frysk-imports/getopt.jar:../frysk-imports/jdom.jar:../frysk-imports/cdtparser.jar 
-Wextraneous-semicolon \
                @./files-java.list \
                2>&1 | tee frysk-core.log
../../frysk/frysk-core/frysk/proc/dead/CorefileByteBuffer.java:128: 
error: The method log(Object, String, Object, String, long, String, 
long, String, int, String) in the type Log is not applicable for the 
arguments (CorefileByteBuffer, String, long, String, long, String, long, 
String, String)
        finest.log(this,



But what I really want is a hex string, converted by long. I do not want 
to convert every single peek() call from decimal to hex in my head. I 
guess I could do, Object, String, String, String, String  ...  and 
convert each Long in the log call, but the end log result would be just 
as messy as concating strings together.

Or a format switch? Or something else?

Regards

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [SCM]  master: Add frysk.rsl loggin.
  2008-02-13 10:18   ` Phil Muldoon
@ 2008-02-13 16:48     ` Andrew Cagney
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2008-02-13 16:48 UTC (permalink / raw)
  To: Phil Muldoon; +Cc: frysk

Phil Muldoon wrote:
> Andrew Cagney wrote:
>> Phil,
>>
>> There's a less leaky way to write this (if a specific sequence is 
>> missing in Log, just add it).
>
> Ok on the adding part, this will not work. Will add later:
>
>          finest.log(this,
>             "peek'ed() 0x", ((long) (buffer[0] & 0xff)),
>             " from address 0x", address,              " offset 0x",  
> offset,
>             " from file: " , metaLine.name);
>
> gets:
>
> gcj -C -fsource=1.4 -d classes -g -O -g -classpath 
> ../../frysk/frysk-core:.:../frysk-sys/frysk-sys.jar:../frysk-imports/jline.jar:../frysk-imports/antlr.jar:../frysk-imports/junit.jar:../frysk-imports/getopt.jar:../frysk-imports/jdom.jar:../frysk-imports/cdtparser.jar 
> -Wextraneous-semicolon \
>                @./files-java.list \
>                2>&1 | tee frysk-core.log
> ../../frysk/frysk-core/frysk/proc/dead/CorefileByteBuffer.java:128: 
> error: The method log(Object, String, Object, String, long, String, 
> long, String, int, String) in the type Log is not applicable for the 
> arguments (CorefileByteBuffer, String, long, String, long, String, 
> long, String, String)
>        finest.log(this,
Ah, given:

  (CorefileByteBuffer, String, long, String, long, String, long, String, 
String)

you'll want to add a method like:

  public void log(Object self, String p1, long p2, String p3, long p4, 
String p5, Object p6) {
        if (!loggging)
            return;
        prefix(self); print(p1); print(p2); print(p3); print(p4); 
print(p5); print(p6); suffix();
  }

to the growing list; they get added on-demand :-).  Notice the general 
form.  The parameters alternate between String <text> and Object / int / 
long / ... <parameter>.

> But what I really want is a hex string, converted by long. I do not 
> want to convert every single peek() call from decimal to hex in my 
> head. I guess I could do, Object, String, String, String, String  ...  
> and convert each Long in the log call, but the end log result would be 
> just as messy as concating strings together.

Right; that is why a "long" parameter is always printed in hex, and an 
integer parameter in decimal.  Hence, instead of:
      "address 0x" + Long.toHexString(address) + " ...."
(which allocates at least two objects - Integer.toHexString() creates a 
String and "+" causes a StringBuffer to be created)  try the simpler:
     "address", address, "..."
It will most likely print what you want.  If you've an integer and want 
it in hex; cast it to a long vis:
     "length", (long)length

Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-13 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080212200324.2256.qmail@sourceware.org>
2008-02-12 21:33 ` [SCM] master: Add frysk.rsl loggin Andrew Cagney
2008-02-13 10:18   ` Phil Muldoon
2008-02-13 16:48     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).