This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Collecting strings at tracepoints


By default, when you ask to collect a char * at a tracepoint, only the numeric address is collected, which is a problem if you really want the string that the char * is pointing to. This patch adds a /s option to the collect action that will dereference character pointers and collect the bytes up to the first zero, just as the familiar print command does. You can optionally add a limit to the collect, so for instance "collect/s80 mystring" collects a maximum of 80 characters.

While conceptually simple, we need a new agent bytecode to make this work (writing a loop using existing bytecodes doesn't let us check that we're running off the edge of valid memory), and a support flag so that users get informed if the target doesn't support string collection.

If you're having a sense of dejavu about all this :-) , there was a discussion of syntax last year, starting from http://sourceware.org/ml/gdb/2010-06/msg00018.html . I ended up following Michael Snyder's suggested syntax.

Stan
stan@codesourcery.com

2011-10-03 Stan Shebs <stan@codesourcery.com>

    String collection for tracepoints.
    * common/ax.def (tracenz): New bytecode.
    * ax-gdb.h (string_kludge): Declare.
    * ax-gdb.c: Include valprint.h and c-lang.h.
    (string_kludge): New global.
    (gen_traced_pop): Add string case.
    (agent_command): Add string case.
    * tracepoint.h (decode_agent_options): Declare.
    * tracepoint.c (decode_agent_options): New function.
    (validate_actionline): Call it.
    (encode_actions_1): Ditto.
    * target.h (struct target_ops): New method to_supports_string_tracing.
    (target_supports_string_tracing): New macro.
    * target.c (update_current_target): Add to_supports_string_tracing.
    * remote.c (struct remote_state): New field string_tracing.
    (remote_string_tracing_feature): New function.
    (remote_protocol_features): New feature tracenz.
    (remote_supports_string_tracing): New function.
    (init_remote_ops): Set to_supports_string_tracing.

    * tracepoint.c (agent_mem_read_string): New function.
    (eval_agent_expr): Call it for tracenz.
    * server.c (handle_query): Report support for tracenz.

    * gdb.texinfo (Tracepoint Action Lists): Document collect/s.
    * agentexpr.texi: Describe tracenz.

    * gdb.trace/collection.c: Add code using strings.
    * gdb.trace/collection.exp: Add tests of string collection.

Attachment: tstr-patch-1
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]