From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8791 invoked by alias); 26 Mar 2010 14:17:40 -0000 Received: (qmail 8781 invoked by uid 22791); 26 Mar 2010 14:17:39 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Mar 2010 14:17:34 +0000 Received: (qmail 31662 invoked from network); 26 Mar 2010 14:17:32 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Mar 2010 14:17:32 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [PATCH/commit] Handle errors in tracepoint target agent Date: Fri, 26 Mar 2010 14:17:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-20-generic; KDE/4.3.2; x86_64; ; ) Cc: Stan Shebs References: <4BAC1426.5050003@codesourcery.com> <4BACAB4A.2060005@codesourcery.com> <201003261338.36658.pedro@codesourcery.com> In-Reply-To: <201003261338.36658.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201003261417.31048.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00886.txt.bz2 On Friday 26 March 2010 13:38:36, Pedro Alves wrote: > On Friday 26 March 2010 12:40:42, Stan Shebs wrote: > > > My interest in the subject is now totally exhausted, > > we'll just do the hex strings here. > > Thanks. I've applied the patch below. I'm applying this one too. I didn't notice these, because I ran the tests against gdbserver, and tfile.exp is skipped if nofileio is set. -- Pedro Alves 2010-03-26 Pedro Alves gdb/ * tracepoint.c (trace_save): Remove X from tracepoint error description. gdb/testsuite/ * gdb.trace/tfile.c (tohex, bin2hex): New. (write_error_trace_file): Hexify error description. --- gdb/testsuite/gdb.trace/tfile.c | 35 +++++++++++++++++++++++++++++++++-- gdb/tracepoint.c | 3 +-- 2 files changed, 34 insertions(+), 4 deletions(-) Index: src/gdb/tracepoint.c =================================================================== --- src.orig/gdb/tracepoint.c 2010-03-26 13:59:21.000000000 +0000 +++ src/gdb/tracepoint.c 2010-03-26 14:01:16.000000000 +0000 @@ -2484,12 +2484,11 @@ trace_save (const char *filename, int ta /* Write out status of the tracing run (aka "tstatus" info). */ fprintf (fp, "status %c;%s", (ts->running ? '1' : '0'), stop_reason_names[ts->stop_reason]); - /* Encode the error message in hex, might have weird chars. */ if (ts->stop_reason == tracepoint_error) { char *buf = (char *) alloca (strlen (ts->error_desc) * 2 + 1); bin2hex ((gdb_byte *) ts->error_desc, buf, 0); - fprintf (fp, ":X%s", buf); + fprintf (fp, ":%s", buf); } fprintf (fp, ":%x", ts->stopping_tracepoint); if (ts->traceframe_count >= 0) Index: src/gdb/testsuite/gdb.trace/tfile.c =================================================================== --- src.orig/gdb/testsuite/gdb.trace/tfile.c 2010-03-26 14:04:23.000000000 +0000 +++ src/gdb/testsuite/gdb.trace/tfile.c 2010-03-26 14:10:28.000000000 +0000 @@ -105,10 +105,38 @@ write_basic_trace_file (void) finish_trace_file (fd); } +/* Convert number NIB to a hex digit. */ + +static int +tohex (int nib) +{ + if (nib < 10) + return '0' + nib; + else + return 'a' + nib - 10; +} + +int +bin2hex (const char *bin, char *hex, int count) +{ + int i; + + for (i = 0; i < count; i++) + { + *hex++ = tohex ((*bin >> 4) & 0xf); + *hex++ = tohex (*bin++ & 0xf); + } + *hex = 0; + return i; +} + void write_error_trace_file (void) { int fd; + const char made_up[] = "made-up error"; + int len = sizeof (made_up) - 1; + char *hex = alloca (len * 2 + 1); fd = start_trace_file ("error.tf"); @@ -120,11 +148,14 @@ write_error_trace_file (void) snprintf (spbuf, sizeof spbuf, "R %x\n", 500 /* FIXME get from arch */); write (fd, spbuf, strlen (spbuf)); + bin2hex (made_up, hex, len); + /* Dump trace status, in the general form of the qTstatus reply. */ snprintf (spbuf, sizeof spbuf, "status 0;" - "terror:made-up error:1;" - "tframes:0;tcreated:0;tfree:100;tsize:1000\n"); + "terror:%s:1;" + "tframes:0;tcreated:0;tfree:100;tsize:1000\n", + hex); write (fd, spbuf, strlen (spbuf)); /* Dump tracepoint definitions, in syntax similar to that used