From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7938 invoked by alias); 14 Feb 2011 12:00:18 -0000 Received: (qmail 7926 invoked by uid 22791); 14 Feb 2011 12:00:17 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Feb 2011 12:00:12 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1EC05Tx024159 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Feb 2011 07:00:05 -0500 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1EC02pL012245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Feb 2011 07:00:04 -0500 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p1EC01PC025187; Mon, 14 Feb 2011 13:00:01 +0100 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id p1EC00a8025127; Mon, 14 Feb 2011 13:00:00 +0100 Date: Mon, 14 Feb 2011 12:00:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [unavailable values part 1, 04/17] map unavailable memory to unavailable value contents Message-ID: <20110214115958.GD2454@host1.dyn.jankratochvil.net> References: <201102071429.40838.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201102071429.40838.pedro@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-02/txt/msg00265.txt.bz2 > @@ -1009,12 +1009,8 @@ value_fetch_lazy (struct value *val) > int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val))); > > if (length) > - { > - if (value_stack (val)) > - read_stack (addr, value_contents_all_raw (val), length); > - else > - read_memory (addr, value_contents_all_raw (val), length); > - } > + read_value_memory (val, 0, value_stack (val), > + addr, value_contents_all_raw (val), length); I think here should be value_contents_raw. It is an unrelated issue. > } > else if (VALUE_LVAL (val) == lval_register) > { > @@ -1113,6 +1109,89 @@ value_fetch_lazy (struct value *val) > return 0; > } > > +void > +read_value_memory (struct value *val, int embedded_offset, > + int stack, CORE_ADDR memaddr, > + gdb_byte *buffer, size_t length) > +{ > + if (length) > + { > + VEC(mem_range_s) *available_memory; > + > + if (get_traceframe_number () < 0 > + || !traceframe_available_memory (&available_memory, memaddr, length)) > + { > + if (stack) > + read_stack (memaddr, buffer, length); > + else > + read_memory (memaddr, buffer, length); > + } > + else > + { > + struct target_section_table *table; > + struct cleanup *old_chain; > + CORE_ADDR unavail; > + mem_range_s *r; > + int i; > + > + /* Fallback to reading from read-only sections. */ > + table = target_get_section_table (&exec_ops); Cannot be table NULL? > + available_memory = > + section_table_available_memory (available_memory, > + memaddr, length, > + table->sections, > + table->sections_end); > + > + old_chain = make_cleanup (VEC_cleanup(mem_range_s), > + &available_memory); > + > --- src.orig/gdb/value.h 2011-02-07 11:12:35.406706000 +0000 > +++ src/gdb/value.h 2011-02-07 11:15:02.926705996 +0000 > @@ -374,6 +374,17 @@ extern int value_bytes_available (const > extern void mark_value_bytes_unavailable (struct value *value, > int offset, int length); > > +/* Read LENGTH bytes of memory starting at MEMADDR into BUFFER, which > + is (or will be copied to) VAL's contents buffer offset by > + EMBEDDED_OFFSET (that is, to &VAL->contents[EMBEDDED_OFFSET]). > + Marks value contents ranges as unavailable if the corresponding > + memory is likewise unavailable. STACK indicates whether the memory > + is known to be stack memory. */ > + > +extern void read_value_memory (struct value *val, int offset, > + int stack, CORE_ADDR memaddr, > + gdb_byte *buffer, size_t length); > + Comment talks about EMBEDDED_OFFSET while the declaration parameter name does not match the function definition parameter name. > @@ -572,6 +572,43 @@ map_vmap (bfd *abfd, bfd *arch) > } > > > +VEC(mem_range_s) * > +section_table_available_memory (VEC(mem_range_s) *memory, > + CORE_ADDR memaddr, LONGEST len, After `int', `ULONGEST' and `size_t' the type is now `LONGEST'. Does it mean there is no intention for >2GB inferior objects handling? I thought some Fortran simulations may use such arrays etc. > + struct target_section *sections, > + struct target_section *sections_end) > +{ > + struct target_section *p; > + ULONGEST memend = memaddr + len; Unused variable `memend'. > + > + for (p = sections; p < sections_end; p++) > + { > + if ((bfd_get_section_flags (p->bfd, p->the_bfd_section) > + & SEC_READONLY) == 0) > + continue; > + > + /* Copy the meta-data, adjusted. */ > + if (mem_ranges_overlap (p->addr, p->endaddr - p->addr, memaddr, len)) > + { > + ULONGEST lo1, hi1, lo2, hi2; > + struct mem_range *r; > + > + lo1 = memaddr; > + hi1 = memaddr + len; > + > + lo2 = p->addr; > + hi2 = p->endaddr; > + > + r = VEC_safe_push (mem_range_s, memory, NULL); > + > + r->start = max (lo1, lo2); > + r->length = min (hi1, hi2) - r->start; > + } > + } > + > + return memory; > +} Thanks, Jan