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

  Switch to unified view

a/daemon/opd_trans.c b/daemon/opd_trans.c
...
...
73
        return;
73
        return;
74
    }
74
    }
75
75
76
    event = pop_buffer_value(trans);
76
    event = pop_buffer_value(trans);
77
77
78
  if (trans->tracing != TRACING_ON)
79
      trans->event = event;
80
78
    trans->pc = pc;
81
    trans->pc = pc;
79
82
80
    /* sfile can change at each sample for kernel */
83
    /* sfile can change at each sample for kernel */
81
    if (trans->in_kernel != 0)
84
    if (trans->in_kernel != 0)
82
        trans->current = NULL;
85
        trans->current = NULL;
...
...
85
    if (!trans->current)
88
    if (!trans->current)
86
        trans->current = sfile_find(trans);
89
        trans->current = sfile_find(trans);
87
90
88
    /* can happen if kernel sample falls through the cracks */
91
    /* can happen if kernel sample falls through the cracks */
89
    if (!trans->current)
92
    if (!trans->current)
90
      return;
93
      goto out;
91
94
92
    if (trans->current->ignored)
95
    if (trans->current->ignored)
93
      return;
96
      goto out;
94
97
95
  sfile_log_sample(trans->current, trans->pc, event);
98
  /* log the sample or arc */
99
  sfile_log_sample(trans);
100
101
out:
102
  /* switch to trace mode */
103
  if (trans->tracing == TRACING_START)
104
      trans->tracing = TRACING_ON;
105
106
  /* used for callgraph only */
107
  trans->last = trans->current;
108
  trans->last_pc = trans->pc;
96
}
109
}
97
110
98
111
99
static void code_unknown(struct transient * trans __attribute__((unused)))
112
static void code_unknown(struct transient * trans __attribute__((unused)))
100
{
113
{
...
...
190
    opd_reread_module_info();
203
    opd_reread_module_info();
191
    trans->current = NULL;
204
    trans->current = NULL;
192
}
205
}
193
206
194
207
208
static void code_trace_begin(struct transient * trans)
209
{
210
  verbprintf("TRACE_BEGIN\n");
211
  trans->tracing = TRACING_START;
212
}
213
214
215
static void code_trace_end(struct transient * trans)
216
{
217
  verbprintf("TRACE_END\n");
218
  trans->tracing = TRACING_OFF;
219
}
220
221
195
typedef void (*handler_t)(struct transient *);
222
typedef void (*handler_t)(struct transient *);
196
223
197
static handler_t handlers[LAST_CODE + 1] = {
224
static handler_t handlers[LAST_CODE + 1] = {
198
    &code_unknown,
225
    &code_unknown,
199
    &code_ctx_switch,
226
    &code_ctx_switch,
200
    &code_cpu_switch,
227
    &code_cpu_switch,
201
    &code_cookie_switch,
228
    &code_cookie_switch,
202
    &code_kernel_enter,
229
    &code_kernel_enter,
203
    &code_kernel_exit,
230
    &code_kernel_exit,
204
    &code_module_loaded,
231
    &code_module_loaded,
205
    &code_unknown /* tgid handled differently */
232
    &code_unknown, /* tgid handled differently */
233
  &code_trace_begin,
234
  &code_trace_end,
206
};
235
};
207
236
208
237
209
void opd_process_samples(char const * buffer, size_t count)
238
void opd_process_samples(char const * buffer, size_t count)
210
{
239
{
211
    struct transient trans = {
240
    struct transient trans = {
212
        .buffer = buffer,
241
        .buffer = buffer,
213
        .remaining = count,
242
        .remaining = count,
243
      .tracing = TRACING_OFF,
214
        .current = NULL,
244
        .current = NULL,
245
      .last = NULL,
215
        .cookie = 0,
246
        .cookie = 0,
216
        .app_cookie = 0,
247
        .app_cookie = 0,
217
        .pc = 0,
248
        .pc = 0,
249
      .last_pc = 0,
250
      .event = 0,
218
        .in_kernel = -1,
251
        .in_kernel = -1,
219
        .cpu = -1,
252
        .cpu = -1,
220
        .tid = -1,
253
        .tid = -1,
221
        .tgid = -1
254
        .tgid = -1
222
    };
255
    };