From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22220 invoked by alias); 12 Aug 2013 12:16:58 -0000 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 Received: (qmail 22211 invoked by uid 89); 12 Aug 2013 12:16:57 -0000 X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD autolearn=ham version=3.3.2 Received: from mms2.broadcom.com (HELO mms2.broadcom.com) (216.31.210.18) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 12 Aug 2013 12:16:56 +0000 Received: from [10.9.208.57] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Mon, 12 Aug 2013 05:10:37 -0700 X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Mon, 12 Aug 2013 05:16:47 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Mon, 12 Aug 2013 05:16:46 -0700 Received: from [10.177.73.61] (unknown [10.177.73.61]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 621A6F2D72 for ; Mon, 12 Aug 2013 05:16:46 -0700 (PDT) Message-ID: <5208D22C.3090701@broadcom.com> Date: Mon, 12 Aug 2013 12:16:00 -0000 From: "Andrew Burgess" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH 01/12] Introduce is_unavailable_error References: <5208D1DF.1090201@broadcom.com> In-Reply-To: <5208D1DF.1090201@broadcom.com> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00301.txt.bz2 Is some places we specifically check for the NOT_AVAILABLE_ERROR error code, in a later patch I'll be adding a new error for optimized out values and I'll want to detect both error codes at the same time. In preparation for this upcoming change I add a new function for detecting the NOT_AVAILABLE_ERROR code, this is just a refactor. OK to apply? Thanks, Andrew gdb/ChangeLog 2013-08-08 Andrew Burgess * exceptions.c (is_unavailable_error): New function definition. * exceptions.h (is_unavailable_error): New function declaration. * cp-abi.c (baseclass_offset): Switch to use is_unavailable_error, and rethrow whatever error we recieved rather than a specific error code. * amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache) (amd64_epilogue_frame_cache): Switch to use is_unavailable_error. * cp-valprint.c (cp_print_value): Likewise. * dwarf2-frame.c (dwarf2_frame_cache): Likewise. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Likewise. * frame-unwind.c (frame_unwind_find_by_frame): Likewise. * frame.c (frame_unwind_pc_if_available) (get_frame_address_in_block_if_available): Likewise. * i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache) (i386_sigtramp_frame_cache): Likewise. * infcmd.c (post_create_inferior): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * stack.c (get_frame_language): Likewise. diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 3ab74f0..71525b8 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2366,7 +2366,7 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache) { amd64_frame_cache_1 (this_frame, cache); } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); return cache; @@ -2490,7 +2490,7 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); *this_cache = cache; @@ -2658,10 +2658,9 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) /* The saved %eip will be at cache->base plus 8. */ cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8; - cache->base_p = 1; } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); return cache; diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index 2540eca..fbc68a4 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -85,8 +85,8 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr, address, val); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) - throw_error (NOT_AVAILABLE_ERROR, + if (ex.reason < 0 && is_unavailable_error (ex.error)) + throw_error (ex.error, _("Cannot determine virtual baseclass offset " "of incomplete object")); else if (ex.reason < 0) diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index e83d979..795b7b0 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -519,7 +519,7 @@ cp_print_value (struct type *type, struct type *real_type, { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && is_unavailable_error (ex.error)) skip = -1; else if (ex.reason < 0) skip = 1; diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 5c88b03..b709d3b 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -1117,7 +1117,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache) } if (ex.reason < 0) { - if (ex.error == NOT_AVAILABLE_ERROR) + if (is_unavailable_error (ex.error)) { cache->unavailable_retaddr = 1; do_cleanups (old_chain); diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 02afcdf..3b843fa 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -2237,7 +2237,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, } if (ex.reason < 0) { - if (ex.error == NOT_AVAILABLE_ERROR) + if (is_unavailable_error (ex.error)) { do_cleanups (old_chain); retval = allocate_value (type); diff --git a/gdb/exceptions.c b/gdb/exceptions.c index c4c1e57..134d918 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -571,3 +571,11 @@ catch_command_errors_const (catch_command_errors_const_ftype *command, return 0; return 1; } + +/* Return true if this is an error indicating a value was unavailable. */ + +int +is_unavailable_error (const enum errors error) +{ + return error == NOT_AVAILABLE_ERROR; +} diff --git a/gdb/exceptions.h b/gdb/exceptions.h index bf41860..1baecf4 100644 --- a/gdb/exceptions.h +++ b/gdb/exceptions.h @@ -101,6 +101,10 @@ struct gdb_exception const char *message; }; +/* Return true for those errors relating to value unavailability. */ + +extern int is_unavailable_error (enum errors error); + /* A pre-defined non-exception. */ extern const struct gdb_exception exception_none; diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index ce2f6da..25b1e08 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -112,7 +112,7 @@ frame_unwind_find_by_frame (struct frame_info *this_frame, void **this_cache) res = entry->unwinder->sniffer (entry->unwinder, this_frame, this_cache); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && is_unavailable_error (ex.error)) { /* This usually means that not even the PC is available, thus most unwinders aren't able to determine if they're diff --git a/gdb/frame.c b/gdb/frame.c index d52c26a..54f828c 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -721,7 +721,7 @@ frame_unwind_pc_if_available (struct frame_info *this_frame, CORE_ADDR *pc) { pc = gdbarch_unwind_pc (prev_gdbarch, this_frame); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && is_unavailable_error (ex.error)) { this_frame->prev_pc.p = -1; @@ -2064,7 +2064,7 @@ get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc) } if (ex.reason < 0) { - if (ex.error == NOT_AVAILABLE_ERROR) + if (is_unavailable_error (ex.error)) return 0; else throw_exception (ex); @@ -2145,7 +2145,7 @@ get_frame_address_in_block_if_available (struct frame_info *this_frame, { *pc = get_frame_address_in_block (this_frame); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && is_unavailable_error (ex.error)) return 0; else if (ex.reason < 0) throw_exception (ex); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index b159b49..1c9fa68 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1834,7 +1834,7 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache) { i386_frame_cache_1 (this_frame, cache); } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); return cache; @@ -2004,7 +2004,7 @@ i386_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); return cache; @@ -2197,7 +2197,7 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) cache->base_p = 1; } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); *this_cache = cache; diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 154cde2..ed9ec5e 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -422,7 +422,7 @@ post_create_inferior (struct target_ops *target, int from_tty) { stop_pc = regcache_read_pc (get_current_regcache ()); } - if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && !is_unavailable_error (ex.error)) throw_exception (ex); if (exec_bfd) diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 05d4c6f..cfafe99 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -754,7 +754,7 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr, { boffset = baseclass_offset (type, i, valaddr, offset, address, val); } - if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR) + if (ex.reason < 0 && is_unavailable_error (ex.error)) skip = -1; else if (ex.reason < 0) skip = 1; diff --git a/gdb/stack.c b/gdb/stack.c index 7d97dc8..af05f84 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2558,7 +2558,7 @@ get_frame_language (void) } if (ex.reason < 0) { - if (ex.error != NOT_AVAILABLE_ERROR) + if (!is_unavailable_error (ex.error)) throw_exception (ex); } else