Repository navigation
Replies: 12 comments 2 replies
|
I'm not quite sure what you are doing, but in case it's useful, here is a script I pilfered from the Internet some time ago. Maybe it has some interesting ideas that you can use. |
0 replies
|
On Sun, Aug 10, 2025 at 04:55:00 (-0700), gerd-moellmann wrote:
gerd-moellmann left a comment (jdtsmith/emacs-mac#77)
I'm not quite sure what you are doing, but in case it's useful, here
is a script I pilfered from the Internet some time ago. Maybe it has
some interesting ideas that you can use.
I tried that script before, I get:
```
emacs-mac/mac/Emacs.app: replacing existing signature
emacs-mac/mac/Emacs.app: resource fork, Finder information, or similar detritus not allowed
codesign failed!
```
I think that bundling might be doing something outdated which requires
to move `libexec` and `Emacs.sh` outside `Contents/` before trying to
sign the bundle (and then move them back ;-))
|
0 replies
|
Alexander Przemysław Kamiński ***@***.***> writes:
*
exlee left a comment (jdtsmith/emacs-mac#77)
On Sun, Aug 10, 2025 at 04:55:00 (-0700), gerd-moellmann wrote:
> gerd-moellmann left a comment (jdtsmith/emacs-mac#77)
>
> I'm not quite sure what you are doing, but in case it's useful, here
> is a script I pilfered from the Internet some time ago. Maybe it has
> some interesting ideas that you can use.
I tried that script before, I get:
```
emacs-mac/mac/Emacs.app: replacing existing signature
emacs-mac/mac/Emacs.app: resource fork, Finder information, or similar detritus not allowed
codesign failed!
```
I think that bundling might be doing something outdated which requires
to move `libexec` and `Emacs.sh` outside `Contents/` before trying to
sign the bundle (and then move them back ;-))
Ah, thanks, good to know.
I think I've only used the script once, when I tried to produce core
files (which worked but didn't seem practical in the end.)
For profiling, with NS that is, I always just use src/emacs as-is, with
xctrace. Haven't tried with mac, though. And the fix for allowing
running src/emacs would be required of course.
|
0 replies
|
For me, |
0 replies
|
JD Smith ***@***.***> writes:
*
jdtsmith left a comment (jdtsmith/emacs-mac#77)
For me, Instruments.app "just works" with any compiled version of Emacs. I did take some notes about using codesign to silence
the annoying SIGTRAP issue when running lldb from within emacs (vs. in Terminal.app). I ended up using csrutil to disable SIP
debug restriction:
I only ever debug src/emacs in lldb, for example if I want to pass
command line options, or use xattacb to attach lldb to the next Emacs I
start. No extra steps.
|
0 replies
So you can start |
0 replies
|
JD Smith ***@***.***> writes:
*
jdtsmith left a comment (jdtsmith/emacs-mac#77)
or use xattacb to attach lldb to the next Emacs I start.
So you can start lldb in Terminal, and attached M-x lldb to it? Could you share how you do this???
I do M-x lldb RET RET, i.e. no arguments to lldb, with default directory
src/ so that it picks up .lldbinit. I have loading .lldbinit enabled as
described in the comment in .lldbinit.
Then in the Gud buffer,
(lldb) xattach
which is defined in .lldbinit.
# Attach to future Emacs. On a tty, it might be advisable to redirect
# Emacs' stderr to some log file so that one can see the output of
# xdebug_print and other output to stderr.
command alias xattach process attach --waitfor --name emacs --continue
Then start Emacs in whatever way you want, for example double-click on a
bundle or run it without -nw from a terminal.
Same procedure for tty Emacs. Start Emacs with -nw from a terminal.
This all requires the "make src/emacs startable" patch of course for the
GUI case.
If I need extra breakpoints from the start, I put them in .lldbinit
before M-x lldb.
|
0 replies
|
Thanks. Perhaps |
0 replies
|
JD Smith ***@***.***> writes:
*
jdtsmith left a comment (jdtsmith/emacs-mac#77)
Thanks. Perhaps --waitfor is a workaround to the SIP restriction of "apps we don't know about can't launch processes with
debugging".
I can also start something in the Gud buffer, if I want, which is
sometimes I sometimes need. Example
M-x lldb RET RET, and in my .lldbinit I have
target create temacs
settings set -- target.run-args --batch -l loadup --temacs=pbootstrap --bin-dest '/Users/gerd/emacs/github/cl-packages/carbon/Emacs.app/Contents/MacOS/' --eln-dest '/Users/gerd/emacs/github/cl-packages/carbon/Emacs.app/Contents/Frameworks/'
command alias go process launch --working-dir .
settings set target.disable-aslr false
Then in Gud type go to run that.
It's not limited to tmeacs.
|
0 replies
|
Gerd Möllmann ***@***.***> writes:
JD Smith ***@***.***> writes:
> *
> jdtsmith left a comment (jdtsmith/emacs-mac#77)
>
> Thanks. Perhaps --waitfor is a workaround to the SIP restriction of "apps we don't know about can't launch processes with
> debugging".
I can also start something in the Gud buffer, if I want, which is
sometimes I sometimes need. Example
M-x lldb RET RET, and in my .lldbinit I have
target create temacs
settings set -- target.run-args --batch -l loadup --temacs=pbootstrap
--bin-dest
'/Users/gerd/emacs/github/cl-packages/carbon/Emacs.app/Contents/MacOS/'
--eln-dest
'/Users/gerd/emacs/github/cl-packages/carbon/Emacs.app/Contents/Frameworks/'
command alias go process launch --working-dir .
settings set target.disable-aslr false
Then in Gud type go to run that.
It's not limited to tmeacs.
Let me add that I used that all with NS, so maybe something in
emacs-mac's build is different.
|
0 replies
|
Gerd Möllmann ***@***.***> writes:
Let me add that I used that all with NS, so maybe something in
emacs-mac's build is different.
Sorry, that can be misunderstood. What I wanted to say is that I've so
far only used the xattach method with mac. I haven't used launch with
it, and I haven't used it with tty Emacs yet.
But I also don't see why that would be different from what it is a
master.
|
2 replies
|
Alexander Przemysław Kamiński ***@***.***> writes:
I know exactly why this happens. It seems that signed binary and executable aren't the same. It's easy to reproduce with
restart-emacs package. Parent - works, forked process - doesn't.
Don't know what you are saying, but there is this in 'main':
macappkit.m:
17253 if (getenv ("EMACS_REINVOKED_FROM_SHELL"))
17254 unsetenv ("EMACS_REINVOKED_FROM_SHELL");
17255 else
17256 {
17257 char *shlvl = getenv ("SHLVL");
17258
17259 if (shlvl == NULL || atoi (shlvl) == 0)
17260 {
17261 CFBundleRef bundle = CFBundleGetMainBundle ();
17262
17263 /* Reinvoke the current executable using the helper script
17264 in .../Emacs.app/Contents/MacOS/Emacs.sh so the
17265 application can get environment variables from the login
17266 shell if necessary. Previously we invoked the helper
17267 script directly by specifying it as the value for
17268 CFBundleExecutable in Info.plist. But this makes
17269 LookupViewSource invoked by Command-Control-D or
17270 three-finger tap crash on OS X 10.10.3. This is because
17271 the ViewBridge framework tries to create a bundle object
17272 from the URL obtained by SecCodeCopyPath, which does not
17273 store the URL for the application bundle but the one for
17274 the executable if CFBundleExecutable does not correspond
17275 to the running application process. */
17276 if (bundle && CFBundleGetIdentifier (bundle))
17277 {
17278 char **new = alloca ((argc + 1) * sizeof *new);
17279 size_t len = strlen (argv[0]);
17280
17281 new[0] = alloca (len + sizeof (".sh"));
17282 strcpy (new[0], argv[0]);
17283 strcpy (new[0] + len, ".sh");
17284 memcpy (new + 1, argv + 1, argc * sizeof *new);
17285 execvp (new[0], new);
17286 }
17287 }
17288 }
That's a bit like exec-path-froms-shell that I use with NS, and which
isn't necessary with mac.
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Took me some time to figure out, sharing:
EmacsMac.mk
Sign.mk
All reactions