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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:06:36+00:00 2026-05-15T21:06:36+00:00

GNU libc’s backtrace and In-circuit emulators/debuggers are not always available when porting code to

  • 0

GNU libc’s backtrace and In-circuit emulators/debuggers are not always available when porting code to a new platform, especially when the target is a micro C compiler such as for the Z80. (Typically a program bug would “just hang” somewhere, or crash the gadget.)

Is there an alternative to the classic “wolf fencing” method of manually inserting printf? Something simple and portable (using no C extensions) that a coder can do while developing a program that includes tracing and backtracing into a C program?

BTW: Here are a couple of other question on stackoverflow that are related, but these both use GNU GLIBC’s backtrace and backtrace is often compiler/implementation specific:

  • Is there a function to invoke a stack dump in C?
  • How to generate a stacktrace when my gcc C++ app crashes
  • 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-15T21:06:37+00:00Added an answer on May 15, 2026 at 9:06 pm

    There is an implementation at RosettaCode.org which uses the same basic idea as @jsl4tv’s suggestion.

    Example, given the following classic C code with built in “hang“:

    #include <stdio.h>
    #include <stdlib.h>
    
    void inner(int k)
    {
       for(;;){} /* hang */
    }
    
    void middle(int x, int y)
    {
      inner(x*y);
    }
    
    void outer(int a, int b, int c)
    {
      middle(a+b, b+c);
    }
    
    int main()
    {
      outer(2,3,5);
      return(EXIT_SUCCESS);
    }
    

    #define STACK_TRACE_ON and #include “stack_trace.h” from RosettaCode.org then insert BEGIN(f)/ENDs where required:

    #include <stdio.h>
    #include <stdlib.h>
    
    #define STACK_TRACE_ON /* compile in these "stack_trace" routines */
    #include "stack_trace.h"
    
    void inner(int k)
    BEGIN(inner)
       print_indent(); printf("*** Now dump the stack ***\n");
       print_stack_trace();
       for(;;){} /* hang */
    END
    
    void middle(int x, int y)
    BEGIN(middle)
      inner(x*y);
    END
    
    void outer(int a, int b, int c)
    BEGIN(outer)
      middle(a+b, b+c);
    END
    
    int main()
    BEGIN(main)
      stack_trace.on = TRUE; /* turn on runtime tracing */
      outer(2,3,5);
      stack_trace.on = FALSE;
      RETURN(EXIT_SUCCESS);
    END
    

    Produces:

    stack_trace_test.c:19: BEGIN outer[0x80487b4], stack(depth:1, size:60)
    stack_trace_test.c:14:   BEGIN middle[0x8048749], stack(depth:2, size:108)
    stack_trace_test.c:8:     BEGIN inner[0x80486d8], stack(depth:3, size:156)
    stack_trace_test.c:8:       *** Now dump the stack ***
    stack_trace_test.c:8:   inner[0x80486d8]        --- stack(depth:4, size:156) ---
    stack_trace_test.c:14:  middle[0x8048749]       --- stack(depth:3, size:108) ---
    stack_trace_test.c:19:  outer[0x80487b4]        --- stack(depth:2, size:60) ---
    stack_trace_test.c:24:  main[0x804882a] --- stack(depth:1, size:0) ---
    stack_trace_test.c:8:       --- (depth 4) ---
    

    A well polished [open source] version of this BEGIN ~ END method would be perfect. (Esp if it has a “FINALLY” clause for exception handling).

    Hints/URLs appreciated.

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

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • 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 As in all statistics your answer will depend on what… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer Your C#/VB.NET/... code is compiled to MSIL (CIL) The MSIL… May 16, 2026 at 3:29 pm
  • Editorial Team
    Editorial Team added an answer When you add the following mapping: routes.MapRoute("hierarchy", "{action}/{*url}" new {… May 16, 2026 at 3:29 pm

Trending Tags

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

Top Members

Related Questions

I am stuck with a fairly complex Python module that does not return useful
GNU Emacs on Mac OS X, by default, uses the control key as CTRL
Is GNU gettext built in into Wordpress or do I have to download it
Despite attempts to master grep and related GNU software, I haven't come close to
I have inherited a pure C project that uses GNU Pth ( http://www.gnu.org/software/pth/ )
I am trying to come up with a GNU extended regular expression that detects
I have a question about the C++ visibility attribute. I have read http://gcc.gnu.org/wiki/Visibility and
Notice these two RedHat Linux system configuration settings: $ getconf GNU_LIBC_VERSION glibc 2.3.4 $
Is it possible to count how many times a substring appears in a string
Inside my atexit() registered function I would like to get the exit status (either

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.