int dmtcp::Util::readProcMapsLine(int mapsfd, dmtcp::Util::ProcMapsArea *area) { char c, rflag, sflag, wflag, xflag; int i; unsigned int long devmajor, devminor, inodenum; VA startaddr, endaddr; c = readHex (mapsfd, &startaddr); if (c != '-') { if ((c == 0) && (startaddr == 0)) return (0); goto skipeol; } c = readHex (mapsfd, &endaddr); if (c != ' ') goto skipeol; if (endaddr < startaddr) goto skipeol; rflag = c = readChar (mapsfd); if ((c != 'r') && (c != '-')) goto skipeol; wflag = c = readChar (mapsfd); if ((c != 'w') && (c != '-')) goto skipeol; xflag = c = readChar (mapsfd); if ((c != 'x') && (c != '-')) goto skipeol; sflag = c = readChar (mapsfd); if ((c != 's') && (c != 'p')) goto skipeol; c = readChar (mapsfd); if (c != ' ') goto skipeol; c = readHex (mapsfd, (VA *)&devmajor); if (c != ' ') goto skipeol; area -> offset = (off_t)devmajor; c = readHex (mapsfd, (VA *)&devmajor); if (c != ':') goto skipeol; c = readHex (mapsfd, (VA *)&devminor); if (c != ' ') goto skipeol; c = readDec (mapsfd, (VA *)&inodenum); area -> name[0] = '\0'; while (c == ' ') c = readChar (mapsfd); if (c == '/' || c == '[') { /* absolute pathname, or [stack], [vdso], etc. */ i = 0; do { area -> name[i++] = c; if (i == sizeof area -> name) goto skipeol; c = readChar (mapsfd); } while (c != '\n'); area -> name[i] = '\0'; } if (c != '\n') goto skipeol; area -> addr = startaddr; area -> size = endaddr - startaddr; area -> endAddr = endaddr; area -> prot = 0; if (rflag == 'r') area -> prot |= PROT_READ; if (wflag == 'w') area -> prot |= PROT_WRITE; if (xflag == 'x') area -> prot |= PROT_EXEC; area -> flags = MAP_FIXED; if (sflag == 's') area -> flags |= MAP_SHARED; if (sflag == 'p') area -> flags |= MAP_PRIVATE; if (area -> name[0] == '\0') area -> flags |= MAP_ANONYMOUS; return (1); skipeol: JASSERT(false) .Text("Not Reached"); return (0); /* NOTREACHED : stop compiler warning */ }
int getDec(void) { extern text_t *dport_ptr; return readDec(dport_ptr); }