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 v2] dynamic printf


Here is a revised patch for the dynamic printf originally posted in http://sourceware.org/ml/gdb-patches/2012-02/msg00689.html .

This patch does not include the agent version of dprintf, which I plan to add later as an additional dprintf style. For the "call" style, there are
now user-settable dprintf-function and dprintf-channel (aka first argument to fprintf-type functions).


The patch is messified by having to add an extra_string argument to many breakpoint functions; it would still make sense to encapsulate 4-5 args in a parse-results struct, but I didn't want to get bogged down in that just yet.

Joel previously noted a problem with the "continue" in the command list, which is that stepping/nexting over a dprintf becomes a continue instead (this is a problem for general breakpoint command lists as well). I tinkered with bpstats a bit, but didn't come up with a good solution. One possibility might be a new pseudo-command for breakpoint command lists, that resumes the program using the same proceed() arguments as the command that caused the breakpoint hit.

If people are satisfied with the general form of this, I'll push it in so it can get some tryout before 7.5 and then work on the agent version.

Stan

2012-05-07 Stan Shebs <stan@codesourcery.com>

    Add dynamic printf.
    * breakpoint.h (enum bptype): New type bp_dprintf.
    (struct breakpoint): New field extra_string.
    (struct breakpoint_ops): Add arg to create_breakpoints_sal.
    (create_breakpoint): Add extra_string arg.
    * breakpoint.c (dprintf_breakpoint_ops): New.
    (is_breakpoint): Add bp_dprintf.
    (bpstat_what): Add dprintf case.
    (bptype_string): Ditto.
    (print_one_breakpoint_location): Ditto.
    (init_bp_location): Ditto.
    (bkpt_print_mention): Ditto.
    (dprintf_style_enums): New array.
    (dprintf_style): New global.
    (dprintf_function): New global.
    (dprintf_channel): New global.
    (update_dprintf_command_list): New function.
    (update_dprintf_commands): New function.
    (init_breakpoint_sal): Add extra_string argument, handle it.
    (create_breakpoint_sal): Add extra_string argument.
    (create_breakpoints_sal): Add extra_string argument, update callers.
    (find_condition_and_thread): Add extra argument.
    (create_breakpoint): Add extra_string argument, record it.
    (dprintf_command): New function.
    (break_command_1): Add arg to create_breakpoint call.
    (handle_gnu_v3_exceptions): Ditto.
    (trace_command): Ditto.
    (ftrace_command): Ditto.
    (strace_command): Ditto.
    (bkpt_print_mention): Add dprintf case.
    (create_breakpoint_sal_default): Add extra_string argument.
    (_initialize_breakpoint): Add new commands.
    * mi/mi-cmd-break.c (mi_cmd_break_insert): Add arg to call.
    * python/py-breakpoint.c (bppy_init): Ditto.
    * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto.

* gdb.texinfo (Dynamic Printf): New subsection.

    * gdb.base/dprintf.c: New file.
    * gdb.base/dprintf.exp: New file.

Attachment: dprintf-patch-2
Description: Text document


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