On Mon, May 10, 2010 at 11:57:08AM +0400, Lev Serebryakov wrote: > Hello, Freebsd-hackers. > > I'm proting some application from Linux, which discover its stack > bounds by reading and pasing "/proc/self/maps". FreeBSD have > "/prov/curproc/map", but I can not find how to determine which record > is for stack (I've looked into implementation of proc_fs, but it > doesn't contain any specail processing for process stack). > > How could I determine stack bounds of current process on FreeBSD > 7/8/9?
I think the right question is why the program needs the information at all. Really, the system has no data to answer your question. Which stack are you asking for ? The stack of main thread, set up by kernel, is very different from the stack established by the threading library for newly created thread. What should happen for signal altstacks ? Also, the threading library clips the main thread stack to match its size with default stack size (I do think this is unsafe and wrong). Also, the application can legitimately allocate arbitrary memory region and use it as the stack (this is essentially what threading library does).
pgpyW5JQTfRcA.pgp
Description: PGP signature