Differential D38165 Diff 118368 www/qt5-webengine/files/patch-src_3rdparty_chromium_base_debug_proc__maps__linux.cc
Changeset View
Changeset View
Standalone View
Standalone View
www/qt5-webengine/files/patch-src_3rdparty_chromium_base_debug_proc__maps__linux.cc
--- src/3rdparty/chromium/base/debug/proc_maps_linux.cc.orig 2020-11-07 01:22:36 UTC | --- src/3rdparty/chromium/base/debug/proc_maps_linux.cc.orig 2021-12-15 16:12:54 UTC | ||||
+++ src/3rdparty/chromium/base/debug/proc_maps_linux.cc | +++ src/3rdparty/chromium/base/debug/proc_maps_linux.cc | ||||
@@ -12,7 +12,7 @@ | @@ -13,7 +13,7 @@ | ||||
#include "base/strings/string_split.h" | #include "base/strings/string_split.h" | ||||
#include "build/build_config.h" | #include "build/build_config.h" | ||||
-#if defined(OS_LINUX) || defined(OS_ANDROID) | -#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) | ||||
+#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_ANDROID) | +#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_BSD) | ||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#endif | #endif | ||||
@@ -28,6 +28,11 @@ | @@ -29,6 +29,11 @@ namespace debug { | ||||
namespace base { | namespace base { | ||||
namespace debug { | namespace debug { | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+const char kProcSelfMapsPath[] = "/proc/curproc/map"; | +const char kProcSelfMapsPath[] = "/proc/curproc/map"; | ||||
+#else | +#else | ||||
+const char kProcSelfMapsPath[] = "/proc/self/maps"; | +const char kProcSelfMapsPath[] = "/proc/self/maps"; | ||||
+ | + | ||||
// Scans |proc_maps| starting from |pos| returning true if the gate VMA was | // Scans |proc_maps| starting from |pos| returning true if the gate VMA was | ||||
// found, otherwise returns false. | // found, otherwise returns false. | ||||
static bool ContainsGateVMA(std::string* proc_maps, size_t pos) { | static bool ContainsGateVMA(std::string* proc_maps, size_t pos) { | ||||
@@ -43,15 +48,16 @@ static bool ContainsGateVMA(std::string* proc_maps, si | @@ -44,15 +49,16 @@ static bool ContainsGateVMA(std::string* proc_maps, si | ||||
return false; | return false; | ||||
#endif | #endif | ||||
} | } | ||||
+#endif | +#endif | ||||
bool ReadProcMaps(std::string* proc_maps) { | bool ReadProcMaps(std::string* proc_maps) { | ||||
// seq_file only writes out a page-sized amount on each call. Refer to header | // seq_file only writes out a page-sized amount on each call. Refer to header | ||||
// file for details. | // file for details. | ||||
const long kReadSize = sysconf(_SC_PAGESIZE); | const long kReadSize = sysconf(_SC_PAGESIZE); | ||||
- base::ScopedFD fd(HANDLE_EINTR(open("/proc/self/maps", O_RDONLY))); | - base::ScopedFD fd(HANDLE_EINTR(open("/proc/self/maps", O_RDONLY))); | ||||
+ base::ScopedFD fd(HANDLE_EINTR(open(kProcSelfMapsPath, O_RDONLY))); | + base::ScopedFD fd(HANDLE_EINTR(open(kProcSelfMapsPath, O_RDONLY))); | ||||
if (!fd.is_valid()) { | if (!fd.is_valid()) { | ||||
- DPLOG(ERROR) << "Couldn't open /proc/self/maps"; | - DPLOG(ERROR) << "Couldn't open /proc/self/maps"; | ||||
+ DPLOG(ERROR) << "Couldn't open " << kProcSelfMapsPath; | + DPLOG(ERROR) << "Couldn't open " << kProcSelfMapsPath; | ||||
return false; | return false; | ||||
} | } | ||||
proc_maps->clear(); | proc_maps->clear(); | ||||
@@ -65,7 +71,7 @@ bool ReadProcMaps(std::string* proc_maps) { | @@ -66,7 +72,7 @@ bool ReadProcMaps(std::string* proc_maps) { | ||||
ssize_t bytes_read = HANDLE_EINTR(read(fd.get(), buffer, kReadSize)); | ssize_t bytes_read = HANDLE_EINTR(read(fd.get(), buffer, kReadSize)); | ||||
if (bytes_read < 0) { | if (bytes_read < 0) { | ||||
- DPLOG(ERROR) << "Couldn't read /proc/self/maps"; | - DPLOG(ERROR) << "Couldn't read /proc/self/maps"; | ||||
+ DPLOG(ERROR) << "Couldn't read " << kProcSelfMapsPath; | + DPLOG(ERROR) << "Couldn't read " << kProcSelfMapsPath; | ||||
proc_maps->clear(); | proc_maps->clear(); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -76,6 +82,7 @@ bool ReadProcMaps(std::string* proc_maps) { | @@ -77,6 +83,7 @@ bool ReadProcMaps(std::string* proc_maps) { | ||||
if (bytes_read == 0) | if (bytes_read == 0) | ||||
break; | break; | ||||
+#if !defined(OS_BSD) | +#if !defined(OS_BSD) | ||||
// The gate VMA is handled as a special case after seq_file has finished | // The gate VMA is handled as a special case after seq_file has finished | ||||
// iterating through all entries in the virtual memory table. | // iterating through all entries in the virtual memory table. | ||||
// | // | ||||
@@ -86,6 +93,7 @@ bool ReadProcMaps(std::string* proc_maps) { | @@ -87,6 +94,7 @@ bool ReadProcMaps(std::string* proc_maps) { | ||||
// Avoid this by searching for the gate VMA and breaking early. | // Avoid this by searching for the gate VMA and breaking early. | ||||
if (ContainsGateVMA(proc_maps, pos)) | if (ContainsGateVMA(proc_maps, pos)) | ||||
break; | break; | ||||
+#endif | +#endif | ||||
} | } | ||||
return true; | return true; | ||||
@@ -114,10 +122,32 @@ bool ParseProcMaps(const std::string& input, | @@ -115,10 +123,32 @@ bool ParseProcMaps(const std::string& input, | ||||
MappedMemoryRegion region; | MappedMemoryRegion region; | ||||
const char* line = lines[i].c_str(); | const char* line = lines[i].c_str(); | ||||
char permissions[5] = {'\0'}; // Ensure NUL-terminated string. | char permissions[5] = {'\0'}; // Ensure NUL-terminated string. | ||||
+ int path_index = 0; | + int path_index = 0; | ||||
+ | + | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ if (lines[i].empty()) | + if (lines[i].empty()) | ||||
+ continue; | + continue; | ||||
Show All 17 Lines | |||||
+#else | +#else | ||||
uint8_t dev_major = 0; | uint8_t dev_major = 0; | ||||
uint8_t dev_minor = 0; | uint8_t dev_minor = 0; | ||||
long inode = 0; | long inode = 0; | ||||
- int path_index = 0; | - int path_index = 0; | ||||
// Sample format from man 5 proc: | // Sample format from man 5 proc: | ||||
// | // | ||||
@@ -133,6 +163,7 @@ bool ParseProcMaps(const std::string& input, | @@ -134,6 +164,7 @@ bool ParseProcMaps(const std::string& input, | ||||
DPLOG(WARNING) << "sscanf failed for line: " << line; | DPLOG(WARNING) << "sscanf failed for line: " << line; | ||||
return false; | return false; | ||||
} | } | ||||
+#endif | +#endif | ||||
region.permissions = 0; | region.permissions = 0; | ||||
@@ -151,14 +182,31 @@ bool ParseProcMaps(const std::string& input, | @@ -152,14 +183,31 @@ bool ParseProcMaps(const std::string& input, | ||||
else if (permissions[2] != '-') | else if (permissions[2] != '-') | ||||
return false; | return false; | ||||
+#if defined(OS_BSD) | +#if defined(OS_BSD) | ||||
+ if (cow == 'C') { | + if (cow == 'C') { | ||||
+ region.permissions |= MappedMemoryRegion::PRIVATE; | + region.permissions |= MappedMemoryRegion::PRIVATE; | ||||
+ } else if (cow != 'N') { | + } else if (cow != 'N') { | ||||
+ DPLOG(WARNING) << "unknown value for COW in line " << line << ": " << cow; | + DPLOG(WARNING) << "unknown value for COW in line " << line << ": " << cow; | ||||
Show All 23 Lines |