From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11540 invoked by alias); 10 Mar 2013 05:01:08 -0000 Received: (qmail 11529 invoked by uid 22791); 10 Mar 2013 05:01:07 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-oa0-f51.google.com (HELO mail-oa0-f51.google.com) (209.85.219.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 10 Mar 2013 05:01:01 +0000 Received: by mail-oa0-f51.google.com with SMTP id h2so3505128oag.10 for ; Sat, 09 Mar 2013 21:01:00 -0800 (PST) X-Received: by 10.60.1.34 with SMTP id 2mr5631756oej.47.1362891660772; Sat, 09 Mar 2013 21:01:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.60.7 with HTTP; Sat, 9 Mar 2013 21:00:20 -0800 (PST) From: Hui Zhu Date: Sun, 10 Mar 2013 05:01:00 -0000 Message-ID: Subject: [PATCH] Fix agent code generate bug of ref To: gdb-patches ml Cc: Joel Brobecker Content-Type: multipart/mixed; boundary=e89a8fb1fa104ecc3c04d78af10c 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: 2013-03/txt/msg00421.txt.bz2 --e89a8fb1fa104ecc3c04d78af10c Content-Type: text/plain; charset=ISO-8859-1 Content-length: 3258 Hi, I meet a issue with tracepoint and Linux kernel is: (gdb) list update_curr 590 cfs_rq->load_unacc_exec_time += delta_exec; 591 #endif 592 } 593 594 static void update_curr(struct cfs_rq *cfs_rq) 595 { 596 struct sched_entity *curr = cfs_rq->curr; 597 u64 now = rq_of(cfs_rq)->clock; 598 unsigned long delta_exec; 599 (gdb) 600 if (unlikely(!curr)) 601 return; 602 603 /* 604 * Get the amount of time the current task was running 605 * since the last time we changed load (this cannot 606 * overflow on 32 bits): 607 */ 608 delta_exec = (unsigned long)(now - curr->exec_start); 609 if (!delta_exec) (gdb) trace 609 Tracepoint 1 at 0xffffffff8104ced6: file /home/teawater/kernel/taobao-kernel/tmp/linux-2.6.32-220.23.1.el5/kernel/sched_fair.c, line 609. (gdb) actions Enter actions for tracepoint 1, one per line. End with a line saying just "end". >collect now >end (gdb) tstart Then it will failed in kernel part, the address that send to kernel to collect is 0x978. But the right address of now is 0xffff880002215578. I check the agent code that is got is: (gdb) maintenance agent -at sched_fair.c:609, now Scope: 0xffffffff8104ced6 Reg mask: 20 0 reg 5 3 const16 128 6 add 7 ref8 8 const16 2232 11 add 12 const8 8 14 trace 15 end I think ref8 is not right because this acode try to get a address from Linux kernel. It should be ref64. I check the code of function dwarf2_compile_expr_to_ax: case DW_OP_deref: case DW_OP_deref_size: { int size; if (op == DW_OP_deref_size) size = *op_ptr++; else size = addr_size; switch (size) { case 8: ax_simple (expr, aop_ref8); aop_ref8 means ref 8 bits. So use addr_size is not right, I add first patch fix-op_deref-size.txt to change addr_size to addr_size_bits. Then the first issue is fixed. And I found that GDB generate right code the collect value from 0xffff880002215578. But after that, I still got error when I tfind: (gdb) tfind Found trace frame 0, tracepoint 1 #0 update_curr (cfs_rq=0xffff880002214d28, cfs_rq@entry=) at /home/teawater/kernel/taobao-kernel/tmp/linux-2.6.32-220.23.1.el5/kernel/sched_fair.c:609 609 if (!delta_exec) (gdb) p now Cannot access memory at address 0xffff880002214da8 This issue is because aop just collect value of now, but not ref address. But GDB need this value. So I add second patch trace_def_if_trace.txt to call ax_trace_quick if need. Then the aop will be changed to: (gdb) maintenance agent -at sched_fair.c:609, now Scope: 0xffffffff8104ced6 Reg mask: 20 0 reg 5 3 const16 128 6 add 7 trace_quick 8 9 ref64 10 const16 2232 13 add 14 const8 8 16 trace 17 end Then all the issue of this tracepoint is fixed. But I failed with make a test code with it. So I just can repeoduce in this Linux kernel code. I suggest the next release just this 2 patches because this 2 issue will affect some code of aop. Thanks, Hui 2013-03-10 Hui Zhu * dwarf2loc.c (dwarf2_compile_expr_to_ax): Change addr_size to addr_size_bits if DW_OP_deref. 2013-03-10 Hui Zhu * dwarf2loc.c (dwarf2_compile_expr_to_ax): Call ax_trace_quick if need. --e89a8fb1fa104ecc3c04d78af10c Content-Type: text/plain; charset=US-ASCII; name="fix-op_deref-size.txt" Content-Disposition: attachment; filename="fix-op_deref-size.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_he3q5hl00 Content-length: 354 LS0tIGEvZHdhcmYybG9jLmMKKysrIGIvZHdhcmYybG9jLmMKQEAgLTI5Mjks NyArMjkyOSw3IEBAIGR3YXJmMl9jb21waWxlX2V4cHJfdG9fYXggKHN0cnVj dCBhZ2VudF8KIAkgICAgaWYgKG9wID09IERXX09QX2RlcmVmX3NpemUpCiAJ ICAgICAgc2l6ZSA9ICpvcF9wdHIrKzsKIAkgICAgZWxzZQotCSAgICAgIHNp emUgPSBhZGRyX3NpemU7CisJICAgICAgc2l6ZSA9IGFkZHJfc2l6ZV9iaXRz OwogCiAJICAgIHN3aXRjaCAoc2l6ZSkKIAkgICAgICB7Cg== --e89a8fb1fa104ecc3c04d78af10c Content-Type: text/plain; charset=US-ASCII; name="trace_def_if_trace.txt" Content-Disposition: attachment; filename="trace_def_if_trace.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_he3q5rwk1 Content-length: 350 LS0tIGEvZHdhcmYybG9jLmMKKysrIGIvZHdhcmYybG9jLmMKQEAgLTI5MzEs NiArMjkzMSw5IEBAIGR3YXJmMl9jb21waWxlX2V4cHJfdG9fYXggKHN0cnVj dCBhZ2VudF8KIAkgICAgZWxzZQogCSAgICAgIHNpemUgPSBhZGRyX3NpemVf Yml0czsKIAorCSAgICBpZiAodHJhY2Vfa2x1ZGdlKQorCSAgICAgIGF4X3Ry YWNlX3F1aWNrIChleHByLCBzaXplIC8gOCk7CisKIAkgICAgc3dpdGNoIChz aXplKQogCSAgICAgIHsKIAkgICAgICBjYXNlIDg6Cg== --e89a8fb1fa104ecc3c04d78af10c--