diff options
author | Hafiz Abid Qadeer <abidh@codesourcery.com> | 2013-03-08 15:06:39 +0000 |
---|---|---|
committer | Hafiz Abid Qadeer <abidh@codesourcery.com> | 2013-03-08 15:06:39 +0000 |
commit | f6f899bfc53faa15406ba58f491760ad07563c47 (patch) | |
tree | 87a405d8290d1bb8308653168ac151be81aedf7c /gdb/gdbserver | |
parent | 7da3ab792088f01bb2d2453e08ef7d5a4458982b (diff) | |
download | gdb-f6f899bfc53faa15406ba58f491760ad07563c47.zip gdb-f6f899bfc53faa15406ba58f491760ad07563c47.tar.gz gdb-f6f899bfc53faa15406ba58f491760ad07563c47.tar.bz2 |
2012-03-08 Stan Shebs <stan@codesourcery.com>
Hafiz Abid Qadeer <abidh@codesourcery.com>
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.
(QTBuffer:size) New remote command.
(PACKET_QTBuffer_size): New enum.
(remote_protocol_features): Add 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. Allocate
trace buffer memory.
(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): Add QTBuffer:size in the
supported packets.
gdb/doc/
* gdb.texinfo (Starting and Stopping Trace Experiments): Document
trace-buffer-size set and show commands.
(Tracepoint Packets): Document QTBuffer:size.
(General Query Packets): Document QTBuffer:size.
gdb/testsuite/
* gdb.trace/trace-buffer-size.exp: New file.
* gdb.trace/trace-buffer-size.c: New file.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 1 | ||||
-rw-r--r-- | gdb/gdbserver/tracepoint.c | 56 |
3 files changed, 66 insertions, 6 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 5e92b7b..8545c6a 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,18 @@ +2012-03-08 Stan Shebs <stan@codesourcery.com> + Hafiz Abid Qadeer <abidh@codesourcery.com> + + * tracepoint.c (trace_buffer_size): New global. + (DEFAULT_TRACE_BUFFER_SIZE): New define. + (init_trace_buffer): Change to one-argument function. Allocate + trace buffer memory. + (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): Add QTBuffer:size in the + supported packets. + 2013-03-07 Yao Qi <yao@codesourcery.com> * tracepoint.c (cur_action, cur_step_action): Make them unsigned. 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+"); } diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 632ee14..dcc2e78 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -30,6 +30,8 @@ #include "ax.h" +#define DEFAULT_TRACE_BUFFER_SIZE 5242880 /* 5*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,10 @@ int current_traceframe = -1; static int circular_trace_buffer; #endif +/* Size of the trace buffer. */ + +static LONGEST trace_buffer_size; + /* Pointer to the block of memory that traceframes all go into. */ static unsigned char *trace_buffer_lo; @@ -1478,9 +1484,13 @@ clear_inferior_trace_buffer (void) #endif static void -init_trace_buffer (unsigned char *buf, int bufsize) +init_trace_buffer (LONGEST bufsize) { - trace_buffer_lo = buf; + trace_buffer_size = bufsize; + + /* If we already have a trace buffer, try realloc'ing. */ + trace_buffer_lo = xrealloc (trace_buffer_lo, bufsize); + trace_buffer_hi = trace_buffer_lo + bufsize; clear_trace_buffer (); @@ -4020,6 +4030,37 @@ cmd_bigqtbuffer_circular (char *own_buf) } static void +cmd_bigqtbuffer_size (char *own_buf) +{ + ULONGEST val; + LONGEST sval; + char *packet = own_buf; + + /* Can't change the size during a tracing run. */ + if (tracing) + { + write_enn (own_buf); + return; + } + + packet += strlen ("QTBuffer:size:"); + + /* -1 is sent as literal "-1". */ + if (strcmp (packet, "-1") == 0) + sval = DEFAULT_TRACE_BUFFER_SIZE; + else + { + unpack_varlen_hex (packet, &val); + sval = (LONGEST) val; + } + + 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 +4184,11 @@ handle_tracepoint_general_set (char *packet) cmd_bigqtbuffer_circular (packet); return 1; } + else if (strncmp ("QTBuffer:size:", packet, strlen ("QTBuffer:size:")) == 0) + { + cmd_bigqtbuffer_size (packet); + return 1; + } else if (strncmp ("QTNotes:", packet, strlen ("QTNotes:")) == 0) { cmd_qtnotes (packet); @@ -7228,10 +7274,8 @@ get_timestamp (void) void initialize_tracepoint (void) { - /* There currently no way to change the buffer size. */ - const int sizeOfBuffer = 5 * 1024 * 1024; - unsigned char *buf = xmalloc (sizeOfBuffer); - init_trace_buffer (buf, sizeOfBuffer); + /* Start with the default size. */ + init_trace_buffer (DEFAULT_TRACE_BUFFER_SIZE); /* Wire trace state variable 1 to be the timestamp. This will be uploaded to GDB upon connection and become one of its trace state |