From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98238 invoked by alias); 5 Feb 2016 23:21:07 -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 98229 invoked by uid 89); 5 Feb 2016 23:21:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1977, FAQs, watchpoints, HX-CTCH-RefID:1,fgs X-HELO: rgout06.bt.lon5.cpcloud.co.uk Received: from rgout06.bt.lon5.cpcloud.co.uk (HELO rgout06.bt.lon5.cpcloud.co.uk) (65.20.0.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 05 Feb 2016 23:21:05 +0000 X-OWM-Source-IP: 109.152.145.204 (GB) X-OWM-Env-Sender: gatk@btinternet.com X-CTCH-RefID: str=0001.0A090204.56B52E5F.0028,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-Junkmail-Premium-Raw: score=28/50,refid=2.7.2:2016.2.5.202416:17:28.394,ip=109.152.145.204,rules=__HAS_FROM, __PHISH_FROM2, __FRAUD_WEBMAIL_FROM, __CT, __CT_TEXT_PLAIN, __CTE, SUBJ_PHRASE_WATCHES, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __MSGID_APPLEMAIL, __TO_MALFORMED_2, __TO_NO_NAME, __MIME_VERSION, __MIME_VERSION_APPLEMAIL, __HAS_X_MAILER, __X_MAILER_APPLEMAIL, MIME_LOWER_CASE, __FRAUD_MONEY_CURRENCY_DOLLAR, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, SXL_IP_DYNAMIC[204.145.152.109.fur], HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, __USER_AGENT_APPLEMAIL, __PHISH_FROM, __PHISH_SPEAR_STRUCTURE_1, RDNS_SUSP, __FRAUD_WEBMAIL, BODY_SIZE_7000_LESS, NO_URI_FOUND, NO_URI_HTTPS, NO_CTA_URI_FOUND X-CTCH-Spam: Unknown Received: from [192.168.1.64] (109.152.145.204) by rgout06.bt.lon5.cpcloud.co.uk (8.6.122.06) (authenticated as gatk@btinternet.com) id 56B0A92D0068B2F0 for gdb@sourceware.org; Fri, 5 Feb 2016 23:21:11 +0000 From: Giles Atkinson Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Dynamic watchpoints in dynamic memory Date: Fri, 05 Feb 2016 23:21:00 -0000 Message-Id: <1C590CEA-031F-40C0-A814-99829DD80E4D@btinternet.com> To: gdb@sourceware.org Mime-Version: 1.0 (Apple Message framework v1085) X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00008.txt.bz2 Greetings, I have a suspicion that these may be somewhat stupid questions, but I feel = I have done enough searching of documentation, FAQs etc., without result, to be ready to ask. I think this could be a FAQ-level quer= y, but found no reference to the topic. I have a C program that crashes on a modify access via a dynamically-alloca= ted structure member with an illegal address, not NULL. The core file, circumstances, and code review suggest that an unusual event= has previously corrupted a pointer in the structure, which the failing instruction dereferences. My approach was to set a breakpoint on structure initialisation, with a com= mand list to set a watchpoint on the=20 pointer member. The watchpoint command list is backtrace and continue, out= put to file. By setting the breakpoint on the right instruction, the breakpoint command list can pick the structure addre= ss from a register, adding an offset. That works: so far, so good. The target structures are created and destroyed fairly frequently, respondi= ng to user input. To avoid noise in the output, and limit the number of watchpoints, there is= a breakpoint before deallocation that attempts to remove the watchpoint on the structure, again using a regi= ster value. Questions: Does this make sense, or have I missed a better way? How to remove the watchpoint? I can not identify the right syntax. The watchpoint is set like this: watch -location *(void **)($esi + $offset) I have tried to remove it with 'clear', but that seems to match watchpoints using the 'watch' expression, and what I have is a different expression tha= t should yield the same address. The register is different on deallocation and the original command is not u= nique. More puzzlement: my printf commands in (nested) command lists do nothing. Environment: Ubuntu X86 32-bit Ubuntu15.10, system supplied gdb 7.10. Prog= ram compiled on vanilla Debian 5. Any advice will be appreciated, Thanks, Giles