From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id DA8ED3857829 for ; Tue, 23 Mar 2021 18:41:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DA8ED3857829 X-ASG-Debug-ID: 1616524899-0c856e67e2a90ab0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 1IAlm7rwQiSoCyp8 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 23 Mar 2021 14:41:39 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 66116441B21; Tue, 23 Mar 2021 14:41:39 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb: move all "current target" wrapper implementations to target.c Date: Tue, 23 Mar 2021 14:41:37 -0400 X-ASG-Orig-Subj: [PATCH 1/2] gdb: move all "current target" wrapper implementations to target.c Message-Id: <20210323184138.876503-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1616524899 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 47406 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.88731 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-22.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Mar 2021 18:41:46 -0000 From: Simon Marchi The following patch removes the current_top_target function, replacing uses with `current_inferior ()->top_target ()`. This is a problem for uses in target.h, because they don't have access to the current_inferior function and the inferior structure: target.h can't include inferior.h, otherwise that would make a cyclic inclusion. Avoid this by moving all implementations of the wrappers that call target methods with the current target to target.c. Many of them are changed from a macro to a function, which is an improvement for readability and debuggability, IMO. target_shortname and target_longname were not function-like macros, so a few adjustments are needed. gdb/ChangeLog: * target.h (target_shortname): Change to function declaration. (target_longname): Likewise. (target_attach_no_wait): Likewise. (target_post_attach): Likewise. (target_prepare_to_store): Likewise. (target_supports_enable_disable_tracepoint): Likewise. (target_supports_string_tracing): Likewise. (target_supports_evaluation_of_breakpoint_conditions): Likewise. (target_supports_dumpcore): Likewise. (target_dumpcore): Likewise. (target_can_run_breakpoint_commands): Likewise. (target_files_info): Likewise. (target_post_startup_inferior): Likewise. (target_insert_fork_catchpoint): Likewise. (target_remove_fork_catchpoint): Likewise. (target_insert_vfork_catchpoint): Likewise. (target_remove_vfork_catchpoint): Likewise. (target_insert_exec_catchpoint): Likewise. (target_remove_exec_catchpoint): Likewise. (target_set_syscall_catchpoint): Likewise. (target_rcmd): Likewise. (target_can_lock_scheduler): Likewise. (target_can_async_p): Likewise. (target_is_async_p): Likewise. (target_execution_direction): Likewise. (target_extra_thread_info): Likewise. (target_pid_to_exec_file): Likewise. (target_thread_architecture): Likewise. (target_find_memory_regions): Likewise. (target_make_corefile_notes): Likewise. (target_get_bookmark): Likewise. (target_goto_bookmark): Likewise. (target_stopped_by_watchpoint): Likewise. (target_stopped_by_sw_breakpoint): Likewise. (target_supports_stopped_by_sw_breakpoint): Likewise. (target_stopped_by_hw_breakpoint): Likewise. (target_supports_stopped_by_hw_breakpoint): Likewise. (target_have_steppable_watchpoint): Likewise. (target_can_use_hardware_watchpoint): Likewise. (target_region_ok_for_hw_watchpoint): Likewise. (target_can_do_single_step): Likewise. (target_insert_watchpoint): Likewise. (target_remove_watchpoint): Likewise. (target_insert_hw_breakpoint): Likewise. (target_remove_hw_breakpoint): Likewise. (target_can_accel_watchpoint_condition): Likewise. (target_can_execute_reverse): Likewise. (target_get_ada_task_ptid): Likewise. (target_filesystem_is_local): Likewise. (target_trace_init): Likewise. (target_download_tracepoint): Likewise. (target_can_download_tracepoint): Likewise. (target_download_trace_state_variable): Likewise. (target_enable_tracepoint): Likewise. (target_disable_tracepoint): Likewise. (target_trace_start): Likewise. (target_trace_set_readonly_regions): Likewise. (target_get_trace_status): Likewise. (target_get_tracepoint_status): Likewise. (target_trace_stop): Likewise. (target_trace_find): Likewise. (target_get_trace_state_variable_value): Likewise. (target_save_trace_data): Likewise. (target_upload_tracepoints): Likewise. (target_upload_trace_state_variables): Likewise. (target_get_raw_trace_data): Likewise. (target_get_min_fast_tracepoint_insn_len): Likewise. (target_set_disconnected_tracing): Likewise. (target_set_circular_trace_buffer): Likewise. (target_set_trace_buffer_size): Likewise. (target_set_trace_notes): Likewise. (target_get_tib_address): Likewise. (target_set_permissions): Likewise. (target_static_tracepoint_marker_at): Likewise. (target_static_tracepoint_markers_by_strid): Likewise. (target_traceframe_info): Likewise. (target_use_agent): Likewise. (target_can_use_agent): Likewise. (target_augmented_libraries_svr4_read): Likewise. (target_log_command): Likewise. * target.c (target_shortname): New. (target_longname): New. (target_attach_no_wait): New. (target_post_attach): New. (target_prepare_to_store): New. (target_supports_enable_disable_tracepoint): New. (target_supports_string_tracing): New. (target_supports_evaluation_of_breakpoint_conditions): New. (target_supports_dumpcore): New. (target_dumpcore): New. (target_can_run_breakpoint_commands): New. (target_files_info): New. (target_post_startup_inferior): New. (target_insert_fork_catchpoint): New. (target_remove_fork_catchpoint): New. (target_insert_vfork_catchpoint): New. (target_remove_vfork_catchpoint): New. (target_insert_exec_catchpoint): New. (target_remove_exec_catchpoint): New. (target_set_syscall_catchpoint): New. (target_rcmd): New. (target_can_lock_scheduler): New. (target_can_async_p): New. (target_is_async_p): New. (target_execution_direction): New. (target_extra_thread_info): New. (target_pid_to_exec_file): New. (target_thread_architecture): New. (target_find_memory_regions): New. (target_make_corefile_notes): New. (target_get_bookmark): New. (target_goto_bookmark): New. (target_stopped_by_watchpoint): New. (target_stopped_by_sw_breakpoint): New. (target_supports_stopped_by_sw_breakpoint): New. (target_stopped_by_hw_breakpoint): New. (target_supports_stopped_by_hw_breakpoint): New. (target_have_steppable_watchpoint): New. (target_can_use_hardware_watchpoint): New. (target_region_ok_for_hw_watchpoint): New. (target_can_do_single_step): New. (target_insert_watchpoint): New. (target_remove_watchpoint): New. (target_insert_hw_breakpoint): New. (target_remove_hw_breakpoint): New. (target_can_accel_watchpoint_condition): New. (target_can_execute_reverse): New. (target_get_ada_task_ptid): New. (target_filesystem_is_local): New. (target_trace_init): New. (target_download_tracepoint): New. (target_can_download_tracepoint): New. (target_download_trace_state_variable): New. (target_enable_tracepoint): New. (target_disable_tracepoint): New. (target_trace_start): New. (target_trace_set_readonly_regions): New. (target_get_trace_status): New. (target_get_tracepoint_status): New. (target_trace_stop): New. (target_trace_find): New. (target_get_trace_state_variable_value): New. (target_save_trace_data): New. (target_upload_tracepoints): New. (target_upload_trace_state_variables): New. (target_get_raw_trace_data): New. (target_get_min_fast_tracepoint_insn_len): New. (target_set_disconnected_tracing): New. (target_set_circular_trace_buffer): New. (target_set_trace_buffer_size): New. (target_set_trace_notes): New. (target_get_tib_address): New. (target_set_permissions): New. (target_static_tracepoint_marker_at): New. (target_static_tracepoint_markers_by_strid): New. (target_traceframe_info): New. (target_use_agent): New. (target_can_use_agent): New. (target_augmented_libraries_svr4_read): New. (target_log_command): New. * bfin-tdep.c (bfin_sw_breakpoint_from_kind): Adjust. * infrun.c (set_schedlock_func): Adjust. * mi/mi-main.c (exec_reverse_continue): Adjust. * reverse.c (exec_reverse_once): Adjust. * sh-tdep.c (sh_sw_breakpoint_from_kind): Adjust. * tui/tui-stack.c (tui_locator_window::make_status_line): Adjust. * remote-sim.c (gdbsim_target::detach): Adjust. (gdbsim_target::files_info): Adjust. Change-Id: I72ef56e9a25adeb0b91f1ad05e34c89f77ebeaa8 --- gdb/bfin-tdep.c | 2 +- gdb/infrun.c | 3 +- gdb/mi/mi-main.c | 2 +- gdb/remote-sim.c | 4 +- gdb/reverse.c | 2 +- gdb/sh-tdep.c | 2 +- gdb/target.c | 558 ++++++++++++++++++++++++++++++++++++++++++++ gdb/target.h | 287 +++++++++-------------- gdb/tui/tui-stack.c | 4 +- 9 files changed, 674 insertions(+), 190 deletions(-) diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 963b0485a48..e3d6eee8832 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -597,7 +597,7 @@ bfin_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) *size = kind; - if (strcmp (target_shortname, "sim") == 0) + if (strcmp (target_shortname (), "sim") == 0) return bfin_sim_breakpoint; else return bfin_breakpoint; diff --git a/gdb/infrun.c b/gdb/infrun.c index 50340e6edad..b6f399d5478 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2030,7 +2030,8 @@ set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c) if (!target_can_lock_scheduler ()) { scheduler_mode = schedlock_off; - error (_("Target '%s' cannot support this command."), target_shortname); + error (_("Target '%s' cannot support this command."), + target_shortname ()); } } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 9a14d78e1e2..d5ce08e95ed 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -322,7 +322,7 @@ exec_reverse_continue (char **argv, int argc) error (_("Already in reverse mode.")); if (!target_can_execute_reverse ()) - error (_("Target %s does not support this command."), target_shortname); + error (_("Target %s does not support this command."), target_shortname ()); scoped_restore save_exec_dir = make_scoped_restore (&execution_direction, EXEC_REVERSE); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 1746b626fa1..f2cf8dbd711 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -836,7 +836,7 @@ gdbsim_target::detach (inferior *inf, int from_tty) inf->unpush_target (this); /* calls gdbsim_close to do the real work */ if (from_tty) - printf_filtered ("Ending simulator %s debugging\n", target_shortname); + printf_filtered ("Ending simulator %s debugging\n", target_shortname ()); } /* Resume execution of the target process. STEP says whether to single-step @@ -1119,7 +1119,7 @@ gdbsim_target::files_info () if (current_program_space->exec_bfd ()) { fprintf_unfiltered (gdb_stdlog, "\tAttached to %s running program %s\n", - target_shortname, file); + target_shortname (), file); sim_info (sim_data->gdbsim_desc, 0); } } diff --git a/gdb/reverse.c b/gdb/reverse.c index 4c618a00173..e51defb27a3 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -45,7 +45,7 @@ exec_reverse_once (const char *cmd, const char *args, int from_tty) cmd); if (!target_can_execute_reverse ()) - error (_("Target %s does not support this command."), target_shortname); + error (_("Target %s does not support this command."), target_shortname ()); std::string reverse_command = string_printf ("%s %s", cmd, args ? args : ""); scoped_restore restore_exec_dir diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index ecd73c17217..5a71d3ac689 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -432,7 +432,7 @@ sh_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) *size = kind; /* For remote stub targets, trapa #20 is used. */ - if (strcmp (target_shortname, "remote") == 0) + if (strcmp (target_shortname (), "remote") == 0) { static unsigned char big_remote_breakpoint[] = { 0xc3, 0x20 }; static unsigned char little_remote_breakpoint[] = { 0x20, 0xc3 }; diff --git a/gdb/target.c b/gdb/target.c index afc4b2cbbb6..e7af5e8a9b0 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -215,6 +215,564 @@ target_has_execution (inferior *inf) return false; } +const char * +target_shortname () +{ + return current_top_target ()->shortname (); +} + +/* See target.h. */ + +bool +target_attach_no_wait () +{ + return current_top_target ()->attach_no_wait (); +} + +/* See target.h. */ + +void +target_post_attach (int pid) +{ + return current_top_target ()->post_attach (pid); +} + +/* See target.h. */ + +void +target_prepare_to_store (regcache *regcache) +{ + return current_top_target ()->prepare_to_store (regcache); +} + +/* See target.h. */ + +bool +target_supports_enable_disable_tracepoint () +{ + return current_top_target ()->supports_enable_disable_tracepoint (); +} + +bool +target_supports_string_tracing () +{ + return current_top_target ()->supports_string_tracing (); +} + +/* See target.h. */ + +bool +target_supports_evaluation_of_breakpoint_conditions () +{ + return current_top_target ()->supports_evaluation_of_breakpoint_conditions (); +} + +/* See target.h. */ + +bool +target_supports_dumpcore () +{ + return current_top_target ()->supports_dumpcore (); +} + +/* See target.h. */ + +void +target_dumpcore (const char *filename) +{ + return current_top_target ()->dumpcore (filename); +} + +/* See target.h. */ + +bool +target_can_run_breakpoint_commands () +{ + return current_top_target ()->can_run_breakpoint_commands (); +} + +/* See target.h. */ + +void +target_files_info () +{ + return current_top_target ()->files_info (); +} + +/* See target.h. */ + +void +target_post_startup_inferior (ptid_t ptid) +{ + return current_top_target ()->post_startup_inferior (ptid); +} + +/* See target.h. */ + +int +target_insert_fork_catchpoint (int pid) +{ + return current_top_target ()->insert_fork_catchpoint (pid); +} + +/* See target.h. */ + +int +target_remove_fork_catchpoint (int pid) +{ + return current_top_target ()->remove_fork_catchpoint (pid); +} + +/* See target.h. */ + +int +target_insert_vfork_catchpoint (int pid) +{ + return current_top_target ()->insert_vfork_catchpoint (pid); +} + +/* See target.h. */ + +int +target_remove_vfork_catchpoint (int pid) +{ + return current_top_target ()->remove_vfork_catchpoint (pid); +} + +/* See target.h. */ + +int +target_insert_exec_catchpoint (int pid) +{ + return current_top_target ()->insert_exec_catchpoint (pid); +} + +/* See target.h. */ + +int +target_remove_exec_catchpoint (int pid) +{ + return current_top_target ()->remove_exec_catchpoint (pid); +} + +/* See target.h. */ + +int +target_set_syscall_catchpoint (int pid, bool needed, int any_count, + gdb::array_view syscall_counts) +{ + return current_top_target ()->set_syscall_catchpoint (pid, needed, any_count, + syscall_counts); +} + +/* See target.h. */ + +void +target_rcmd (const char *command, struct ui_file *outbuf) +{ + return current_top_target ()->rcmd (command, outbuf); +} + +/* See target.h. */ + +bool +target_can_lock_scheduler () +{ + return (current_top_target ()->get_thread_control_capabilities () + & tc_schedlock) != 0; +} + +/* See target.h. */ + +bool +target_can_async_p () +{ + return current_top_target ()->can_async_p (); +} + +/* See target.h. */ + +bool +target_is_async_p () +{ + return current_top_target ()->is_async_p (); +} + +exec_direction_kind +target_execution_direction () +{ + return current_top_target ()->execution_direction (); +} + +/* See target.h. */ + +const char * +target_extra_thread_info (thread_info *tp) +{ + return current_top_target ()->extra_thread_info (tp); +} + +/* See target.h. */ + +char * +target_pid_to_exec_file (int pid) +{ + return current_top_target ()->pid_to_exec_file (pid); +} + +/* See target.h. */ + +gdbarch * +target_thread_architecture (ptid_t ptid) +{ + return current_top_target ()->thread_architecture (ptid); +} + +/* See target.h. */ + +int +target_find_memory_regions (find_memory_region_ftype func, void *data) +{ + return current_top_target ()->find_memory_regions (func, data); +} + +/* See target.h. */ + +gdb::unique_xmalloc_ptr +target_make_corefile_notes (bfd *bfd, int *size_p) +{ + return current_top_target ()->make_corefile_notes (bfd, size_p); +} + +gdb_byte * +target_get_bookmark (const char *args, int from_tty) +{ + return current_top_target ()->get_bookmark (args, from_tty); +} + +void +target_goto_bookmark (const gdb_byte *arg, int from_tty) +{ + return current_top_target ()->goto_bookmark (arg, from_tty); +} + +/* See target.h. */ + +bool +target_stopped_by_watchpoint () +{ + return current_top_target ()->stopped_by_watchpoint (); +} + +/* See target.h. */ + +bool +target_stopped_by_sw_breakpoint () +{ + return current_top_target ()->stopped_by_sw_breakpoint (); +} + +bool +target_supports_stopped_by_sw_breakpoint () +{ + return current_top_target ()->supports_stopped_by_sw_breakpoint (); +} + +bool +target_stopped_by_hw_breakpoint () +{ + return current_top_target ()->stopped_by_hw_breakpoint (); +} + +bool +target_supports_stopped_by_hw_breakpoint () +{ + return current_top_target ()->supports_stopped_by_hw_breakpoint (); +} + +/* See target.h. */ + +bool +target_have_steppable_watchpoint () +{ + return current_top_target ()->have_steppable_watchpoint (); +} + +/* See target.h. */ + +int +target_can_use_hardware_watchpoint (bptype type, int cnt, int othertype) +{ + return current_top_target ()->can_use_hw_breakpoint (type, cnt, othertype); +} + +/* See target.h. */ + +int +target_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) +{ + return current_top_target ()->region_ok_for_hw_watchpoint (addr, len); +} + + +int +target_can_do_single_step () +{ + return current_top_target ()->can_do_single_step (); +} + +/* See target.h. */ + +int +target_insert_watchpoint (CORE_ADDR addr, int len, target_hw_bp_type type, + expression *cond) +{ + return current_top_target ()->insert_watchpoint (addr, len, type, cond); +} + +/* See target.h. */ + +int +target_remove_watchpoint (CORE_ADDR addr, int len, target_hw_bp_type type, + expression *cond) +{ + return current_top_target ()->remove_watchpoint (addr, len, type, cond); +} + +/* See target.h. */ + +int +target_insert_hw_breakpoint (gdbarch *gdbarch, bp_target_info *bp_tgt) +{ + return current_top_target ()->insert_hw_breakpoint (gdbarch, bp_tgt); +} + +/* See target.h. */ + +int +target_remove_hw_breakpoint (gdbarch *gdbarch, bp_target_info *bp_tgt) +{ + return current_top_target ()->remove_hw_breakpoint (gdbarch, bp_tgt); +} + +/* See target.h. */ + +bool +target_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int type, + expression *cond) +{ + return current_top_target ()->can_accel_watchpoint_condition (addr, len, type, cond); +} + +/* See target.h. */ + +bool +target_can_execute_reverse () +{ + return current_top_target ()->can_execute_reverse (); +} + +ptid_t +target_get_ada_task_ptid (long lwp, long tid) +{ + return current_top_target ()->get_ada_task_ptid (lwp, tid); +} + +bool +target_filesystem_is_local () +{ + return current_top_target ()->filesystem_is_local (); +} + +void +target_trace_init () +{ + return current_top_target ()->trace_init (); +} + +void +target_download_tracepoint (bp_location *location) +{ + return current_top_target ()->download_tracepoint (location); +} + +bool +target_can_download_tracepoint () +{ + return current_top_target ()->can_download_tracepoint (); +} + +void +target_download_trace_state_variable (const trace_state_variable &tsv) +{ + return current_top_target ()->download_trace_state_variable (tsv); +} + +void +target_enable_tracepoint (bp_location *loc) +{ + return current_top_target ()->enable_tracepoint (loc); +} + +void +target_disable_tracepoint (bp_location *loc) +{ + return current_top_target ()->disable_tracepoint (loc); +} + +void +target_trace_start () +{ + return current_top_target ()->trace_start (); +} + +void +target_trace_set_readonly_regions () +{ + current_top_target ()->trace_set_readonly_regions (); +} + +int +target_get_trace_status (trace_status *ts) +{ + return current_top_target ()->get_trace_status (ts); +} + +void +target_get_tracepoint_status (breakpoint *tp, uploaded_tp *utp) +{ + return current_top_target ()->get_tracepoint_status (tp, utp); +} + +void +target_trace_stop () +{ + return current_top_target ()->trace_stop (); +} + +int +target_trace_find (trace_find_type type, int num, + CORE_ADDR addr1, CORE_ADDR addr2, int *tpp) +{ + return current_top_target ()->trace_find (type, num, addr1, addr2, tpp); +} + +bool +target_get_trace_state_variable_value (int tsv, LONGEST *val) +{ + return current_top_target ()->get_trace_state_variable_value (tsv, val); +} + +int +target_save_trace_data (const char *filename) +{ + return current_top_target ()->save_trace_data (filename); +} + +int +target_upload_tracepoints (uploaded_tp **utpp) +{ + return current_top_target ()->upload_tracepoints (utpp); +} + +int +target_upload_trace_state_variables (uploaded_tsv **utsvp) +{ + return current_top_target ()->upload_trace_state_variables (utsvp); +} + +LONGEST +target_get_raw_trace_data (gdb_byte *buf, ULONGEST offset, LONGEST len) +{ + return current_top_target ()->get_raw_trace_data (buf, offset, len); +} + +int +target_get_min_fast_tracepoint_insn_len () +{ + return current_top_target ()->get_min_fast_tracepoint_insn_len (); +} + +void +target_set_disconnected_tracing (int val) +{ + return current_top_target ()->set_disconnected_tracing (val); +} + +void +target_set_circular_trace_buffer (int val) +{ + return current_top_target ()->set_circular_trace_buffer (val); +} + +void +target_set_trace_buffer_size (LONGEST val) +{ + return current_top_target ()->set_trace_buffer_size (val); +} + +bool +target_set_trace_notes (const char *user, const char *notes, + const char *stopnotes) +{ + return current_top_target ()->set_trace_notes (user, notes, stopnotes); +} + +bool +target_get_tib_address (ptid_t ptid, CORE_ADDR *addr) +{ + return current_top_target ()->get_tib_address (ptid, addr); +} + +void +target_set_permissions () +{ + return current_top_target ()->set_permissions (); +} + +bool +target_static_tracepoint_marker_at (CORE_ADDR addr, + static_tracepoint_marker *marker) +{ + return current_top_target ()->static_tracepoint_marker_at (addr, marker); +} + +std::vector +target_static_tracepoint_markers_by_strid (const char *marker_id) +{ + return current_top_target ()->static_tracepoint_markers_by_strid (marker_id); +} + +traceframe_info_up +target_traceframe_info () +{ + return current_top_target ()->traceframe_info (); +} + +bool +target_use_agent (bool use) +{ + return current_top_target ()->use_agent (use); +} + +bool +target_can_use_agent () +{ + return current_top_target ()->can_use_agent (); +} + +bool +target_augmented_libraries_svr4_read () +{ + return current_top_target ()->augmented_libraries_svr4_read (); +} + +void +target_log_command (const char *p) +{ + return current_top_target ()->log_command (p); +} + /* This is used to implement the various target commands. */ static void diff --git a/gdb/target.h b/gdb/target.h index 8c11fb76d4c..8b223c0283f 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -917,8 +917,8 @@ struct target_ops /* Target file operations. */ - /* Return nonzero if the filesystem seen by the current inferior - is the local filesystem, zero otherwise. */ + /* Return true if the filesystem seen by the current inferior + is the local filesystem, false otherwise. */ virtual bool filesystem_is_local () TARGET_DEFAULT_RETURN (true); @@ -1069,8 +1069,8 @@ struct target_ops virtual void set_trace_buffer_size (LONGEST val) TARGET_DEFAULT_IGNORE (); - /* Add/change textual notes about the trace run, returning 1 if - successful, 0 otherwise. */ + /* Add/change textual notes about the trace run, returning true if + successful, false otherwise. */ virtual bool set_trace_notes (const char *user, const char *notes, const char *stopnotes) TARGET_DEFAULT_RETURN (false); @@ -1363,7 +1363,7 @@ extern target_ops *get_dummy_target (); /* Define easy words for doing these operations on our current target. */ -#define target_shortname (current_top_target ()->shortname ()) +extern const char *target_shortname (); /* Does whatever cleanup is required for a target that we are no longer going to be calling. This routine is automatically always @@ -1390,16 +1390,15 @@ extern struct target_ops *find_run_target (void); or their target_attach implementation takes care of the waiting. These targets must set to_attach_no_wait. */ -#define target_attach_no_wait() \ - (current_top_target ()->attach_no_wait ()) +extern bool target_attach_no_wait (); /* The target_attach operation places a process under debugger control, and stops the process. This operation provides a target-specific hook that allows the necessary bookkeeping to be performed after an attach completes. */ -#define target_post_attach(pid) \ - (current_top_target ()->post_attach) (pid) + +extern void target_post_attach (int pid); /* Display a message indicating we're about to detach from the current inferior process. */ @@ -1480,8 +1479,7 @@ extern void target_store_registers (struct regcache *regcache, int regs); that REGISTERS contains all the registers from the program being debugged. */ -#define target_prepare_to_store(regcache) \ - (current_top_target ()->prepare_to_store) (regcache) +extern void target_prepare_to_store (regcache *regcache); /* Determine current address space of thread PTID. */ @@ -1501,33 +1499,27 @@ int target_supports_disable_randomization (void); /* Returns true if this target can enable and disable tracepoints while a trace experiment is running. */ -#define target_supports_enable_disable_tracepoint() \ - (current_top_target ()->supports_enable_disable_tracepoint) () +extern bool target_supports_enable_disable_tracepoint (); -#define target_supports_string_tracing() \ - (current_top_target ()->supports_string_tracing) () +extern bool target_supports_string_tracing (); /* Returns true if this target can handle breakpoint conditions on its end. */ -#define target_supports_evaluation_of_breakpoint_conditions() \ - (current_top_target ()->supports_evaluation_of_breakpoint_conditions) () +extern bool target_supports_evaluation_of_breakpoint_conditions (); /* Does this target support dumpcore API? */ -#define target_supports_dumpcore() \ - (current_top_target ()->supports_dumpcore) () +extern bool target_supports_dumpcore (); /* Generate the core file with target API. */ -#define target_dumpcore(x) \ - (current_top_target ()->dumpcore (x)) +extern void target_dumpcore (const char *filename); /* Returns true if this target can handle breakpoint commands on its end. */ -#define target_can_run_breakpoint_commands() \ - (current_top_target ()->can_run_breakpoint_commands) () +extern bool target_can_run_breakpoint_commands (); /* Read a string from target memory at address MEMADDR. The string will be at most LEN bytes long (note that excess bytes may be read @@ -1614,8 +1606,7 @@ int target_write_memory_blocks /* Print a line about the current target. */ -#define target_files_info() \ - (current_top_target ()->files_info) () +extern void target_files_info (); /* Insert a breakpoint at address BP_TGT->placed_address in the target machine. Returns 0 for success, and returns non-zero or @@ -1664,25 +1655,20 @@ extern void target_load (const char *arg, int from_tty); Such targets will supply an appropriate definition for this function. */ -#define target_post_startup_inferior(ptid) \ - (current_top_target ()->post_startup_inferior) (ptid) +extern void target_post_startup_inferior (ptid_t ptid); /* On some targets, we can catch an inferior fork or vfork event when it occurs. These functions insert/remove an already-created catchpoint for such events. They return 0 for success, 1 if the catchpoint type is not supported and -1 for failure. */ -#define target_insert_fork_catchpoint(pid) \ - (current_top_target ()->insert_fork_catchpoint) (pid) +extern int target_insert_fork_catchpoint (int pid); -#define target_remove_fork_catchpoint(pid) \ - (current_top_target ()->remove_fork_catchpoint) (pid) +extern int target_remove_fork_catchpoint (int pid); -#define target_insert_vfork_catchpoint(pid) \ - (current_top_target ()->insert_vfork_catchpoint) (pid) +extern int target_insert_vfork_catchpoint (int pid); -#define target_remove_vfork_catchpoint(pid) \ - (current_top_target ()->remove_vfork_catchpoint) (pid) +extern int target_remove_vfork_catchpoint (int pid); /* If the inferior forks or vforks, this function will be called at the next resume in order to perform any bookkeeping and fiddling @@ -1704,11 +1690,9 @@ void target_follow_exec (struct inferior *inf, const char *execd_pathname); catchpoint for such events. They return 0 for success, 1 if the catchpoint type is not supported and -1 for failure. */ -#define target_insert_exec_catchpoint(pid) \ - (current_top_target ()->insert_exec_catchpoint) (pid) +extern int target_insert_exec_catchpoint (int pid); -#define target_remove_exec_catchpoint(pid) \ - (current_top_target ()->remove_exec_catchpoint) (pid) +extern int target_remove_exec_catchpoint (int pid); /* Syscall catch. @@ -1726,9 +1710,9 @@ void target_follow_exec (struct inferior *inf, const char *execd_pathname); Return 0 for success, 1 if syscall catchpoints are not supported or -1 for failure. */ -#define target_set_syscall_catchpoint(pid, needed, any_count, syscall_counts) \ - (current_top_target ()->set_syscall_catchpoint) (pid, needed, any_count, \ - syscall_counts) +extern int target_set_syscall_catchpoint + (int pid, bool needed, int any_count, + gdb::array_view syscall_counts); /* The debugger has completed a blocking wait() call. There is now some process event that must be processed. This function should @@ -1812,9 +1796,7 @@ extern void default_target_pass_ctrlc (struct target_ops *ops); (shell,interpreter) for execution. The result of the query is placed in OUTBUF. */ -#define target_rcmd(command, outbuf) \ - (current_top_target ()->rcmd) (command, outbuf) - +extern void target_rcmd (const char *command, struct ui_file *outbuf); /* Does the target include memory? (Dummy targets don't.) */ @@ -1843,21 +1825,16 @@ extern bool target_has_execution (inferior *inf = nullptr); /* Can the target support the debugger control of thread execution? Can it lock the thread scheduler? */ -static inline bool -target_can_lock_scheduler () -{ - return (current_top_target ()->get_thread_control_capabilities () - & tc_schedlock) != 0; -} +extern bool target_can_lock_scheduler (); /* Controls whether async mode is permitted. */ extern bool target_async_permitted; /* Can the target support asynchronous execution? */ -#define target_can_async_p() (current_top_target ()->can_async_p ()) +extern bool target_can_async_p (); /* Is the target in asynchronous execution mode? */ -#define target_is_async_p() (current_top_target ()->is_async_p ()) +extern bool target_is_async_p (); /* Enables/disabled async target events. */ extern void target_async (int enable); @@ -1877,8 +1854,7 @@ extern bool target_is_non_stop_p (); /* Return true if at least one inferior has a non-stop target. */ extern bool exists_non_stop_target (); -#define target_execution_direction() \ - (current_top_target ()->execution_direction ()) +extern exec_direction_kind target_execution_direction (); /* Converts a process id to a string. Usually, the string just contains `process xyz', but on some systems it may contain @@ -1892,8 +1868,7 @@ extern std::string normal_pid_to_str (ptid_t ptid); e.g. "sleeping", "runnable", "running on LWP 3". Null return value is okay. */ -#define target_extra_thread_info(TP) \ - (current_top_target ()->extra_thread_info (TP)) +extern const char *target_extra_thread_info (thread_info *tp); /* Return the thread's name, or NULL if the target is unable to determine it. The returned value must not be freed by the caller. */ @@ -1924,13 +1899,11 @@ extern gdb::byte_vector target_thread_info_to_thread_handle the client if the string will not be immediately used, or if it must persist. */ -#define target_pid_to_exec_file(pid) \ - (current_top_target ()->pid_to_exec_file) (pid) +extern char *target_pid_to_exec_file (int pid); /* See the to_thread_architecture description in struct target_ops. */ -#define target_thread_architecture(ptid) \ - (current_top_target ()->thread_architecture (ptid)) +extern gdbarch *target_thread_architecture (ptid_t ptid); /* * Iterator function for target memory regions. @@ -1939,22 +1912,20 @@ extern gdb::byte_vector target_thread_info_to_thread_handle * as a function macro so that it can be tested for nullity. */ -#define target_find_memory_regions(FUNC, DATA) \ - (current_top_target ()->find_memory_regions) (FUNC, DATA) +extern int target_find_memory_regions (find_memory_region_ftype func, + void *data); /* * Compose corefile .note section. */ -#define target_make_corefile_notes(BFD, SIZE_P) \ - (current_top_target ()->make_corefile_notes) (BFD, SIZE_P) +extern gdb::unique_xmalloc_ptr target_make_corefile_notes (bfd *bfd, + int *size_p); /* Bookmark interfaces. */ -#define target_get_bookmark(ARGS, FROM_TTY) \ - (current_top_target ()->get_bookmark) (ARGS, FROM_TTY) +extern gdb_byte *target_get_bookmark (const char *args, int from_tty); -#define target_goto_bookmark(ARG, FROM_TTY) \ - (current_top_target ()->goto_bookmark) (ARG, FROM_TTY) +extern void target_goto_bookmark (const gdb_byte *arg, int from_tty); /* Hardware watchpoint interfaces. */ @@ -1992,34 +1963,25 @@ extern gdb::byte_vector target_thread_info_to_thread_handle gdbarch_have_nonsteppable_watchpoint, GDB assumes continuable watchpoints. */ -/* Returns non-zero if we were stopped by a hardware watchpoint (memory read or +/* Returns true if we were stopped by a hardware watchpoint (memory read or write). Only the INFERIOR_PTID task is being queried. */ -#define target_stopped_by_watchpoint() \ - ((current_top_target ()->stopped_by_watchpoint) ()) +extern bool target_stopped_by_watchpoint (); -/* Returns non-zero if the target stopped because it executed a +/* Returns true if the target stopped because it executed a software breakpoint instruction. */ -#define target_stopped_by_sw_breakpoint() \ - ((current_top_target ()->stopped_by_sw_breakpoint) ()) +extern bool target_stopped_by_sw_breakpoint (); -#define target_supports_stopped_by_sw_breakpoint() \ - ((current_top_target ()->supports_stopped_by_sw_breakpoint) ()) +extern bool target_supports_stopped_by_sw_breakpoint (); -#define target_stopped_by_hw_breakpoint() \ - ((current_top_target ()->stopped_by_hw_breakpoint) ()) +extern bool target_stopped_by_hw_breakpoint (); -#define target_supports_stopped_by_hw_breakpoint() \ - ((current_top_target ()->supports_stopped_by_hw_breakpoint) ()) +extern bool target_supports_stopped_by_hw_breakpoint (); -/* Non-zero if we have steppable watchpoints */ +/* True if we have steppable watchpoints */ -static inline bool -target_have_steppable_watchpoint () -{ - return current_top_target ()->have_steppable_watchpoint (); -} +extern bool target_have_steppable_watchpoint (); /* Provide defaults for hardware watchpoint functions. */ @@ -2035,19 +1997,15 @@ target_have_steppable_watchpoint () one. OTHERTYPE is the number of watchpoints of other types than this one used so far. */ -#define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \ - (current_top_target ()->can_use_hw_breakpoint) ( \ - TYPE, CNT, OTHERTYPE) +extern int target_can_use_hardware_watchpoint (bptype type, int cnt, + int othertype); /* Returns the number of debug registers needed to watch the given memory region, or zero if not supported. */ -#define target_region_ok_for_hw_watchpoint(addr, len) \ - (current_top_target ()->region_ok_for_hw_watchpoint) (addr, len) - +extern int target_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len); -#define target_can_do_single_step() \ - (current_top_target ()->can_do_single_step) () +extern int target_can_do_single_step (); /* Set/clear a hardware watchpoint starting at ADDR, for LEN bytes. TYPE is 0 for write, 1 for read, and 2 for read/write accesses. @@ -2055,11 +2013,11 @@ target_have_steppable_watchpoint () Returns 0 for success, 1 if the watchpoint type is not supported, -1 for failure. */ -#define target_insert_watchpoint(addr, len, type, cond) \ - (current_top_target ()->insert_watchpoint) (addr, len, type, cond) +extern int target_insert_watchpoint (CORE_ADDR addr, int len, + target_hw_bp_type type, expression *cond); -#define target_remove_watchpoint(addr, len, type, cond) \ - (current_top_target ()->remove_watchpoint) (addr, len, type, cond) +extern int target_remove_watchpoint (CORE_ADDR addr, int len, + target_hw_bp_type type, expression *cond); /* Insert a new masked watchpoint at ADDR using the mask MASK. RW may be hw_read for a read watchpoint, hw_write for a write watchpoint @@ -2082,11 +2040,11 @@ extern int target_remove_mask_watchpoint (CORE_ADDR, CORE_ADDR, throws an error (with a detailed failure reason error code and message) otherwise. */ -#define target_insert_hw_breakpoint(gdbarch, bp_tgt) \ - (current_top_target ()->insert_hw_breakpoint) (gdbarch, bp_tgt) +extern int target_insert_hw_breakpoint (gdbarch *gdbarch, + bp_target_info *bp_tgt); -#define target_remove_hw_breakpoint(gdbarch, bp_tgt) \ - (current_top_target ()->remove_hw_breakpoint) (gdbarch, bp_tgt) +extern int target_remove_hw_breakpoint (gdbarch *gdbarch, + bp_target_info *bp_tgt); /* Return number of debug registers needed for a ranged breakpoint, or -1 if ranged breakpoints are not supported. */ @@ -2114,8 +2072,9 @@ extern int target_ranged_break_num_registers (void); expression is false, but may report some false positives as well. For this reason, GDB will still evaluate the condition expression when the watchpoint triggers. */ -#define target_can_accel_watchpoint_condition(addr, len, type, cond) \ - (current_top_target ()->can_accel_watchpoint_condition) (addr, len, type, cond) + +extern bool target_can_accel_watchpoint_condition (CORE_ADDR addr, int len, + int type, expression *cond); /* Return number of debug registers needed for a masked watchpoint, -1 if masked watchpoints are not supported or -2 if the given address @@ -2124,16 +2083,12 @@ extern int target_ranged_break_num_registers (void); extern int target_masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask); /* Target can execute in reverse? */ -static inline bool -target_can_execute_reverse () -{ - return current_top_target ()->can_execute_reverse (); -} + +extern bool target_can_execute_reverse (); extern const struct target_desc *target_read_description (struct target_ops *); -#define target_get_ada_task_ptid(lwp, tid) \ - (current_top_target ()->get_ada_task_ptid) (lwp,tid) +extern ptid_t target_get_ada_task_ptid (long lwp, long tid); /* Main entry point for searching memory. */ extern int target_search_memory (CORE_ADDR start_addr, @@ -2144,10 +2099,10 @@ extern int target_search_memory (CORE_ADDR start_addr, /* Target file operations. */ -/* Return nonzero if the filesystem seen by the current inferior +/* Return true if the filesystem seen by the current inferior is the local filesystem, zero otherwise. */ -#define target_filesystem_is_local() \ - current_top_target ()->filesystem_is_local () + +extern bool target_filesystem_is_local (); /* Open FILENAME on the target, in the filesystem as seen by INF, using FLAGS and MODE. If INF is NULL, use the filesystem seen by @@ -2227,102 +2182,72 @@ extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc /* Tracepoint-related operations. */ -#define target_trace_init() \ - (current_top_target ()->trace_init) () - -#define target_download_tracepoint(t) \ - (current_top_target ()->download_tracepoint) (t) - -#define target_can_download_tracepoint() \ - (current_top_target ()->can_download_tracepoint) () +extern void target_trace_init (); -#define target_download_trace_state_variable(tsv) \ - (current_top_target ()->download_trace_state_variable) (tsv) +extern void target_download_tracepoint (bp_location *location); -#define target_enable_tracepoint(loc) \ - (current_top_target ()->enable_tracepoint) (loc) +extern bool target_can_download_tracepoint (); -#define target_disable_tracepoint(loc) \ - (current_top_target ()->disable_tracepoint) (loc) +extern void target_download_trace_state_variable (const trace_state_variable &tsv); -#define target_trace_start() \ - (current_top_target ()->trace_start) () +extern void target_enable_tracepoint (bp_location *loc); -#define target_trace_set_readonly_regions() \ - (current_top_target ()->trace_set_readonly_regions) () +extern void target_disable_tracepoint (bp_location *loc); -#define target_get_trace_status(ts) \ - (current_top_target ()->get_trace_status) (ts) +extern void target_trace_start (); -#define target_get_tracepoint_status(tp,utp) \ - (current_top_target ()->get_tracepoint_status) (tp, utp) +extern void target_trace_set_readonly_regions (); -#define target_trace_stop() \ - (current_top_target ()->trace_stop) () +extern int target_get_trace_status (trace_status *ts); -#define target_trace_find(type,num,addr1,addr2,tpp) \ - (current_top_target ()->trace_find) (\ - (type), (num), (addr1), (addr2), (tpp)) +extern void target_get_tracepoint_status (breakpoint *tp, uploaded_tp *utp); -#define target_get_trace_state_variable_value(tsv,val) \ - (current_top_target ()->get_trace_state_variable_value) ((tsv), (val)) +extern void target_trace_stop (); -#define target_save_trace_data(filename) \ - (current_top_target ()->save_trace_data) (filename) +extern int target_trace_find (trace_find_type type, int num, CORE_ADDR addr1, + CORE_ADDR addr2, int *tpp); -#define target_upload_tracepoints(utpp) \ - (current_top_target ()->upload_tracepoints) (utpp) +extern bool target_get_trace_state_variable_value (int tsv, LONGEST *val); -#define target_upload_trace_state_variables(utsvp) \ - (current_top_target ()->upload_trace_state_variables) (utsvp) +extern int target_save_trace_data (const char *filename); -#define target_get_raw_trace_data(buf,offset,len) \ - (current_top_target ()->get_raw_trace_data) ((buf), (offset), (len)) +extern int target_upload_tracepoints (uploaded_tp **utpp); -#define target_get_min_fast_tracepoint_insn_len() \ - (current_top_target ()->get_min_fast_tracepoint_insn_len) () +extern int target_upload_trace_state_variables (uploaded_tsv **utsvp); -#define target_set_disconnected_tracing(val) \ - (current_top_target ()->set_disconnected_tracing) (val) +extern LONGEST target_get_raw_trace_data (gdb_byte *buf, ULONGEST offset, + LONGEST len); -#define target_set_circular_trace_buffer(val) \ - (current_top_target ()->set_circular_trace_buffer) (val) +extern int target_get_min_fast_tracepoint_insn_len (); -#define target_set_trace_buffer_size(val) \ - (current_top_target ()->set_trace_buffer_size) (val) +extern void target_set_disconnected_tracing (int val); -#define target_set_trace_notes(user,notes,stopnotes) \ - (current_top_target ()->set_trace_notes) ((user), (notes), (stopnotes)) +extern void target_set_circular_trace_buffer (int val); -#define target_get_tib_address(ptid, addr) \ - (current_top_target ()->get_tib_address) ((ptid), (addr)) +extern void target_set_trace_buffer_size (LONGEST val); -#define target_set_permissions() \ - (current_top_target ()->set_permissions) () +extern bool target_set_trace_notes (const char *user, const char *notes, + const char *stopnotes); -#define target_static_tracepoint_marker_at(addr, marker) \ - (current_top_target ()->static_tracepoint_marker_at) (addr, marker) +extern bool target_get_tib_address (ptid_t ptid, CORE_ADDR *addr); -#define target_static_tracepoint_markers_by_strid(marker_id) \ - (current_top_target ()->static_tracepoint_markers_by_strid) (marker_id) +extern void target_set_permissions (); -#define target_traceframe_info() \ - (current_top_target ()->traceframe_info) () +extern bool target_static_tracepoint_marker_at + (CORE_ADDR addr, static_tracepoint_marker *marker); -#define target_use_agent(use) \ - (current_top_target ()->use_agent) (use) +extern std::vector + target_static_tracepoint_markers_by_strid (const char *marker_id); -#define target_can_use_agent() \ - (current_top_target ()->can_use_agent) () +extern traceframe_info_up target_traceframe_info (); -#define target_augmented_libraries_svr4_read() \ - (current_top_target ()->augmented_libraries_svr4_read) () +extern bool target_use_agent (bool use); -/* Command logging facility. */ +extern bool target_can_use_agent (); -#define target_log_command(p) \ - (current_top_target ()->log_command) (p) +extern bool target_augmented_libraries_svr4_read (); +extern void target_log_command (const char *p); extern int target_core_of_thread (ptid_t ptid); diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index b5daa61b4e2..0200a111c92 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -77,7 +77,7 @@ tui_locator_window::make_status_line () const pid_name = pid_name_holder.c_str (); } - target_width = strlen (target_shortname); + target_width = strlen (target_shortname ()); if (target_width > MAX_TARGET_WIDTH) target_width = MAX_TARGET_WIDTH; @@ -149,7 +149,7 @@ tui_locator_window::make_status_line () const string_file string; if (target_width > 0) - string.printf ("%*.*s ", -target_width, target_width, target_shortname); + string.printf ("%*.*s ", -target_width, target_width, target_shortname ()); if (pid_width > 0) string.printf ("%*.*s ", -pid_width, pid_width, pid_name); -- 2.30.0