Hi all, Is it somehow possible to use tracemem() (or anything else which is able to print array of uchar_t''s or string) to print stream of bytes in hexadecimal on single line ? I''d like to do something like this: printf("0x"); tracemem(this->oinfo.xxx_id, 32); printf("A:%-15s ... \n", this->oinfo.xxx_raddr, ... where xxx_id and xxx_raddr are of type string. I''d like the above to produce the output on single line: 0x7FFA403D13DF... A:... v.
Hey Vladimir, Is it somehow possible to use tracemem() (or anything else which is able to> print array of uchar_t''s or string) to print stream of bytes in hexadecimal > on single line ? > > I''d like to do something like this: > > printf("0x"); > tracemem(this->oinfo.xxx_id, 32); > printf("A:%-15s ... \n", > this->oinfo.xxx_raddr, > ... > > where xxx_id and xxx_raddr are of type string. > > I''d like the above to produce the output on single line: > > 0x7FFA403D13DF... A:... >There''s nothing particularly convenient, but you could just print out your array by hand: %02x%02x... To simplify it a little, you could cast it to a uint64_t *: printf("%16x%16x", ((uint64_t *)this->oinfo.xxx_id)[0], ((uint64_t *)this->oinfo.xxx_id)[1]); I hope that helps. Adam -- Adam Leventhal, Delphix http://dtrace.org/blogs/ahl 275 Middlefield Road, Suite 50 Menlo Park, CA 94025 http://www.delphix.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20110413/9f2305f5/attachment.html>
On 04/13/11 06:18 PM, Adam Leventhal wrote: <snip>> There''s nothing particularly convenient, but you could just print out > your array by hand: %02x%02x... To simplify it a little, you could cast > it to a uint64_t *: > > printf("%16x%16x", ((uint64_t *)this->oinfo.xxx_id)[0], ((uint64_t > *)this->oinfo.xxx_id)[1]); > > I hope that helps.Yes, this should do it for my case. Thanks. But I also wonder what would you say about e.g. adding new pragma/option to change the behavior of tracemem(). v.
> But I also wonder what would you say about e.g. adding new pragma/option to > change the behavior of tracemem().... or a printf() format character that does what you want. Sounds reasonable. Adam -- Adam Leventhal, Delphix http://dtrace.org/blogs/ahl 275 Middlefield Road, Suite 50 Menlo Park, CA 94025 http://www.delphix.com