mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-28 20:43:45 +08:00
bd8a901f9e
This main idea behind this patch is this change to xml-support.c:scope_level - /* Body text accumulation. This is an owning pointer. */ - struct obstack *body; + /* Body text accumulation. */ + std::string body; ... which allows simplifying other parts of the code. In target_fetch_description_xml, we want to distinguish between returning "success + empty std::string" and "no success", and gdb::optional is a natural fit for that. gdb/ChangeLog: 2017-04-18 Pedro Alves <palves@redhat.com> * tracefile-tfile.c (tfile_write_tdesc): Adjust to use gdb::optional<std::string>. * xml-support.c: Include <string>. (scope_level::scope_level(scope_level &&)) (scope_level::~scope_level): Delete. (scope_level::body): Now a std::string. (gdb_xml_body_text, gdb_xml_end_element): Adjust. (xinclude_parsing_data::xinclude_parsing_data): Add 'output' parameter. (xinclude_parsing_data::~xinclude_parsing_data): Delete. (xinclude_parsing_data::output): Now a std::string reference. (xinclude_start_include): Adjust. (xml_xinclude_default): Adjust. (xml_process_xincludes): Add 'output' parameter, and return bool. * xml-support.h (xml_process_xincludes): Add 'output' parameter, and return bool. * xml-tdesc.c: Include <unordered_map> and <string>. (tdesc_xml_cache): Delete. (tdesc_xml_cache_s): Delete. (xml_cache): Now an std::unordered_map. (tdesc_parse_xml): Adjust to use std::string and unordered_map. (target_fetch_description_xml): Change return type to gdb::optional<std::string>, and adjust. * xml-tdesc.h: Include "common/gdb_optional.h" and <string>. (target_fetch_description_xml): Change return type to gdb::optional<std::string>.
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
/* XML target description support for GDB.
|
|
|
|
Copyright (C) 2006-2017 Free Software Foundation, Inc.
|
|
|
|
Contributed by CodeSourcery.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef XML_TDESC_H
|
|
#define XML_TDESC_H
|
|
|
|
#include "common/gdb_optional.h"
|
|
#include <string>
|
|
|
|
struct target_ops;
|
|
struct target_desc;
|
|
|
|
/* Read an XML target description from FILENAME. Parse it, and return
|
|
the parsed description. */
|
|
|
|
const struct target_desc *file_read_description_xml (const char *filename);
|
|
|
|
/* Read an XML target description using OPS. Parse it, and return the
|
|
parsed description. */
|
|
|
|
const struct target_desc *target_read_description_xml (struct target_ops *);
|
|
|
|
/* Fetches an XML target description using OPS, processing includes,
|
|
but not parsing it. Used to dump whole tdesc as a single XML file.
|
|
Returns the description on success, and a disengaged optional
|
|
otherwise. */
|
|
gdb::optional<std::string> target_fetch_description_xml (target_ops *ops);
|
|
|
|
#endif /* XML_TDESC_H */
|
|
|