(2014/08/28 6:50), Hemant Kumar wrote:
[...]
+/*Hmm, this will show
+ * get_sdt_note_info(): flush the SDT notes onto stdout
+ */
+static void get_sdt_note_info(struct list_head *start, const char *target)
+{
+ struct sdt_note *pos;
+
+ if (list_empty(start))
+ return;
+
+ printf("%s :\n", target);
+ list_for_each_entry(pos, start, note_list) {
+ printf("%%%s : %s\n", pos->provider, pos->name);
%app : marker
instead of
%app:marker
(blanks are placed around ":")
I think it should be the latter format.
+ }Please use pr_err or pr_warning for error messages.
+}
+
+/*
+ * Error displayed in case of query of a
+ * single file for SDT markers
+ */
+static int sdt_err(int val, const char *target)
+{
+ switch (-val) {
+ case 0:
+ break;
+ case ENOENT:
+ /* Absence of SDT markers */
+ printf("%s : No SDT events found\n", target);
+ break;And strerror_r instead of strerror (see https://lkml.org/lkml/2014/8/13/828)
+ case EBADF:
+ printf("%s : Bad file name\n", target);
+ break;
+ default:
+ printf("%s\n", strerror(val));
+ }
+You don't need to check this. If the list is empty list_for_each...
+ return val;
+}
+
+/*
+ * cleanup_sdt_note_list() : Free the sdt note list
+ */
+static void cleanup_sdt_note_list(struct list_head *sdt_notes)
+{
+ struct sdt_note *tmp, *pos;
+
+ if (list_empty(sdt_notes))
+ return;
just skips loops.
+Thank you,
+ list_for_each_entry_safe(pos, tmp, sdt_notes, note_list) {
+ list_del(&pos->note_list);
+ free(pos->name);
+ free(pos->provider);
+ free(pos);
+ }
+}
+
+/*
+ * filename__find_sdt() : looks for sdt markers and the list is
+ * stored in sdt_notes
+ */
+static int filename__find_sdt(const char *target)
+{
+ int ret;
+
+ LIST_HEAD(sdt_notes);
+
+ ret = get_sdt_note_list(&sdt_notes, target);
+ if (!ret)
+ get_sdt_note_info(&sdt_notes, target);
+ else
+ sdt_err(ret, target);
+
+ cleanup_sdt_note_list(&sdt_notes);
+
+ return ret;
+}
+
+/*
+ * print_sdt_notes() : wrapper function
+ */
+void print_sdt_events(const char *arg)
+{
+ if (arg) {
+ filename__find_sdt(arg);
+ return;
+ }
+ pr_err("Error : File Name must be specified with \"sdt\" option!\n"
+ "Usage :\n perf list sdt <file-name>\n");
+
+ return;
+}