public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Type of event in eCos instrumentation record
@ 2010-03-28  8:37 Nodir Kodirov
  2010-03-29 14:30 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Nodir Kodirov @ 2010-03-28  8:37 UTC (permalink / raw)
  To: Yuriy Coureelo; +Cc: eCos Discussion

Hello Mr. Yuriy!

I was using eCos kernel instrumentation feature to analyze behavior of
my application. I tried the sample given at
http://ecos.sourceware.org/docs-latest/user-guide/kernel-instrumentation.html
where with these lines of the code:

[...]
for (i = 0; i < instrument_buffer_size; ++i) {
 printf("Record %02d: type 0x%04x, thread %d, ",
	i, instrument_buffer[i].type, instrument_buffer[i].thread);
 printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
	instrument_buffer[i].timestamp, instrument_buffer[i].arg1,
	instrument_buffer[i].arg2);
}
I have got instrumentation info in this format:

Record 00: type 0x0207, thread 2, time  6057, arg1 0x48001cd8, arg2 0x00000002
Record 01: type 0x0202, thread 2, time  6153, arg1 0x48001cd8, arg2 0x00000000
Record 02: type 0x0904, thread 2, time  6358, arg1 0x48001d24, arg2 0x00000000
Record 03: type 0x0905, thread 2, time  6424, arg1 0x00000002, arg2 0x00000000
Record 04: type 0x0906, thread 2, time  6490, arg1 0x00000000, arg2 0x00000000
[...]

My question to you (or to all who might know) is how to get the type
of the event in each instrumentation record. I looked through eCos
discussion mailing list and I found in your question asked at 2005
with title "Task switching problem"
http://sourceware.org/ml/ecos-discuss/2005-07/msg00036.html you
printed your instrumentation information with type of record. Here is
the excerpt of your output:

> Num Thread Time                    Arg1       Arg2
>
> 130 0e     0x2316 SCHED_UNLOCK     0x00000001 0x00000000
> 131 0e     0x2327 SCHED_LOCK       0x00000001 0x00000000
> 132 0e     0x232d SCHED_UNLOCK     0x00000001 0x00000000
> 133 0e     0x2344 ALARM_INIT       0x020f3080 0x00000000
> 134 0e     0x234a ALARM_TRIGGER    0x00000af6 0x00000000
> 135 0e     0x234f ALARM_INTERVAL   0x00000000 0x00000000
> 136 0e     0x2358 SCHED_LOCK       0x00000001 0x00000000

So, what I need is the type of the event as it is indicated as
SCHED_UNLOCK, SCHED_LOCK, ALARM_INIT, ALARM_TRIGGER and so on. Can you
share the code which you used to have instrumentation info with type
of event?

Thanks a lot!
Nodir.

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] Type of event in eCos instrumentation record
  2010-03-28  8:37 [ECOS] Type of event in eCos instrumentation record Nodir Kodirov
@ 2010-03-29 14:30 ` Andrew Lunn
  2010-03-30 11:49   ` Nodir Kodirov
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2010-03-29 14:30 UTC (permalink / raw)
  To: Nodir Kodirov; +Cc: Yuriy Coureelo, eCos Discussion

On Sun, Mar 28, 2010 at 03:48:50PM +0900, Nodir Kodirov wrote:
> Hello Mr. Yuriy!
> 
> I was using eCos kernel instrumentation feature to analyze behavior of
> my application. I tried the sample given at
> http://ecos.sourceware.org/docs-latest/user-guide/kernel-instrumentation.html
> where with these lines of the code:
> 
> [...]
> for (i = 0; i < instrument_buffer_size; ++i) {
>  printf("Record %02d: type 0x%04x, thread %d, ",
> 	i, instrument_buffer[i].type, instrument_buffer[i].thread);
>  printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
> 	instrument_buffer[i].timestamp, instrument_buffer[i].arg1,
> 	instrument_buffer[i].arg2);
> }
> I have got instrumentation info in this format:
> 
> Record 00: type 0x0207, thread 2, time  6057, arg1 0x48001cd8, arg2 0x00000002
> Record 01: type 0x0202, thread 2, time  6153, arg1 0x48001cd8, arg2 0x00000000
> Record 02: type 0x0904, thread 2, time  6358, arg1 0x48001d24, arg2 0x00000000
> Record 03: type 0x0905, thread 2, time  6424, arg1 0x00000002, arg2 0x00000000
> Record 04: type 0x0906, thread 2, time  6490, arg1 0x00000000, arg2 0x00000000
> [...]
> 
> My question to you (or to all who might know) is how to get the type
> of the event in each instrumentation record.

http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/kernel/current/host/instr/readme.txt?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=ecos

	Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] Type of event in eCos instrumentation record
  2010-03-29 14:30 ` Andrew Lunn
@ 2010-03-30 11:49   ` Nodir Kodirov
  2010-03-30 16:53     ` [ECOS] " John Dallaway
  0 siblings, 1 reply; 5+ messages in thread
From: Nodir Kodirov @ 2010-03-30 11:49 UTC (permalink / raw)
  To: Yuriy Coureelo, eCos Discussion

> http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/kernel/current/host/instr/readme.txt?rev=1.1&content-type=text/x-cvsweb-markup&cvsroot=ecos
>
>        Andrew
>
Thank you Mr. Andrew! I did all steps listed at readme file. But, I
couldn't solve my problem.

Let me give you more information what/how I am doing.
I am using Single Producer and Single Consumer application as a test.
Here is the code, where I enabled only CYG_INSTRUMENT_CLASS_THREAD
macro. Currently, I need number of thread exchanges only.

[...]
cyg_instrument_enable(CYG_INSTRUMENT_CLASS_THREAD, 0);
diag_printf("Consumer started\n");
int k = 0;
while (k<10)
{
	cyg_semaphore_wait(&sem_wrote);
	diag_printf("consumed = %d\n", data);
	cyg_semaphore_post(&sem_read);
	cyg_thread_delay(100);
	k++;
}
cyg_instrument_disable(CYG_INSTRUMENT_CLASS_THREAD, 0);
[...]

I have a similar code for producer thread as well.
Based on your link, I have built my instrument_desc.h file and I could
see event types and number are made as dictionary (key and value).
Here is the excerpt.

struct instrument_desc_s {
    char *   msg;
    CYG_WORD num;
};
struct instrument_desc_s instrument_desc[] = {
{"ALARM",   0x0900},
{"ALARM_ADD",   1},
{"ALARM_CALL",   3},
{"ALARM_INIT",   4},
{"ALARM_INTERVAL",   6},
{"ALARM_REM",   2},
{"ALARM_TRIGGER",   5},
[...]

If I am not wrong, *CYG_WORD num* of *instrument_desc_s* should be
equal to instrument_buffer[INDEX].type of Instrument_Record:

struct Instrument_Record
{
 CYG_WORD16 type; // record type
 CYG_WORD16 thread; // current thread id
 CYG_WORD timestamp; // 32 bit timestamp
 CYG_WORD arg1; // first arg
 CYG_WORD arg2; // second arg
};
struct Instrument_Record instrument_buffer[100];

So, I made a simple function, where I got name of the instrumentation
event based on its number. Here is function code:

void print_instr(){

	int i =0, j=0;
	bool found = false;
	char *message;

	intr_count = 0;
	while (instrument_desc[j].num != 0)
	{
		intr_count++;   j++;
	}
	for (i = 0; i <instrument_buffer_size; i++) {
		j = 0;		found = false;
		while ((!found) && (j<intr_count))
		{
			if (instrument_buffer[i].type == instrument_desc[j].num)
			{
				message = instrument_desc[j].msg;
				found = true;
			} else
				message = "unknown event";
			j++;
			diag_printf("j=%d\n",j);
		}
		printf("Record %02d: type %s, thread %d, ",
			i, message, instrument_buffer[i].thread);
		printf("time %5d, arg1 0x%08x, arg2 0x%08x\n",
			instrument_buffer[i].timestamp, instrument_buffer[i].arg1,
			instrument_buffer[i].arg2);
	}
}

Now I have two problems.
1) All of the events are "unknown event". instrument_buffer[i].type
and instrument_desc[j].num does not match.
2) If you look to struct instrument_desc_s instrument_desc[] there are
125 instrumentation event types and for several event types, it has
the same number. So, my print_instr() I am taking the first occurred
one, while it is not always correct.

How can have "instrumentation event names" as it is given at
http://sourceware.org/ml/ecos-discuss/2005-07/msg00036.html ?

Thanks,
Nodir.

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* [ECOS] Re: Type of event in eCos instrumentation record
  2010-03-30 11:49   ` Nodir Kodirov
@ 2010-03-30 16:53     ` John Dallaway
  2010-04-02 12:46       ` Nodir Kodirov
  0 siblings, 1 reply; 5+ messages in thread
From: John Dallaway @ 2010-03-30 16:53 UTC (permalink / raw)
  To: Nodir Kodirov; +Cc: eCos Discussion

Hi Nodir

Nodir Kodirov wrote:

> Now I have two problems.
> 1) All of the events are "unknown event". instrument_buffer[i].type
> and instrument_desc[j].num does not match.
> 2) If you look to struct instrument_desc_s instrument_desc[] there are
> 125 instrumentation event types and for several event types, it has
> the same number. So, my print_instr() I am taking the first occurred
> one, while it is not always correct.

Take at look at the dump_instr.c example code which locates the
description string within instrument_desc[] in two stages:

http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/kernel/current/host/instr/dump_instr.c?rev=1&content-type=text/x-cvsweb-markup&cvsroot=ecos

I hope this helps...

John Dallaway
eCos maintainer

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* [ECOS] Re: Type of event in eCos instrumentation record
  2010-03-30 16:53     ` [ECOS] " John Dallaway
@ 2010-04-02 12:46       ` Nodir Kodirov
  0 siblings, 0 replies; 5+ messages in thread
From: Nodir Kodirov @ 2010-04-02 12:46 UTC (permalink / raw)
  To: John Dallaway; +Cc: Andrew Lunn, eCos Discussion

Thank you John! That worked fine!

Now I have very a simple solution. I use eCos 3.0 and there is
cyg_instrument_msg(CYG_WORD16 type) function defined in
packages/kernel/v3_0/src/instrmnt/meminst.cxx file. This function is
supposed to take *CYG_WORD16 type* of instrumentation event as an
argument and return its string representation, as it is defined at
packages/kernel/v3_0/include/instrument_desc.h.

So, simply
> #include <cyg/kernel/instrument_desc.h>
> #include <cyg/kernel/instrmnt.h>
and
> char * message = cyg_instrument_msg(instrument_buffer[INDEX].type);
we will have a string representation of the instrumentation event.

Once again, a lot of thanks to all for hints!
Regards,
Nodir.

On 30 March 2010 20:49, John Dallaway <john@dallaway.org.uk> wrote:
> Hi Nodir
>
> Nodir Kodirov wrote:
>
>> Now I have two problems.
>> 1) All of the events are "unknown event". instrument_buffer[i].type
>> and instrument_desc[j].num does not match.
>> 2) If you look to struct instrument_desc_s instrument_desc[] there are
>> 125 instrumentation event types and for several event types, it has
>> the same number. So, my print_instr() I am taking the first occurred
>> one, while it is not always correct.
>
> Take at look at the dump_instr.c example code which locates the
> description string within instrument_desc[] in two stages:
>
> http://ecos.sourceware.org/cgi-bin/cvsweb.cgi/ecos/packages/kernel/current/host/instr/dump_instr.c?rev=1&content-type=text/x-cvsweb-markup&cvsroot=ecos
>
> I hope this helps...
>
> John Dallaway
> eCos maintainer
>

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

end of thread, other threads:[~2010-04-02 12:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-28  8:37 [ECOS] Type of event in eCos instrumentation record Nodir Kodirov
2010-03-29 14:30 ` Andrew Lunn
2010-03-30 11:49   ` Nodir Kodirov
2010-03-30 16:53     ` [ECOS] " John Dallaway
2010-04-02 12:46       ` Nodir Kodirov

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).