!446 fix: hiperf侧剔除没有使用的mingw环境的mmap和munmap函数定义

Merge pull request !446 from hw_mzyan/master
This commit is contained in:
openharmony_ci 2024-03-01 07:16:56 +00:00 committed by Gitee
commit b4c2223be4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 1 additions and 71 deletions

View File

@ -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_

View File

@ -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 {

View File

@ -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