-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improving debuggee memory I/O by using direct calls instead of the QF…
…ile abstraction new code is simpler and more efficient since it doens't need to seek before reading/writing instead it just uses pread/pwrite which have existed for a long time now.
- Loading branch information
Showing
4 changed files
with
89 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright (C) 2024 - 2024 Evan Teran | ||
[email protected] | ||
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 2 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 PLATFORM_FILE_H_20150517_ | ||
#define PLATFORM_FILE_H_20150517_ | ||
|
||
#include <fcntl.h> | ||
#include <string> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
namespace DebuggerCorePlugin { | ||
|
||
class PlatformFile { | ||
public: | ||
explicit PlatformFile(const char *filename, int flags = O_RDWR) { | ||
fd_ = ::open(filename, flags); | ||
} | ||
|
||
~PlatformFile() { | ||
::close(fd_); | ||
} | ||
|
||
ssize_t writeAt(const void *buf, size_t count, off_t offset) { | ||
return ::pwrite(fd_, buf, count, offset); | ||
} | ||
|
||
ssize_t readAt(void *buf, size_t count, off_t offset) { | ||
return ::pread(fd_, buf, count, offset); | ||
} | ||
|
||
explicit operator bool() { | ||
return fd_ != -1; | ||
} | ||
|
||
private: | ||
int fd_ = -1; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters