2014-09-11 18:19:56 +08:00
|
|
|
/* Declarations for common target functions.
|
|
|
|
|
2016-01-01 12:33:14 +08:00
|
|
|
Copyright (C) 1986-2016 Free Software Foundation, Inc.
|
2014-09-11 18:19:56 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#ifndef TARGET_COMMON_H
|
|
|
|
#define TARGET_COMMON_H
|
|
|
|
|
|
|
|
#include "target/waitstatus.h"
|
|
|
|
/* This header is a stopgap until more code is shared. */
|
|
|
|
|
|
|
|
/* Read LEN bytes of target memory at address MEMADDR, placing the
|
|
|
|
results in GDB's memory at MYADDR. Return zero for success,
|
|
|
|
nonzero if any error occurs. This function must be provided by
|
|
|
|
the client. Implementations of this function may define and use
|
|
|
|
their own error codes, but functions in the common, nat and target
|
|
|
|
directories must treat the return code as opaque. No guarantee is
|
|
|
|
made about the contents of the data at MYADDR if any error
|
|
|
|
occurs. */
|
|
|
|
|
|
|
|
extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
|
|
|
|
ssize_t len);
|
|
|
|
|
|
|
|
/* Read an unsigned 32-bit integer in the target's format from target
|
|
|
|
memory at address MEMADDR, storing the result in GDB's format in
|
|
|
|
GDB's memory at RESULT. Return zero for success, nonzero if any
|
|
|
|
error occurs. This function must be provided by the client.
|
|
|
|
Implementations of this function may define and use their own error
|
|
|
|
codes, but functions in the common, nat and target directories must
|
|
|
|
treat the return code as opaque. No guarantee is made about the
|
|
|
|
contents of the data at RESULT if any error occurs. */
|
|
|
|
|
|
|
|
extern int target_read_uint32 (CORE_ADDR memaddr, uint32_t *result);
|
|
|
|
|
|
|
|
/* Write LEN bytes from MYADDR to target memory at address MEMADDR.
|
|
|
|
Return zero for success, nonzero if any error occurs. This
|
|
|
|
function must be provided by the client. Implementations of this
|
|
|
|
function may define and use their own error codes, but functions
|
|
|
|
in the common, nat and target directories must treat the return
|
|
|
|
code as opaque. No guarantee is made about the contents of the
|
|
|
|
data at MEMADDR if any error occurs. */
|
|
|
|
|
|
|
|
extern int target_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
|
|
|
|
ssize_t len);
|
|
|
|
|
2014-09-22 18:33:59 +08:00
|
|
|
/* Cause the target to stop in a continuable fashion--for instance,
|
|
|
|
under Unix, this should act like SIGSTOP--and wait for the target
|
|
|
|
to be stopped before returning. This function must be provided by
|
|
|
|
the client. */
|
2014-09-11 18:19:56 +08:00
|
|
|
|
2014-09-22 18:33:59 +08:00
|
|
|
extern void target_stop_and_wait (ptid_t ptid);
|
2014-09-11 18:19:56 +08:00
|
|
|
|
Use target_continue{,_no_signal} instead of target_resume
This commit implements a new function, target_continue, on top of the
target_resume function. Then, it replaces all calls to target_resume
by calls to target_continue or to the already existing
target_continue_no_signal.
This is one of the (many) necessary steps needed to consolidate the
target interface between GDB and gdbserver. In particular, I am
interested in the impact this change will have on the unification of
the fork_inferior function (which I have been working on).
Tested on the BuildBot, no regressions introduced.
gdb/gdbserver/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): New variable 'ptid'. Replace calls
to the_target->resume by target_continue{,_no_signal}, depending
on the case.
* target.c (target_stop_and_wait): Call target_continue_no_signal
instead of the_target->resume.
(target_continue): New function.
gdb/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* fork-child.c (startup_inferior): Replace calls to target_resume
by target_continue{,_no_signal}, depending on the case.
* linux-nat.c (cleanup_target_stop): Call
target_continue_no_signal instead of target_resume.
* procfs.c (procfs_wait): Likewise.
* target.c (target_continue): New function.
* target/target.h (target_continue): New prototype.
2016-08-26 04:26:24 +08:00
|
|
|
/* Restart a target previously stopped. No signal is delivered to the
|
|
|
|
target. This function must be provided by the client. */
|
2014-09-11 18:19:56 +08:00
|
|
|
|
2014-09-22 18:33:59 +08:00
|
|
|
extern void target_continue_no_signal (ptid_t ptid);
|
2014-09-11 18:19:56 +08:00
|
|
|
|
Use target_continue{,_no_signal} instead of target_resume
This commit implements a new function, target_continue, on top of the
target_resume function. Then, it replaces all calls to target_resume
by calls to target_continue or to the already existing
target_continue_no_signal.
This is one of the (many) necessary steps needed to consolidate the
target interface between GDB and gdbserver. In particular, I am
interested in the impact this change will have on the unification of
the fork_inferior function (which I have been working on).
Tested on the BuildBot, no regressions introduced.
gdb/gdbserver/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): New variable 'ptid'. Replace calls
to the_target->resume by target_continue{,_no_signal}, depending
on the case.
* target.c (target_stop_and_wait): Call target_continue_no_signal
instead of the_target->resume.
(target_continue): New function.
gdb/ChangeLog:
2016-09-31 Sergio Durigan Junior <sergiodj@redhat.com>
* fork-child.c (startup_inferior): Replace calls to target_resume
by target_continue{,_no_signal}, depending on the case.
* linux-nat.c (cleanup_target_stop): Call
target_continue_no_signal instead of target_resume.
* procfs.c (procfs_wait): Likewise.
* target.c (target_continue): New function.
* target/target.h (target_continue): New prototype.
2016-08-26 04:26:24 +08:00
|
|
|
/* Restart a target previously stopped. SIGNAL is delivered to the
|
|
|
|
target. This function must be provided by the client. */
|
|
|
|
|
|
|
|
extern void target_continue (ptid_t ptid, enum gdb_signal signal);
|
|
|
|
|
2016-08-29 11:39:45 +08:00
|
|
|
/* Wait for process pid to do something. PTID = -1 to wait for any
|
|
|
|
pid to do something. Return pid of child, or -1 in case of error;
|
|
|
|
store status through argument pointer STATUS. Note that it is
|
|
|
|
_NOT_ OK to throw_exception() out of target_wait() without popping
|
|
|
|
the debugging target from the stack; GDB isn't prepared to get back
|
|
|
|
to the prompt with a debugging target but without the frame cache,
|
|
|
|
stop_pc, etc., set up. OPTIONS is a bitwise OR of TARGET_W*
|
|
|
|
options. */
|
|
|
|
|
|
|
|
extern ptid_t target_wait (ptid_t ptid, struct target_waitstatus *status,
|
|
|
|
int options);
|
|
|
|
|
Consolidate target_mourn_inferior between GDB and gdbserver
This patch consolidates the API of target_mourn_inferior between GDB
and gdbserver, in my continuing efforts to make sharing the
fork_inferior function possible between both.
GDB's version of the function did not care about the inferior's ptid
being mourned, but gdbserver's needed to know this information. Since
it actually makes sense to pass the ptid as an argument, instead of
depending on a global value directly (which GDB's version did), I
decided to make the generic API to accept it. I then went on and
extended all calls being made on GDB to include a ptid argument (which
ended up being inferior_ptid most of the times, anyway), and now we
have a more sane interface.
On GDB's side, after talking to Pedro a bit about it, we decided that
just an assertion to make sure that the ptid being passed is equal to
inferior_ptid would be enough for now, on the GDB side. We can remove
the assertion and perform more operations later if we ever pass
anything different than inferior_ptid.
Regression tested on our BuildBot, everything OK.
I'd appreciate a special look at gdb/windows-nat.c's modification
because I wasn't really sure what to do there. It seemed to me that
maybe I should build a ptid out of the process information there, but
then I am almost sure the assertion on GDB's side would trigger.
gdb/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* darwin-nat.c (darwin_kill_inferior): Adjusting call to
target_mourn_inferior to include ptid_t argument.
* fork-child.c (startup_inferior): Likewise.
* gnu-nat.c (gnu_kill_inferior): Likewise.
* inf-ptrace.c (inf_ptrace_kill): Likewise.
* infrun.c (handle_inferior_event_1): Likewise.
* linux-nat.c (linux_nat_attach): Likewise.
(linux_nat_kill): Likewise.
* nto-procfs.c (interrupt_query): Likewise.
(procfs_interrupt): Likewise.
(procfs_kill_inferior): Likewise.
* procfs.c (procfs_kill_inferior): Likewise.
* record.c (record_mourn_inferior): Likewise.
* remote-sim.c (gdbsim_kill): Likewise.
* remote.c (remote_detach_1): Likewise.
(remote_kill): Likewise.
* target.c (target_mourn_inferior): Change declaration to accept
new ptid_t argument; use gdb_assert on it.
* target.h (target_mourn_inferior): Move function prototype from
here...
* target/target.h (target_mourn_inferior): ... to here. Adjust it
to accept new ptid_t argument.
* windows-nat.c (get_windows_debug_event): Adjusting call to
target_mourn_inferior to include ptid_t argument.
gdb/gdbserver/ChangeLog:
2016-09-19 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c (start_inferior): Call target_mourn_inferior instead of
mourn_inferior; pass ptid_t argument to it.
(resume): Likewise.
(handle_target_event): Likewise.
* target.c (target_mourn_inferior): New function.
* target.h (mourn_inferior): Delete macro.
2016-09-12 11:45:31 +08:00
|
|
|
/* The inferior process has died. Do what is right. */
|
|
|
|
|
|
|
|
extern void target_mourn_inferior (ptid_t ptid);
|
|
|
|
|
2014-09-11 18:19:56 +08:00
|
|
|
#endif /* TARGET_COMMON_H */
|