From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7756 invoked by alias); 21 Mar 2009 08:52:49 -0000 Received: (qmail 7748 invoked by uid 22791); 21 Mar 2009 08:52:48 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_05,SARE_MSGID_LONG40,SPF_PASS,WEIRD_PORT X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.185) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Mar 2009 08:52:42 +0000 Received: by ti-out-0910.google.com with SMTP id a1so848712tib.12 for ; Sat, 21 Mar 2009 01:52:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.110.11.4 with SMTP id 4mr7283653tik.47.1237625559075; Sat, 21 Mar 2009 01:52:39 -0700 (PDT) Date: Sat, 21 Mar 2009 09:17:00 -0000 Message-ID: Subject: [RFA] Patch to fix reverse-debug recursion function tail bug From: Hui Zhu To: "gdb-patches@sourceware.org" Cc: Michael Snyder , Marc Khouzam Content-Type: multipart/mixed; boundary=0016e651fad0d04b6904659d27f7 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00429.txt.bz2 --0016e651fad0d04b6904659d27f7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 2521 Hi, This patch is for bug report by Marc in http://sourceware.org/ml/gdb/2009-03/msg00127.html. This bug in "handle_inferior_event" deal with recursion function tail in reverse debug. infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc = 0x8048457 infrun: stepping inside range [0x8048457-0x804845a] infrun: stop_stepping factorial (x=4) at b.cc:5 Inferior already step into another frame. But because this is a recursion function call, And 0x8048457 is in ecs->event_thread->step_range_start and ecs->event_thread->step_range_start. So gdb run in: if (stop_pc >= ecs->event_thread->step_range_start && stop_pc < ecs->event_thread->step_range_end) { This code is in front of: if (!frame_id_eq (get_frame_id (get_current_frame ()), ecs->event_thread->step_frame_id) && (frame_id_eq (frame_unwind_id (get_current_frame ()), ecs->event_thread->step_frame_id) || execution_direction == EXEC_REVERSE)) So gdb check range without check frame_id. So I make a patch to check frame_id when check range in reverse debug mode. 2008-03-21 Hui Zhu * infrun.c (handle_inferior_event): Check frame_id when check range in reverse debug mode. Actually, there is another thing, when gdb begin reverse-debug, it's range is: 8048439: 8b 45 08 mov 0x8(%ebp),%eax 804843c: 83 e8 01 sub $0x1,%eax 804843f: 89 04 24 mov %eax,(%esp) 8048442: e8 dd ff ff ff call 8048424 <_Z9factoriali> 8048447: 0f af 45 08 imul 0x8(%ebp),%eax 804844b: 89 45 fc mov %eax,-0x4(%ebp) Why is changed to infrun: stepping inside range [0x8048457-0x804845a]? That is because when inferior step at: 8048458: c3 ret In this address, $ebp is same with high level function and this function is factorial too. So the gdb can't found inferior step into another frame. It will run to: ecs->event_thread->step_range_start = stop_pc_sal.pc; ecs->event_thread->step_range_end = stop_pc_sal.end; ecs->event_thread->step_frame_id = get_frame_id (get_current_frame ()); ecs->event_thread->current_line = stop_pc_sal.line; ecs->event_thread->current_symtab = stop_pc_sal.symtab; if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: keep going\n"); keep_going (ecs); } So ecs->event_thread->step_range_start and ecs->event_thread->step_range_end. I don't find that it affect the reverse debug or something. So I didn't fix it. Thanks, Hui --0016e651fad0d04b6904659d27f7 Content-Type: text/plain; charset=US-ASCII; name="fix-function-tail-stack-same.txt" Content-Disposition: attachment; filename="fix-function-tail-stack-same.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fsk1os680 Content-length: 944 LS0tCiBpbmZydW4uYyB8ICAgIDUgKysrKy0KIDEgZmlsZSBjaGFuZ2VkLCA0 IGluc2VydGlvbnMoKyksIDEgZGVsZXRpb24oLSkKCi0tLSBhL2luZnJ1bi5j CisrKyBiL2luZnJ1bi5jCkBAIC0zMzk3LDcgKzMzOTcsMTAgQEAgaW5mcnVu OiBCUFNUQVRfV0hBVF9TRVRfTE9OR0pNUF9SRVNVTUUgKAogICAgICBiZXlv bmQgdGhlIHN0ZXAgcmFuZ2UsIGFuZCBOT1QgdGhlIGFkZHJlc3Mgb2YgdGhl IGxhc3QgaW5zdHJ1Y3Rpb24KICAgICAgd2l0aGluIGl0ISAqLwogICBpZiAo c3RvcF9wYyA+PSBlY3MtPmV2ZW50X3RocmVhZC0+c3RlcF9yYW5nZV9zdGFy dAotICAgICAgJiYgc3RvcF9wYyA8IGVjcy0+ZXZlbnRfdGhyZWFkLT5zdGVw X3JhbmdlX2VuZCkKKyAgICAgICYmIHN0b3BfcGMgPCBlY3MtPmV2ZW50X3Ro cmVhZC0+c3RlcF9yYW5nZV9lbmQKKyAgICAgICYmIChmcmFtZV9pZF9lcSAo Z2V0X2ZyYW1lX2lkIChnZXRfY3VycmVudF9mcmFtZSAoKSksCisJCSAgICAg IGVjcy0+ZXZlbnRfdGhyZWFkLT5zdGVwX2ZyYW1lX2lkKQorICAgICAgICAg IHx8IGV4ZWN1dGlvbl9kaXJlY3Rpb24gIT0gRVhFQ19SRVZFUlNFKSkKICAg ICB7CiAgICAgICBpZiAoZGVidWdfaW5mcnVuKQogCWZwcmludGZfdW5maWx0 ZXJlZCAoZ2RiX3N0ZGxvZywgImluZnJ1bjogc3RlcHBpbmcgaW5zaWRlIHJh bmdlIFsweCVzLTB4JXNdXG4iLAo= --0016e651fad0d04b6904659d27f7--