Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 170181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:45:45+00:00 2026-05-11T12:45:45+00:00

I’m using the driver I posted at Direct Memory Access in Linux to mmap

  • 0

I’m using the driver I posted at Direct Memory Access in Linux to mmap some physical ram into a userspace address. However, I can’t use GDB to look at any of the address; i.e., x 0x12345678 (where 0x12345678 is the return value of mmap) fails with an error ‘Cannot access memory at address 0x12345678’.

Is there any way to tell GDB that this memory can be viewed? Alternatively, is there something different I can do in the mmap (either the call or the implementation of foo_mmap there) that will allow it to access this memory?

Note that I’m not asking about /dev/mem (as in the first snippet there) but about a mmap to memory acquired via ioremap(), virt_to_phys() and remap_pfn_range()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:45:46+00:00Added an answer on May 11, 2026 at 12:45 pm

    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' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.