Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 927 → Rev 1027

/shark/trunk/tracer/include/FTrace_disk.h
0,0 → 1,13
#ifndef __FTRACE_DISK__
#define __FTRACE_DISK__
 
/* OS Dependent functions */
 
#include <FTrace_types.h>
 
int FTrace_init_disk_writer(char *fname, int flag, char *l_ip, char *t_ip);
 
void FTrace_disk_writer(FTrace_Chunk_Ptr c);
 
#endif
 
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: include/FTrace.h
===================================================================
--- include/FTrace.h (revision 927)
+++ include/FTrace.h (revision 1027)
@@ -14,6 +14,9 @@
// the high 4 bits indicate the type of event in the class.
// (This allows an easy mechanisms for filtering events)
+/* Tool : used for the filter masking*/
+#define FTrace_family_mask 0x0F
+
// general trace events
#define FTrace_EVT_empty 0x00
#define FTrace_EVT_cycles_per_msec 0x10 // Par1 [empty] Par2 [clk/msec]
@@ -95,7 +98,7 @@
#define FTrace_EVT_user_event_12 0xC9
#define FTrace_EVT_user_event_13 0xD9
#define FTrace_EVT_user_event_14 0xE9
-#define FTrace_EVT_user_event_15 0xF9
+//#define FTrace_EVT_user_event_15 0xF9 // Tool: removed
// Timer Events
#define FTrace_EVT_timer_post 0x0B // Par 1 [empty] Par2 [empty]
/shark/trunk/tracer/newtrace/FTrace_disk.c
0,0 → 1,170
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Tullio Facchinetti <tullio.facchinetti@unipv.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
* http://robot.unipv.it
*/
 
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#include <ll/sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <tracer.h>
#include <unistd.h>
 
#include <FTrace_disk.h>
#include <FTrace_OSD.h>
#include <FTrace_chunk.h>
#include <FTrace_types.h>
 
#include "ll/i386/x-dos.h"
 
#include <kernel/kern.h>
 
#define TRACER_DISK_DEBUG
 
void write_all_to_disk();
void write_to_disk(FTrace_Chunk_Ptr c, char *my_fname);
 
int TracerDiskInit = 0;
 
char fname[255];
 
/**
* Contains the data of all the chunks that is wanted to write to file.
*/
FTrace_Chunk_Ptr chunk_to_disk[MAX_CHUNK];
 
/**
* Keeps track of the number of chunks to be written on disk.
*/
int n_chunks_to_disk = 0;
 
/**
* Initialize the Tracer chunk dumper to disk.
* It sets the internal chunk sender to the function that writes
* the chunk on disk. It initializes the filename that will be used
* to open the file for saving the chunk.
*/
int FTrace_init_disk_writer(char *fn, int flag, char *l_ip, char *t_ip) {
FTrace_set_internal_chunk_sender(FTrace_disk_writer);
memcpy(fname, fn, sizeof(fname));
TracerDiskInit = 1;
return 0;
}
 
/**
* This function is called by the application when it asks to write a chunk on disk.
* It saves the chunk data into the chunk_to_disk array. At the runlevel after the exit,
* all the saved chunks will be written to disk.
*/
void FTrace_disk_writer(FTrace_Chunk_Ptr c) {
chunk_to_disk[n_chunks_to_disk++] = c;
sys_atrunlevel(write_all_to_disk, NULL, RUNLEVEL_AFTER_EXIT);
}
 
/**
* This function is invoked at the runlevel after the exit .
* It calls write_to_disk for each chunk that has to be wrote on disk.
* To avoid to use the append flag of the fopen, that seems to not to work properly,
* a new filename is generated for each different chunk (). An incremental number is
* put before the filename and passed to the write_to_disk function.
*/
void write_all_to_disk() {
int i;
char fname1[225];
for (i = 0; i < n_chunks_to_disk; i++) {
sprintf(fname1, "%d%s", i, fname);
write_to_disk(chunk_to_disk[i], fname1);
}
}
 
/**
* This function is called by the tracer to write the num-th chunk
* on disk.
*/
void write_to_disk(FTrace_Chunk_Ptr c, char *my_fname) {
DWORD total_size = (DWORD)(c->size) + (DWORD)(c->emergency_size);
DWORD start = (DWORD)(c->osd + FTRACE_OSD_CHUNK_HEAD);
DWORD current = start;
int writtenbytes; /* number of bytes written */
int err;
long count = 0;
DOS_FILE *f;
if (!TracerDiskInit) {
cprintf("FTrace_disk_writer: disk writing not initialized.\n");
return;
}
/* open the DOS file for writing */
f = DOS_fopen(my_fname, "w");
/* check for open errors */
if (!f) {
/* error!! */
err = DOS_error();
/* note that if you call DOS_error() here, it return 0!!! */
printk("Error %d opening %s...\n", err, fname);
return;
}
FTrace_chunck_output_start();
/** Writes blocks of 16 bytes (a single event) on the disk. */
int block_size = 16;
while (current + block_size <= start + total_size) {
if (*(WORD *)(current) != 0) {
writtenbytes = DOS_fwrite(current, block_size, 1, f);
count++;
}
current += block_size;
#ifdef TRACER_DISK_DEBUG
if (!(count % 10))
printk("count %d\n", count);
#endif
}
FTrace_chunck_output_end();
 
#ifdef TRACER_DISK_DEBUG
printk("Wrote: %d bytes in file %s (count = %ld)\n", total_size, fname, count);
printk("FTrace_OSD_disk_writer: end function\n");
#endif
 
/* Close the file */
DOS_fclose(f);
return;
}
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: newtrace/FTrace_OSD_ll.c
===================================================================
--- newtrace/FTrace_OSD_ll.c (revision 927)
+++ newtrace/FTrace_OSD_ll.c (revision 1027)
@@ -1,5 +1,6 @@
#include <FTrace_types.h>
#include <FTrace_OSD.h>
+#include <FTrace.h>
#include <ll/i386/hw-instr.h>
@@ -15,6 +16,11 @@
*/
+extern WORD FTrace_filter_mask;
+
+/**
+ * This is the function that actually store the event into the selected chunk.
+ */
void FTrace_safe_ipoint(WORD type, WORD par1, DWORD par2)
{
@@ -33,6 +39,11 @@
if (FTraceEnable) {
+ /** Tool: do not filter the "filter" event family. */
+ if ((type & 0xF0) != 0xF0)
+ if (FTrace_filter_mask & (0x01 << (type & FTrace_family_mask)))
+ return;
+
current = *(DWORD *)(OSD_current_pointer);
start = *(DWORD *)(OSD_current_pointer + 4);
size = *(DWORD *)(OSD_current_pointer + 8);
@@ -50,7 +61,7 @@
return;
}
- /* Cyclical Buffer */
+ /** Cyclical Buffer */
if (current + 16 >= (start + size)) {
if ((flags & 0x0C) == FTRACE_CHUNK_FLAG_CYC) {
current = start;
/shark/trunk/tracer/newtrace/FTrace.c
1,9 → 1,13
#include <FTrace_chunk.h>
#include <FTrace_types.h>
#include <FTrace_OSD.h>
#include <FTrace.h>
#include <tracer.h>
 
//#define FTRACE_DEBUG
#define FTRACE_DEBUG
 
WORD FTrace_filter_mask = 0;
 
/* Globals */
 
FTrace_Chunk_Ptr ChunkTable[MAX_CHUNK]; /* Chunk array */
30,6 → 34,23
 
}
 
/**
* Set the filter for a specific family of events.
* Store the choice into the filter mask.
* If status is 1 then enable the filter.
* If status is 0 then disable the filter.
*/
void FTrace_set_filter(BYTE filter, int status) {
if (status) FTrace_filter_mask |= (0x01 << (filter & FTrace_family_mask));
if (!status) FTrace_filter_mask &= ~(0x01 << (filter & FTrace_family_mask));
#ifdef FTRACE_DEBUG
printk("FTrace_set_filter: %x\n", FTrace_filter_mask);
#endif
TRACER_LOGEVENT(filter, status, 0);
}
 
/* Find a free slot in ChunkTable */
static int FTrace_find_free_slot()
{
/shark/trunk/tracer/newtrace/FTrace_OSD.c
12,6 → 12,40
extern FTrace_Chunk_Ptr ActualChunk;
extern void *OSD_current_pointer;
 
/**
* This flag keeps track of the current chunk sending action.
* It is 1 if the output is still ongoing.
* It is reset to 0 if the output is finished.
*/
int chunk_sending = 0;
 
/**
* Pointer to the function that actually perform the chunk send.
*/
void (*FTrace_internal_send_chunk)(FTrace_Chunk_Ptr) = NULL;
 
/**
* Initializes the poiter to the function for actually sending the chunk.
*/
void FTrace_set_internal_chunk_sender(void (*ptr)(FTrace_Chunk_Ptr)) {
FTrace_internal_send_chunk = ptr;
}
 
/**
* This function is called before starting the chunck sending.
*/
void FTrace_chunck_output_start() {
chunk_sending = 1;
}
 
/**
* This function is called after the chunck has been entirely sent.
*/
void FTrace_chunck_output_end() {
chunk_sending = 0;
}
 
 
void FTrace_fsave()
{
 
110,17 → 144,24
 
}
 
int FTrace_OSD_send_chunk(FTrace_Chunk_Ptr c, int osd_flag)
{
int FTrace_OSD_send_chunk(FTrace_Chunk_Ptr c, int osd_flag) {
 
extern volatile int sending_flag;
// Tool: send the chunk using the selected method
if (FTrace_internal_send_chunk != NULL)
FTrace_internal_send_chunk(c);
 
FTrace_OSD_create_udp_task(c);
 
while(sending_flag);
struct timespec t;
t.tv_sec = 2;
t.tv_nsec = 0;
//cprintf("Chunk sending"); // Tool: DEBUG
while(chunk_sending) {
//cprintf("."); // Tool: DEBUG
nanosleep(&t,NULL);
}
//cprintf("\n"); // Tool: DEBUG
 
return 0;
 
}
 
int FTrace_OSD_chunk_dump(FTrace_Chunk_Ptr c)
/shark/trunk/tracer/newtrace/FTrace_udp.c
7,6 → 7,7
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* Tullio Facchinetti <tullio.facchinetti@unipv.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
14,6 → 15,9
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*
* Robotib Lab (University of Pavia)
* http://robot.unipv.it
*/
 
/*
72,11 → 76,20
unsigned int total_size;
};
 
//Init UDP, if flag = 1 init the network driver
/**
* Initialize the Tracer chunk sender through the network using the UDP
* protocol supported by S.Ha.R.K.
* If flag = 1 initializes the network driver, otherwise it considers
* that the network layer has already been initialized.
* It also sets the internal chunk sender to the function that initializes
* the task for sending the chunk.
*/
int FTrace_OSD_init_udp(int flag, char *l_ip, char *t_ip) {
 
struct net_model m = net_base;
 
FTrace_set_internal_chunk_sender(FTrace_OSD_create_udp_task); // Tool
 
strcpy(local_ip,l_ip);
strcpy(target_ip,t_ip);
 
192,7 → 205,7
// Flush the buffer out
send_udp_event(NULL, 0);
 
sending_flag = 0;
FTrace_chunck_output_end(); // Tool
 
#ifdef TRACER_UDP_DEBUG
cprintf("\nTotal Chunk Event Sent: %d\n",(int)count);
207,7 → 220,7
 
NRT_TASK_MODEL st;
 
sending_flag = 1;
FTrace_chunck_output_start(); // Tool
 
nrt_task_default_model(st);
nrt_task_def_arg(st,(void *)c);
/shark/trunk/tracer/makefile
17,7 → 17,7
 
ifeq ($(findstring NEW,$(TRACER)) , NEW)
OBJS = newtrace/FTrace.o newtrace/FTrace_OSD.o newtrace/FTrace_OSD_ll.o\
newtrace/FTrace_udp.o
newtrace/FTrace_udp.o newtrace/FTrace_disk.o
CFG_OPT += -D__NEW_TRACER__
endif
ifeq ($(findstring OLD,$(TRACER)) , OLD)