<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 16, 2009, at 11:21 AM, Daniel Waterworth wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks very much. I only have one more question, (hopefully), which is, is there a better way of finding the direction of stack growth other than:<br></blockquote><div><br></div>That's a somewhat reasonable, but fragile way to go. Make sure to mark StackCmp with attribute(noinline). Don't be too surprised if it doesn't work on some compiler. I don't know a better way to do it though.</div><div><br></div><div>-Chris</div><div><br><blockquote type="cite"><br>static bool StackCmp(void *ptr) {<br> volatile int a;<br> return (void *)&a > ptr;<br> }<br><br>bool FindStackDirection() {<br> volatile int a;<br> return StackCmp((void *)&a);<br>}<br><br>Preferably one which isn't destroyed by optimization.<br><br>Thanks again,<br><br>Daniel<br><br><div class="gmail_quote"> 2009/10/16 Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div style=""><br><div><div class="im"><div>On Oct 16, 2009, at 4:43 AM, Daniel Waterworth wrote:</div><br><blockquote type="cite">Never mind, I used ExecutionEngine's InstallLazyFunctionCreator and DisableSymbolSearching to cause malloc and free calls to be handled by my logging functions. Sorry for the unnecessary list mail. <br> </blockquote><div><br></div></div>No problem, this is a better way to go. The MallocInst and FreeInst instructions are about to be removed from LLVM IR. Malloc and free will be represented normal 'call' instructions.</div> <div><br></div><div><div class="im"><blockquote type="cite">Is it possible to find out the size and beginning pointer of the current stack frame, from a function operating outside of the virtual machine, but called by a function within it?<br> </blockquote><div><br></div></div><div>I don't think so. Typically, applications that need this sort of thing get the address of the function and then do a fuzzy disassembly of the prolog.</div><div><br></div><div>-Chris</div> <br><blockquote type="cite"><div class="im"> <br>Thanks,<br><br>Daniel<br><br><div class="gmail_quote">2009/10/16 Daniel Waterworth <span dir="ltr"><<a href="mailto:da.waterworth@googlemail.com" target="_blank">da.waterworth@googlemail.com</a>></span><br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hello,<br><br>I'm writing a virtual machine that functions as a sandbox based on llvm. In order to prevent programs from accessing memory that has not been allocated to them, I want to replace calls to malloc and free with calls to a logged functions that will record the memory that is being allocated to the program. Is it possible to cast/convert a MallocInst or FreeInst to a CallInst?<br> <br>Thanks,<br><font color="#888888"><br>Daniel<br> </font></blockquote></div><br></div> _______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></blockquote></div><br></blockquote></div><br></body></html>