mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-23 07:29:42 +00:00
!213 keep kptr_restrict unchanged
Merge pull request !213 from zhangcui/master
This commit is contained in:
commit
a436cce44b
@ -193,9 +193,12 @@ class GetLibFiles(object):
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
if self.hdc.switch_root():
|
||||
oldKptrRestrict = os.popen('hdc shell cat /proc/sys/kernel/kptr_restrict').read()
|
||||
self.hdc.run_hdc_cmd(['shell',
|
||||
'"echo 0 >/proc/sys/kernel/kptr_restrict"'])
|
||||
self.hdc.run_hdc_cmd(['file recv', '/proc/kallsyms', file_path])
|
||||
self.hdc.run_hdc_cmd(['shell',
|
||||
'"echo ' + oldKptrRestrict[0] + ' >/proc/sys/kernel/kptr_restrict"'])
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -949,10 +949,12 @@ public:
|
||||
printf("No vmlinux path is given, and kallsyms cannot be opened\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ReadFileToString(KPTR_RESTRICT).front() != '0') {
|
||||
bool hasChangeKptr = false;
|
||||
std::string oldKptrRestrict = ReadFileToString(KPTR_RESTRICT);
|
||||
if (oldKptrRestrict.front() != '0') {
|
||||
printf("/proc/sys/kernel/kptr_restrict is NOT 0, will try set it to 0.\n");
|
||||
if (!WriteStringToFile(KPTR_RESTRICT, "0")) {
|
||||
hasChangeKptr = WriteStringToFile(KPTR_RESTRICT, "0");
|
||||
if (!hasChangeKptr) {
|
||||
printf("/proc/sys/kernel/kptr_restrict write failed and we can't not change it.\n");
|
||||
}
|
||||
}
|
||||
@ -962,6 +964,12 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasChangeKptr) {
|
||||
if (!WriteStringToFile(KPTR_RESTRICT, oldKptrRestrict)) {
|
||||
printf("recover /proc/sys/kernel/kptr_restrict fail.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (symbols_.empty()) {
|
||||
printf("The symbol table addresses in /proc/kallsyms are all 0.\n"
|
||||
"Please check the value of /proc/sys/kernel/kptr_restrict, it "
|
||||
|
@ -277,11 +277,7 @@ HWTEST_F(SymbolsFileTest, LoadKernelSymbols, TestSize.Level1)
|
||||
ASSERT_EQ(symbolsFile->LoadSymbols(), true);
|
||||
|
||||
const std::vector<Symbol> &symbols = symbolsFile->GetSymbols();
|
||||
if (KptrRestrict()) {
|
||||
EXPECT_EQ(symbols.empty(), true);
|
||||
} else {
|
||||
EXPECT_EQ(symbols.empty(), false);
|
||||
}
|
||||
EXPECT_EQ(symbols.empty(), false);
|
||||
|
||||
std::string modulesMap = ReadFileToString("/proc/modules");
|
||||
int lines = std::count(modulesMap.begin(), modulesMap.end(), '\n');
|
||||
|
Loading…
Reference in New Issue
Block a user