Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 100457
b: refs/heads/master
c: cb0f12a
h: refs/heads/master
i:
  100455: 2408449
v: v3
  • Loading branch information
Ingo Molnar authored and Thomas Gleixner committed May 23, 2008
1 parent 2067db0 commit dfb313d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f9896bf30928922a3913a3810a4ab7908da6cfe7
refs/heads/master: cb0f12aae8d085140d37ada351aa5a8e76c3f9b0
50 changes: 50 additions & 0 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ enum trace_iterator_flags {
TRACE_ITER_SYM_ADDR = 0x04,
TRACE_ITER_VERBOSE = 0x08,
TRACE_ITER_RAW = 0x10,
TRACE_ITER_BIN = 0x20,
};

#define TRACE_ITER_SYM_MASK \
Expand All @@ -166,6 +167,7 @@ static const char *trace_options[] = {
"sym-addr",
"verbose",
"raw",
"bin",
NULL
};

Expand Down Expand Up @@ -275,6 +277,18 @@ trace_seq_putc(struct trace_seq *s, unsigned char c)
return 1;
}

static notrace int
trace_seq_putmem(struct trace_seq *s, void *mem, size_t len)
{
if (len > ((PAGE_SIZE - 1) - s->len))
return 0;

memcpy(s->buffer + s->len, mem, len);
s->len += len;

return len;
}

static notrace void
trace_seq_reset(struct trace_seq *s)
{
Expand Down Expand Up @@ -1261,6 +1275,39 @@ static notrace int print_raw_fmt(struct trace_iterator *iter)
return 1;
}

#define SEQ_PUT_FIELD_RET(s, x) \
do { \
if (!trace_seq_putmem(s, &(x), sizeof(x))) \
return 0; \
} while (0)

static notrace int print_bin_fmt(struct trace_iterator *iter)
{
struct trace_seq *s = &iter->seq;
struct trace_entry *entry;

entry = iter->ent;

SEQ_PUT_FIELD_RET(s, entry->pid);
SEQ_PUT_FIELD_RET(s, entry->cpu);
SEQ_PUT_FIELD_RET(s, entry->t);

switch (entry->type) {
case TRACE_FN:
SEQ_PUT_FIELD_RET(s, entry->fn.ip);
SEQ_PUT_FIELD_RET(s, entry->fn.parent_ip);
break;
case TRACE_CTX:
SEQ_PUT_FIELD_RET(s, entry->ctx.prev_pid);
SEQ_PUT_FIELD_RET(s, entry->ctx.prev_prio);
SEQ_PUT_FIELD_RET(s, entry->ctx.prev_state);
SEQ_PUT_FIELD_RET(s, entry->ctx.next_pid);
SEQ_PUT_FIELD_RET(s, entry->ctx.next_prio);
break;
}
return 1;
}

static int trace_empty(struct trace_iterator *iter)
{
struct trace_array_cpu *data;
Expand All @@ -1279,6 +1326,9 @@ static int trace_empty(struct trace_iterator *iter)

static int print_trace_line(struct trace_iterator *iter)
{
if (trace_flags & TRACE_ITER_BIN)
return print_bin_fmt(iter);

if (trace_flags & TRACE_ITER_RAW)
return print_raw_fmt(iter);

Expand Down

0 comments on commit dfb313d

Please sign in to comment.