unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: sva-news@mygooglest.com, 20843@debbugs.gnu.org
Subject: bug#20843: 24.5; Profiler error: "Invalid sampling interval"
Date: Sun, 21 Jun 2015 18:17:27 -0400	[thread overview]
Message-ID: <558737F7.4080709@cornell.edu> (raw)
In-Reply-To: <83oak9hzzs.fsf@gnu.org>

On 6/21/2015 10:56 AM, Eli Zaretskii wrote:
>> Date: Sat, 20 Jun 2015 17:47:21 -0400
>> From: Ken Brown <kbrown@cornell.edu>
>> CC: sva-news@mygooglest.com, 20843@debbugs.gnu.org
>>
>>> Then I guess the configure-time test for setitimer should also test
>>> for ITIMER_PROF.
>>
>> I'd be glad to give this a try, but I don't have any experience writing
>> autoconf macros.  Is there a standard macro to test whether a function
>> accepts a particular argument?  If not, can you (or anyone) point me to
>> an example that I can imitate?
>
> Actually, perhaps I misunderstood you: are you saying that Cygwin does
> have ITIMER_PROF defined in the appropriate header, but when setitimer
> is called with it, it always fails?

Yes.

> If so, we cannot test this at
> configure time, because it means we will have to run a program, which
> is not a good idea.
>
> So in that case, I think we should simply disable the CPU profiler on
> Cygwin using "#ifndef __CYGWIN__" or some such.

Done as commit 5fac0de.

>>>   Also, the diagnostics should be improved, as the
>>> wording is misleading in that case.
>>
>> As it stands, profiler-cpu-start reports "Invalid sampling interval"
>> whenever setup_cpu_timer fails to start the timer, regardless of the
>> reason.  I'll try to improve this.
>
> Yes, please.

How's this:

--- a/src/profiler.c
+++ b/src/profiler.c
@@ -250,6 +250,8 @@ deliver_profiler_signal (int signal)
    deliver_process_signal (signal, handle_profiler_signal);
  }

+static bool sampling_interval_ok;
+
  static enum profiler_cpu_running
  setup_cpu_timer (Lisp_Object sampling_interval)
  {
@@ -258,11 +260,13 @@ setup_cpu_timer (Lisp_Object sampling_interval)
    struct timespec interval;
    int billion = 1000000000;

-  if (! RANGED_INTEGERP (1, sampling_interval,
-                        (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / billion
-                         ? ((EMACS_INT) TYPE_MAXIMUM (time_t) * billion
-                            + (billion - 1))
-                         : EMACS_INT_MAX)))
+  sampling_interval_ok =
+    RANGED_INTEGERP (1, sampling_interval,
+                    (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / billion
+                     ? ((EMACS_INT) TYPE_MAXIMUM (time_t) * billion
+                        + (billion - 1))
+                     : EMACS_INT_MAX));
+  if (! sampling_interval_ok)
      return NOT_RUNNING;

    current_sampling_interval = XINT (sampling_interval);
@@ -338,7 +342,12 @@ See also `profiler-log-size' and 
`profiler-max-stack-depth'.  */)

    profiler_cpu_running = setup_cpu_timer (sampling_interval);
    if (! profiler_cpu_running)
-    error ("Invalid sampling interval");
+    {
+      if (! sampling_interval_ok)
+       error ("Invalid sampling interval");
+      else
+       error ("Unable to start profiler timer");
+    }

    return Qt;
  }

Ken





  reply	other threads:[~2015-06-21 22:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18  8:37 bug#20843: 24.5; Profiler error: "Invalid sampling interval" Sebastien Vauban
2015-06-18  8:57 ` Eli Zaretskii
     [not found]   ` <83k2v1l7g4.fsf-mXXj517/zsQ@public.gmane.org>
2015-06-18 11:58     ` Sebastien Vauban
     [not found]   ` <mailman.5225.1434628753.904.bug-gnu-emacs@gnu.org>
     [not found]     ` <mailman.5225.1434628753.904.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2015-06-19 13:38       ` Sebastien Vauban
2015-06-19 17:42         ` Eli Zaretskii
2015-06-20 19:02   ` Ken Brown
2015-06-20 19:10     ` Eli Zaretskii
2015-06-20 21:47       ` Ken Brown
2015-06-21 14:56         ` Eli Zaretskii
2015-06-21 22:17           ` Ken Brown [this message]
     [not found]             ` <558737F7.4080709-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org>
2015-06-22  8:00               ` Sebastien Vauban
2015-06-22 11:57                 ` Ken Brown
2015-06-22 15:12                   ` Eli Zaretskii
2015-06-22 21:15                     ` Ken Brown
2015-06-22 21:44                       ` Ken Brown
     [not found]                         ` <558881B0.6080404-HmMyXyqgL2CVc3sceRu5cw@public.gmane.org>
2015-06-23  8:39                           ` Sebastien Vauban
2015-06-23 17:20                             ` Ken Brown
     [not found]                             ` <mailman.5513.1435080075.904.bug-gnu-emacs@gnu.org>
     [not found]                               ` <mailman.5513.1435080075.904.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2015-07-02 13:27                                 ` Sebastien Vauban
2015-07-02 13:59                                   ` Ken Brown
2015-06-22 15:35             ` Eli Zaretskii
2015-06-22 18:04               ` Ken Brown
2015-06-22 18:50                 ` Eli Zaretskii
2015-06-22 19:30                   ` Ken Brown

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=558737F7.4080709@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=20843@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=sva-news@mygooglest.com \
    /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 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).