Thread: Viewing stack frames

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    9

    Viewing stack frames

    "Write a program that includes a memory introspection function view stack frame(), printing out the stack frame of caller functions. you may assume that all variables inside the callers’ stack frames are all of the same type, although their number may vary. The function displays output organized in two columns, the first displaying addresses of variables while the second displays their corresponding values. Symbolic identifiers do not feature."

    I am stuck on this question again, I am imagining a program that has a couple of functions and in each function there is a local variable and value assigned to the variable AND these functions are being called in the main function. Now how do I fetch the address of the functions? How do I use backtrace??



    • #include <execinfo.h>
      #include <stdio.h>
      #include <stdlib.h>

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,616
    Which OS?
    Which compiler?
    Which processor type?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2017
    Posts
    9
    Windows 10, MinGW-W64 compiler. What do you mean by processer type?

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by jonathan123456 View Post
    What do you mean by processer type?
    He means what architecture. Is it x86, ARM, PowerPC? 32 or 64-bit? Things of that nature.
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Nov 2017
    Posts
    9
    x86_64

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,616
    So did you read your previous replies?
    C programming homework

    Code:
    void foo ( ) {
      int a = 42;
      int *pa = &a;
    }
    At this point, you now have a 'stack pointer'.

    Assuming your stack grows down, incrementing this pointer allows you to 'walk the stack'.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sdi? Mdi? Frames?
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-16-2006, 08:05 PM
  2. constructing frames...
    By Devil Panther in forum Networking/Device Communication
    Replies: 20
    Last Post: 08-09-2004, 12:34 PM
  3. Emacs frames
    By frenchfry164 in forum Tech Board
    Replies: 2
    Last Post: 12-28-2003, 02:04 PM
  4. HTML frames
    By Monster in forum Tech Board
    Replies: 3
    Last Post: 08-23-2002, 02:02 AM
  5. Getting the FPS (Frames Per Second)
    By Unregistered in forum Game Programming
    Replies: 12
    Last Post: 05-05-2002, 10:58 AM

Tags for this Thread