Timer

Marc Brünink
2013-05-06T09:52:30Z

I want to execute a piece of code at regular intervals. Actually I'm sampling $pc.
(let's not go into detail why I use gdb)

My current solution just starts another process that sends a SIGTRAP to the debugged application. Using a simple script I can print the $pc.

However, I just realised that this approach does not work too well. If gdb is stopped due to a breakpoint it will interpret the received SIGTRAP as another hit of the very same breakpoint.

Reproduce:
1. Attach to any program
2. Create any breakpoint
3. Wait until breakpoint is hit
4. Send SIGTRAP to debugged application
5. continue

Actually, now that I think about it, I should have anticipated this behaviour.
Is there a better way to execute a piece of code at regular intervals?

Marc
From gdb-return-42099-listarch-gdb=sources.redhat.com@sourceware.org Mon May 06 17:12:03 2013
Return-Path: <gdb-return-42099-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 9572 invoked by alias); 6 May 2013 17:12:03 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 9560 invoked by uid 89); 6 May 2013 17:12:02 -0000
X-Spam-SWARE-Status: No, score=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1
Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 06 May 2013 17:12:02 +0000
Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r46HBua3025203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits%6 verify=OK); Mon, 6 May 2013 13:11:56 -0400
Received: from barimba (ovpn-113-163.phx2.redhat.com [10.3.113.163]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r46HBtp1019867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits\x128 verify=NO); Mon, 6 May 2013 13:11:55 -0400
From: Tom Tromey <tromey@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: "Miguel A. G L" <miguelnum@gmail.com>, gdb@sourceware.org
Subject: Re: How I can force "gdb" for internal use command-messages only in English?
References: <CAAZ-Otu15DunhUQ_qc2TvB6mXr40TsfADk2iCX1jNmhjBGJL3Q@mail.gmail.com> <20130502054104.GH3525@adacore.com>
Date: Mon, 06 May 2013 17:12:00 -0000
In-Reply-To: <20130502054104.GH3525@adacore.com> (Joel Brobecker's message of "Thu, 2 May 2013 09:41:04 +0400")
Message-ID: <87wqrcyqw5.fsf@fleche.redhat.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SW-Source: 2013-05/txt/msg00026.txt.bz2
Content-length: 717

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

>> Basically the problem occurs because some commands that sends "gdb" to
>> the IDE are translated into "Spanish" and the IDE looks texts these
>> commands in English.

Joel> If Lazarus is depending on the language used by GDB to be English,
Joel> it sounds like Lazarus should override the user's environment in
Joel> terms of i18n. Typically, the language is determined via the LANG
Joel> and/or LC_* environment variables, so it should be able to force
Joel> English by setting LANG/LC_ALL et al to Eg. "C" before starting GDB.

I just wanted to mention that it would be even better to change Lazarus
to use MI. This is what MI was made for.

Tom