Sponsored Content
Top Forums Programming finding stack location in C using program Post 302093614 by Corona688 on Friday 20th of October 2006 11:04:48 PM
Old 10-21-2006
If the general area will do, you can just take the address of a local variable.

If you want the stack pointer itself, you can get that through assembly language.

If you need the top of it, on my system at least, it counts down from one system page less than the highest address.

Depending on your system, you might be able to see the memory arrangement by processing /proc/<processid>/maps.
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

get stack trace from C program on Solaris 8

I'm on solaris 8. I need to check the stack trace inside my C program. I don't have printstack or walkstack. I tested getcontext and it works. But how do I get the symbols from "stack_t" ? Help please. Many thanks! (4 Replies)
Discussion started by: rydahl
4 Replies

2. UNIX for Dummies Questions & Answers

Finding files in subdirectories from one location

Using ssh, is there a simple command to find files in subdirectories from, let's say, the home directory on a shared server? (2 Replies)
Discussion started by: endl
2 Replies

3. Programming

access variable through program stack

I am working on garbage collector in C? How should :confused: I find the part of heap where the variable are stored. It there any compiler (GCC) support for this. (2 Replies)
Discussion started by: amit gangarade
2 Replies

4. Shell Programming and Scripting

Finding a word at specific location in a string

Hi All , I have different strings (SQL queries infact) of different lengths such as: 1. "SELECT XYZ FROM ABC WHERE ABC.DEF='123' " 2. "DELETE FROM ABC WHERE ABC.DEF='567'" 3. "SELECT * FROM ABC" I need to find out the word coming after the... (1 Reply)
Discussion started by: swapnil.nawale
1 Replies

5. UNIX for Advanced & Expert Users

Finding register set being used in program

How can i find( or list) contents of all registers being used by my program? Is there any system call or library available for this?:confused: At runtime in my c/c++ program. At runtime using may be some assembly hack!!!!!!!!!!! (2 Replies)
Discussion started by: amit gangarade
2 Replies

6. UNIX for Dummies Questions & Answers

finding my location in a string

I'm a relative newbie and apologize if this is silly... Suppose I have a file with English words and their Spanish translations. I read them in like this: while(getline < myfile > 0) { eng = $1 SPAN = $2 } Now, for every eng in SPAN, I want to scan through SPAN and search for a... (2 Replies)
Discussion started by: DrLeeDetroit
2 Replies

7. Programming

Finding the path of the C program

Hi All, I have a c program called findPath.c in a path /home/harsh/c-Programs/. How can i find the path where the program is stored at runtime?? I have given the following #include<stdio.h> int main() { system("dirname $0"); return 0; } This is resulting in the output as . <single dot... (6 Replies)
Discussion started by: sreeharshasn
6 Replies

8. UNIX for Dummies Questions & Answers

program location

Hello all, one of application on system requires that "uname" program is in "/usr/uname" location. I can find uname in "/usr/bin/uname" location. Is it possible to present the /usr/bin/uname as that it was located in /usr/uname location? Thank you in advanced, M (1 Reply)
Discussion started by: kreno
1 Replies

9. Programming

How to read max stack size -Xss that is set/default for a java program?

I need to know what is the maximum stack size i.e. -Xss my java program is running with. Is there a way to find that out from inside my java program code and outside of it. What i am looking for is to read whatever the current set max limit -Xss (stack sie) is for a particular JVM(not... (3 Replies)
Discussion started by: mohtashims
3 Replies

10. UNIX Desktop Questions & Answers

Knowing the size and location of variables in a C program

So I need some help with this. Pardon me if I'm posting in the wrong forum, after some googling for my answer and finding nothing I found this forum. It seemed appropriate for what I was seeking. I just didnt find a forum that concerned the use of GDB. I'm learning to use the C language and GDB.... (2 Replies)
Discussion started by: Cambria
2 Replies
PTHREAD_ATTR_SETSTACKADDR(3)				     Linux Programmer's Manual				      PTHREAD_ATTR_SETSTACKADDR(3)

NAME
pthread_attr_setstackaddr, pthread_attr_getstackaddr - set/get stack address attribute in thread attributes object SYNOPSIS
#include <pthread.h> int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr); int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr); Compile and link with -pthread. DESCRIPTION
These functions are obsolete: do not use them. Use pthread_attr_setstack(3) and pthread_attr_getstack(3) instead. The pthread_attr_setstackaddr() function sets the stack address attribute of the thread attributes object referred to by attr to the value specified in stackaddr. This attribute specifies the location of the stack that should be used by a thread that is created using the thread attributes object attr. stackaddr should point to a buffer of at least PTHREAD_STACK_MIN bytes that was allocated by the caller. The pages of the allocated buffer should be both readable and writable. The pthread_attr_getstackaddr() function returns the stack address attribute of the thread attributes object referred to by attr in the buffer pointed to by stackaddr. RETURN VALUE
On success, these functions return 0; on error, they return a nonzero error number. ERRORS
No errors are defined (but applications should nevertheless handle a possible error return). VERSIONS
These functions are provided by glibc since version 2.1. CONFORMING TO
POSIX.1-2001 specifies these functions but marks them as obsolete. POSIX.1-2008 removes the specification of these functions. NOTES
Do not use these functions! They cannot be portably used, since they provide no way of specifying the direction of growth or the range of the stack. For example, on architectures with a stack that grows downward, stackaddr specifies the next address past the highest address of the allocated stack area. However, on architectures with a stack that grows upward, stackaddr specifies the lowest address in the allo- cated stack area. By contrast, the stackaddr used by pthread_attr_setstack(3) and pthread_attr_getstack(3), is always a pointer to the lowest address in the allocated stack area (and the stacksize argument specifies the range of the stack). SEE ALSO
pthread_attr_init(3), pthread_attr_setstack(3), pthread_attr_setstacksize(3), pthread_create(3), pthreads(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-10-24 PTHREAD_ATTR_SETSTACKADDR(3)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy