mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-17 07:53:51 +08:00
Constify target_pid_to_exec_file
This changes target_pid_to_exec_file and target_ops::pid_to_exec_file to return a "const char *". I couldn't build many of these targets, but did examine the code by hand -- also, as this only affects the return type, it's normally pretty safe. This brings gdb and gdbserver a bit closer, and allows for the removal of a const_cast as well.
This commit is contained in:
@ -2373,7 +2373,7 @@ set_enable_mach_exceptions (const char *args, int from_tty,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
darwin_nat_target::pid_to_exec_file (int pid)
|
darwin_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static char path[PATH_MAX];
|
static char path[PATH_MAX];
|
||||||
|
@ -100,7 +100,7 @@ class darwin_nat_target : public inf_child_target
|
|||||||
|
|
||||||
std::string pid_to_str (ptid_t) override;
|
std::string pid_to_str (ptid_t) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
enum target_xfer_status xfer_partial (enum target_object object,
|
enum target_xfer_status xfer_partial (enum target_object object,
|
||||||
const char *annex,
|
const char *annex,
|
||||||
|
@ -314,7 +314,7 @@ validate_exec_file (int from_tty)
|
|||||||
void
|
void
|
||||||
exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
|
exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
|
||||||
{
|
{
|
||||||
char *exec_file_target;
|
const char *exec_file_target;
|
||||||
symfile_add_flags add_flags = 0;
|
symfile_add_flags add_flags = 0;
|
||||||
|
|
||||||
/* Do nothing if we already have an executable filename. */
|
/* Do nothing if we already have an executable filename. */
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
/* Return the name of a file that can be opened to get the symbols for
|
/* Return the name of a file that can be opened to get the symbols for
|
||||||
the child process identified by PID. */
|
the child process identified by PID. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
fbsd_nat_target::pid_to_exec_file (int pid)
|
fbsd_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
class fbsd_nat_target : public inf_ptrace_target
|
class fbsd_nat_target : public inf_ptrace_target
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
int find_memory_regions (find_memory_region_ftype func, void *data) override;
|
int find_memory_regions (find_memory_region_ftype func, void *data) override;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ inf_child_target::can_attach ()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
inf_child_target::pid_to_exec_file (int pid)
|
inf_child_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
/* This target doesn't support translation of a process ID to the
|
/* This target doesn't support translation of a process ID to the
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
|
|
||||||
void post_attach (int) override;
|
void post_attach (int) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
int fileio_open (struct inferior *inf, const char *filename,
|
int fileio_open (struct inferior *inf, const char *filename,
|
||||||
int flags, int mode, int warn_if_slow,
|
int flags, int mode, int warn_if_slow,
|
||||||
|
@ -3764,7 +3764,7 @@ linux_nat_target::thread_name (struct thread_info *thr)
|
|||||||
/* Accepts an integer PID; Returns a string representing a file that
|
/* Accepts an integer PID; Returns a string representing a file that
|
||||||
can be opened to get the symbols for the child process. */
|
can be opened to get the symbols for the child process. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
linux_nat_target::pid_to_exec_file (int pid)
|
linux_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
return linux_proc_pid_to_exec_file (pid);
|
return linux_proc_pid_to_exec_file (pid);
|
||||||
|
@ -123,7 +123,7 @@ public:
|
|||||||
int set_syscall_catchpoint (int pid, bool needed, int any_count,
|
int set_syscall_catchpoint (int pid, bool needed, int any_count,
|
||||||
gdb::array_view<const int> syscall_counts) override;
|
gdb::array_view<const int> syscall_counts) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
void post_attach (int) override;
|
void post_attach (int) override;
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ linux_proc_task_list_dir_exists (pid_t pid)
|
|||||||
|
|
||||||
/* See linux-procfs.h. */
|
/* See linux-procfs.h. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
linux_proc_pid_to_exec_file (int pid)
|
linux_proc_pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
|
@ -78,7 +78,7 @@ extern int linux_proc_task_list_dir_exists (pid_t pid);
|
|||||||
to create the process PID. The returned value persists until this
|
to create the process PID. The returned value persists until this
|
||||||
function is next called. */
|
function is next called. */
|
||||||
|
|
||||||
extern char *linux_proc_pid_to_exec_file (int pid);
|
extern const char *linux_proc_pid_to_exec_file (int pid);
|
||||||
|
|
||||||
/* Display possible problems on this system. Display them only once
|
/* Display possible problems on this system. Display them only once
|
||||||
per GDB execution. */
|
per GDB execution. */
|
||||||
|
@ -34,10 +34,10 @@
|
|||||||
/* Return the name of a file that can be opened to get the symbols for
|
/* Return the name of a file that can be opened to get the symbols for
|
||||||
the child process identified by PID. */
|
the child process identified by PID. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
nbsd_nat_target::pid_to_exec_file (int pid)
|
nbsd_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
return const_cast<char *> (netbsd_nat::pid_to_exec_file (pid));
|
return netbsd_nat::pid_to_exec_file (pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the current directory for the process identified by PID. */
|
/* Return the current directory for the process identified by PID. */
|
||||||
|
@ -28,7 +28,7 @@ struct thread_info;
|
|||||||
|
|
||||||
struct nbsd_nat_target : public inf_ptrace_target
|
struct nbsd_nat_target : public inf_ptrace_target
|
||||||
{
|
{
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
bool thread_alive (ptid_t ptid) override;
|
bool thread_alive (ptid_t ptid) override;
|
||||||
const char *thread_name (struct thread_info *thr) override;
|
const char *thread_name (struct thread_info *thr) override;
|
||||||
|
@ -121,7 +121,7 @@ struct nto_procfs_target : public inf_child_target
|
|||||||
|
|
||||||
const char *extra_thread_info (struct thread_info *) override;
|
const char *extra_thread_info (struct thread_info *) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* For "target native". */
|
/* For "target native". */
|
||||||
@ -664,7 +664,7 @@ nto_procfs_target::files_info ()
|
|||||||
|
|
||||||
/* Target to_pid_to_exec_file implementation. */
|
/* Target to_pid_to_exec_file implementation. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
nto_procfs_target::pid_to_exec_file (const int pid)
|
nto_procfs_target::pid_to_exec_file (const int pid)
|
||||||
{
|
{
|
||||||
int proc_fd;
|
int proc_fd;
|
||||||
|
@ -127,7 +127,7 @@ public:
|
|||||||
|
|
||||||
std::string pid_to_str (ptid_t) override;
|
std::string pid_to_str (ptid_t) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
thread_control_capabilities get_thread_control_capabilities () override
|
thread_control_capabilities get_thread_control_capabilities () override
|
||||||
{ return tc_schedlock; }
|
{ return tc_schedlock; }
|
||||||
@ -2927,7 +2927,7 @@ procfs_target::pid_to_str (ptid_t ptid)
|
|||||||
/* Accepts an integer PID; Returns a string representing a file that
|
/* Accepts an integer PID; Returns a string representing a file that
|
||||||
can be opened to get the symbols for the child process. */
|
can be opened to get the symbols for the child process. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
procfs_target::pid_to_exec_file (int pid)
|
procfs_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
|
@ -508,7 +508,7 @@ public:
|
|||||||
|
|
||||||
void rcmd (const char *command, struct ui_file *output) override;
|
void rcmd (const char *command, struct ui_file *output) override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
void log_command (const char *cmd) override
|
void log_command (const char *cmd) override
|
||||||
{
|
{
|
||||||
@ -14353,7 +14353,7 @@ remote_target::load (const char *name, int from_tty)
|
|||||||
can be opened on the remote side to get the symbols for the child
|
can be opened on the remote side to get the symbols for the child
|
||||||
process. Returns NULL if the operation is not supported. */
|
process. Returns NULL if the operation is not supported. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
remote_target::pid_to_exec_file (int pid)
|
remote_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static gdb::optional<gdb::char_vector> filename;
|
static gdb::optional<gdb::char_vector> filename;
|
||||||
|
@ -94,7 +94,7 @@ struct dummy_target : public target_ops
|
|||||||
void interrupt () override;
|
void interrupt () override;
|
||||||
void pass_ctrlc () override;
|
void pass_ctrlc () override;
|
||||||
void rcmd (const char *arg0, struct ui_file *arg1) override;
|
void rcmd (const char *arg0, struct ui_file *arg1) override;
|
||||||
char *pid_to_exec_file (int arg0) override;
|
const char *pid_to_exec_file (int arg0) override;
|
||||||
void log_command (const char *arg0) override;
|
void log_command (const char *arg0) override;
|
||||||
const target_section_table *get_section_table () override;
|
const target_section_table *get_section_table () override;
|
||||||
thread_control_capabilities get_thread_control_capabilities () override;
|
thread_control_capabilities get_thread_control_capabilities () override;
|
||||||
@ -268,7 +268,7 @@ struct debug_target : public target_ops
|
|||||||
void interrupt () override;
|
void interrupt () override;
|
||||||
void pass_ctrlc () override;
|
void pass_ctrlc () override;
|
||||||
void rcmd (const char *arg0, struct ui_file *arg1) override;
|
void rcmd (const char *arg0, struct ui_file *arg1) override;
|
||||||
char *pid_to_exec_file (int arg0) override;
|
const char *pid_to_exec_file (int arg0) override;
|
||||||
void log_command (const char *arg0) override;
|
void log_command (const char *arg0) override;
|
||||||
const target_section_table *get_section_table () override;
|
const target_section_table *get_section_table () override;
|
||||||
thread_control_capabilities get_thread_control_capabilities () override;
|
thread_control_capabilities get_thread_control_capabilities () override;
|
||||||
@ -1983,28 +1983,28 @@ debug_target::rcmd (const char *arg0, struct ui_file *arg1)
|
|||||||
gdb_puts (")\n", gdb_stdlog);
|
gdb_puts (")\n", gdb_stdlog);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
target_ops::pid_to_exec_file (int arg0)
|
target_ops::pid_to_exec_file (int arg0)
|
||||||
{
|
{
|
||||||
return this->beneath ()->pid_to_exec_file (arg0);
|
return this->beneath ()->pid_to_exec_file (arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
dummy_target::pid_to_exec_file (int arg0)
|
dummy_target::pid_to_exec_file (int arg0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
debug_target::pid_to_exec_file (int arg0)
|
debug_target::pid_to_exec_file (int arg0)
|
||||||
{
|
{
|
||||||
char * result;
|
const char * result;
|
||||||
gdb_printf (gdb_stdlog, "-> %s->pid_to_exec_file (...)\n", this->beneath ()->shortname ());
|
gdb_printf (gdb_stdlog, "-> %s->pid_to_exec_file (...)\n", this->beneath ()->shortname ());
|
||||||
result = this->beneath ()->pid_to_exec_file (arg0);
|
result = this->beneath ()->pid_to_exec_file (arg0);
|
||||||
gdb_printf (gdb_stdlog, "<- %s->pid_to_exec_file (", this->beneath ()->shortname ());
|
gdb_printf (gdb_stdlog, "<- %s->pid_to_exec_file (", this->beneath ()->shortname ());
|
||||||
target_debug_print_int (arg0);
|
target_debug_print_int (arg0);
|
||||||
gdb_puts (") = ", gdb_stdlog);
|
gdb_puts (") = ", gdb_stdlog);
|
||||||
target_debug_print_char_p (result);
|
target_debug_print_const_char_p (result);
|
||||||
gdb_puts ("\n", gdb_stdlog);
|
gdb_puts ("\n", gdb_stdlog);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ target_extra_thread_info (thread_info *tp)
|
|||||||
|
|
||||||
/* See target.h. */
|
/* See target.h. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
target_pid_to_exec_file (int pid)
|
target_pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
return current_inferior ()->top_target ()->pid_to_exec_file (pid);
|
return current_inferior ()->top_target ()->pid_to_exec_file (pid);
|
||||||
|
@ -688,7 +688,7 @@ struct target_ops
|
|||||||
TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
|
TARGET_DEFAULT_FUNC (default_target_pass_ctrlc);
|
||||||
virtual void rcmd (const char *command, struct ui_file *output)
|
virtual void rcmd (const char *command, struct ui_file *output)
|
||||||
TARGET_DEFAULT_FUNC (default_rcmd);
|
TARGET_DEFAULT_FUNC (default_rcmd);
|
||||||
virtual char *pid_to_exec_file (int pid)
|
virtual const char *pid_to_exec_file (int pid)
|
||||||
TARGET_DEFAULT_RETURN (NULL);
|
TARGET_DEFAULT_RETURN (NULL);
|
||||||
virtual void log_command (const char *)
|
virtual void log_command (const char *)
|
||||||
TARGET_DEFAULT_IGNORE ();
|
TARGET_DEFAULT_IGNORE ();
|
||||||
@ -1951,7 +1951,7 @@ extern gdb::byte_vector target_thread_info_to_thread_handle
|
|||||||
the client if the string will not be immediately used, or if
|
the client if the string will not be immediately used, or if
|
||||||
it must persist. */
|
it must persist. */
|
||||||
|
|
||||||
extern char *target_pid_to_exec_file (int pid);
|
extern const char *target_pid_to_exec_file (int pid);
|
||||||
|
|
||||||
/* See the to_thread_architecture description in struct target_ops. */
|
/* See the to_thread_architecture description in struct target_ops. */
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
|
|||||||
|
|
||||||
void interrupt () override;
|
void interrupt () override;
|
||||||
|
|
||||||
char *pid_to_exec_file (int pid) override;
|
const char *pid_to_exec_file (int pid) override;
|
||||||
|
|
||||||
ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
|
ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
|
||||||
|
|
||||||
@ -2005,7 +2005,7 @@ windows_get_exec_module_filename (char *exe_name_ret, size_t exe_name_max_len)
|
|||||||
|
|
||||||
/* The pid_to_exec_file target_ops method for this platform. */
|
/* The pid_to_exec_file target_ops method for this platform. */
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
windows_nat_target::pid_to_exec_file (int pid)
|
windows_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
static char path[__PMAX];
|
static char path[__PMAX];
|
||||||
|
Reference in New Issue
Block a user