Thread: RE: [GD-Windows] Function to see if a pointer is on the stack
Brought to you by:
vexxed72
From: Jacob T. \(C. D. Ltd\) <Ja...@Co...> - 2004-08-20 11:27:27
|
Unfortunately can't do the reliable method. My example for copying = strings is just an example so can't use std::string<> or bare pointer = technique. Bit scared about the other option because we are in a multi-threaded app = and this function would be common to all threads and we don't have = explicit creation of common library stuff when a new thread is made. Isn't there a really PC specific code e.g. getting the stack ptr etc. = This is how I am doing the function on consoles. Mind you not a big hassle because on the PC we have so much memory that = don't care if just always copy strings or whatever data i.e. can make is = variable on stack function return TRUE all the time. Thanks Jake > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jon Watte > Sent: 19 August 2004 18:19 > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack >=20 >=20 > The most reliable way of doing this is to use a class for > your argument rather than bare pointers, and have a > constructor from bare pointers, and use reference counting > in the class implementation -- this is almost exactly what > std::string<> already does for you! >=20 > Else, you can register the stack pointer in main() (or the > entry function for each thread/fiber), and get the stack > pointer in the called function, and compare -- this is not > entirely portable, because the stack may grow up on some > architectures. >=20 > // non-threaded version -- if you use threads or fibers, > // you need one gBase per thread/fiber >=20 > char * gBase; >=20 > void register_main( char * base ) { > gBase =3D base; > } >=20 > bool is_stack_pointer( char const * ptr ) { > char top[10]; > assert( top < gBase ); // else stack grows up > return (ptr < gBase) && (ptr > top); > } >=20 > int main() { > ... > char junk[ 10 ]; > register_main( junk ); > ... > } >=20 > void some_func( char * anArg ) { > if( is_stack_pointer( anArg ) ) { > ... > } > } >=20 >=20 > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jacob Turner (Core Design Ltd) > Sent: Thursday, August 19, 2004 9:30 AM > To: gam...@li... > Subject: [GD-Windows] Function to see if a pointer is on the stack >=20 >=20 > Is there some simple and reliable code for a console or=20 > windows app to test > if a pointer value is on the stack or not ? >=20 > If the pointer is on the stack (e.g. a string) then we want=20 > to copy the > string to heap memory for reuse later on. >=20 > Cheers >=20 > Jake >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU5 >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >=20 |
From: Andrew G. <ag...@cl...> - 2004-08-20 11:52:55
|
I think Jon's point wasn't necessarily to use std::string, but to use a refcounted technique with something like a smartpointer. That ensures that your encapsulated data stays alive as long as the smartpointer does - which can be returned, passed back by reference and so on. Consoles are easy as you can control where the stack goes yourself and check the range (for instance on PS2 our main thread's on the top half of the scratchpad) but trying something like this on Windows would fill me with dread :) I'm curious as to what you're trying to do though, I can see the case with strings where e.g you might want to format and return an error message (we do this and have a string class with derivatives for stack usage and heap usage which understand each other and know how to handle the situation of e.g passing a string which was build up on the heap). _____________________________ andrew grant lead programmer, climax brighton -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Jacob Turner (Core Design Ltd) Sent: 20 August 2004 12:29 To: gam...@li... Subject: RE: [GD-Windows] Function to see if a pointer is on the stack Unfortunately can't do the reliable method. My example for copying strings is just an example so can't use std::string<> or bare pointer technique. Bit scared about the other option because we are in a multi-threaded app and this function would be common to all threads and we don't have explicit creation of common library stuff when a new thread is made. Isn't there a really PC specific code e.g. getting the stack ptr etc. This is how I am doing the function on consoles. Mind you not a big hassle because on the PC we have so much memory that don't care if just always copy strings or whatever data i.e. can make is variable on stack function return TRUE all the time. Thanks Jake > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jon Watte > Sent: 19 August 2004 18:19 > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack > > > The most reliable way of doing this is to use a class for your > argument rather than bare pointers, and have a constructor from bare > pointers, and use reference counting in the class implementation -- > this is almost exactly what std::string<> already does for you! > > Else, you can register the stack pointer in main() (or the entry > function for each thread/fiber), and get the stack pointer in the > called function, and compare -- this is not entirely portable, because > the stack may grow up on some architectures. > > // non-threaded version -- if you use threads or fibers, // you need > one gBase per thread/fiber > > char * gBase; > > void register_main( char * base ) { > gBase = base; > } > > bool is_stack_pointer( char const * ptr ) { > char top[10]; > assert( top < gBase ); // else stack grows up > return (ptr < gBase) && (ptr > top); } > > int main() { > ... > char junk[ 10 ]; > register_main( junk ); > ... > } > > void some_func( char * anArg ) { > if( is_stack_pointer( anArg ) ) { > ... > } > } > > > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jacob Turner (Core Design Ltd) > Sent: Thursday, August 19, 2004 9:30 AM > To: gam...@li... > Subject: [GD-Windows] Function to see if a pointer is on the stack > > > Is there some simple and reliable code for a console or windows app to > test if a pointer value is on the stack or not ? > > If the pointer is on the stack (e.g. a string) then we want to copy > the string to heap memory for reuse later on. > > Cheers > > Jake > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save > 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU5 > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save > 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU5 |
From: Jacob T. \(C. D. Ltd\) <Ja...@Co...> - 2004-08-20 12:08:04
|
Yes and unfortunately I can't use ref counted technique. What we are using this for is: when we construct hash'es from a string we save the string ptr in a map = table so we can go back from a hash value to a string to aid debugging. = This fails if the string was constructed on the stack. So now we are = copying the string to our own string table and saving the pointer to the = copy. But in a quest for optimisation (because we are cross-platform = and want to run on some console h/w with no extra debug memory) we only = want to copy the string to our string table if the string is on the = stack, because for strings from static data then the pointer is valid. I think for now we will just make the PC function return TRUE and write = correct versions for other consoles which need it. In fact we might just ditch the whole thing are just always use the = string table because it doesn't require that much space (~8KB) and I = have also thought of a situation where the copying of the pointer would = fail even for non-stack strings. For hash'es made from strings in a = loaded in from an asset file then the pointer could be invalid because = we allow our asset files to get moved around in memory. Thanks anyway Jake > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Andrew Grant > Sent: 20 August 2004 12:53 > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack >=20 >=20 > =20 > I think Jon's point wasn't necessarily to use std::string,=20 > but to use a > refcounted technique with something like a smartpointer. That=20 > ensures that > your encapsulated data stays alive as long as the=20 > smartpointer does - which > can be returned, passed back by reference and so on. >=20 > Consoles are easy as you can control where the stack goes=20 > yourself and check > the range (for instance on PS2 our main thread's on the top=20 > half of the > scratchpad) but trying something like this on Windows would=20 > fill me with > dread :) >=20 > I'm curious as to what you're trying to do though, I can see=20 > the case with > strings where e.g you might want to format and return an=20 > error message (we > do this and have a string class with derivatives for stack=20 > usage and heap > usage which understand each other and know how to handle the=20 > situation of > e.g passing a string which was build up on the heap). >=20 >=20 > _____________________________ > andrew grant > lead programmer, climax brighton >=20 >=20 >=20 >=20 > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...] On=20 > Behalf Of Jacob > Turner (Core Design Ltd) > Sent: 20 August 2004 12:29 > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack >=20 > Unfortunately can't do the reliable method. My example for=20 > copying strings > is just an example so can't use std::string<> or bare pointer=20 > technique. >=20 > Bit scared about the other option because we are in a=20 > multi-threaded app and > this function would be common to all threads and we don't=20 > have explicit > creation of common library stuff when a new thread is made. >=20 > Isn't there a really PC specific code e.g. getting the stack=20 > ptr etc. This > is how I am doing the function on consoles. >=20 > Mind you not a big hassle because on the PC we have so much=20 > memory that > don't care if just always copy strings or whatever data i.e.=20 > can make is > variable on stack function return TRUE all the time. >=20 > Thanks >=20 > Jake >=20 > > -----Original Message----- > > From: gam...@li... > > [mailto:gam...@li...]On=20 > Behalf Of=20 > > Jon Watte > > Sent: 19 August 2004 18:19 > > To: gam...@li... > > Subject: RE: [GD-Windows] Function to see if a pointer is=20 > on the stack > >=20 > >=20 > > The most reliable way of doing this is to use a class for your=20 > > argument rather than bare pointers, and have a constructor=20 > from bare=20 > > pointers, and use reference counting in the class implementation --=20 > > this is almost exactly what std::string<> already does for you! > >=20 > > Else, you can register the stack pointer in main() (or the entry=20 > > function for each thread/fiber), and get the stack pointer in the=20 > > called function, and compare -- this is not entirely=20 > portable, because=20 > > the stack may grow up on some architectures. > >=20 > > // non-threaded version -- if you use threads or fibers, //=20 > you need=20 > > one gBase per thread/fiber > >=20 > > char * gBase; > >=20 > > void register_main( char * base ) { > > gBase =3D base; > > } > >=20 > > bool is_stack_pointer( char const * ptr ) { > > char top[10]; > > assert( top < gBase ); // else stack grows up > > return (ptr < gBase) && (ptr > top); } > >=20 > > int main() { > > ... > > char junk[ 10 ]; > > register_main( junk ); > > ... > > } > >=20 > > void some_func( char * anArg ) { > > if( is_stack_pointer( anArg ) ) { > > ... > > } > > } > >=20 > >=20 > > -----Original Message----- > > From: gam...@li... > > [mailto:gam...@li...]On=20 > Behalf Of=20 > > Jacob Turner (Core Design Ltd) > > Sent: Thursday, August 19, 2004 9:30 AM > > To: gam...@li... > > Subject: [GD-Windows] Function to see if a pointer is on the stack > >=20 > >=20 > > Is there some simple and reliable code for a console or=20 > windows app to=20 > > test if a pointer value is on the stack or not ? > >=20 > > If the pointer is on the stack (e.g. a string) then we want to copy=20 > > the string to heap memory for reuse later on. > >=20 > > Cheers > >=20 > > Jake > >=20 > >=20 > > ------------------------------------------------------- > > SF.Net email is sponsored by Shop4tech.com-Lowest price on=20 > Blank Media=20 > > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for=20 > only $33 Save=20 > > 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_idU5 > >=20 > >=20 > >=20 > > ------------------------------------------------------- > > SF.Net email is sponsored by Shop4tech.com-Lowest price on=20 > Blank Media=20 > > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for=20 > only $33 Save=20 > > 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 > >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on=20 > Blank Media 100pk > Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33=20 > Save 50% off > Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU5 >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >=20 |
From: Jon W. <hp...@mi...> - 2004-08-20 15:51:12
|
You should be able to easily wrap the thread creation functions to initialize thread-local data for the "isonstack" call. You could also add a grep for thread creation to your checkin tests to make sure nobody breaks the rule (make sure to exempt the actual wrapper implementation, though :-) Sadly, the Platform SDK doesn't have a function to test whether something is on a stack or not -- in fact, there isn't even a function to query the stack extent of a specific thread, only the current stack pointer! (By getting the CONTEXT structure) This has annoyed me in the past, but if you're Windows specific, the creation wrapping and Tls / Fls stack base works pretty well. Cheers, / h+ -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Jacob Turner (Core Design Ltd) Sent: Friday, August 20, 2004 4:29 AM To: gam...@li... Subject: RE: [GD-Windows] Function to see if a pointer is on the stack Unfortunately can't do the reliable method. My example for copying strings is just an example so can't use std::string<> or bare pointer technique. Bit scared about the other option because we are in a multi-threaded app and this function would be common to all threads and we don't have explicit creation of common library stuff when a new thread is made. Isn't there a really PC specific code e.g. getting the stack ptr etc. This is how I am doing the function on consoles. Mind you not a big hassle because on the PC we have so much memory that don't care if just always copy strings or whatever data i.e. can make is variable on stack function return TRUE all the time. Thanks Jake > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jon Watte > Sent: 19 August 2004 18:19 > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack > > > The most reliable way of doing this is to use a class for > your argument rather than bare pointers, and have a > constructor from bare pointers, and use reference counting > in the class implementation -- this is almost exactly what > std::string<> already does for you! > > Else, you can register the stack pointer in main() (or the > entry function for each thread/fiber), and get the stack > pointer in the called function, and compare -- this is not > entirely portable, because the stack may grow up on some > architectures. > > // non-threaded version -- if you use threads or fibers, > // you need one gBase per thread/fiber > > char * gBase; > > void register_main( char * base ) { > gBase = base; > } > > bool is_stack_pointer( char const * ptr ) { > char top[10]; > assert( top < gBase ); // else stack grows up > return (ptr < gBase) && (ptr > top); > } > > int main() { > ... > char junk[ 10 ]; > register_main( junk ); > ... > } > > void some_func( char * anArg ) { > if( is_stack_pointer( anArg ) ) { > ... > } > } > > > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jacob Turner (Core Design Ltd) > Sent: Thursday, August 19, 2004 9:30 AM > To: gam...@li... > Subject: [GD-Windows] Function to see if a pointer is on the stack > > > Is there some simple and reliable code for a console or > windows app to test > if a pointer value is on the stack or not ? > > If the pointer is on the stack (e.g. a string) then we want > to copy the > string to heap memory for reuse later on. > > Cheers > > Jake > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU5 > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU5 |
From: Dan T. <da...@ar...> - 2004-08-20 17:03:51
|
Dunno, I think (Since its debug code), I would chuck cycles at it and just check against my stored list of strings. If I have it already I would point to the old copy, otherwise make a new one. (may refcount?) Okay... train of thought gone. My coworker thought he'd be funny and leave a watch with an alarm set hidden on my desk. ..copy..stack... Yeah. If you are just on windows machines, you can use the CONTEXT structure. I think (not sure) all windows boxes grow down with the stack, so that makes the is stack function trivial.(If not its fairly easy to see which way it goes). If you have to run on too many machines, it may not be worth all the crazy code, so I'd say stick with tracking anything you haven't seen yet. This minor feature probably has already cost you enough in terms of time spent. -Dan ----- Original Message ----- From: "Jon Watte" <hp...@mi...> To: <gam...@li...> Sent: Friday, August 20, 2004 8:49 AM Subject: [email] RE: [GD-Windows] Function to see if a pointer is on the stack > > You should be able to easily wrap the thread creation functions > to initialize thread-local data for the "isonstack" call. You > could also add a grep for thread creation to your checkin tests > to make sure nobody breaks the rule (make sure to exempt the > actual wrapper implementation, though :-) > > Sadly, the Platform SDK doesn't have a function to test whether > something is on a stack or not -- in fact, there isn't even a > function to query the stack extent of a specific thread, only > the current stack pointer! (By getting the CONTEXT structure) > This has annoyed me in the past, but if you're Windows specific, > the creation wrapping and Tls / Fls stack base works pretty > well. > > Cheers, > > / h+ > > > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...]On Behalf Of > Jacob Turner (Core Design Ltd) > Sent: Friday, August 20, 2004 4:29 AM > To: gam...@li... > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack > > > Unfortunately can't do the reliable method. My example for copying strings > is just an example so can't use std::string<> or bare pointer technique. > > Bit scared about the other option because we are in a multi-threaded app and > this function would be common to all threads and we don't have explicit > creation of common library stuff when a new thread is made. > > Isn't there a really PC specific code e.g. getting the stack ptr etc. This > is how I am doing the function on consoles. > > Mind you not a big hassle because on the PC we have so much memory that > don't care if just always copy strings or whatever data i.e. can make is > variable on stack function return TRUE all the time. > > Thanks > > Jake > > > -----Original Message----- > > From: gam...@li... > > [mailto:gam...@li...]On Behalf Of > > Jon Watte > > Sent: 19 August 2004 18:19 > > To: gam...@li... > > Subject: RE: [GD-Windows] Function to see if a pointer is on the stack > > > > > > The most reliable way of doing this is to use a class for > > your argument rather than bare pointers, and have a > > constructor from bare pointers, and use reference counting > > in the class implementation -- this is almost exactly what > > std::string<> already does for you! > > > > Else, you can register the stack pointer in main() (or the > > entry function for each thread/fiber), and get the stack > > pointer in the called function, and compare -- this is not > > entirely portable, because the stack may grow up on some > > architectures. > > > > // non-threaded version -- if you use threads or fibers, > > // you need one gBase per thread/fiber > > > > char * gBase; > > > > void register_main( char * base ) { > > gBase = base; > > } > > > > bool is_stack_pointer( char const * ptr ) { > > char top[10]; > > assert( top < gBase ); // else stack grows up > > return (ptr < gBase) && (ptr > top); > > } > > > > int main() { > > ... > > char junk[ 10 ]; > > register_main( junk ); > > ... > > } > > > > void some_func( char * anArg ) { > > if( is_stack_pointer( anArg ) ) { > > ... > > } > > } > > > > > > -----Original Message----- > > From: gam...@li... > > [mailto:gam...@li...]On Behalf Of > > Jacob Turner (Core Design Ltd) > > Sent: Thursday, August 19, 2004 9:30 AM > > To: gam...@li... > > Subject: [GD-Windows] Function to see if a pointer is on the stack > > > > > > Is there some simple and reliable code for a console or > > windows app to test > > if a pointer value is on the stack or not ? > > > > If the pointer is on the stack (e.g. a string) then we want > > to copy the > > string to heap memory for reuse later on. > > > > Cheers > > > > Jake > > > > > > ------------------------------------------------------- > > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_idU5 > > > > > > > > ------------------------------------------------------- > > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU5 > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Jon W. <hp...@mi...> - 2004-08-20 18:13:48
|
> Yeah. If you are just on windows machines, you can use the > CONTEXT structure. I think (not sure) all windows boxes grow CONTEXT does not tell you the stack base, does it? It'll tell you the stack pointer, but you can get that equally easily by just taking the address of a local variable. Cheers, / h+ |
From: Dan T. <da...@ar...> - 2004-08-20 18:37:52
|
If I remember right its just the pointer. Last time I mucked with it was for a user level threading library, and I don't remember anything else stack related. Dan ----- Original Message ----- From: "Jon Watte" <hp...@mi...> To: <gam...@li...> Sent: Friday, August 20, 2004 11:12 AM Subject: RE: [email] RE: [GD-Windows] Function to see if a pointer is on the stack > > > Yeah. If you are just on windows machines, you can use the > > CONTEXT structure. I think (not sure) all windows boxes grow > > CONTEXT does not tell you the stack base, does it? It'll tell > you the stack pointer, but you can get that equally easily by > just taking the address of a local variable. > > Cheers, > > / h+ > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Tham <th...@ga...> - 2004-08-29 03:34:15
|
Hi, How can my C# application receive an event (or any sort of notification) when it hits a break point? I need to be notified because i have a real time clock that drives my time-delta based animation and i need to stop it and resume it from where i left off to avoid driving my animation way ahead when i return. many thanks tham |
From: Jon W. <hp...@mi...> - 2004-08-29 22:11:56
|
I'm not sure you can get an event like that. However, what I do is to put an upper limit on the amount of time that I will progress based on real time between steps. I put a wrapper in front of the real time clock, and this wrapper adds an adjustable delta to the time actually returned. Then, in the main loop, I'll do something like: static double then = 0; double now = myClock.time(); double deltaTime = now - then; if( deltaTime > 0.1 ) { myClock.adjust( deltaTime ); deltaTime = 0.05; } ... advance animations by deltaTime ... double ClockClass::time() { return readRealClock() - adjustDelta_; } void ClockClass::adjust( double delta ) { adjustDelta_ += delta; } The side effect is that, if the frame rate falls lower than 10 fps, then animations will play in automatic slow-motion. However, this is somewhat useful -- I'll know for sure what the problem is when users report "things run in slow motion" ;-) Cheers, / h+ -----Original Message----- From: gam...@li... [mailto:gam...@li...]On Behalf Of Tham Sent: Saturday, August 28, 2004 8:34 PM To: gam...@li... Subject: [GD-Windows] Catching Break Point event... Hi, How can my C# application receive an event (or any sort of notification) when it hits a break point? I need to be notified because i have a real time clock that drives my time-delta based animation and i need to stop it and resume it from where i left off to avoid driving my animation way ahead when i return. many thanks tham ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555 |