From: hx <silent2600@gmail.com>
To: emacs-devel@gnu.org
Subject: how to keep a copy of emacs_env or ert in module ?
Date: Sun, 11 Sep 2016 12:28:49 +0800 [thread overview]
Message-ID: <CAALPCHtSpVtb8Wb=Kr2JLzC6FF5oaVWd-9K_T9fP52=USEwc1w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3278 bytes --]
//mymodule.c
#include <emacs-module.h>
struct emacs_runtime *gert = NULL;
emacs_env *genv = NULL;
void my_test(void) {
genv->intern(genv, "nil"); // sig seg fault -_-!
}
int emacs_module_init(struct emacs_runtime *ert) {
emacs_env *env = ert->get_environment(ert);
gert = ert;
genv = env;
return 0;
} // until here, the gert and genv content still correct.
//EOF
I want to use "env" in my_test(void) but don't want to pass it as a
parameter,
so I set a global genv to save the pointer.
but the *genv content was changed:
Breakpoint 4, emacs_module_init (ert=0xbfb904f0) at mymodule.c:411
411 return 0;
(gdb) p *gert
$4 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
412 } ########### out of emacs_module_init() #######################
(gdb) s
0x081680b1 in Fmodule_load ()
(gdb) p *gert
$5 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function Fmodule_load,
which has no line number information.
0x08164610 in Fload ()
(gdb) p *gert
$6 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function Fload,
which has no line number information.
0x0814ee38 in Frequire ()
(gdb) p *gert
$7 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function Frequire,
which has no line number information.
0x08141530 in unbind_to ()
(gdb) p *gert
$8 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function unbind_to,
which has no line number information.
0x08141d8b in eval_sub ()
(gdb) p *gert
$9 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function eval_sub,
which has no line number information.
0x08143fa8 in Feval ()
(gdb) p *gert
$10 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function Feval,
which has no line number information.
0x08141530 in unbind_to ()
(gdb) p *gert
$11 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function unbind_to,
which has no line number information.
0x081427fd in Ffuncall ()
(gdb) p *gert
$12 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function Ffuncall,
which has no line number information.
0x081770bf in exec_byte_code ()
(gdb) p *gert
$13 = {size = 12, private_members = 0xbfb904fc, get_environment = 0x8165910
<module_get_environment>}
(gdb) s
Single stepping until exit from function exec_byte_code,
which has no line number information.
0x08142355 in funcall_lambda ()
(gdb) p *gert
$14 = {size = 138896016, private_members = 0x0, get_environment = 0x4c38}
(gdb) q
A debugging session is active.
what's happened after calling funcall_lambda () ?
is it possible to keep a copy of the *env in module ?
thanks!
[-- Attachment #2: Type: text/html, Size: 4493 bytes --]
next reply other threads:[~2016-09-11 4:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-11 4:28 hx [this message]
2016-09-11 6:41 ` how to keep a copy of emacs_env or ert in module ? Andreas Schwab
2016-09-11 8:02 ` Philipp Stephani
2016-09-13 0:02 ` hx
2016-09-13 6:18 ` Philipp Stephani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAALPCHtSpVtb8Wb=Kr2JLzC6FF5oaVWd-9K_T9fP52=USEwc1w@mail.gmail.com' \
--to=silent2600@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.