473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

real time printf-like logging

Hi!

There's this way of doing real time debug prints which look like
printf calls:

log3("points[%d]={%d,%d}\n", i, points[i].x, points[i].y);

The implementation writes something like {format-string-ptr, num-args,
arg0, arg1, arg2} to a binary log buffer. The buffer is written out in
binary form, and then the formatting is done at the host. The string
pointers are "decoded" by reading the constant format strings out of
the program image or, more portably, they can be collected by the
target code when the binary log buffer is written out, at the cost of
a slight time & space overhead.

Is there a free implementation of something like this? Do you think it
would be useful?

-- Yossi
Dec 1 '07 #1
3 3389
Yossi Kreinin wrote:
Hi!

There's this way of doing real time debug prints which look like
printf calls:

log3("points[%d]={%d,%d}\n", i, points[i].x, points[i].y);

The implementation writes something like {format-string-ptr, num-args,
arg0, arg1, arg2} to a binary log buffer. The buffer is written out in
binary form, and then the formatting is done at the host. The string
pointers are "decoded" by reading the constant format strings out of
the program image or, more portably, they can be collected by the
target code when the binary log buffer is written out, at the cost of
a slight time & space overhead.

Is there a free implementation of something like this? Do you think it
would be useful?

-- Yossi
Of course it is possible. I did it when implementing a debugger for an
embedded DSP. The printf specs were kept in the host,
and the in place debugger sent the raw data through a serial line.

Now, "real time" will be another thing, since this takes time, the
serial line keeps the processor busy, and there is obviously a
big debugger overhead. But there is no free lunch!

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Dec 1 '07 #2
Yossi Kreinin wrote:
Hi!

There's this way of doing real time debug prints which look like
printf calls:

log3("points[%d]={%d,%d}\n", i, points[i].x, points[i].y);
Certainly.
The implementation writes something like {format-string-ptr, num-args,
arg0, arg1, arg2} to a binary log buffer. The buffer is written out in
binary form, and then the formatting is done at the host. The string
pointers are "decoded" by reading the constant format strings out of
the program image or, more portably, they can be collected by the
target code when the binary log buffer is written out, at the cost of
a slight time & space overhead.
Yes, I used something like this on a couple of projects where we only
had a very small area of non-volatile storage for logging. I still have
at least one in production where this technique is used for assert logs.
Is there a free implementation of something like this? Do you think it
would be useful?
Maybe, but it is trivial to implement.

--
Ian Collins.
Dec 1 '07 #3
On Dec 1, 9:31 pm, jacob navia <ja...@nospam.comwrote:
>
Of course it is possible. I did it when implementing a debugger for an
embedded DSP. The printf specs were kept in the host,
and the in place debugger sent the raw data through a serial line.
Cool stuff. Was it by any chance the CCS? I think it has a trace
facility like this.
Now, "real time" will be another thing, since this takes time, the
serial line keeps the processor busy, and there is obviously a
big debugger overhead. But there is no free lunch!
Well, sometimes you could DMA them out pretty fast in "standalone"
runs (without a debugger attached), so the lunch would be cheap if not
completely free.

I think you can do it more neatly when you control the software tools
implementation. That is, you can have a compiler/linker convert format
specs to IDs and emit a table of ID->string for the debugger to use.
What I thought was the case when you don't control the tools, so you
have the strings linked into the executable (wasting a certain amount
of space), and then you parse the executable and read the strings out
of it, or you have the strings written out at the target. Which, of
course, isn't a big deal, either; I just wondered if there's a free
implementation people use for this.
Dec 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Lorn | last post by:
I was hoping some of you might be able to help me understand the following code defining a typedef for a time query to the WINAPI. I understand the basics of what's going on, I just don't...
8
by: Trishia Rose | last post by:
this is something ive always wondered, does it take cpu time at run time to typecast or just at compile time? for example consider the two little bits of code: int a = 5; int b = a; and: ...
1
by: Intaek LIM | last post by:
generally, we use srand(time(0)) to generate random numbers. i know why we use time(0), but i can not explain how it operates. first, see example source below. ...
11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
2
by: Suresh | last post by:
hello, i am new to c and how do i use time function to get time. thanks, Sean
11
by: srkkreddy | last post by:
Hi, I have written a large program which makes multiple calls to number of functions (also written by me) of the program. Now, I want to know the collective time taken by all the calls to a...
3
by: babis85 | last post by:
Hello guys, i have this part of code and i want to compute the time of processes A, B and C : /* process A */ pid_t pid1, pid2, pid; struct rusage ru1, ru2; pid1 = fork(); if (pid != 0) {/*...
5
by: Summu82 | last post by:
HI I have to convert a time in the format i have year month day hour min and seconds I need to convert this into time in seconds since 1 jan 1970 i.e the
0
hqprog
by: hqprog | last post by:
Having search extensively I've learned the two functions timegm and gmtime_r though in the GNU standard C library extend the ISO standard. I need to use these two functions in myprog.c (on pc - ...
12
by: webinfinite | last post by:
I am starting a new thread for this topic since previous problem has been solved. I have code like this: #include <stdio.h> int main(){
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.