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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:47:16+00:00 2026-06-10T18:47:16+00:00

Not sure if feasible… I am reading a large software code, and sometimes feel

  • 0

Not sure if feasible… I am reading a large software code, and sometimes feel lost when tracing how certain variable is accessed.

It would be great if there is tool/method to trace that.

More specifically, suppose I have the following class.

class A
{
  public:
    int _a;
};

...

and whenever

... = ...->_a;

during runtime, I would like to print out FILE and LINE. Thank you for the suggestion.

P.S., I could grep all “->_a” appearances, but that is also pretty hard to sort out.

  • 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-06-10T18:47:17+00:00Added an answer on June 10, 2026 at 6:47 pm

    Instead of:

    class A
    {
      public:
        int _a;
    };
    

    You could do something like this:

    #include <iostream>
    
    class Integer
    {
    public:
        Integer(int value) : value(value)
        {
        }
    
        operator int()
        {
            std::cout << "Integer called\n";
            return value;
        }
    private:
        int value;
    };
    
    class A
    {
    public:
        A() : _a(5) {}
        Integer _a;
    };
    
    int main(int argc, char *argv[])
    {
        A a;
        std::cout << a._a << std::endl;
    
        return 0;
    }
    

    Following your example:

    • Create a class and provide an operator for implicit conversion;

    • Substitute your member variable for this new class.

    The implicit conversion operator will do the work.

    It will print:

    Integer called

    5

    A tip: never let a member variable be public. Always provide an accessor method.

    Edit

    Sorry, I forgot about FILE and LINE:

    I didn’t find a way to inject LINE or FILE because the implicit cast will be done at runtime while macro substitution under preprocessing.

    What you can do it is to put a breakpoint at implicit conversion function, as pointed by @veer, and manually trace each calling.

    Edit 2

    At least it is possible to see the call stack at runtime.

    On Linux this can be done through execinfo and on Windows through StackWalker.

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

Sidebar

Related Questions

I'm not sure how to approach this or if it is even feasible. I
I'm not sure if this is feasible, but I figured I'd ask and see
I'm not sure how feasible this will be without some thirdparty libraries, but here
I'm not sure if this is feasible or not but is there a way
So this is pretty advanced and I am not sure if it is feasible
Not sure whats going on here, or what could be the integer in this
Not sure if im just being stupid or something but here goes i work
Not sure how to ask this, but i'll give it a try: I have
Not sure if this is a big deal. But wondering why when the site
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid

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.