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

  • Home
  • SEARCH
  • 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 6662043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:53+00:00 2026-05-26T02:20:53+00:00

I have an interesting problem in one of my C++ programs. Apperantly the vtable

  • 0

I have an interesting problem in one of my C++ programs. Apperantly the vtable of one of my classes is/becomes messed up during program execution. In a gdb session I found out that if I call a method of the object directly it succeeds, but if I use a pointer or reference I end up in the destructor of a completely unrelated class which isn’t going to be instantiated anytime soon. Without the this-Pointer changing of course.

Assuming my observations are correct, how do I watch the vtable of an object in gdb? I’m on Linux using gcc, my gdb version is GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08.

  • 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-26T02:20:54+00:00Added an answer on May 26, 2026 at 2:20 am

    You can use the -fdump-class-hierarchy option of gcc which will give you the vtable information, however the output can be very verbose and hard to read.

    For instance, given the following trivial classes:

    class Base {                                                                            
        public:                                                                             
            virtual int method() = 0;                                                       
    };                                                                                      
    
    class Derived : public Base {                                                           
        public:                                                                             
            int method() {                                                                  
                return 10;                                                                  
            }                                                                               
    };  
    

    the relevant output is

    Vtable for Base
    Base::_ZTV4Base: 3u entries
    0     (int (*)(...))0
    8     (int (*)(...))(& _ZTI4Base)
    16    (int (*)(...))__cxa_pure_virtual
    
    Class Base
       size=8 align=8
       base size=8 base align=8
    Base (0x7f14c308ccc0) 0 nearly-empty
        vptr=((& Base::_ZTV4Base) + 16u)
    
    Vtable for Derived
    Derived::_ZTV7Derived: 3u entries
    0     (int (*)(...))0
    8     (int (*)(...))(& _ZTI7Derived)
    16    (int (*)(...))Derived::method
    
    Class Derived
       size=8 align=8
       base size=8 base align=8
    Derived (0x7f14c2ee7208) 0 nearly-empty
        vptr=((& Derived::_ZTV7Derived) + 16u)
      Base (0x7f14c308cd20) 0 nearly-empty
          primary-for Derived (0x7f14c2ee7208)
    

    This should give you an idea which address ranges to expect during debuggng etc.

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

Sidebar

Related Questions

I have one interesting problem. I must parse mail body (regular expression), get some
I have an interesting problem to solve. One of my clients has me developing
I have an interesting problem and would appreciate your thoughts for the best solution.
I have a very interesting problem on my LinqToSql model. On some of my
So I came across an interesting problem today. We have a WCF web service
He're an interesting problem that looks for the most Pythonic solution. Suppose I have
Greetings, currently I am refactoring one of my programs, and I found an interesting
I have an interesting problem here... <cfloop from=1 to=#form.countField# index=i> <cfif isdefined('form[semester#i#]')> <cfquery name
I have an interesting problem. I have to assign an ID to a group
I have an interesting problem and I was looking for a solution; Hoping that

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.