Skip to content
Snippets Groups Projects
Commit 7137d1f4 authored by Duc Ta's avatar Duc Ta
Browse files

Merge branch '21.0-ATEAM-963' into '21.0'

CxxUtils: Apply procmaps fixes to 21.0

See merge request atlas/athena!69486
// dear emacs, this is -*- C++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#ifndef PROCMAPS_H
#define PROCMAPS_H 1
#include <boost/pool/pool_alloc.hpp>
#include <vector>
#include <string>
#include <sys/types.h>
/** @class procmaps
* @brief A simple API to access /proc/self/maps info
*
......@@ -26,8 +28,8 @@ public:
bool isPrivate; ///=true page is private(COW), =false page is shared
unsigned int offset;
unsigned int dev[2]; /// dev[0] major, dev[1] minor
unsigned int inode;
char pathname[32]; ///truncated if needed
ino_t inode;
std::string pathname;
};
procmaps(size_t entries=1024);
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include <algorithm>
......@@ -15,20 +15,23 @@ procmaps::Entry::Entry(const char* procMapsLine) :
offset(0), inode(0)
{
dev[0]=0; dev[1]=0;
memset(pathname,' ',31);
char pageProts[5];
memset(pageProts,' ', 4);
uint64_t inode_tmp;
char path[2048] = "";
sscanf(procMapsLine,
"%80lx-%80lx %4s %80x %2x:%2x %80x %31s",
"%80lx-%80lx %4s %80x %4x:%4x %80lu %2047s",
&this->begAddress,
&this->endAddress,
pageProts,
&this->offset,
&this->dev[0],
&this->dev[1],
&this->inode,
this->pathname
&inode_tmp,
path
);
this->inode = inode_tmp;
this->pathname = std::string (path);
//printf("pageProts %s pathname <%s> \n", pageProts, pathname);
this->readable = (pageProts[0] == 'r');
this->writable = (pageProts[1] == 'w');
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#undef NDEBUG
#include <cassert>
#include <iostream>
#include <fstream>
#include <boost/pool/pool_alloc.hpp>
#include "CxxUtils/procmaps.h"
//#define DEBUGIT 1
......@@ -29,7 +30,29 @@ int main(void) {
assert(pCodeEntry->executable);
assert(pCodeEntry->readable);
assert(!pCodeEntry->writable);
assert(0 != pCodeEntry->inode);
//assert(0 != pCodeEntry->inode);
if (0 == pCodeEntry->inode) {
printf ("Test fail: null inode %0lx-%0lx %u %u %u %u %u %u %u %lu %s\n",
pCodeEntry->begAddress,
pCodeEntry->endAddress,
pCodeEntry->readable,
pCodeEntry->writable,
pCodeEntry->executable,
pCodeEntry->isPrivate,
pCodeEntry->offset,
pCodeEntry->dev[0],
pCodeEntry->dev[1],
static_cast<unsigned long>(pCodeEntry->inode),
pCodeEntry->pathname.c_str());
fflush (stdout);
std::ifstream f("/proc/self/maps");
const int LMAX=256;
char line[LMAX];
while ( f.getline(line,LMAX) ) {
printf("%s\n",line);
}
std::abort();
}
//now with a heap page
int* pi= new int(2);
const procmaps::Entry* pHeapEntry(pmaps.getEntry(pi));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment