gdb_server: support File-I/O Remote Protocol Extension
The File I/O remote protocol extension allows the target to use the host's file system and console I/O to perform various system calls. To use the function, targets need to prepare two callback functions: * get_gdb_finish_info: to get file I/O parameters from target * gdb_fileio_end: pass file I/O response to target As target is halted, gdb_server will try to get file-I/O information from target through target_get_gdb_fileio_info(). If the callback function returns ERROR_OK, gdb_server will initiate a file-I/O request to gdb. After gdb finishes system call, gdb will pass response of the system call to target through target_gdb_fileio_end() and continue to run(continue or step). To implement the function, I add a new data structure in struct target, called struct gdb_fileio_info, to record file I/O name and parameters. Details refer to GDB manual "File-I/O Remote Protocol Extension" Change-Id: I7f4d45e7c9e967b6d898dc79ba01d86bc46315d3 Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com> Reviewed-on: http://openocd.zylin.com/1102 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
committed by
Spencer Oliver
parent
80d412bafc
commit
0a4c8990c2
@@ -68,6 +68,10 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
|
||||
static int target_mem2array(Jim_Interp *interp, struct target *target,
|
||||
int argc, Jim_Obj * const *argv);
|
||||
static int target_register_user_commands(struct command_context *cmd_ctx);
|
||||
static int target_get_gdb_fileio_info_default(struct target *target,
|
||||
struct gdb_fileio_info *fileio_info);
|
||||
static int target_gdb_fileio_end_default(struct target *target, int retcode,
|
||||
int fileio_errno, bool ctrl_c);
|
||||
|
||||
/* targets */
|
||||
extern struct target_type arm7tdmi_target;
|
||||
@@ -1065,6 +1069,24 @@ int target_step(struct target *target,
|
||||
return target->type->step(target, current, address, handle_breakpoints);
|
||||
}
|
||||
|
||||
int target_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info)
|
||||
{
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target %s is not halted", target->cmd_name);
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
return target->type->get_gdb_fileio_info(target, fileio_info);
|
||||
}
|
||||
|
||||
int target_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, bool ctrl_c)
|
||||
{
|
||||
if (target->state != TARGET_HALTED) {
|
||||
LOG_WARNING("target %s is not halted", target->cmd_name);
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
return target->type->gdb_fileio_end(target, retcode, fileio_errno, ctrl_c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the @c examined flag for the given target.
|
||||
* Pure paranoia -- targets are zeroed on allocation.
|
||||
@@ -1151,6 +1173,12 @@ static int target_init_one(struct command_context *cmd_ctx,
|
||||
if (target->type->bulk_write_memory == NULL)
|
||||
target->type->bulk_write_memory = target_bulk_write_memory_default;
|
||||
|
||||
if (target->type->get_gdb_fileio_info == NULL)
|
||||
target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;
|
||||
|
||||
if (target->type->gdb_fileio_end == NULL)
|
||||
target->type->gdb_fileio_end = target_gdb_fileio_end_default;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
@@ -1700,6 +1728,20 @@ int target_arch_state(struct target *target)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int target_get_gdb_fileio_info_default(struct target *target,
|
||||
struct gdb_fileio_info *fileio_info)
|
||||
{
|
||||
LOG_ERROR("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
static int target_gdb_fileio_end_default(struct target *target,
|
||||
int retcode, int fileio_errno, bool ctrl_c)
|
||||
{
|
||||
LOG_ERROR("Not implemented: %s", __func__);
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/* Single aligned words are guaranteed to use 16 or 32 bit access
|
||||
* mode respectively, otherwise data is handled as quickly as
|
||||
* possible
|
||||
|
||||
Reference in New Issue
Block a user