From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23522 invoked by alias); 11 Mar 2013 16:50:55 -0000 Received: (qmail 23508 invoked by uid 22791); 11 Mar 2013 16:50:54 -0000 X-SWARE-Spam-Status: No, hits=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_GD,TW_VT X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Mar 2013 16:50:34 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2BGoXZU004843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 11 Mar 2013 12:50:33 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r2BGoW4Y010419 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 11 Mar 2013 12:50:33 -0400 Message-ID: <513E0B58.4090800@redhat.com> Date: Mon, 11 Mar 2013 16:50:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Tom Tromey CC: Pedro Alves , "gdb-patches@sourceware.org ml" Subject: Re: [RFA] "constify" parse_exp_1 References: <51392C56.7040302@redhat.com> <51392F3F.5090102@redhat.com> <51393886.9030602@redhat.com> <87obeuc58e.fsf@fleche.redhat.com> In-Reply-To: <87obeuc58e.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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/msg00473.txt.bz2 On 03/08/2013 06:53 AM, Tom Tromey wrote: >>>>>> "Keith" == Keith Seitz 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