unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Is compiling Emacs with -finstrument-functions supported?
@ 2021-12-09 17:11 Arthur Miller
  2021-12-09 18:43 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Arthur Miller @ 2021-12-09 17:11 UTC (permalink / raw)
  To: emacs-devel

temacs crashes when compiled with -finstrument-functions when it tries to
produce dump file:

  CC       json.o
  CC       terminfo.o
  CC       lastfile.o
  CCLD     temacs
/usr/bin/mkdir -p ../etc
make -C ../lisp update-subdirs
make[3]: Går till katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
make[3]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
cp -f temacs bootstrap-emacs
rm -f bootstrap-emacs.pdmp
./temacs --batch  -l loadup --temacs=pbootstrap \
        --bin-dest /usr/local/bin/ --eln-dest /usr/local/lib/emacs/29.0.50/
make[2]: *** [Makefile:908: bootstrap-emacs.pdmp] Segmenteringsfel (minnesdump)
make[2]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/src”
make[1]: *** [Makefile:456: src] Fel 2
make[1]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs”
make: *** [Makefile:1166: bootstrap] Fel 2

I had no other configure options but debug flags:

$ ./config.status --config
'CFLAGS=-finstrument-functions -ggdb3 -O0'

I pulled just before the build, run make clean, created new branch and
configured and run make bootstrap.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is compiling Emacs with -finstrument-functions supported?
  2021-12-09 17:11 Is compiling Emacs with -finstrument-functions supported? Arthur Miller
@ 2021-12-09 18:43 ` Eli Zaretskii
  2021-12-09 20:33   ` Arthur Miller
  2021-12-09 20:56   ` Arthur Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Eli Zaretskii @ 2021-12-09 18:43 UTC (permalink / raw)
  To: Arthur Miller; +Cc: emacs-devel

> From: Arthur Miller <arthur.miller@live.com>
> Date: Thu, 09 Dec 2021 18:11:13 +0100
> 
> temacs crashes when compiled with -finstrument-functions when it tries to
> produce dump file:
> 
>   CC       json.o
>   CC       terminfo.o
>   CC       lastfile.o
>   CCLD     temacs
> /usr/bin/mkdir -p ../etc
> make -C ../lisp update-subdirs
> make[3]: Går till katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
> make[3]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
> cp -f temacs bootstrap-emacs
> rm -f bootstrap-emacs.pdmp
> ./temacs --batch  -l loadup --temacs=pbootstrap \
>         --bin-dest /usr/local/bin/ --eln-dest /usr/local/lib/emacs/29.0.50/
> make[2]: *** [Makefile:908: bootstrap-emacs.pdmp] Segmenteringsfel (minnesdump)
> make[2]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/src”
> make[1]: *** [Makefile:456: src] Fel 2
> make[1]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs”
> make: *** [Makefile:1166: bootstrap] Fel 2

Can you run the failing command under GDB, and when it crashes, post
the C-level backtrace?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is compiling Emacs with -finstrument-functions supported?
  2021-12-09 18:43 ` Eli Zaretskii
@ 2021-12-09 20:33   ` Arthur Miller
  2021-12-09 20:56   ` Arthur Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Arthur Miller @ 2021-12-09 20:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Thu, 09 Dec 2021 18:11:13 +0100
>> 
>> temacs crashes when compiled with -finstrument-functions when it tries to
>> produce dump file:
>> 
>>   CC       json.o
>>   CC       terminfo.o
>>   CC       lastfile.o
>>   CCLD     temacs
>> /usr/bin/mkdir -p ../etc
>> make -C ../lisp update-subdirs
>> make[3]: Går till katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
>> make[3]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
>> cp -f temacs bootstrap-emacs
>> rm -f bootstrap-emacs.pdmp
>> ./temacs --batch  -l loadup --temacs=pbootstrap \
>>         --bin-dest /usr/local/bin/ --eln-dest /usr/local/lib/emacs/29.0.50/
>> make[2]: *** [Makefile:908: bootstrap-emacs.pdmp] Segmenteringsfel (minnesdump)
>> make[2]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/src”
>> make[1]: *** [Makefile:456: src] Fel 2
>> make[1]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs”
>> make: *** [Makefile:1166: bootstrap] Fel 2
>
> Can you run the failing command under GDB, and when it crashes, post
> the C-level backtrace?

Seems like I can not read function addresses:

$ gdb --args src/temacs --batch  -l loadup --temacs=pbootstrap --bin-dest  --eln-dest
GNU gdb (GDB) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from src/temacs...
(gdb) r
Starting program: /home/arthur/repos/emacs-tests/emacs/src/temacs --batch -l loadup --temacs=pbootstrap --bin-dest --eln-dest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x000055555572c41c in __cyg_profile_func_enter (func=<error reading variable: Cannot access memory at address 0x7fffff66fff8>, caller=<error reading variable: Cannot access memory at address 0x7fffff66fff0>) at emacs.c:173                                                                      
173     __cyg_profile_func_enter (void *func,  void *caller) {
(gdb)

I put my trace hooks in emacs.c. This is maybe nuts place to put them into? I
don't really know where I should put them, but it shouldn't matter? Or I am
wrong there?

static FILE *log_file = 0;
void __attribute__ ((constructor)) trace_begin (void);
void __attribute__ ((destructor)) trace_end (void);
void __cyg_profile_func_enter (void *func,  void *caller);
void __cyg_profile_func_exit (void *func, void *caller);

void
__attribute__ ((constructor))
trace_begin (void) {
 log_file = fopen("trace.log", "w");
}
 
void
__attribute__ ((destructor))
trace_end (void) {
 if(log_file) {
 fclose(log_file);
 }
}
 
void
__cyg_profile_func_enter (void *func,  void *caller) {
 if(log_file) {
 fprintf(log_file, "IN %p %p\n", func, caller);
 }
}

void
__cyg_profile_func_exit (void *func, void *caller) {
 if(log_file) {
 fprintf(log_file, "UT %p %p\n", func, caller);
 }
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Is compiling Emacs with -finstrument-functions supported?
  2021-12-09 18:43 ` Eli Zaretskii
  2021-12-09 20:33   ` Arthur Miller
@ 2021-12-09 20:56   ` Arthur Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Arthur Miller @ 2021-12-09 20:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Date: Thu, 09 Dec 2021 18:11:13 +0100
>> 
>> temacs crashes when compiled with -finstrument-functions when it tries to
>> produce dump file:
>> 
>>   CC       json.o
>>   CC       terminfo.o
>>   CC       lastfile.o
>>   CCLD     temacs
>> /usr/bin/mkdir -p ../etc
>> make -C ../lisp update-subdirs
>> make[3]: Går till katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
>> make[3]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/lisp”
>> cp -f temacs bootstrap-emacs
>> rm -f bootstrap-emacs.pdmp
>> ./temacs --batch  -l loadup --temacs=pbootstrap \
>>         --bin-dest /usr/local/bin/ --eln-dest /usr/local/lib/emacs/29.0.50/
>> make[2]: *** [Makefile:908: bootstrap-emacs.pdmp] Segmenteringsfel (minnesdump)
>> make[2]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs/src”
>> make[1]: *** [Makefile:456: src] Fel 2
>> make[1]: Lämnar katalogen ”/home/arthur/repos/emacs-tests/emacs”
>> make: *** [Makefile:1166: bootstrap] Fel 2
>
> Can you run the failing command under GDB, and when it crashes, post
> the C-level backtrace?

Sorry, my bad; I ended up in infinite loop :). I thought GCC was clever enough
to not instrument trace function on it's own. After adding
no_instrument_function to tracing hooks, it works. 

__attribute__((no_instrument_function))
void __cyg_profile_func_enter (void *func,  void *caller) {
 if(log_file) {
 fprintf(log_file, "IN %p %p\n", func, caller);
 }
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-09 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 17:11 Is compiling Emacs with -finstrument-functions supported? Arthur Miller
2021-12-09 18:43 ` Eli Zaretskii
2021-12-09 20:33   ` Arthur Miller
2021-12-09 20:56   ` Arthur Miller

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).