Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
Thanks
--pradeep 17 2314
In article <11*********************@q19g2000prn.googlegroups. com>,
blufox <25**********@gmail.comwrote:
>Can i change the execution path of methods in my process at runtime?
Not in C, because C does not have methods.
>e.g
>a()->b()->c()->d()->e()
>Now, i want execution to be altered at runtime as -
>a()->b()->myfun1()->myfun2()->myfun3()... ->e()
>Can this be done without changing the actual source file, may be by adding a new module at runtime?
C does not have modules either. Furthermore, C does not offer any
method of activating new code at runtime.
Some operating systems provide mechanisms for dynamically loadable
objects. In the Windows world, these are usually called 'dll';
in the Unix world, these are usually called 'dso' but the
Unix operating system calls usually begin with dlopen() .
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
On May 29, 7:43 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <1180449520.473891.53...@q19g2000prn.googlegroups. com>,
blufox <2500.prad...@gmail.comwrote:
Can i change the execution path of methods in my process at runtime?
Not in C, because C does not have methods.
Right. Apologies i meant kernel functions in linux which are usually
called methods.
>
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
C does not have modules either. Furthermore, C does not offer any
method of activating new code at runtime.
Some operating systems provide mechanisms for dynamically loadable
objects. In the Windows world, these are usually called 'dll';
in the Unix world, these are usually called 'dso' but the
Unix operating system calls usually begin with dlopen() .
Right, and i mean a Linux kernel module here.
Essentially it is C(with loads of GCCism) i guess.
So, is it possible using modules in unix/linux then. i must ask?
Thanks for the reply
--pradeep
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
blufox wrote:
Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
Thanks
--pradeep
Hi
a()->b()->c()->d()->e()
means (in C):
call function a(), that returns some pointer to a
structure that has a field called "b". This field is a function
pointer. Call that, and that will return some structure with
a field "c". That field is a function pointer...
etc
Note that the type of the return of a() is known at compile
time. The compiler has then calculated at which offset the "b"
pointer is, and generates code to access that pointer at that
offset. You can't change that. You can only change the value
in the field "b", in the structure returned by a().
If a returns the same structure but with a function pointer to
"myfun", the generated code will work the same, but you will
end calling another function, not the one that you were calling
This requires a modification at compile time to a() or to b(), etc.
Somehow those functions will need to figure out when they should put
a certain function pointer in field "b" or not.
But all this looks far too complicated.
WHAT are you trying to do?
Explain that first.
jacob
On May 29, 8:01 pm, jacob navia <j...@jacob.remcomp.frwrote:
blufox wrote:
Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
Thanks
--pradeep
Hi
a()->b()->c()->d()->e()
means (in C):
call function a(), that returns some pointer to a
structure that has a field called "b". This field is a function
pointer. Call that, and that will return some structure with
a field "c". That field is a function pointer...
etc
Note that the type of the return of a() is known at compile
time. The compiler has then calculated at which offset the "b"
pointer is, and generates code to access that pointer at that
offset. You can't change that. You can only change the value
in the field "b", in the structure returned by a().
If a returns the same structure but with a function pointer to
"myfun", the generated code will work the same, but you will
end calling another function, not the one that you were calling
This requires a modification at compile time to a() or to b(), etc.
Somehow those functions will need to figure out when they should put
a certain function pointer in field "b" or not.
But all this looks far too complicated.
WHAT are you trying to do?
Explain that first.
Oops i messed it up i must admit. :-(
No it is not pointer dereferencing literally here.
Just to illustrate the flow of program here, i used arrows "->" .
What I intend to do?
I want to invoke my function without changing the actual source code
at runtime.
Is this somehow possible on a Linux system?
Thanks
--pradeep
>
jacob
On May 29, 4:07 pm, blufox <2500.prad...@gmail.comwrote:
On May 29, 8:01 pm, jacob navia <j...@jacob.remcomp.frwrote:
blufox wrote:
Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
Thanks
--pradeep
Hi
a()->b()->c()->d()->e()
means (in C):
call function a(), that returns some pointer to a
structure that has a field called "b". This field is a function
pointer. Call that, and that will return some structure with
a field "c". That field is a function pointer...
etc
Note that the type of the return of a() is known at compile
time. The compiler has then calculated at which offset the "b"
pointer is, and generates code to access that pointer at that
offset. You can't change that. You can only change the value
in the field "b", in the structure returned by a().
If a returns the same structure but with a function pointer to
"myfun", the generated code will work the same, but you will
end calling another function, not the one that you were calling
This requires a modification at compile time to a() or to b(), etc.
Somehow those functions will need to figure out when they should put
a certain function pointer in field "b" or not.
But all this looks far too complicated.
WHAT are you trying to do?
Explain that first.
Oops i messed it up i must admit. :-(
No it is not pointer dereferencing literally here.
Just to illustrate the flow of program here, i used arrows "->" .
What I intend to do?
I want to invoke my function without changing the actual source code
at runtime.
Is this somehow possible on a Linux system?
Thanks
--pradeep
jacob
It's just about possible using portable C, but only if you design the
source file to make it possible. For instance:
/* whichfunc.c */
extern void c(void);
extern void myfun1(void);
void (*func)()=c; /* =myfun1; */
/* prog.c */
extern void (*func)();
void a(void)
{
b();
}
void b(void)
{
(*func)(); /* the key line */
}
/* ... whatever ... */
Then you can link both files together using whatever implementation-
specific method your implementation provides (if you're on Linux,
you're quite possibly using gcc, in which case you specify both files
on the command line or probably use a makefile if it's a complex
project). Changing func will change the path of execution b takes.
Of course, modifying the source code is nearly always going to be
easier (the only advantage of doing it like this is that you can
change the flow pattern at runtime if you want to, by assigning to
func).
In the general case, in which you haven't deliberately written the
source code in this unusual form, you can't substitute a call to one
function with another using what's available in standard C89/C99.
--
ais523
blufox <25**********@gmail.comwrites:
On May 29, 7:43 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
>In article <1180449520.473891.53...@q19g2000prn.googlegroups. com>,
blufox <2500.prad...@gmail.comwrote:
>Can i change the execution path of methods in my process at runtime?
Not in C, because C does not have methods.
Right. Apologies i meant kernel functions in linux which are usually
called methods.
They are? That's news to me.
In any case, you should ask on a Linux-specific newsgroup.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On May 30, 3:00 am, Keith Thompson <k...@mib.orgwrote:
blufox <2500.prad...@gmail.comwrites:
On May 29, 7:43 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <1180449520.473891.53...@q19g2000prn.googlegroups. com>,
blufox <2500.prad...@gmail.comwrote:
Can i change the execution path of methods in my process at runtime?
Not in C, because C does not have methods.
Right. Apologies i meant kernel functions in linux which are usually
called methods.
They are? That's news to me.
Yes they are called methods in the kernel AFAIK.
May be i am misunderstanding it.
>
In any case, you should ask on a Linux-specific newsgroup.
Tried that, didn't get satisfying answers so resorted to clc.
I 'll give another try though.
Thank you
--psr
>
--
Keith Thompson (The_Other_Keith) k...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On May 29, 8:30 pm, ais523 <ais...@bham.ac.ukwrote:
On May 29, 4:07 pm, blufox <2500.prad...@gmail.comwrote:
On May 29, 8:01 pm, jacob navia <j...@jacob.remcomp.frwrote:
blufox wrote:
Hi All,
Can i change the execution path of methods in my process at runtime?
e.g
a()->b()->c()->d()->e()
Now, i want execution to be altered at runtime as -
a()->b()->myfun1()->myfun2()->myfun3()... ->e()
Can this be done without changing the actual source file, may be by
adding a new module at runtime?
Thanks
--pradeep
Hi
a()->b()->c()->d()->e()
means (in C):
call function a(), that returns some pointer to a
structure that has a field called "b". This field is a function
pointer. Call that, and that will return some structure with
a field "c". That field is a function pointer...
etc
Note that the type of the return of a() is known at compile
time. The compiler has then calculated at which offset the "b"
pointer is, and generates code to access that pointer at that
offset. You can't change that. You can only change the value
in the field "b", in the structure returned by a().
If a returns the same structure but with a function pointer to
"myfun", the generated code will work the same, but you will
end calling another function, not the one that you were calling
This requires a modification at compile time to a() or to b(), etc.
Somehow those functions will need to figure out when they should put
a certain function pointer in field "b" or not.
But all this looks far too complicated.
WHAT are you trying to do?
Explain that first.
Oops i messed it up i must admit. :-(
No it is not pointer dereferencing literally here.
Just to illustrate the flow of program here, i used arrows "->" .
What I intend to do?
I want to invoke my function without changing the actual source code
at runtime.
Is this somehow possible on a Linux system?
Thanks
--pradeep
jacob
It's just about possible using portable C, but only if you design the
source file to make it possible. For instance:
/* whichfunc.c */
extern void c(void);
extern void myfun1(void);
void (*func)()=c; /* =myfun1; */
/* prog.c */
extern void (*func)();
void a(void)
{
b();
}
void b(void)
{
(*func)(); /* the key line */
}
/* ... whatever ... */
Then you can link both files together using whatever implementation-
specific method your implementation provides (if you're on Linux,
you're quite possibly using gcc, in which case you specify both files
on the command line or probably use a makefile if it's a complex
project). Changing func will change the path of execution b takes.
Of course, modifying the source code is nearly always going to be
easier (the only advantage of doing it like this is that you can
change the flow pattern at runtime if you want to, by assigning to
func).
In the general case, in which you haven't deliberately written the
source code in this unusual form, you can't substitute a call to one
function with another using what's available in standard C89/C99.
This is fruitful.
I ll look into this and see if i can get something concrete from this
hint.
Thanks a ton for the help.
--psr
--
ais523
blufox wrote:
ais523 <ais...@bham.ac.ukwrote:
.... snip about 100 lines ...
>> Of course, modifying the source code is nearly always going to be easier (the only advantage of doing it like this is that you can change the flow pattern at runtime if you want to, by assigning to func).
In the general case, in which you haven't deliberately written the source code in this unusual form, you can't substitute a call to one function with another using what's available in standard C89/C99.
This is fruitful. I ll look into this and see if i can get something
concrete from this hint.
Please snip irrelevant data from the quoted portion of your
replies. The links below (in my sig) may be helpful.
--
Some useful links on quoting:
<http://www.xs4all.nl/%7ewijnands/nnq/nquote.html>
<http://www.complang.tuwien.ac.at/anton/mail-news-errors.html>
<http://www.netmeister.org/news/learn2quote2.html>
<http://www.star-one.org.uk/computer/format.htm>
--
Posted via a free Usenet account from http://www.teranews.com
On 29 May 2007 20:42:00 -0700, in comp.lang.c , blufox
<25**********@gmail.comwrote:
>On May 30, 3:00 am, Keith Thompson <k...@mib.orgwrote:
>blufox <2500.prad...@gmail.comwrites:
Right. Apologies i meant kernel functions in linux which are usually
called methods.
>They are? That's news to me.
>Yes they are called methods in the kernel AFAIK.
I've never heard anything called a method in C or C++. Some other
languages such as VB and the ilk have methods.
>May be i am misunderstanding it.
Its possible...
--
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
In article <5m********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>On 29 May 2007 20:42:00 -0700, in comp.lang.c , blufox <25**********@gmail.comwrote:
>>On May 30, 3:00 am, Keith Thompson <k...@mib.orgwrote:
>>blufox <2500.prad...@gmail.comwrites:
>Right. Apologies i meant kernel functions in linux which are usually called methods.
>>They are? That's news to me.
>>Yes they are called methods in the kernel AFAIK.
I've never heard anything called a method in C or C++. Some other languages such as VB and the ilk have methods.
Of course you have (heard someone refer to C++ as having methods).
That part of your statement (that "I've never heard...") is plain and
simply a lie.
The more substantive question is whether or not C++ has methods. Pretty
clearly, it does (although of course this is all OT here), but I would
imagine that you or one of your buddies will come up with some bit of
sophistry to explain why it doesn't.
Mark McIntyre <ma**********@spamcop.netwrites:
On 29 May 2007 20:42:00 -0700, in comp.lang.c , blufox
<25**********@gmail.comwrote:
>>On May 30, 3:00 am, Keith Thompson <k...@mib.orgwrote:
>>blufox <2500.prad...@gmail.comwrites:
>Right. Apologies i meant kernel functions in linux which are usually called methods.
>>They are? That's news to me.
>>Yes they are called methods in the kernel AFAIK.
I've never heard anything called a method in C or C++. Some other
languages such as VB and the ilk have methods.
Then you are purposely complicating things for some reason or have not,
in any shape or form, had any worthwhile experience in C++.
The term "method" is widely used to C++. Not necessarily in the Linux
kernel of course since that is C and Assembler.
>
>>May be i am misunderstanding it.
Its possible...
http://www.google.de/search?q=c%2B%2...ient=firefox-a
Or not.
Richard wrote:
Mark McIntyre <ma**********@spamcop.netwrites:
.... snip ...
>> I've never heard anything called a method in C or C++. Some other languages such as VB and the ilk have methods.
Then you are purposely complicating things for some reason or have
not, in any shape or form, had any worthwhile experience in C++.
The term "method" is widely used to C++. Not necessarily in the
Linux kernel of course since that is C and Assembler.
You have obviously failed to read the name of this newsgroup. It
is "comp.lang.c". Note the absence of ++. C++ is another
language, and has its own newsgroup, where you may discuss it.
Meanwhile C++ is off-topic here.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com
CBFalconer wrote:
Richard wrote:
>Mark McIntyre <ma**********@spamcop.netwrites:
... snip ...
>>> I've never heard anything called a method in C or C++. Some other languages such as VB and the ilk have methods.
Then you are purposely complicating things for some reason or have not, in any shape or form, had any worthwhile experience in C++.
The term "method" is widely used to C++. Not necessarily in the Linux kernel of course since that is C and Assembler.
You have obviously failed to read the name of this newsgroup. It
is "comp.lang.c". Note the absence of ++. C++ is another
language, and has its own newsgroup, where you may discuss it.
Meanwhile C++ is off-topic here.
Then complain to Mark, not to Richard.
On Sun, 10 Jun 2007 17:19:45 +0200, in comp.lang.c , Harald van D?k
<tr*****@gmail.comwrote:
>CBFalconer wrote:
>Richard wrote:
>>Mark McIntyre <ma**********@spamcop.netwrites:
... snip ...
>>>> I've never heard anything called a method in C or C++. Some other languages such as VB and the ilk have methods.
Then you are purposely complicating things for some reason or have not, in any shape or form, had any worthwhile experience in C++.
The term "method" is widely used to C++. Not necessarily in the Linux kernel of course since that is C and Assembler.
You have obviously failed to read the name of this newsgroup. It is "comp.lang.c". Note the absence of ++. C++ is another language, and has its own newsgroup, where you may discuss it. Meanwhile C++ is off-topic here.
Then complain to Mark, not to Richard.
Why? I didn't post the original question.
--
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
Mark McIntyre wrote:
On Sun, 10 Jun 2007 17:19:45 +0200, in comp.lang.c , Harald van D?k
<tr*****@gmail.comwrote:
>>CBFalconer wrote:
>>Richard wrote: Mark McIntyre <ma**********@spamcop.netwrites:
... snip ... > I've never heard anything called a method in C or C++. Some other languages such as VB and the ilk have methods.
Then you are purposely complicating things for some reason or have not, in any shape or form, had any worthwhile experience in C++.
The term "method" is widely used to C++. Not necessarily in the Linux kernel of course since that is C and Assembler.
You have obviously failed to read the name of this newsgroup. It is "comp.lang.c". Note the absence of ++. C++ is another language, and has its own newsgroup, where you may discuss it. Meanwhile C++ is off-topic here.
Then complain to Mark, not to Richard.
Why? I didn't post the original question.
blufox:
>>Yes they are called methods in the kernel AFAIK.
You:
>I've never heard anything called a method in C or C++.
You were the one who gave the first mention of C++.
As far as I'm concerned your comment is fine. But as far as I'm concerned,
Richard's message is fine too.
On Tue, 12 Jun 2007 07:37:31 +0200, in comp.lang.c , Harald van D?k
<tr*****@gmail.comwrote:
>Mark McIntyre wrote:
>On Sun, 10 Jun 2007 17:19:45 +0200, in comp.lang.c , Harald van D?k <tr*****@gmail.comwrote:
>>>CBFalconer wrote: Richard wrote: Mark McIntyre <ma**********@spamcop.netwrites: > ... snip ... >> >I've never heard anything called a method in C or C++. Some other >languages such as VB and the ilk have methods. > Then you are purposely complicating things for some reason or have not, in any shape or form, had any worthwhile experience in C++. > The term "method" is widely used to C++. Not necessarily in the Linux kernel of course since that is C and Assembler.
You have obviously failed to read the name of this newsgroup. It is "comp.lang.c". Note the absence of ++. C++ is another language, and has its own newsgroup, where you may discuss it. Meanwhile C++ is off-topic here.
Then complain to Mark, not to Richard.
Why? I didn't post the original question.
blufox:
>>>Yes they are called methods in the kernel AFAIK.
You:
>>I've never heard anything called a method in C or C++.
You were the one who gave the first mention of C++.
To forestall the next response which was going to be exactly what we
got.
>As far as I'm concerned your comment is fine.
Good. Then why tell people to complain to me? And I didn't go off and
start lecturing people about whether or not C++ actually had methods.
--
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Graham |
last post by:
I've found that other thing that returns the assembly
executable but I don't need the file tacked on to the
path, just need the path. I don't want to always have to
write code to trim off the...
|
by: chris |
last post by:
im new to javascript but slowly getting better
what i want to do is have some text on the screen and when an event happens
for example click a button the text would change to what i want.
how...
|
by: Tony W |
last post by:
Hi,
I am trying to write a simple application to retrieve data from the
Windows registry and insert it into textboxs on a windows form.
So far I have one namespace containing two classess.
...
|
by: AdamM |
last post by:
How can I change an object's type at runtime?
For example, here's what I want to do in psedocode:
object animal;
if (dog)
{
animal=(dog)animal;
|
by: Bassel Tabbara |
last post by:
I wrote the following code:
oApp = new Outlook.Application();
oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
//gets defaultfolder...
|
by: lprisr |
last post by:
Hi,
I have double byte characters in the content that I am returning using Web
Services. However, the encoding in the xml file returned by Web Services is
utf-8 and I am unable to read the...
|
by: Mikael Olofsson |
last post by:
Hi!
This is in Python 2.3.4 under WinXP.
I have a situation where I think changing the behaviour of a namespace
would be very nice. The goal is to be able to run a python file from
another in...
|
by: Tom Cole |
last post by:
I'm working on a small Ajax request library to simplify some tasks
that I will be taking on shortly. For the most part everything works
fine, however I seem to have some issues when running two...
|
by: Zytan |
last post by:
I have public methods in a form. The main form calls them, to update
that form's display. This form is like a real-time view of data that
is changing.
But, the form may not exist (it is...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
| |