-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracer_plantuml.h
87 lines (74 loc) · 2.45 KB
/
tracer_plantuml.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef __TRACER_PLANTUML_H__
#define __TRACER_PLANTUML_H__
#include "tracer_util.h"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#define OUTPUT_PLANTUML_FILENAME "output.txt"
const char Main[] = "main";
FILE *g_output_fp = NULL;
void output_to_file_enter_plantuml(const char *func_name, const char *demangled,
const char *caller,
const char *demangled_caller, void *param) {
if (!g_output_fp) {
g_output_fp = fopen(OUTPUT_PLANTUML_FILENAME, "w+");
fprintf(g_output_fp, "@startuml %s.png\n", OUTPUT_PLANTUML_FILENAME);
}
printf("%s %p %s\n", __FUNCTION__, (char *)param, (char *)param);
char *callee_object = NULL;
char *p = (char *)malloc(strlen(demangled) + 1);
strcpy(p, demangled);
demangled_split(p);
callee_object = split_caller_object(p);
char *p2 = 0;
char *caller_object = NULL;
if (!strcmp(Main, caller)) {
caller_object = (char *)&Main[0];
} else {
p2 = (char *)malloc(strlen(demangled_caller) + 1);
strcpy(p2, demangled_caller);
demangled_split(p2);
caller_object = split_caller_object(p);
}
fprintf(g_output_fp, "%s -> %s : %s [%s]\n", caller_object, callee_object,
split_caller_method(p), (char *)param);
if (strcmp(caller_object, callee_object))
fprintf(g_output_fp, "activate %s\n", callee_object);
if (p)
free(p);
if (p2)
free(p2);
}
void output_to_file_exit_plantuml(const char *func_name, const char *demangled,
const char *caller,
const char *demangled_caller) {
if (g_output_fp) {
char *callee_object = NULL;
char *p = (char *)malloc(strlen(demangled) + 1);
strcpy(p, demangled);
demangled_split(p);
callee_object = split_caller_object(p);
char *p2 = 0;
char *caller_object = NULL;
if (!strcmp(Main, caller)) {
caller_object = (char *)&Main[0];
} else {
p2 = (char *)malloc(strlen(demangled_caller) + 1);
strcpy(p2, demangled_caller);
demangled_split(p2);
caller_object = split_caller_object(p);
}
if (strcmp(caller_object, callee_object)) {
fprintf(g_output_fp, "%s <-- %s : return\n", caller_object,
callee_object);
fprintf(g_output_fp, "deactivate %s\n", callee_object);
}
if (p)
free(p);
if (p2)
free(p2);
}
}
#endif /* end of include guard: __TRACER_PLANTUML_H__ */