[PATCH 3/4] gdb/riscv: Create each unique target description only once

Andrew Burgess andrew.burgess@embecosm.com
Thu Nov 29 19:17:00 GMT 2018


* Pedro Alves <palves@redhat.com> [2018-11-29 18:12:29 +0000]:

> On 11/29/2018 04:48 PM, Andrew Burgess wrote:
> 
> > +
> > +  /* Add TDESC into the cache, a target description created to match
> > +     FEATURES.  */
> > +  void add (const struct riscv_gdbarch_features features,
> > +            const target_desc *tdesc)
> > +  {
> > +    feature_tdesc_pair p (features, tdesc);
> > +    m_tdesc_list.push_back (p);
> > +  }
> > +
> > +private:
> > +
> > +  /* Map from a feature set to the corresponding target description.  */
> > +  typedef std::pair<const struct riscv_gdbarch_features,
> > +                    const target_desc *> feature_tdesc_pair;
> > +
> > +  /* List of all target descriptions we've previously seen.  */
> > +  std::vector<feature_tdesc_pair> m_tdesc_list;
> > +};
> 
> Did you consider an unordered_map instead of this whole class here?
> See xml-tdesc.c's xml_cache.  If there's a reason the custom data
> structure is preferred, I think that warrants a comment.

No, the class only exists to group the lookup/update methods.  As I
only expect the list to contain 1 or 2 items in a "normal" session I
didn't invest much thought into it really.  I'll take a look at the
example you suggest and update the patch accordingly.

Thanks for the feedback,

Andrew



More information about the Gdb-patches mailing list