<div dir="ltr"><div dir="ltr"><div>Okay, that was my thinking though I couldn't remember exactly how to get function pointers in C. After some fun setting up a cross-compiler, I got the test C program on the device, and then wrote the following Lisp code to try to duplicate the code.</div><div><br></div><div>-----------------------------------------------------<br></div><div>(defun peek-getpid-memory ()<br> (let* ((addr (%ptr-to-int (foreign-symbol-address "getpid"))))<br> (loop for offset from 0 to 15<br> do</div><div> (format t "~X " (%get-unsigned-long (%int-to-ptr (+ addr (* 4 offset))))))))</div><div><div>(peek-getpid-memory)</div><div>-----------------------------------------------------<br></div></div></div><div><br></div><div>I hope I did that right. I'm not terribly familiar with CCL's FFI yet. Given that I got the exact same output, I think it means I did.</div><div><br></div><div>-----------------------------------------------------</div><div>remarkable: ~/ ./test<br>ee1d2f70 e52d7004 e5123454 e3530000 da000002 e1a00003 e49d7004 e12fff1e 1a000003 e5121458 e3510000 11a03001 1afffff7 e3a07014 ef000000 e3530000 <br>remarkable: ~/ ccl/armcl -l test.lisp<br>EE1D2F70 E52D7004 E5123454 E3530000 DA000002 E1A00003 E49D7004 E12FFF1E 1A000003 E5121458 E3510000 11A03001 1AFFFFF7 E3A07014 EF000000 E3530000 <br></div><div>-----------------------------------------------------</div><div><br></div><div>That seems to indicate it's pointing at the same place. Assuming that the address coming back from (foriegn-symbol-address "getpid") is the same thing that is invoked by the reader macro in (#_getpid), then it's confusing that I'm getting a segfault.<br></div><div><br></div><div>Any other ideas?</div><div><br></div><div>Jeremy<br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Wed, Jun 19, 2019 at 4:26 PM Ron Garret <<a href="mailto:ron@flownet.com">ron@flownet.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><br><div><div>On Jun 19, 2019, at 2:04 PM, Jeremy Shoemaker <<a href="mailto:jeremy@codingkoi.com" target="_blank">jeremy@codingkoi.com</a>> wrote:</div><br class="gmail-m_6671958095781508981Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div dir="ltr">> One suggestion: use %get-signed-long to read out a few bytes of memory
at the location reported by (external "getpid”) and then write a little C
program that does the same thing and see if you get the same result.</div><div dir="ltr"><br></div><div>I'm not sure I entirely follow, at least the C program part. Are you suggesting peeking at the memory pointed to by the `getpid` function in C?</div></div></blockquote><div><br></div><div>Yes. Exactly.</div><br><blockquote type="cite"><div dir="ltr"><div> I'm not quite sure how to do that, but my C is pretty rusty.<br></div></div></blockquote><div><br></div><div><div style="margin:0px;font-size:10px;font-family:Monaco">#include <unistd.h></div><div style="margin:0px;font-size:10px;font-family:Monaco">#include <stdio.h></div><div style="margin:0px;font-size:10px;font-family:Monaco;min-height:14px"><br></div><div style="margin:0px;font-size:10px;font-family:Monaco">int main() {</div><div style="margin:0px;font-size:10px;font-family:Monaco"> unsigned int *p = (unsigned int *)getpid;</div><div style="margin:0px;font-size:10px;font-family:Monaco"> for (int i=0; i<16; i++) printf("%x ", *(p+i));</div><div style="margin:0px;font-size:10px;font-family:Monaco">}</div><div style="margin:0px;font-size:10px;font-family:Monaco"><br></div></div></div></div></blockquote></div></div>