From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31825 invoked by alias); 30 Oct 2014 12:43:13 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 31815 invoked by uid 89); 30 Oct 2014 12:43:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 30 Oct 2014 12:43:11 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9UCh3Vw010664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Oct 2014 08:43:03 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9UCh03T030022; Thu, 30 Oct 2014 08:43:01 -0400 Message-ID: <54523254.8070706@redhat.com> Date: Thu, 30 Oct 2014 12:43:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: joaoandreferro@sapo.pt, Doug Evans CC: gdb Subject: Re: Can GDB support "temporal breakpoints"? References: <20141029185541.Horde._3keczfPGLf4wL2j8_4tFw6@mail.sapo.pt> <20141030121815.Horde.8vqm4_U-9cztH4TOoUFeYQ2@mail.sapo.pt> In-Reply-To: <20141030121815.Horde.8vqm4_U-9cztH4TOoUFeYQ2@mail.sapo.pt> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-10/txt/msg00136.txt.bz2 On 10/30/2014 12:18 PM, joaoandreferro@sapo.pt wrote: >> I can also imagine a hack where you run a side program >> that sleeps for the specified period of time and it sends SIGUSR1 >> (or whatever) to the inferior, and then have gdb catch SIGUSR1, >> do whatever you want at that time, >> and then resume the inferior (discarding the signal). > > I'll investigate this solution, although I think I'll have the sma > intrusion problem (in the Linux kernel). Alternatively, write a little Python. You can subclass python's gdb.Breakpoint to create new breakpoint types, and implement the Breakpoint.stop method to adjust when the breakpoint causes a stop or not. See https://sourceware.org/gdb/onlinedocs/gdb/Breakpoints-In-Python.html In your case, you'd return false if the time hasn't passed yet. Something like: class bp_timer (gdb.Breakpoint): def stop (self): if timer has elapsed return True return False end (gdb) python bp = bp_timer("function_foo") Alternatively, write a convenience function in Python, that handles the "has time elapsed time" part. Then use that as breakpoint's condition predicate. Something along the lines of: (gdb) python mytimer = MyTimer(10) (gdb) break foo if $my_timer_elapsed_predicate(mytimer) https://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html Thanks, Pedro Alves