mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-27 09:40:42 +00:00
!446 fix: hiperf侧剔除没有使用的mingw环境的mmap和munmap函数定义
Merge pull request !446 from hw_mzyan/master
This commit is contained in:
commit
b4c2223be4
@ -367,15 +367,4 @@ static inline ScopeGuard<Func> operator+(ScopeGuardOnExit, Func&& fn)
|
||||
} // namespace HiPerf
|
||||
} // namespace Developtools
|
||||
} // namespace OHOS
|
||||
|
||||
// this will also used for libunwind head (out of namespace)
|
||||
#if defined(is_mingw) && is_mingw
|
||||
#if !is_double_framework
|
||||
#define HAVE_MMAP 1
|
||||
#define MAP_PRIVATE 0x02
|
||||
void *mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset);
|
||||
int munmap(void *addr, size_t);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // HIPERF_UTILITIES_H_
|
||||
|
@ -436,7 +436,7 @@ private:
|
||||
// or both drop if build id is not same
|
||||
std::string buildIdFound = elfFile_->GetBuildId();
|
||||
std::vector<DfxSymbol> symbolsTable;
|
||||
AddSymbols(symbolsTable, elfFile_, elfPath);
|
||||
AddSymbols(symbolsTable, elfFile_, filePath_);
|
||||
if (UpdateBuildIdIfMatch(buildIdFound)) {
|
||||
UpdateSymbols(symbolsTable, elfPath);
|
||||
} else {
|
||||
|
@ -779,62 +779,3 @@ bool IsArkJsFile(const std::string& filepath)
|
||||
} // namespace HiPerf
|
||||
} // namespace Developtools
|
||||
} // namespace OHOS
|
||||
|
||||
// this will also used for libunwind head (out of namespace)
|
||||
#if defined(is_mingw) && is_mingw
|
||||
using namespace OHOS::Developtools::HiPerf;
|
||||
std::string GetLastErrorString()
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, GetLastError(), 0, (LPTSTR)&lpMsgBuf, 0, NULL);
|
||||
std::string error((LPTSTR)lpMsgBuf);
|
||||
LocalFree(lpMsgBuf);
|
||||
return error;
|
||||
}
|
||||
|
||||
void *mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset)
|
||||
{
|
||||
HANDLE FileHandle = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
|
||||
if (FileHandle == INVALID_HANDLE_VALUE) {
|
||||
return MMAP_FAILED;
|
||||
}
|
||||
|
||||
HLOGV("fd is %d", fd);
|
||||
|
||||
HANDLE FileMappingHandle = ::CreateFileMappingW(FileHandle, 0, PAGE_READONLY, 0, 0, 0);
|
||||
if (FileMappingHandle == nullptr) {
|
||||
HLOGE("CreateFileMappingW %zu Failed with %ld:%s", length, GetLastError(),
|
||||
GetLastErrorString().c_str());
|
||||
return MMAP_FAILED;
|
||||
}
|
||||
|
||||
void *mapAddr = ::MapViewOfFile(FileMappingHandle, FILE_MAP_READ, 0, 0, 0);
|
||||
if (mapAddr == nullptr) {
|
||||
HLOGE("MapViewOfFile %zu Failed with %ld:%s", length, GetLastError(),
|
||||
GetLastErrorString().c_str());
|
||||
return MMAP_FAILED;
|
||||
}
|
||||
|
||||
// Close all the handles except for the view. It will keep the other handles
|
||||
// alive.
|
||||
::CloseHandle(FileMappingHandle);
|
||||
return mapAddr;
|
||||
}
|
||||
|
||||
int munmap(void *addr, size_t)
|
||||
{
|
||||
/*
|
||||
On success, munmap() returns 0. On failure, it returns -1, and
|
||||
errno is set to indicate the error (probably to EINVAL).
|
||||
|
||||
UnmapViewOfFile function (memoryapi.h)
|
||||
|
||||
If the function succeeds, the return value is nonzero.
|
||||
If the function fails, the return value is zero. To get extended error information, call
|
||||
GetLastError.
|
||||
*/
|
||||
return !UnmapViewOfFile(addr);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user