From patchwork Sat Oct 9 15:48:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 67324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 459BFB70A9 for ; Sun, 10 Oct 2010 02:49:51 +1100 (EST) Received: from localhost ([127.0.0.1]:55186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4bgC-0007DM-FX for incoming@patchwork.ozlabs.org; Sat, 09 Oct 2010 11:49:48 -0400 Received: from [140.186.70.92] (port=46974 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4bf6-0007CB-AO for qemu-devel@nongnu.org; Sat, 09 Oct 2010 11:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P4bf4-0006il-U6 for qemu-devel@nongnu.org; Sat, 09 Oct 2010 11:48:39 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:35965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P4bf4-0006ig-Qd for qemu-devel@nongnu.org; Sat, 09 Oct 2010 11:48:38 -0400 Received: by qyk8 with SMTP id 8so1108286qyk.4 for ; Sat, 09 Oct 2010 08:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=GYE2fwn2x3O3iwASdBuSrhR5B+bjY+xeM2gYmPv0cIg=; b=og3cox5KMe2/RS3M+a6ah2B5YBXJ2bUCfjv4GiLIFbYBQAzi/uKO6TY2z1pWThFWtg xV+llLKyoJlzAAaqQPcEX74v3/LdNnb3Jmvbl1v5R8neGUrxlUVtU/o7g67yGNyQnOch Hd0//3/5vSlp7HaivW24eQ0JE3Wlp3+xXuR58= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=C8zxau6nL3dKYnMk5RsreMaBekLs4xLtJK9vp2gzo1JLCu/MJd8qYvk/Wxqs4hWH4D +ZbfTqD/+oU6YeZ4qDoNMN1DEXVrJFBS9qEAldL46obNJBqqRxAeQnS1M5pxRk+GN0qg GIx/RjL+pAhc1dKTZizol0FHEC5ShFLCI5mSM= Received: by 10.224.209.6 with SMTP id ge6mr2714490qab.110.1286639318097; Sat, 09 Oct 2010 08:48:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.64.196 with HTTP; Sat, 9 Oct 2010 08:48:18 -0700 (PDT) From: Blue Swirl Date: Sat, 9 Oct 2010 15:48:18 +0000 Message-ID: To: Stefan Hajnoczi , qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Subject: [Qemu-devel] [PATCH] trace: print a warning if user tries to enable an unknown trace event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There was no warning if a bad trace event name was given to 'trace-event' command, thus the user could think that the command was successful even if this was not the case. Print a warning if the user tries to enable a trace event which is not known. Signed-off-by: Blue Swirl Acked-by: Stefan Hajnoczi --- monitor.c | 6 +++++- simpletrace.c | 4 +++- simpletrace.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) -void st_change_trace_event_state(const char *tname, bool tstate); +bool st_change_trace_event_state(const char *tname, bool tstate); void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)); void st_set_trace_file_enabled(bool enable); bool st_set_trace_file(const char *file); diff --git a/monitor.c b/monitor.c index fbb678d..260cc02 100644 --- a/monitor.c +++ b/monitor.c @@ -549,7 +549,11 @@ static void do_change_trace_event_state(Monitor *mon, const QDict *qdict) { const char *tp_name = qdict_get_str(qdict, "name"); bool new_state = qdict_get_bool(qdict, "option"); - st_change_trace_event_state(tp_name, new_state); + int ret = st_change_trace_event_state(tp_name, new_state); + + if (!ret) { + monitor_printf(mon, "unknown event name \"%s\"\n", tp_name); + } } static void do_trace_file(Monitor *mon, const QDict *qdict) diff --git a/simpletrace.c b/simpletrace.c index f849e42..deb1e07 100644 --- a/simpletrace.c +++ b/simpletrace.c @@ -246,12 +246,14 @@ static TraceEvent* find_trace_event_by_name(const char *tname) return NULL; /* indicates end of list reached without a match */ } -void st_change_trace_event_state(const char *tname, bool tstate) +bool st_change_trace_event_state(const char *tname, bool tstate) { TraceEvent *tp; tp = find_trace_event_by_name(tname); if (tp) { tp->state = tstate; + return true; } + return false; } diff --git a/simpletrace.h b/simpletrace.h index cf35897..72614ec 100644 --- a/simpletrace.h +++ b/simpletrace.h @@ -31,7 +31,7 @@ void trace5(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t void trace6(TraceEventID event, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, uint64_t x5, uint64_t x6); void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...)); void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...));