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

Ask A Question

Stats

  • Questions 157k
  • Answers 157k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't rely on auto generated exceptions across service boundaries! Do… May 12, 2026 at 11:08 am
  • Editorial Team
    Editorial Team added an answer Finally I've got it. It seems that I just didn't… May 12, 2026 at 11:08 am
  • Editorial Team
    Editorial Team added an answer There are many: http://www.jppf.org/ https://jxta.dev.java.net/ https://java.net/projects/cajo/pages/Home http://www.dmoz.org/Computers/Programming/Languages/Java/Class_Libraries/Networking_and_Distributed_Computing/ Google is your… May 12, 2026 at 11:08 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.