From patchwork Sat Oct 17 21:41:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marcin_Ko=C5=9Bcielnicki?= X-Patchwork-Id: 9210 Received: (qmail 58130 invoked by alias); 17 Oct 2015 21:41:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 58007 invoked by uid 89); 17 Oct 2015 21:41:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: xyzzy.0x04.net Received: from xyzzy.0x04.net (HELO xyzzy.0x04.net) (109.74.193.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 17 Oct 2015 21:41:36 +0000 Received: from hogfather.0x04.net (89-65-84-110.dynamic.chello.pl [89.65.84.110]) by xyzzy.0x04.net (Postfix) with ESMTPS id D1A043FF6A for ; Sat, 17 Oct 2015 23:41:43 +0200 (CEST) Received: by hogfather.0x04.net (Postfix, from userid 1000) id 5BAB6580190; Sat, 17 Oct 2015 23:41:27 +0200 (CEST) From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= To: gdb-patches@sourceware.org Cc: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Subject: [PATCH 09/11] gdb/linux-record: Fix old_select syscall handling Date: Sat, 17 Oct 2015 23:41:19 +0200 Message-Id: <1445118081-10908-10-git-send-email-koriakin@0x04.net> In-Reply-To: <1445118081-10908-1-git-send-email-koriakin@0x04.net> References: <1445118081-10908-1-git-send-email-koriakin@0x04.net> We have to use extract_unsigned_integer to read paramaters structure - target pointers can have different endianness and size. --- gdb/linux-record.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/gdb/linux-record.c b/gdb/linux-record.c index 9f38c0b..091ac8a 100644 --- a/gdb/linux-record.c +++ b/gdb/linux-record.c @@ -645,38 +645,45 @@ record_linux_system_call (enum gdb_syscall syscall, case gdb_old_select: { - struct sel_arg_struct - { - CORE_ADDR n; - CORE_ADDR inp; - CORE_ADDR outp; - CORE_ADDR exp; - CORE_ADDR tvp; - } sel; + unsigned long sz_sel_arg = tdep->size_long + tdep->size_pointer * 4; + gdb_byte *a = (gdb_byte *) alloca (sz_sel_arg); + CORE_ADDR inp, outp, exp, tvp; regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest); if (tmpulongest) { - if (target_read_memory (tmpulongest, (gdb_byte *) &sel, - sizeof(sel))) + if (target_read_memory (tmpulongest, a, sz_sel_arg)) { if (record_debug) fprintf_unfiltered (gdb_stdlog, "Process record: error reading memory " "at addr = 0x%s len = %lu.\n", OUTPUT_REG (tmpulongest, tdep->arg1), - (unsigned long) sizeof (sel)); + sz_sel_arg); return -1; } - if (record_full_arch_list_add_mem (sel.inp, tdep->size_fd_set)) - return -1; - if (record_full_arch_list_add_mem (sel.outp, tdep->size_fd_set)) - return -1; - if (record_full_arch_list_add_mem (sel.exp, tdep->size_fd_set)) - return -1; - if (record_full_arch_list_add_mem (sel.tvp, tdep->size_timeval)) - return -1; + /* Skip n. */ + a += tdep->size_long; + inp = extract_unsigned_integer (a, tdep->size_pointer, byte_order); + a += tdep->size_pointer; + outp = extract_unsigned_integer (a, tdep->size_pointer, byte_order); + a += tdep->size_pointer; + exp = extract_unsigned_integer (a, tdep->size_pointer, byte_order); + a += tdep->size_pointer; + tvp = extract_unsigned_integer (a, tdep->size_pointer, byte_order); + if (inp) + if (record_full_arch_list_add_mem (inp, tdep->size_fd_set)) + return -1; + if (outp) + if (record_full_arch_list_add_mem (outp, tdep->size_fd_set)) + return -1; + if (exp) + if (record_full_arch_list_add_mem (exp, tdep->size_fd_set)) + return -1; + if (tvp) + if (record_full_arch_list_add_mem (tvp, tdep->size_timeval)) + return -1; } } break;