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]

Re: [RFA] "constify" parse_exp_1


On 03/08/2013 06:53 AM, Tom Tromey wrote:
"Keith" == Keith Seitz <keiths@redhat.com> writes:
There is a deletable strdup in gdbpy_parse_and_eval.
I don't know if there are others in the tree.
I think you need to look at the indirect callers of parse_exp_1.

Ok, that strdup, while not necessary, is not yet ready to be removed until parse_and_eval is const, which I did not do. I thought that might be a much more involved patch, and planned to do that separately.


It turns out to be pretty simple, actually, so I'll include that in my next revision (see my reply to Pedro).

Analyzing the call graph (by hand!?), I found one other place that allocates a copy: mi_interpreter_exec. AFAICT, it is not needed. I will submit a patch for that separately.

I'm including a list of the callgraphs I investigated. Each '-' refers to a caller, e.g.:

- a
-- b
-- c
--- d

d calls c which calls a; b calls a. Anything marked with "X"s indicates that an alloc appears to have been made explicitly to workaround const-correctness. There are only two that I found (gdbpy_parse_and_eval and mi_interpreter_exec).

    parse_exp_1:
    - parse_expression (parse.c)
    -- execute_control_command (cli-script.c)
    -- info_mach_region_command (darwin-nat-info.c)
    -- parse_and_eval_address
    --- ada_unhandled_exception_name_addr (ada-lang.c)
    --- ada_unhandled_exception_name_addr_from_raise
    --- ada_exception_name_addr_1
    --- bsd_kvm_proc_cmd (bsd-kvm.c)
    --- bsd_kvm_pcb_cmd
    --- disassemble_command (cli-cmds.c)
    --- dump_memory_to_file (cli-dump.c)
    --- restore_command
    --- set_section_command
    --- set_task_exc_port_cmd (gnu-nat.c)
    --- set_thread_exc_port_cmd
    --- go32_pte_for_address (go32-nat.c)
    --- unwind_command (hppa-tdep.c)
    --- maintenance_translate_address (maint.c)
    --- mem_command (memattr.c)
    --- mi_cmd_disassemble (mi-cmd-disas.c)
    --- mi_cmd_data_write_register_values (mi-main.c)
    --- mi_cmd_data_read_memory
    --- mi_cmd_data_read_memory_bytes
    --- mi_cmd_data_write_memory
    --- mi_cmd_data_write_memory_bytes
    --- mi_cmd_trace_find
    --- sym_info (printcmd.c)
    --- add_symbol_file_command (symfile.c)
    --- add_symbol_file_from_memory_command (symfile-mem.c)
    --- trace_find_pc_command (tracepoint.c)
    --- trace_find_range_command
    --- trace_find_outside_command
    -- parse_and_eval_long
    --- breakpoint_1i (breakpoint.c)
    ---- breakpoints_info
    ---- watchpoints_info
    ---- maintenance_info_breakpoints
    ---- tracepoints_info
    --- do_set_command (cli-setshow.c)
    ---- execute_command (top.c)
    --- restore_command (cli-dump.c)
    --- go32_sldt (go32-nat.c)
    --- go32_sgdt
    --- go32_sidt
    --- go32_pde
    --- go32_pte
    --- continue_command (infcmd.c)
    --- step_1
    ---- step_command
    ---- next_command
    ---- stepi_command
    ---- nexti_command
    --- signal_command
    --- inferior_command (inferior.c)
    --- add_inferior_command
    --- clone_inferior_command
    --- signals_info (infrun.c)
    --- call_lseek (linux-fork.c)
    --- delete_checkpoint_command
    --- detach_checkpoint_command
    --- info_checkpoints_command
    --- restart_command
    --- maintenance_info_program_spaces_command (progspace.c)
    --- cmd_record_goto (record.c)
    ---- record_goto_bookmark
    ----- target_goto_bookmark (target.h)
    ------ goto_bookmark_command (reverse.c)
    --- backtrace_command_1 (stack.c)
    ---- backtrace_command
    ---- backtrace_full_command
    --- up_silently_base
    ---- up_silently_command
    ---- up_command
    --- down_silently_base
    ---- down_silently_command
    ---- down_command
    --- show_commands (top.c)
    --- trace_find_command (tracepoint.c)
    ---- trace_find_end_command
    ---- trace_find_start_command
    ---- tfind_1
    --- trace_find_tracepoint_command
    --- set_radix (valrpint.c)
    --- show_values (value.c)
    --- display_selectors (windows-nat.c)
    -- parse_and_eval
    --- print_ada_task_info (ada-tasks.c)
    ---- info_tasks_command
    --- info_task
    ---- info_tasks_command
    --- task_command_1
    ---- task_command
    --- ignore_command (breakpoint.c)
    --- dump_value_to_file (cli-dump.c)
    ---- dump_value_command
    ---- dump_srec_value
    ---- dump_ihex_value
    ---- dump_texhex_value
    ---- dump_binary_value
    ---- append_binary_value
    --- info_vtbl_command (cp-support.c)
    --- mi_cmd_trace_define_variable
    XXX gdbpy_parse_and_eval (python.c)
    --- parse_frame_specification_1 (stack.c)
    ---- parse_frame_specification
    ----- func_command
    ---- frame_info
    ---- select_frame_command
    ----- frame_command
    ------ return_command
    ----- return_command
    --- do_captured_thread_select (thread.c)
    ---- gdb_thread_select
    ----- thread_command
    --- quit_force (top.c)
    ---- quit_command (cli-cmds.c)
    ----- stdin_event_handler (event-top.c)
    ----- captured_command_loop (main.c)
    ---- handle_sigterm (event-top.c)
    ---- captured_main (main.c)
    ---- mi_cmd_gdb_exit (mi-main.c)
    ---- mi_execute_command (mi-main.c)
    ----- mi_execute_command_wrapper
    ------ mi_execute_command_input_handler
    XXXXXX mi_interpreter_exec
    --- trace_variable_command (tracepoint.c)
    --- display_tob (windows-tdep.c)
    -- parse_and_eval_type
    ---- safe_parse_type (gdbtypes.c)
    ----- check_stub_method
    -- mi_cmd_data_evaluate_expression (mi-main.c)
    -- print_object_command (objc-lang.c)
    -- print_command_1 (printcmd.c)
    --- print_command
    --- call_command
    -- output_command
    --- trace_dump_actions (tracepoint.c)
    -- set_command
    -- x_command
    -- display_command
    -- doo_one_display
    -- return_command (stack.c)
    -- whatis_exp (typeprint.c)
    -- maintenance_print_type
    -- init_if_undefined_command (value.c)
    - ada_read_renaming_var_value (ada-lang.c)
    - create_excep_cond_exprs (ada-lang.c)
    - agent_eval_command_one (ax-gdb.c)
    - maint_agent_print_command (ax-gdb.c)
    - set_breakpoint_condition (breakpoint.c)
    - update_watchpoint
    - parse_cmd_to_aexpr
      X Why cmd1 = cmdrest, parse_exp_1 (&cmd1), cmdrest = cmd1?
    - init_breakpoint_sal
    - find_condition_and_thread
    - watch_command_1
    - update_breakpoint_locations
    - parse_to_comma_and_eval (eval.c)
    - validate_actionline (tracepoint.c)
    -- check_tracepoint_command (breakpoint.c)
    -- trace_dump_command
   - varobj_create (varobj.c)

I have not attempted to constify the other parse_and_eval_* functions yet. I leave that for a follow-on patch.

That's all of them AFAICT. Anything further you want wrt to analyzing callers that I missed?

Keith


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