Associate target_ops with target_fileio file descriptors
authorGary Benson <gbenson@redhat.com>
Wed, 25 Mar 2015 11:26:43 +0000 (11:26 +0000)
committerGary Benson <gbenson@redhat.com>
Wed, 25 Mar 2015 11:26:43 +0000 (11:26 +0000)
commit1c4b552ba553c4dbbb066c9ef8667209553444ca
tree0e1760a4e3082ffc5d5f63afedc05b9f879fb3d9
parentd422d1c433073ba412287334a7ec3aa95e03c5e9
Associate target_ops with target_fileio file descriptors

Various target_fileio_* functions use integer file descriptors to
refer to open files.  File operation functions are looked up from
the target stack as they are used, which causes problems if the
target stack changes after the file is opened.

For example, if a file is opened on a remote target and the remote
target disconnects or closes the remote target will be popped off
the stack.  If target_fileio_close is then called on that file and
"set auto-connect-native-target" is "on" (the default) then the
native target's close method will be called.  If the file opened
on the remote happens to share the same number with a file open in
GDB then that file will be closed by mistake.

This commit changes target_fileio_open to store newly opened file
descriptors in a table together with the target_ops used to open
them.  The index into the table is returned and used as the file
descriptor argument to all target_fileio_* functions that accept
file descriptor arguments.

gdb/ChangeLog:

* target.c (fileio_ft_t): New typedef, define object vector.
(fileio_fhandles): New static variable.
(is_closed_fileio_fh): New macro.
(lowest_closed_fd): New static variable.
(acquire_fileio_fd): New function.
(release_fileio_fd): Likewise.
(fileio_fd_to_fh): New macro.
(target_fileio_open): Wrap the file descriptor on success.
(target_fileio_pwrite): Updated to use wrapped file descriptor.
(target_fileio_pread): Likewise.
(target_fileio_close): Likewise.
gdb/ChangeLog
gdb/target.c
This page took 0.025174 seconds and 4 git commands to generate.