stack

Android stack size

怎甘沉沦 提交于 2019-12-04 11:27:02
How can i get and change the stack size (even for the main thread) of my Android application. AFAIK -Xss can be used as a command line to change the main threads stacks size, if not using the command line the app framework will use the default size. In this case if you need more stack you will need to start a thread (using this ctor ) to do the work. The main thread stack size is set in the firmware and cannot be modified, short of modifying the firmware for your own phone. As Mr. Strong indicates, for threads you fork, you can set your own stack size. 来源: https://stackoverflow.com/questions

Retrieving return address of an exception on ARM Cortex M0

让人想犯罪 __ 提交于 2019-12-04 10:12:48
I am trying to retrieve the return address of an IRQ handler in my code. My aim is to save the value of the PC just before the watchdog timer expires and before the reset for debug purposes, using WDT_IRQHandler(). I am also testing this approach with other IRQs to check if I grasped the idea. But it seems I haven't. I have read the documentation available. I understood that when an exception happens, 8 registers are pushed to the stack: R0, R1, R2, R3, R12, LR, PC and XPSR. I have also read that the stack is automatically double word aligned. So in my mind, retrieving the return address is as

How come Go doesn't have stackoverflows

笑着哭i 提交于 2019-12-04 07:58:35
问题 I read in this presentation http://golang.org/doc/ExpressivenessOfGo.pdf page 42: Safe - no stack overflows How is this possible? and/or how does Go works to avoid this? 回答1: It's a feature called "segmented stacks": every goroutine has its own stack, allocated on the heap. In the simplest case, programming language implementations use a single stack per process/address space, commonly managed with special processor instructions called push and pop (or something like that) and implemented as

Remove activities manually from Android app stack

被刻印的时光 ゝ 提交于 2019-12-04 07:25:07
I been working on Android Native App , What i was trying to do is : Activities - A -> B -> C Then A-> B -> C -> C . From C Activity if it again point to C then i want to remove C , B from stack manually . On my back it should move only to A . I tried finish() but problem is : Activities - A -> B -> C Then A-> B -> C -> C on finish A -> B -> C required state A-> C . Is anyone know how to catch all activities in stack and remove specific activities from stack ?? In Activity C, override onBackPressed and add in something like: @Override public void onBackPressed() { if (shouldGoBackToA) { //

How to find the matching pair of braces in a string?

心不动则不痛 提交于 2019-12-04 07:14:20
Suppose I have a string "(paid for) + (8 working hours) + (company rules)" . Now I want to check whether this complete string is surrounded with parentheses or not. Basically I want to check if the string is like this or not : "((paid for) + (8 working hours) + (company rules))". If it is already surrounded with parentheses, then I will leave it as it is, otherwise I will apply parentheses to the complete string so that the ouput is : "((paid for) + (8 working hours) + (company rules))" . By counting the number of parentheses, I am not able to solve this problem. Can anyone please suggest a

Is it on the Stack or Heap?

馋奶兔 提交于 2019-12-04 07:12:30
I have some C code that is something of a puzzle. For a reason to do with this code, I'm wondering how I can tell if a struct object is ending up on the heap or stack? The objects are not being created with malloc or calloc . They start their life in the form of an array. For the purposes of this post, I'm going to call the struct Emp. Emp myEmp[6]; /* Each myEmp[?] item is populated in code */ The objects are sorted and manipulated in various ways and at some point, the objects are copied and then handed to a array-pointer. The copy is done via memcpy . The objects are then put in to

Does Stack<> constructor reverse the stack when being initialized from other one?

帅比萌擦擦* 提交于 2019-12-04 06:47:39
Here is the code: var s = new Stack<int>(); s.Push(1); s.Push(2); s.Push(3); s.Push(4); var ns = new Stack<int>(s); var nss = new Stack<int>(new Stack<int>(s)); and then let's see the result tbLog.Text += "s stack:"; while(s.Count > 0) { tbLog.Text += s.Pop() + ","; } tbLog.Text += Environment.NewLine; tbLog.Text += "ns stack:"; while (ns.Count > 0) { tbLog.Text += ns.Pop() + ","; } tbLog.Text += Environment.NewLine; tbLog.Text += "nss stack:"; while (nss.Count > 0) { tbLog.Text += nss.Pop() + ","; } produces the following output: s stack:4,3,2,1, ns stack:1,2,3,4, nss stack:4,3,2,1, So, ns

Which versions of GCC, or flags, should I use when studying buffer overflows?

最后都变了- 提交于 2019-12-04 06:04:05
Recently, I've been studying buffer overflows as an undergraduate student in Computer Engineering. Simply out of interest, I began researching and studying buffer overflows, but have gotten stuck when attempting to implement them in my own C programs on my computer, compiled with GCC 4.9.1 (in Debian Jessie). I've heard that there are sorts of stack overflow protection in newer compilers, so I'm thinking that my issue is that my compiler version is too new. Either that, or I'm not compiling with the correct flags (none). So are there good versions of GCC for me to obtain to test buffer

Refill Stack using Node Implementation

ぃ、小莉子 提交于 2019-12-04 05:40:14
问题 I'm having a hard time refilling the stack after i take it all off in order to print it out. I am using node implementation so i think this fact is what is confusing me. Any suggestions would be appreciated, thank you. This is my original stack::print() // Function to print Gumball info field (color and counter) void Stack::print() { Node *p; Type x; while(top != NULL) { p = top; x = p -> getinfo(); cout << " " << x.color << " " << " " << x.counter << endl << endl; top = p -> getnext(); }

Why can't we allocate dynamic memory on the stack?

谁说我不能喝 提交于 2019-12-04 05:29:55
Allocating stuff on the stack is awesome because than we have RAII and don't have to worry about memory leaks and such. However sometimes we must allocate on the heap: If the data is really big (recommended) - because the stack is small. If the size of the data to be allocated is only known at runtime (dynamic allocation). Two questions: Why can't we allocate dynamic memory (i.e. memory of size that is only known at runtime) on the stack? Why can we only refer to memory on the heap through pointers, while memory on the stack can be referred to via a normal variable? I.e. Thing t; . Edit: I