Re: Why the setjmp and longjmp I wrote can not work?
From: Paul Pluzhnikov (ppluzhnikov-nsp_at_charter.net)
Date: 11/06/05
- Next message: Jordan Abel: "Re: Floyd Davidson 's getch() routine"
- Previous message: Gustavo Rios: "Re: open source: ASD project"
- In reply to: Zheng Da: "Why the setjmp and longjmp I wrote can not work?"
- Next in thread: Zheng Da: "Re: Why the setjmp and longjmp I wrote can not work?"
- Reply: Zheng Da: "Re: Why the setjmp and longjmp I wrote can not work?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 06 Nov 2005 12:17:10 -0800
"Zheng Da" <zhengda1936@gmail.com> writes:
> #include <stdio.h>
Your program as posted doesn't compile:
junk.c: In function `mysetjmp':
junk.c:13: error: subscripted value is neither array nor pointer
junk.c:16: error: subscripted value is neither array nor pointer
... etc ...
Fixing these ...
> When the computer execute jmp %2, and gives me a segment fault.
Nope. It crashes *before* it reaches that instruction.
Learn to use the debugger to figure that out.
> I do not know why the address I save is a invalid address, and wonder
> to know what should I do if I want that mysetjmp and mylongjmp can work
The 'mylongjmp' can't be reasonably implemented with inline assembly.
You'll have to use "pure" assembly if you are to have any chance
of success. Also note that setjmp/longjmp must save *all* registers.
At a minimum you must save/resore %esp in addition to %ebp.
Cheers,
-- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email.
- Next message: Jordan Abel: "Re: Floyd Davidson 's getch() routine"
- Previous message: Gustavo Rios: "Re: open source: ASD project"
- In reply to: Zheng Da: "Why the setjmp and longjmp I wrote can not work?"
- Next in thread: Zheng Da: "Re: Why the setjmp and longjmp I wrote can not work?"
- Reply: Zheng Da: "Re: Why the setjmp and longjmp I wrote can not work?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|