forked from torvalds/linux
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
dyndbg: issue trace-events from pr_debug, dev_dbg
ddebug_trace() currently issues a single printk:console event.
Upgrade it to issue either of 2 new events:
- dyndbg:prdbg - from trace_prdbg() - if !dev
- dyndbg:devdbg - from trace_devdbg() - if !!dev
This links the legacy pr_debug API to tracefs, via dyndbg, allowing
pr_debug()s etc to add just a little more user-context to the
trace-logs, and then at users option, less syslog.
The 2 new trace_*() calls accept their caller's args respectively,
keeping the available info w/o alteration; ISTM this is the best basis
to support filtering. The args:
1- struct _ddebug *descriptor, giving tracefs all of dyndbg's info.
2- struct device *dev, used by trace_devdbg(), if !!dev
To pass the descriptor into the trace_*() calls, the callchains from
__dynamic_{pr_debug,{dev,netdev,ibdev}_dbg} are altered to provide it.
The existing category param in this callchain is partially redundant,
as it is also in the descriptor; it may be possible to remove later.
dev_dbg(desc, dev...), if dev is true, issues a trace_devdbg(),
otherwise trace_prdbg(). This way we dont consume buffer space
storing nulls.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>- Loading branch information
Showing
2 changed files
with
110 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
| #undef TRACE_SYSTEM | ||
| #define TRACE_SYSTEM dyndbg | ||
|
|
||
| #if !defined(_TRACE_DYNDBG_H) || defined(TRACE_HEADER_MULTI_READ) | ||
| #define _TRACE_DYNDBG_H | ||
|
|
||
| #include <linux/tracepoint.h> | ||
|
|
||
| /* capture pr_debug() callsite descriptor and message */ | ||
| TRACE_EVENT(prdbg, | ||
| TP_PROTO(const struct _ddebug *desc, const char *text, size_t len), | ||
|
|
||
| TP_ARGS(desc, text, len), | ||
|
|
||
| TP_STRUCT__entry( | ||
| __field(const struct _ddebug *, desc) | ||
| __dynamic_array(char, msg, len + 1) | ||
| ), | ||
|
|
||
| TP_fast_assign( | ||
| __entry->desc = desc; | ||
| /* | ||
| * Each trace entry is printed in a new line. | ||
| * If the msg finishes with '\n', cut it off | ||
| * to avoid blank lines in the trace. | ||
| */ | ||
| if (len > 0 && (text[len - 1] == '\n')) | ||
| len -= 1; | ||
|
|
||
| memcpy(__get_str(msg), text, len); | ||
| __get_str(msg)[len] = 0; | ||
| ), | ||
|
|
||
| TP_printk("%s.%s %s", __entry->desc->modname, | ||
| __entry->desc->function, __get_str(msg)) | ||
| ); | ||
|
|
||
| /* capture dev_dbg() callsite descriptor, device, and message */ | ||
| TRACE_EVENT(devdbg, | ||
| TP_PROTO(const struct _ddebug *desc, const struct device *dev, | ||
| const char *text, size_t len), | ||
|
|
||
| TP_ARGS(desc, dev, text, len), | ||
|
|
||
| TP_STRUCT__entry( | ||
| __field(const struct _ddebug *, desc) | ||
| __field(const struct device *, dev) | ||
| __dynamic_array(char, msg, len + 1) | ||
| ), | ||
|
|
||
| TP_fast_assign( | ||
| __entry->desc = desc; | ||
| __entry->dev = (struct device *) dev; | ||
| /* | ||
| * Each trace entry is printed in a new line. | ||
| * If the msg finishes with '\n', cut it off | ||
| * to avoid blank lines in the trace. | ||
| */ | ||
| if (len > 0 && (text[len - 1] == '\n')) | ||
| len -= 1; | ||
|
|
||
| memcpy(__get_str(msg), text, len); | ||
| __get_str(msg)[len] = 0; | ||
| ), | ||
|
|
||
| TP_printk("%s.%s %s", __entry->desc->modname, | ||
| __entry->desc->function, __get_str(msg)) | ||
| ); | ||
|
|
||
| #endif /* _TRACE_DYNDBG_H */ | ||
|
|
||
| /* This part must be outside protection */ | ||
| #include <trace/define_trace.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters