From patchwork Mon Mar 24 09:28:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 243 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (caibbdcaabij.dreamhost.com [208.113.200.189]) by wilcox.dreamhost.com (Postfix) with ESMTP id 9032036009E for ; Mon, 24 Mar 2014 02:28:10 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 3FC72528E29A; Mon, 24 Mar 2014 02:28:10 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 19FB9528E29C for ; Mon, 24 Mar 2014 02:28:10 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:content-type:content-transfer-encoding :subject:message-id:date:to:mime-version; q=dns; s=default; b=MH hz5MhWtcPf3kHD5MkiBUhzguHx/b8MkY/qN+2g5p9akPXbNOVeiAGbpgFG1/1SR7 d268SThtZphtJsIfAdiJNarCmITGRjA6HKTFO7aA2444cu8jJVbTftWmQoz2e/77 v6t5zsoChucV9FBB2LZ3JEEo4mWWvtKFMgzeC/zUU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:content-type:content-transfer-encoding :subject:message-id:date:to:mime-version; s=default; bh=hqgT/h83 PdLb/f6r4z58ew9LRco=; b=GIcdLeTs8cqA5vkFE4JdZ3mItuF3DvlLkRGZ5zKM kDFXH+v+EGfi72f2KouCW0GlmoOD4cT8/e+KpUgKXOQkuPa6FYGI6GjgeERB8dRn X5YugoSNWVpPl8BXUufF+ISGBUnuFSWFjX70BZw3nOPY68G8yvEfLqEbSgdFMqic iTI= Received: (qmail 31900 invoked by alias); 24 Mar 2014 09:28:08 -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 31886 invoked by uid 89); 24 Mar 2014 09:28:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 24 Mar 2014 09:28:06 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id F0C98270A7CA for ; Mon, 24 Mar 2014 10:28:03 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2llDi-ECoyAw for ; Mon, 24 Mar 2014 10:28:03 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id D61B7270A74C for ; Mon, 24 Mar 2014 10:28:03 +0100 (CET) From: Tristan Gingold Subject: [committed, darwin]: Fix dump of messages on x86_64 Message-Id: Date: Mon, 24 Mar 2014 10:28:10 +0100 To: " ml" Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hello, this patch fix the output of darwin messages (enabled by set debug darwin X, with X > 10) on x86_64: the data associated with the message must always be interpreted as 32 bit values. I added a few comments and style fixes. Committed on trunk. Tristan. gdb/ * darwin-nat.c (exc_server): Remove unused prototype. (darwin_dump_message): Correctly display data on x86_64. (darwin_encode_reply): Fix style. Add comments and fix indentation. diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 23a921d..3ea9696 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -85,8 +85,6 @@ #define PTRACE(CMD, PID, ADDR, SIG) \ darwin_ptrace(#CMD, CMD, (PID), (ADDR), (SIG)) -extern boolean_t exc_server (mach_msg_header_t *in, mach_msg_header_t *out); - static void darwin_stop (struct target_ops *self, ptid_t); static void darwin_resume_to (struct target_ops *ops, ptid_t ptid, int step, @@ -127,7 +125,7 @@ mach_port_t darwin_host_self; /* Exception port. */ mach_port_t darwin_ex_port; -/* Port set. */ +/* Port set, to wait for answer on all ports. */ mach_port_t darwin_port_set; /* Page size. */ @@ -149,10 +147,8 @@ static unsigned int darwin_debug_flag = 0; /* Create a __TEXT __info_plist section in the executable so that gdb could be signed. This is required to get an authorization for task_for_pid. - Once gdb is built, you can either: - * make it setgid procmod - * or codesign it with any system-trusted signing authority. - See taskgated(8) for details. */ + Once gdb is built, you must codesign it with any system-trusted signing + authority. See taskgated(8) for details. */ static const unsigned char info_plist[] __attribute__ ((section ("__TEXT,__info_plist"),used)) = "\n" @@ -492,7 +488,7 @@ darwin_dump_message (mach_msg_header_t *hdr, int disp_body) if (disp_body) { const unsigned char *data; - const unsigned long *ldata; + const unsigned int *ldata; int size; int i; @@ -538,9 +534,9 @@ darwin_dump_message (mach_msg_header_t *hdr, int disp_body) } printf_unfiltered (_(" data:")); - ldata = (const unsigned long *)data; - for (i = 0; i < size / sizeof (unsigned long); i++) - printf_unfiltered (" %08lx", ldata[i]); + ldata = (const unsigned int *)data; + for (i = 0; i < size / sizeof (unsigned int); i++) + printf_unfiltered (" %08x", ldata[i]); printf_unfiltered (_("\n")); } } @@ -561,7 +557,7 @@ darwin_decode_exception_message (mach_msg_header_t *hdr, kern_return_t kret; int i; - /* Check message identifier. 2401 is exc. */ + /* Check message identifier. 2401 == 0x961 is exc. */ if (hdr->msgh_id != 2401) return -1; @@ -616,8 +612,8 @@ darwin_decode_exception_message (mach_msg_header_t *hdr, return -1; *pthread = thread; - /* The thread should be running. However we have observed cases where a thread - got a SIGTTIN message after being stopped. */ + /* The thread should be running. However we have observed cases where a + thread got a SIGTTIN message after being stopped. */ gdb_assert (thread->msg_state != DARWIN_MESSAGE); /* Finish decoding. */ @@ -644,9 +640,10 @@ darwin_encode_reply (mig_reply_error_t *reply, mach_msg_header_t *hdr, integer_t code) { mach_msg_header_t *rh = &reply->Head; - rh->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(hdr->msgh_bits), 0); + + rh->msgh_bits = MACH_MSGH_BITS (MACH_MSGH_BITS_REMOTE (hdr->msgh_bits), 0); rh->msgh_remote_port = hdr->msgh_remote_port; - rh->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t); + rh->msgh_size = (mach_msg_size_t) sizeof (mig_reply_error_t); rh->msgh_local_port = MACH_PORT_NULL; rh->msgh_id = hdr->msgh_id + 100; @@ -1137,7 +1134,7 @@ darwin_wait (ptid_t ptid, struct target_waitstatus *status) } static ptid_t -darwin_wait_to (struct target_ops *ops, +darwin_wait_to (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options) { return darwin_wait (ptid, status); @@ -1325,7 +1322,7 @@ darwin_kill_inferior (struct target_ops *ops) if (res == 0) { darwin_resume_inferior (inf); - + ptid = darwin_wait (inferior_ptid, &wstatus); } else if (errno != ESRCH)