From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2373 invoked by alias); 4 Mar 2013 19:03:35 -0000 Received: (qmail 2357 invoked by uid 22791); 4 Mar 2013 19:03:33 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_QT,TW_XS X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Mar 2013 19:02:57 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UCaf1-0003te-Gi from Hafiz_Abid@mentor.com ; Mon, 04 Mar 2013 11:02:55 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 4 Mar 2013 11:02:55 -0800 Received: from abidh-ubunto1104 (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.1.289.1; Mon, 4 Mar 2013 19:02:53 +0000 Date: Mon, 04 Mar 2013 19:03:00 -0000 From: "Abid, Hafiz" Subject: Re: [patch] Change trace buffer size(v3) To: Pedro Alves CC: , , , In-Reply-To: <51310936.40406@redhat.com> (from palves@redhat.com on Fri Mar 1 20:01:58 2013) Message-ID: <1362423773.18746.0@abidh-ubunto1104> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-09R3RLywOd4Q3WJOOryo" 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: 2013-03/txt/msg00126.txt.bz2 --=-09R3RLywOd4Q3WJOOryo Content-Type: text/plain; charset="us-ascii"; delsp=Yes; format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 6999 Hi Pedro, Thanks for review. Here is an updated patch which tries to addresses=20=20 your comments. On 01/03/13 20:01:58, Pedro Alves wrote: > but, OTOH, new packets should really be using packet_ok. > I think you missed this note. Fixed. >=20 > Good idea. >=20 > I think it'd be even better to run the test twice, once with > a larger buffer that fits the same trace frames, and make sure > the buffer doesn't end up full, and then another time with the > small buffer. That'd cover the case of the target's buffer being > small by default, and the buffer size packet failing to work. Done. >=20 > Please model from previous examples: >=20 > * New remote packets > ... > QTBuffer:circular > Set the trace buffer to be linear or circular. Done. >=20 > > +@item QTBuffer:size:@var{size} > > +This packet directs the target to make the trace buffer be of size > > +@var{size} if possible. A value of @code{-1} tells the target to > > +use whatever size it likes. >=20 > Double space after period. I think "prefers" is more natural in the > manual. Fixed. >=20 > > + /* If we don't care about the size, or the size is unchanged, > > + all is happy and nothing to do. */ >=20 > s/all is happy and/there's/ Fixed. >=20 > > + /* Right now we can't change the size during a tracing run. */ >=20 > Let's drop distracting speculation: > s/Right now we can't/Can't/ Fixed. >=20 > > + if (tracing) > > + { > > + write_enn (own_buf); > > + return; > > + } >=20 > Better do this check before anything else, avoid > unnecessary special cases. Moved to start of function. >=20 > Also, if sval is < 0, this is not checking for "tracing" (fixed > by doing the check earlier), but also, >=20 > > + init_trace_buffer (sval); >=20 > ... nor does init_trace_buffer have any logic to > set the trace buffer size to whatever the "target likes": I have now added a default size. On -1, that deafult size is used. >=20 > static void > -init_trace_buffer (unsigned char *buf, int bufsize) > +init_trace_buffer (LONGEST bufsize) > { > - trace_buffer_lo =3D buf; > + trace_buffer_size =3D bufsize; > + > + /* If we already have a trace buffer, try realloc'ing. */ > + trace_buffer_lo =3D xrealloc (trace_buffer_lo, bufsize); > + > trace_buffer_hi =3D trace_buffer_lo + bufsize; >=20 > clear_trace_buffer (); >=20 >=20 > Please make sure to test that at least manually, though > it'd be better if the testsuite also exercised this. I tested this manualy by running trace experiment to fill the trace=20=20 buffer. Then changed the size to a larger value and run trace again. It worked=20=20 ok. >=20 >=20 > > +static void > > +remote_set_trace_buffer_size (LONGEST val) > > +{ > > + struct remote_state *rs =3D get_remote_state (); > > + char *reply; > > + char *buf =3D rs->buf; > > + char *endbuf =3D rs->buf + get_remote_packet_size (); > > + > > + buf +=3D xsnprintf (buf, endbuf - buf, "QTBuffer:size:"); > > + /* Send -1 as literal "-1" to avoid host size dependency. */ > > + if (val =3D=3D -1) > > + buf +=3D xsnprintf (buf, endbuf - buf, "-1"); > > + else > > + buf +=3D hexnumstr (buf, (ULONGEST) val); >=20 > This would mishandle other negative numbers (though > something else should be preventing those. > var_zuinteger_unlimited would be one way, though it'd > probably be a good idea to check for val<0 && val !=3D -1 here too. Added check for val<0 && val !=3D -1. >=20 > FYI, there's no need to special case -1 actually: >=20 > if (val < 0) > buf +=3D hexnumstr (buf, (ULONGEST) -val); > else > buf +=3D hexnumstr (buf, (ULONGEST) val); I did not clearly understand how it works. Because -val will end up=20=20 sending 1. So I kept the literal -1 as you suggested in previous email. Although I modified the=20=20 check from =3D=3D -1 to < 0. >=20 >=20 > > + > > + putpkt (rs->buf); > > + reply =3D remote_get_noisy_reply (&rs->buf, &rs->buf_size); > > + if (*rs->buf =3D=3D '\0') >=20 > Did you try packet_ok? Really new commands/packets should be > using it. I have used packet_ok and related machinery so that gdbserver informs=20=20 about the support of QTBuffer:size packet now. >=20 > > +set BUFFER_SIZE 4 > > +gdb_test_no_output "set trace-buffer-size $BUFFER_SIZE" "Set Trace=20= =20 > Buffer Size" > > +gdb_test "show trace-buffer-size $BUFFER_SIZE" "Requested size of=20=20 > trace buffer is $BUFFER_SIZE.*" \ > > +"Show Trace Buffer Size" >=20 > I think this overflows 80 columns. Since you're breaking the line,=20=20 > could > you break it so it doesn't overflow 80 columns, please? Fixed > > + > > +# We set trace buffer to very small size. Then after running=20=20 > trace, we check > > +# if it is full. This will show if setting trace buffer size=20=20 > really worked. >=20 > Double space after period. Fixed >=20 > > +gdb_test "tstart" ".*" "" >=20 > gdb_test_no_output "tstart" Done >=20 > > +gdb_test "continue" ".*" "" > Better to match something rather than ".*". > Look for "run trace experiment" on other tests. Fixed. >=20 > > +gdb_test "tstatus" ".*Trace stopped because the buffer was=20=20 > full.*" \ > > +"Buffer full check" >=20 > Column overflow again, I think. Fixed. >=20 > gdb_test_test_no_output. Removed this command as it was not really needed. >=20 >=20 > As I mentioned elsewhere, I think it'd be better to use the > new var_zuinteger_unlimited. Done. >=20 > We should really fix the broken -1 handling too, before 7.6. >=20 How do you suggest we do that? Regards, Abid 2012-03-04 Stan Shebs Hafiz Abid Qadeer gdb/ * NEWS: Mention set and show trace-buffer-size commands. Mention new packet. * target.h (struct target_ops): New method to_set_trace_buffer_size. (target_set_trace_buffer_size): New macro. * target.c (update_current_target): Set up new method. * tracepoint.c (trace_buffer_size): New global. (start_tracing): Send it to the target. (set_trace_buffer_size): New function. (_initialize_tracepoint): Add new setshow for trace-buffer-size. * remote.c (remote_set_trace_buffer_size): New function. (_initialize_remote): Use it. (PACKET_QTBuffer_size): New enum. (remote_protocol_features): Added an entry for PACKET_QTBuffer_size. gdb/gdbserver/ * tracepoint.c (trace_buffer_size): New global. (DEFAULT_TRACE_BUFFER_SIZE): New define. (init_trace_buffer): Change to one-argument function, add realloc option. (handle_tracepoint_general_set): Call cmd_bigqtbuffer_size to handle QTBuffer:size packet. (cmd_bigqtbuffer_size): New function. (initialize_tracepoint): Call init_trace_buffer with DEFAULT_TRACE_BUFFER_SIZE. * server.c (handle_query): Added QTBuffer:size in the supported packets. gdb/doc/ * gdb.texinfo (Starting and Stopping Trace Experiments):=20=20 Document trace-buffer-size set and show commands. (Tracepoint Packets): Document QTBuffer:size . gdb/testsuite/ * gdb.trace/trace-buffer-size.exp: New file. * gdb.trace/trace-buffer-size.c: New file. --=-09R3RLywOd4Q3WJOOryo Content-Type: text/x-patch; charset="us-ascii"; name="trace-buffer-size_v3.patch" Content-Disposition: attachment; filename="trace-buffer-size_v3.patch" Content-Transfer-Encoding: quoted-printable Content-length: 16565 diff --git a/gdb/NEWS b/gdb/NEWS index 0877aa2..3fb68eb 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -104,6 +104,10 @@ set debug notification show debug notification Control display of debugging info for async remote notification. =20 +set trace-buffer-size +show trace-buffer-size + Request target to change the size of trace buffer. + * Removed commands =20 ** For the Renesas Super-H architecture, the "regs" command has been rem= oved @@ -159,6 +163,11 @@ show filename-display feature to be enabled. For more information, see: http://fedoraproject.org/wiki/Features/MiniDebugInfo =20 +* New remote packets + +QTBuffer:size + Set the size of trace buffer. + *** Changes in GDB 7.5 =20 * GDB now supports x32 ABI. Visit diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5f39d2e..99745f1 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -11728,6 +11728,25 @@ for instance if you are looking at frames from a t= race file. @end table =20 @table @code +@item set trace-buffer-size @var{n} +@kindex set trace-buffer-size +Request that the target use a trace buffer of @var{n} bytes. Not all +targets will honor the request; they may have a compiled-in size for +the trace buffer, or some other limitation. Set to a value of +@code{-1} to let the target use whatever size it likes. This is also +the default. + +@item show trace-buffer-size +@kindex show trace-buffer-size +Show the current requested size for the trace buffer. Note that this +will only match the actual size if the target supports size-setting, +and was able to handle the requested size. For instance, if the +target can only change buffer size between runs, this variable will +not reflect the change until the next run starts. Use @code{tstatus} +to get a report of the actual buffer size. +@end table + +@table @code @item set trace-user @var{text} @kindex set trace-user =20 @@ -38450,6 +38469,11 @@ available. This packet directs the target to use a circular trace buffer if @var{value} is 1, or a linear buffer if the value is 0. =20 +@item QTBuffer:size:@var{size} +This packet directs the target to make the trace buffer be of size +@var{size} if possible. A value of @code{-1} tells the target to +use whatever size it prefers. + @item QTNotes:@r{[}@var{type}:@var{text}@r{]}@r{[};@var{type}:@var{text}@r= {]}@dots{} @cindex @samp{QTNotes} packet This packet adds optional textual notes to the trace run. Allowable diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 768eae7..922a5bf 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1637,6 +1637,7 @@ handle_query (char *own_buf, int packet_len, int *new= _packet_len_p) strcat (own_buf, ";qXfer:statictrace:read+"); strcat (own_buf, ";qXfer:traceframe-info:read+"); strcat (own_buf, ";EnableDisableTracepoints+"); + strcat (own_buf, ";QTBuffer:size+"); strcat (own_buf, ";tracenz+"); } =20 diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 0f83ae6..61d09c0 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -30,6 +30,8 @@ =20 #include "ax.h" =20 +#define DEFAULT_TRACE_BUFFER_SIZE 1048576 /* 1024*1024 */ + /* This file is built for both GDBserver, and the in-process agent (IPA), a shared library that includes a tracing agent that is loaded by the inferior to support fast tracepoints. Fast @@ -992,6 +994,8 @@ int current_traceframe =3D -1; static int circular_trace_buffer; #endif =20 +static LONGEST trace_buffer_size; + /* Pointer to the block of memory that traceframes all go into. */ =20 static unsigned char *trace_buffer_lo; @@ -1478,9 +1482,13 @@ clear_inferior_trace_buffer (void) #endif =20 static void -init_trace_buffer (unsigned char *buf, int bufsize) +init_trace_buffer (LONGEST bufsize) { - trace_buffer_lo =3D buf; + trace_buffer_size =3D bufsize; + + /* If we already have a trace buffer, try realloc'ing. */ + trace_buffer_lo =3D xrealloc (trace_buffer_lo, bufsize); + trace_buffer_hi =3D trace_buffer_lo + bufsize; =20 clear_trace_buffer (); @@ -4020,6 +4028,43 @@ cmd_bigqtbuffer_circular (char *own_buf) } =20 static void +cmd_bigqtbuffer_size (char *own_buf) +{ + ULONGEST val; + LONGEST sval; + char *packet =3D own_buf; + + /* Can't change the size during a tracing run. */ + if (tracing) + { + write_enn (own_buf); + return; + } + + packet +=3D strlen ("QTBuffer:size:"); + + /* -1 is sent as literal "-1". */ + if (strcmp (packet, "-1") =3D=3D 0) + sval =3D DEFAULT_TRACE_BUFFER_SIZE; + else + { + unpack_varlen_hex (packet, &val); + sval =3D (LONGEST)val; + } + /* If the size is unchanged, there's nothing to do. */ + if (sval =3D=3D trace_buffer_size) + { + write_ok (own_buf); + return; + } + + init_trace_buffer (sval); + trace_debug ("Trace buffer is now %s bytes", + plongest (trace_buffer_size)); + write_ok (own_buf); +} + +static void cmd_qtnotes (char *own_buf) { size_t nbytes; @@ -4143,6 +4188,11 @@ handle_tracepoint_general_set (char *packet) cmd_bigqtbuffer_circular (packet); return 1; } + else if (strncmp ("QTBuffer:size:", packet, strlen ("QTBuffer:size:")) = =3D=3D 0) + { + cmd_bigqtbuffer_size (packet); + return 1; + } else if (strncmp ("QTNotes:", packet, strlen ("QTNotes:")) =3D=3D 0) { cmd_qtnotes (packet); @@ -7228,10 +7278,8 @@ get_timestamp (void) void initialize_tracepoint (void) { - /* There currently no way to change the buffer size. */ - const int sizeOfBuffer =3D 5 * 1024 * 1024; - unsigned char *buf =3D xmalloc (sizeOfBuffer); - init_trace_buffer (buf, sizeOfBuffer); + /* Start with the default size. */ + init_trace_buffer (DEFAULT_TRACE_BUFFER_SIZE); =20 /* Wire trace state variable 1 to be the timestamp. This will be uploaded to GDB upon connection and become one of its trace state diff --git a/gdb/remote.c b/gdb/remote.c index 88a57c8..6e9a59b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1284,6 +1284,7 @@ enum { PACKET_qXfer_fdpic, PACKET_QDisableRandomization, PACKET_QAgent, + PACKET_QTBuffer_size, PACKET_MAX }; =20 @@ -3993,6 +3994,8 @@ static struct protocol_feature remote_protocol_featur= es[] =3D { { "QDisableRandomization", PACKET_DISABLE, remote_supported_packet, PACKET_QDisableRandomization }, { "QAgent", PACKET_DISABLE, remote_supported_packet, PACKET_QAgent}, + { "QTBuffer:size", PACKET_DISABLE, + remote_supported_packet, PACKET_QTBuffer_size}, { "tracenz", PACKET_DISABLE, remote_string_tracing_feature, -1 }, }; @@ -11042,6 +11045,41 @@ remote_get_min_fast_tracepoint_insn_len (void) } } =20 +static void +remote_set_trace_buffer_size (LONGEST val) +{ + if (remote_protocol_packets[PACKET_QTBuffer_size].support !=3D + PACKET_DISABLE) + { + struct remote_state *rs =3D get_remote_state (); + char *buf =3D rs->buf; + char *endbuf =3D rs->buf + get_remote_packet_size (); + enum packet_result result; + + if (val < 0 && val !=3D -1) + { + warning (_("Invalid value %s for the size of trace buffer."), + plongest (val) ); + return; + } + + buf +=3D xsnprintf (buf, endbuf - buf, "QTBuffer:size:"); + /* Send -1 as literal "-1" to avoid host size dependency. */ + if (val < 0) + buf +=3D xsnprintf (buf, endbuf - buf, "-1"); + else + buf +=3D hexnumstr (buf, (ULONGEST) val); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + result =3D packet_ok (rs->buf, + &remote_protocol_packets[PACKET_QTBuffer_size]); + + if (result !=3D PACKET_OK) + warning (_("Bogus reply from target: %s"), rs->buf); + } +} + static int remote_set_trace_notes (char *user, char *notes, char *stop_notes) { @@ -11219,6 +11257,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_get_min_fast_tracepoint_insn_len =3D remote_get_min_fast_t= racepoint_insn_len; remote_ops.to_set_disconnected_tracing =3D remote_set_disconnected_traci= ng; remote_ops.to_set_circular_trace_buffer =3D remote_set_circular_trace_bu= ffer; + remote_ops.to_set_trace_buffer_size =3D remote_set_trace_buffer_size; remote_ops.to_set_trace_notes =3D remote_set_trace_notes; remote_ops.to_core_of_thread =3D remote_core_of_thread; remote_ops.to_verify_memory =3D remote_verify_memory; @@ -11755,6 +11794,9 @@ Show the maximum size of the address (in bits) in a= memory packet."), NULL, add_packet_config_cmd (&remote_protocol_packets[PACKET_QAgent], "QAgent", "agent", 0); =20 + add_packet_config_cmd (&remote_protocol_packets[PACKET_QTBuffer_size], + "QTBuffer:size", "trace-buffer-size", 0); + /* Keep the old ``set remote Z-packet ...'' working. Each individual Z sub-packet has its own set and show commands, but users may have sets to this variable in their .gdbinit files (or in their diff --git a/gdb/target.c b/gdb/target.c index 9d8bf6e..2e507e0 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -693,6 +693,7 @@ update_current_target (void) INHERIT (to_get_min_fast_tracepoint_insn_len, t); INHERIT (to_set_disconnected_tracing, t); INHERIT (to_set_circular_trace_buffer, t); + INHERIT (to_set_trace_buffer_size, t); INHERIT (to_set_trace_notes, t); INHERIT (to_get_tib_address, t); INHERIT (to_set_permissions, t); @@ -912,6 +913,9 @@ update_current_target (void) de_fault (to_set_circular_trace_buffer, (void (*) (int)) target_ignore); + de_fault (to_set_trace_buffer_size, + (void (*) (LONGEST)) + target_ignore); de_fault (to_set_trace_notes, (int (*) (char *, char *, char *)) return_zero); diff --git a/gdb/target.h b/gdb/target.h index 1971265..c99642d 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -806,6 +806,8 @@ struct target_ops disconnection - set VAL to 1 to keep tracing, 0 to stop. */ void (*to_set_disconnected_tracing) (int val); void (*to_set_circular_trace_buffer) (int val); + /* Set the size of trace buffer in the target. */ + void (*to_set_trace_buffer_size) (LONGEST val); =20 /* Add/change textual notes about the trace run, returning 1 if successful, 0 otherwise. */ @@ -1700,6 +1702,9 @@ extern char *target_fileio_read_stralloc (const char = *filename); #define target_set_circular_trace_buffer(val) \ (*current_target.to_set_circular_trace_buffer) (val) =20 +#define target_set_trace_buffer_size(val) \ + (*current_target.to_set_trace_buffer_size) (val) + #define target_set_trace_notes(user,notes,stopnotes) \ (*current_target.to_set_trace_notes) ((user), (notes), (stopnotes)) =20 diff --git a/gdb/testsuite/gdb.trace/trace-buffer-size.c b/gdb/testsuite/gd= b.trace/trace-buffer-size.c new file mode 100644 index 0000000..e32b756 --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-buffer-size.c @@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011-2013 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . = */ + +int var =3D 10; + +int +test_function () +{ + return 0; +} + +int +main () +{ + test_function ();=20 + return 0; /*breakpoint1*/ +} diff --git a/gdb/testsuite/gdb.trace/trace-buffer-size.exp b/gdb/testsuite/= gdb.trace/trace-buffer-size.exp new file mode 100644 index 0000000..7891cc6 --- /dev/null +++ b/gdb/testsuite/gdb.trace/trace-buffer-size.exp @@ -0,0 +1,79 @@ +# Copyright 1998-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "trace-support.exp" + +standard_testfile + +if [prepare_for_testing ${testfile}.exp $testfile $srcfile \ + {debug nowarnings}] { + untested "failed to prepare for trace tests" + return -1 +} + +if ![runto_main] { + fail "can't run to main to check for trace support" + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1; +} + +set BUFFER_SIZE 4 +gdb_test_no_output \ +"set trace-buffer-size $BUFFER_SIZE" \ +"Set Trace Buffer Size" + +gdb_test "show trace-buffer-size $BUFFER_SIZE" \ +"Requested size of trace buffer is $BUFFER_SIZE.*" \ +"Show Trace Buffer Size" + +# We set trace buffer to very small size. Then after running trace, +# we check if it is full. This will show if setting trace buffer +# size really worked. +gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"] +gdb_test "trace test_function" \ + "Tracepoint \[0-9\]+ at .*" \ + "set tracepoint at test_function" +gdb_trace_setactions "Set action for trace point 1" "" \ + "collect var" "^$" +gdb_test_no_output "tstart"=20 +gdb_test "continue" \ + "Continuing.*Breakpoint $decimal.*" \ + "run trace experiment 1" +gdb_test "tstatus" \ + ".*Trace stopped because the buffer was full.*" \ + "Buffer full check 1" + +# Use the default size and trace buffer should not be +# full this time. +clean_restart ${testfile} +runto_main +gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"] +gdb_test "trace test_function" \ + "Tracepoint \[0-9\]+ at .*" \ + "set tracepoint at test_function" +gdb_trace_setactions "Set action for trace point 2" "" \ + "collect var" "^$" +gdb_test_no_output "tstart"=20 +gdb_test "continue" \ + "Continuing.*Breakpoint $decimal.*" \ + "run trace experiment 2" +gdb_test "tstatus" \ + ".*Trace is running on the target.*" \ + "Buffer full check 2" +gdb_test_no_output "tstop" diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 9a80aa3..b8945bb 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -173,6 +173,11 @@ static int disconnected_tracing; =20 static int circular_trace_buffer; =20 +/* This variable is the requested trace buffer size, or -1 to indicate + that we don't care and leave it up to the target to set a size. */ + +static int trace_buffer_size =3D -1; + /* Textual notes applying to the current and/or future trace runs. */ =20 char *trace_user =3D NULL; @@ -1829,6 +1834,7 @@ start_tracing (char *notes) /* Set some mode flags. */ target_set_disconnected_tracing (disconnected_tracing); target_set_circular_trace_buffer (circular_trace_buffer); + target_set_trace_buffer_size (trace_buffer_size); =20 if (!notes) notes =3D trace_notes; @@ -3231,6 +3237,13 @@ set_circular_trace_buffer (char *args, int from_tty, } =20 static void +set_trace_buffer_size (char *args, int from_tty, + struct cmd_list_element *c) +{ + target_set_trace_buffer_size (trace_buffer_size); +} + +static void set_trace_user (char *args, int from_tty, struct cmd_list_element *c) { @@ -5416,6 +5429,16 @@ up and stopping the trace run."), &setlist, &showlist); =20 + add_setshow_zuinteger_unlimited_cmd ("trace-buffer-size", no_class, + &trace_buffer_size, _("\ +Set requested size of trace buffer."), _("\ +Show requested size of trace buffer."), _("\ +Use this to choose a size for the trace buffer. Some targets\n\ +may have fixed or limited buffer sizes. A value of -1 disables\n\ +any attempt to set the buffer size and lets the target choose."), + set_trace_buffer_size, NULL, + &setlist, &showlist); + add_setshow_string_cmd ("trace-user", class_trace, &trace_user, _("\ Set the user name to use for current and future trace runs"), _("\ --=-09R3RLywOd4Q3WJOOryo--