summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorguanglei <guanglei>2006-06-01 13:45:52 +0000
committerguanglei <guanglei>2006-06-01 13:45:52 +0000
commitf73723169cbb753d04e66acf697c72adc20c6ee0 (patch)
tree408b591672dd303df11cff48a01f05fd95c24be7 /runtime
parent01133ccb0ee31f7108f7cb4e89454f2693df912e (diff)
downloadsystemtap-steved-f73723169cbb753d04e66acf697c72adc20c6ee0.tar.gz
systemtap-steved-f73723169cbb753d04e66acf697c72adc20c6ee0.tar.xz
systemtap-steved-f73723169cbb753d04e66acf697c72adc20c6ee0.zip
make lket-b2a able to read user added trace data and backtrace
Diffstat (limited to 'runtime')
-rw-r--r--runtime/ChangeLog5
-rw-r--r--runtime/lket/b2a/lket_b2a.c39
-rw-r--r--runtime/lket/b2a/lket_b2a.h4
3 files changed, 37 insertions, 11 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index 497ae6d8..3554a89b 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-01 Li Guanglei <guanglei@cn.ibm.com>
+
+ * lket/b2a/lket_b2a.h, lket/b2a/lket_b2a.c: make it able to
+ read user added trace data and backtrace
+
2006-05-30 Martin Hunt <hunt@redhat.com>
* string.c (_stp_text_str): New function.
diff --git a/runtime/lket/b2a/lket_b2a.c b/runtime/lket/b2a/lket_b2a.c
index 0aa0124b..be78c302 100644
--- a/runtime/lket/b2a/lket_b2a.c
+++ b/runtime/lket/b2a/lket_b2a.c
@@ -87,7 +87,7 @@ int main(int argc, char *argv[])
goto failed;
}
}
-
+#if !defined(DEBUG_OUTPUT)
if(strnlen(outfilename, MAX_STRINGLEN) == 0)
strncpy(outfilename, DEFAULT_OUTFILE_NAME, MAX_STRINGLEN);
outfp = fopen(outfilename, "w");
@@ -95,6 +95,9 @@ int main(int argc, char *argv[])
printf("Unable to create %s\n", outfilename);
goto failed;
}
+#else
+ outfp = stdout;
+#endif
/* create the search tree */
appNameTree = g_tree_new_full(compareFunc, NULL, NULL, destroyAppName);
@@ -429,6 +432,8 @@ void b2a_vsnprintf(const char *fmt, FILE *infp, FILE *outfile, size_t size)
int32_t ntemp;
long ltemp;
long long lltemp;
+ short length;
+ char format[128];
if(size <= 0 || !outfile)
return;
@@ -548,15 +553,27 @@ void b2a_vsnprintf(const char *fmt, FILE *infp, FILE *outfile, size_t size)
}
filled:
- // print possible backtrace string
- while(readbytes++ < size ) {
- if((c=fgetc_unlocked(infp)) != EOF)
- break;
- if(!c)
- break;
- fputc_unlocked(c, outfile);
+
+ readbytes = 0;
+
+ c=fgetc_unlocked(infp);
+
+ if(c == LKET_PKT_BT) {
+ fread(&length, 2, 1, infp);
+ strncpy(format, "BACKTRACE: ", 12);
+ fwrite(format, 11, 1, outfile);
+ strncpy(format, "%0s", 4);
+ b2a_vsnprintf(format, infp, outfile, length);
+ } else if(c == LKET_PKT_USER) {
+ fread(&length, 2, 1, infp);
+ strncpy(format, "USER: ", 6);
+ fwrite(format, 6, 1, outfile);
+ do {
+ c = fgetc_unlocked(infp);
+ format[readbytes++] = c;
+ } while(c);
+ b2a_vsnprintf(format, infp, outfile, length - readbytes);
+ } else {
+ fputc_unlocked('\n', outfile);
}
- if(readbytes < size)
- fseek(infp, size - readbytes, SEEK_CUR);
- fprintf(outfile, "\n");
}
diff --git a/runtime/lket/b2a/lket_b2a.h b/runtime/lket/b2a/lket_b2a.h
index dd239126..94d1d8b2 100644
--- a/runtime/lket/b2a/lket_b2a.h
+++ b/runtime/lket/b2a/lket_b2a.h
@@ -12,6 +12,10 @@
#define SEQID_SIZE 4
+#define LKET_PKT_SYS 1
+#define LKET_PKT_BT 2
+#define LKET_PKT_USER 3
+
#define DEFAULT_OUTFILE_NAME "lket.out"
typedef struct _lket_pkt_header {