-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfct_annexe.c
74 lines (66 loc) · 1.43 KB
/
fct_annexe.c
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
/*
** fct_annexe.c for fct_annexe in /home/marcha_j//svn/c/ftrace-2015-2014s-marcha_j
**
** Made by hugo marchadier
** Login <marcha_j@epitech.net>
**
** Started on Fri Jun 22 14:20:50 2012 hugo marchadier
** Last update Tue Jun 26 17:31:06 2012 hugo marchadier
*/
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "ftrace.h"
#include "dyntab_sym.h"
#include "xfct.h"
void xwrite(char *msg, t_info *info)
{
if (info->fd != -1)
write(info->fd, msg, strlen(msg));
}
void xopen(char *path, t_info *info)
{
if ((info->fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
return ;
xwrite("graph FTRACE {\n", info);
}
void xclose(t_info *info)
{
if (info->fd != -1)
{
xwrite("}\n", info);
close(info->fd);
}
}
void print_graph_sym(t_list *sym, int pos, t_info *info)
{
int i = 0;
if (pos != 0 && sym != NULL)
{
while (sym != NULL && i != pos)
{
i++;
sym = sym->next;
}
if (sym != NULL && sym->prev != NULL && sym->prev->data != NULL
&& sym->data != NULL)
{
xwrite(sym->prev->data->name, info);
xwrite(" -- ", info);
xwrite(sym->data->name, info);
xwrite(";\n", info);
}
}
}
void init_info(t_info *info, pid_t pid)
{
info->pid = pid;
info->save_rip = NULL;
info->status_call = NONE;
info->tab = tab_sym(pid);
info->dyntab = tab_dynsym(pid);
xopen(GRAPH_NAME, info);
}