473,419 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

How can i read the stack frames of running process?

Hi all,

Can we read the stack frame's of the current process.
as we know that whenever a function call is made in c new functions
stack frame
is created and pushed on to the stack. and when the function returns
it is popped out from the stack. i want to know the caller functions
name.

i mean i want something like this

int a()
{
printf("File = %s\n",__FILE__);
/* i want to print the callers name over here. something like this
printf("Caller function = %s\n",__CALLER_FUN__); it should print
b*/
return 0;
}

int b()
{
a();
return 0;
}

int main()
{
b();
}

if there is any way please tell me.

Thanks and Regards
Harshal Shete

Oct 17 '07
60 4803
On Mon, 22 Oct 2007 12:25:56 -0400, in comp.lang.c , Ernie Wright
<er****@comcast.netwrote:
>Mark McIntyre wrote:
>On Sun, 21 Oct 2007 11:00:37 -0400, in comp.lang.c , Ernie Wright
<er****@comcast.netwrote:
>>>Mark McIntyre wrote:

There is no intrinsic reason (other than ludditism) to distrust
either search facility.

It's not clear to me what you mean by "instrinsic" here.

intrinsic as in built in?

Well, yeah, but as opposed to what?
Sorry, but I pretty much assumed my audience could read english. Not
trying to be offensive, but I have no intention of defining what an
intrinsic property is.
>This falls under the heading of "ludditism"... :-)

Or Luddism, even. You say that like it's a bad thing.
From Wikipedia: An official announcement, 12th February 1811 "Any
person who breaks or destroys machinery in any mill used in the
preparing or spinning of wool or cotton or other material for the use
of the stocking or lace manufacture, on being lawfully convicted
.....shall suffer death."

Seems pretty bad to me...
>While there are different reasons why the plaintext search might fail.

There's no symmetry here. There are *more* reasons that a PDF search
might fail.
I disagree. There are *different* reasons.
>What, for example, do you think is going on in this search:

http://home.comcast.net/~erniew/images/pdfsearch.gif
*shrug*
Probably there's an embedded n-dash sized space in "angle".
Plaintext searches can and do fail for similar reasons - I've seen
searches fail because of embedded (invisible) characters outside the
range 32-127.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 22 '07 #51
On Mon, 22 Oct 2007 05:38:50 +0000 (UTC), in comp.lang.c , $)CHarald
van D)&k <tr*****@gmail.comwrote:
>The problem with the spellings in this thread was that you can't search
for __func__ and find where it's referenced. (Or more accurately, that
you can't search for __FUNCTION__ to find that it's not referenced.)
Perhaps not - but you can search for UNCTI, which is highly likely to
be unique.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 22 '07 #52
Mark McIntyre wrote:
On Sat, 20 Oct 2007 18:09:04 -0400, in comp.lang.c , CBFalconer
<cb********@yahoo.comwrote:
>>No, you misinterpret my comment. The point is that PDF searches
can only be done by a PDF reader. With text you have a choice,
such as grep, a text editor, or any other piece of text handling
software on your system. So you can suit your search methods to
software familiar to you.

Why would anyone under the age of 30 be familiar with arcane stuff
like grep?
People who read C Standards are not likely to be a "Joe" user,
notwithstanding their age.

<snip>

Oct 22 '07 #53
CBFalconer <cb********@yahoo.comwrites:
$)CHarald van D)&k wrote:
>Keith Thompson wrote:
>>As far as I can tell, it has not yet been established that, for
example, n1256.pdf contains any incorrect spellings.

From n869.txt, from the foreword:
-- __func__ predefined identifier

From n1256.pdf:
â

” _ _func_ _
predeï¬
identiï¬
Oct 23 '07 #54
Mark McIntyre <ma**********@spamcop.netwrote:
On Mon, 22 Oct 2007 05:38:50 +0000 (UTC), in comp.lang.c , $)CHarald
van D)&k <tr*****@gmail.comwrote:
The problem with the spellings in this thread was that you can't search
for __func__ and find where it's referenced. (Or more accurately, that
you can't search for __FUNCTION__ to find that it's not referenced.)

Perhaps not - but you can search for UNCTI, which is highly likely to
be unique.
Or you could - perhaps? revolutionary idea, I know - check the index.
I know that this is the C Standard we're talking about, not the Perl...
erm... lack of any standard, but there _is_ more than one way to do it.

Richard
Oct 23 '07 #55
Ben Bacarisse wrote:
CBFalconer <cb********@yahoo.comwrites:
.... snip ...
>
>The blanks between '_' chars are an effect of the font used. The
other anomaly is due to the use of some peculiar character to
represent the sequence 'fi'. So there are no incorrect spelling
identified, but one more of the penalties of .PDF publication is
exposed.

I disagree. From what I can see the "_ _" problem *is* a case of
incorrect spelling (but a well-intentioned one). It seems to have
been put in deliberately to make the double underscore obvious.
The "fi" ligature is simply correct and good quality PDF readers
will cut and paste it as "fi" (two characters) and match it in a
search for "f" followed by "i". In other words, it works just
fine.

I don't think either says anything about the penalty of PDF
publication. In fact for interactive (i.e. non scripted) searches
I like the PDF better, now. I can search for text, jump to
specific pages or go right to a given section just by typing any
part of the section number or name.
We'll just have to agree to disagree. My main point was that with
text you have no problem selecting the search software to suit your
tastes and needs.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Oct 23 '07 #56
On Tue, 23 Oct 2007 06:14:22 GMT, in comp.lang.c ,
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
>Or you could - perhaps? revolutionary idea, I know - check the index.
Typically, an index doesn't index every single word!

A - see pages 2-1200 inclusive.
But - see pages 2,3,4,5,6,7,8,11,12,14,16,....
for - see pages 2-1200 except 1104 and 896

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 25 '07 #57
Mark McIntyre <ma**********@spamcop.netwrote:
On Tue, 23 Oct 2007 06:14:22 GMT, in comp.lang.c ,
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
Or you could - perhaps? revolutionary idea, I know - check the index.

Typically, an index doesn't index every single word!

A - see pages 2-1200 inclusive.
But - see pages 2,3,4,5,6,7,8,11,12,14,16,....
for - see pages 2-1200 except 1104 and 896
Typically, one doesn't search for indefinite articles or coordinating
conjunctions. One searches for important nouns - precisely the ones that
are found in a good index. In this case, __func__ is in the index, while
__FUNCTION__ is not; one look at this index at the start of this whole
useless argument about PDF versus text versus underscores versus
identifiers would have settled the matter.

Richard
Oct 26 '07 #58
On Fri, 26 Oct 2007 06:26:20 GMT, in comp.lang.c ,
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
>In this case, __func__ is in the index, while
__FUNCTION__ is not; one look at this index at the start of this whole
useless argument about PDF versus text versus underscores versus
identifiers would have settled the matter.
I agree, but I think the point being made is that indices do not index
everything, and can thus only tell what _is_ in the book.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 27 '07 #59
Mark McIntyre <ma**********@spamcop.netwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
In this case, __func__ is in the index, while
__FUNCTION__ is not; one look at this index at the start of this whole
useless argument about PDF versus text versus underscores versus
identifiers would have settled the matter.

I agree, but I think the point being made is that indices do not index
everything, and can thus only tell what _is_ in the book.
A good index, which I think one should assume the Standard does have,
indexes everything important. Thus, if something is not in the
Standard's index, either it isn't in the Standard, or it's only
mentioned in passing. Since __func__ is in it but __FUNCTION__ is not...
draw your own conclusion.

Richard
Oct 29 '07 #60
On Mon, 29 Oct 2007 13:26:40 GMT, in comp.lang.c ,
rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
>Mark McIntyre <ma**********@spamcop.netwrote:
>rl*@hoekstra-uitgeverij.nl (Richard Bos) wrote:
>In this case, __func__ is in the index, while
__FUNCTION__ is not; one look at this index at the start of this whole
useless argument about PDF versus text versus underscores versus
identifiers would have settled the matter.

I agree, but I think the point being made is that indices do not index
everything, and can thus only tell what _is_ in the book.

A good index,
....
>indexes everything important.
....
>Since __func__ is in it but __FUNCTION__ is not...
draw your own conclusion.
I agree, but its not a proof and cannot settle the matter.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 29 '07 #61

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
1
by: garth ferris | last post by:
i'm having a problem with a 3d engine i'm writing (just for fun, i'm kind of a beginner) and i was wondering if anyone could look through the following drwtsn32.log entry. the problem (among...
5
by: Adrian | last post by:
Is there a way (understandably non-portable) to get the call stack from within a function? That is, assuming the application has been compiled with symbols, get the list of calling function names...
2
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do....
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
4
by: code break | last post by:
Hi all, What is the difference between stack pointer and frame pointer ? Any suggestions are welcome ,,,
20
by: deepak | last post by:
Hi All, In C I heard the stack grows from top to bottom and heap from bottom to top. Is it compiler depend?
87
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first...
1
by: davidcollins001 | last post by:
Hi, I am trying to write a stack walking program to trace back along the stack for a process that the trace function is called from. I am doing it the cheating way, in that I have a ruby program...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.