Diff of /daemon/opd_mangling.c [9871f0] .. [0d0e60] Maximize Restore

  Switch to unified view

a/daemon/opd_mangling.c b/daemon/opd_mangling.c
...
...
31
#include <errno.h>
31
#include <errno.h>
32
32
33
33
34
static char const * get_dep_name(struct sfile const * sf)
34
static char const * get_dep_name(struct sfile const * sf)
35
{
35
{
36
  /* don't add a useless depname */
36
  /* avoid to call find_cookie(), caller can recover using image_name */
37
    if (sf->cookie == sf->app_cookie)
37
    if (sf->cookie == sf->app_cookie)
38
        return NULL;
38
        return NULL;
39
39
40
    if (!separate_kernel && !(separate_lib && !sf->kernel))
40
    if (!separate_kernel && !(separate_lib && !sf->kernel))
41
        return NULL;
41
        return NULL;
...
...
46
46
47
    return find_cookie(sf->app_cookie);
47
    return find_cookie(sf->app_cookie);
48
}
48
}
49
49
50
50
51
static char * mangle_filename(struct sfile const * sf, int counter)
51
static char *
52
mangle_filename(struct sfile * last, struct sfile const * sf, int counter, int cg)
52
{
53
{
53
    char * mangled;
54
    char * mangled;
54
    struct mangle_values values;
55
    struct mangle_values values;
55
    struct opd_event * event = find_counter_event(counter);
56
    struct opd_event * event = find_counter_event(counter);
56
57
...
...
65
    /* FIXME: log */
66
    /* FIXME: log */
66
    if (!values.image_name)
67
    if (!values.image_name)
67
        return NULL;
68
        return NULL;
68
69
69
    values.dep_name = get_dep_name(sf);
70
    values.dep_name = get_dep_name(sf);
70
    if (values.dep_name)
71
    if (!values.dep_name)
71
      values.flags |= MANGLE_DEP_NAME;
72
      values.dep_name = values.image_name;
72
73
73
    if (separate_thread) {
74
    if (separate_thread) {
74
        values.flags |= MANGLE_TGID | MANGLE_TID;
75
        values.flags |= MANGLE_TGID | MANGLE_TID;
75
        values.tid = sf->tid;
76
        values.tid = sf->tid;
76
        values.tgid = sf->tgid;
77
        values.tgid = sf->tgid;
...
...
79
    if (separate_cpu) {
80
    if (separate_cpu) {
80
        values.flags |= MANGLE_CPU;
81
        values.flags |= MANGLE_CPU;
81
        values.cpu = sf->cpu;
82
        values.cpu = sf->cpu;
82
    }
83
    }
83
84
85
  if (cg) {
86
      values.flags |= MANGLE_CALLGRAPH;
87
      if (last->kernel)
88
          values.cg_image_name = last->kernel->name;
89
      else
90
          values.cg_image_name = find_cookie(last->cookie);
91
      if (!values.cg_image_name)
92
          return NULL;
93
  }
94
84
    values.event_name = event->name;
95
    values.event_name = event->name;
85
    values.count = event->count;
96
    values.count = event->count;
86
    values.unit_mask = event->um;
97
    values.unit_mask = event->um;
87
98
88
    mangled = op_mangle_filename(&values);
99
    mangled = op_mangle_filename(&values);
89
100
90
    return mangled;
101
    return mangled;
91
}
102
}
92
103
93
104
94
int opd_open_sample_file(struct sfile * sf, int counter)
105
int opd_open_sample_file(samples_odb_t * file, struct sfile * last,
106
                         struct sfile * sf, int counter, int cg)
95
{
107
{
96
    char * mangled;
108
    char * mangled;
97
  samples_odb_t * file;
98
    char const * binary;
109
    char const * binary;
99
    int err;
110
    int err;
100
111
101
  file = &sf->files[counter];
102
103
    mangled = mangle_filename(sf, counter);
112
    mangled = mangle_filename(last, sf, counter, cg);
104
113
105
    if (!mangled)
114
    if (!mangled)
106
        return EINVAL;
115
        return EINVAL;
107
116
108
    verbprintf("Opening \"%s\"\n", mangled);
117
    verbprintf("Opening \"%s\"\n", mangled);
109
118
110
    create_path(mangled);
119
    create_path(mangled);
111
120
112
  sfile_get(sf);
121
  sfile_get(sf);  /* locking sf will lock associated cg files too */
113
122
114
retry:
123
retry:
115
    err = odb_open(file, mangled, ODB_RDWR, sizeof(struct opd_header));
124
    err = odb_open(file, mangled, ODB_RDWR, sizeof(struct opd_header));
116
125
117
    /* This can naturally happen when racing against opcontrol --reset. */
126
    /* This can naturally happen when racing against opcontrol --reset. */
...
...
133
        binary = find_cookie(sf->cookie);
142
        binary = find_cookie(sf->cookie);
134
    else
143
    else
135
        binary = sf->kernel->name;
144
        binary = sf->kernel->name;
136
145
137
    fill_header(file->base_memory, counter, !!sf->kernel,
146
    fill_header(file->base_memory, counter, !!sf->kernel,
147
          last ? !!last->kernel : 0,
138
                binary ? op_get_mtime(binary) : 0);
148
                binary ? op_get_mtime(binary) : 0);
139
149
140
out:
150
out:
141
    sfile_put(sf);
151
    sfile_put(sf);
142
    free(mangled);
152
    free(mangled);