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 6552161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:25:35+00:00 2026-05-25T12:25:35+00:00

From this link gdb interpret memory address as an object we know that, if

  • 0

From this link
gdb interpret memory address as an object
we know that, if an object of class type A is at a specific address such as 0x6cf010, then we can use:

(gdb) p *(A *) 0x6cf010 

to print the member elements of this object.

However, this seems doesn’t work when c++ namespace is involved. That is, if the object of class type A::B, then all the following trying doesn’t work:

(gdb) p *(A::B *) 0x6cf010
(gdb) p *((A::B *) 0x6cf010)

So, who knows how to print the object elements under this conditions?


We can use the following deliberate core code to try to print the members of p from the address (we can use “info locals” to show the address).

#include <stdio.h>

namespace A
{
    class B
    {
    public:
        B(int a) : m_a(a) {}

        void print()
        {
            printf("m_a is %d\n", m_a);
        }

    private:
        int  m_a;
    };
}

int main()
{
    A::B *p = new A::B(100);

    p->print();

    int *q = 0;

    // Generating a core here
    *q = 0;
    return 0;

}

  • 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. Editorial Team
    Editorial Team
    2026-05-25T12:25:36+00:00Added an answer on May 25, 2026 at 12:25 pm

    Works for me:

    g++ -g test.cpp -o test
    gdb test
    (gdb) break main
    (gdb) r
    
    
    Breakpoint 1, main () at test.cpp:22
    22      A::B *p = new A::B(100);
    (gdb) n
    24      p->print();
    (gdb) n
    m_a is 100
    26      int *q = 0;
    (gdb) p p
    $1 = (A::B *) 0x602010
    (gdb) p (A::B *) 0x602010
    $2 = (A::B *) 0x602010
    (gdb) p *((A::B *) 0x602010)
    $3 = {m_a = 100}
    

    It works for me. What are you using (gcc version, OS, compilation flags?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the context of this question link text is possible from a Controller that
how to show specific tab with link from another page <a href=index.php?page=home#tab2>Home</a> this is
Branching off from this link it seems that Request.ServerVariables(SCRIPT_NAME) doesn't return anything. I've just
I have a link from that link: http://api.maxxiscentral.com/maxxiscentral/GetTyrePatterns from this link i want to
This link suggests to create an abstract base class that can read the job
I have borrowed code from this link PHP regex templating - find all occurrences
I recently downloaded an event calendar from this link: http://www.asp.net/downloads/starter-kits/club/EventCalendar.zip I want to use
following this link i was able to load and read pixels from a .gif.
I'm having this link statement: List<UserGroup> domains = UserRepository.Instance.UserIsAdminOf(currentUser.User_ID); query = (from doc in
How do other people debug HTTPS sites from Visual Studio 2008? This link seems

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.