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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:22:42+00:00 2026-06-09T21:22:42+00:00

We are developing a new interrupt system (in c++), to replace the old inconsistant

  • 0

We are developing a new interrupt system (in c++), to replace the old inconsistant one.

It works like this:

  1. A programmer who wants to make his method interruptable accepts a BreakFlag object as an argument to the method.

  2. At points during the method the programmer checks break_flag.is_set(), and exits and tidies up if it is.

We want to be able te test that all the orginal calls to break_flag.is_set() remain in the same order, after some change is made to the program. (We count multiple calls in the same loop as one call, so that two operations of different size appear to be the same)

Our first approach was to use the call stack to identify each instance. For example in the code:

void A(BreakFlag& flag) {
  flag.is_set();
  B(flag);
  C(flag);
}

void B(BreakFlag& flag) {
  flag.is_set();
  C(flag);
}

void C(BreakFlag& flag) {
  flag.is_set();
}

We would look at the call stack each time is_set is called and generate the following sequence for this method:

A
A, B
A, B, C
A, C

We could then use this to check that this sequence of checks occers every time we test the program, so that somebody could not come along and do this:

void A(BreakFlag& flag) {
flag.is_set();
B(flag);
C(flag);
}

void B(BreakFlag& flag) {
  flag.is_set();
  //C(flag); // I HAVE COMMENTED THIS OUT BECAUSE I DONT LIKE FLAG!
}

void C(BreakFlag& flag) {
  flag.is_set();
}

Because it would result in the sequence:

A
A, B
A, C

Which would not match our original.

The problem that we have, is that the compiler sometimes optomizes in such a way that the call stack changes, which causes our proposed system to register a false failed test since the call stack is not what it is expecting, even though it is correct.

We could solve it by doing something similar to the following:

#define CHECK_FLAG(x) actually_check_flag(__LINE__,__FILE__,x)

Which would allow us to essentially ID each instance in code.

Other than that we cant think of any way to ID each call to .is_set that wont change in optomized code, can you?

  • 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-09T21:22:44+00:00Added an answer on June 9, 2026 at 9:22 pm

    You can use RAII to maintain a call stack manually. On entry to each function construct a guard object:

    void B(BreakFlag& flag) {
        BreakFlagStackGuard guard(flag, "B");
        flag.is_set();
        C(flag);
    }
    

    The constructor of BreakFlagStackGuard pushes the function name "B" onto a flag.stack, while the destructor ~BreakFlagStackGuard() (which will be called when B returns) pops it.

    Whatever the compiler does to optimise it will need to respect your guard objects so you can guarantee that the observed call stack reflects the source code.

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

Sidebar

Related Questions

I'm developing a new website and I'd like to make use of AJAX as
Our team is developing a new product on the base of the old one
I'm developing a new website (ASP.Net, VB codebehind pages, .Net 3.5) to replace a
If any one want to start developing new web application with real cool and
i'm developing a new site and i have this situation: - Products \_ Category1
I'm developing a new application which is based on a legacy database. The old
(I just finished developing my new site and I am testing if it works
I'm new developing android and web apps, I would like to know if is
I'm developing new web app with Struts2 framework, eclipse, and I've mapped the db
I am developing a new site in ColdFusion 10 and doing some url rewriting

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.