reading Memory-Mapped IO registers How to (from datasheet) and using them in mmap
in kernel function iomem_is_exclusive check IS_ENABLED(CONFIG_IO_STRICT_DEVMEM) or IORESOURCE_EXCLUSIVE flag is set:
if (IS_ENABLED(CONFIG_IO_STRICT_DEVMEM)
|| p->flags & IORESOURCE_EXCLUSIVE) {
err = true;
break;
}
we can simply use stap to pass through the check for test:
stap -g -e 'probe kernel.function("iomem_is_exclusive").return { $return = 0 }'
Examining mmaped addresses using GDB
I believe Linux does not make I/O memory accessible via ptrace(). You could write a function that simply reads the mmap'ed address and have gdb invoke it. Here's a slightly modified version of your foo-user.c program along with the output from a gdb session.
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/mman.h>
char *mptr;
char peek(int offset)
{
return mptr[offset];
}
int main(void)
{
int fd;
fd = open("/dev/foo", O_RDWR | O_SYNC);
if (fd == -1) {
printf("open error...\n");
return 1;
}
mptr = mmap(0, 1 * 1024 * 1024, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, 4096);
printf("On start, mptr points to 0x%lX.\n", (unsigned long) mptr);
printf("mptr points to 0x%lX. *mptr = 0x%X\n", (unsigned long) mptr,
*mptr);
mptr[0] = 'a';
mptr[1] = 'b';
printf("mptr points to 0x%lX. *mptr = 0x%X\n", (unsigned long) mptr,
*mptr);
close(fd);
return 0;
}
$ make foo-user CFLAGS=-g
$ gdb -q foo-user
(gdb) break 27
Breakpoint 1 at 0x804855f: file foo-user.c, line 27.
(gdb) run
Starting program: /home/me/foo/foo-user
On start, mptr points to 0xB7E1E000.
mptr points to 0xB7E1E000. *mptr = 0x61
Breakpoint 1, main () at foo-user.c:27
27 mptr[0] = 'a';
(gdb) n
28 mptr[1] = 'b';
(gdb) print peek(0)
$1 = 97 'a'
(gdb) print peek(1)
$2 = 98 'b'
python mmap.error: Too many open files. What's wrong?
My guess is that the mmap.mmap call in pupynere is holding the file descriptor open (or creating a new one). What if you do this:
vals.append(curData.variables['O3.MIXING.RATIO'][:].copy())
alts.append(curData.variables['ALTITUDE'][:].copy())
Related Topics
How to Schedule a Cron Job to Run 4Th Week of the Year
How to Do Like "Netstat -P", But Faster
Linux Randomly Deleted My File While Compiling What Do I Do
Git Shows Random Files Changed on MAC Nfs Filesystem
Why Ln -Sf Does Not Overwrite Existing Link to Directory
How to Not Emit Local Symbols in Nasm So That Gdb Disas Won't Stop at Them
Linux Equivalent of Windows Dll Forwarders or MACos Reexport_Library
Glassfish There Is a Process Already Using the Admin Port 4848
Why This Bash Function Prints Only First Word of Whole String
Removing of Specific Line in Text File
Grep for String and Open at the Corresponding Line
Linking to Modules Folder Gives Undefined Reference
How to Install Asp on Linux Ubuntu Hardy
Delete Files with Backslash in Linux
Linux C Socket: Blocked on Recv Call