void
set_write_comp_dir(write_context& ctxt, bool flag);
+void
+set_short_locs(write_context& ctxt, bool flag);
+
/// A convenience generic function to set common options (usually used
/// by Libabigail tools) from a generic options carrying-object, into
/// a given @ref write_context.
set_write_architecture(ctxt, opts.write_architecture);
set_write_corpus_path(ctxt, opts.write_corpus_path);
set_write_comp_dir(ctxt, opts.write_comp_dir);
+ set_short_locs(ctxt, opts.short_locs);
}
void
bool m_write_architecture;
bool m_write_corpus_path;
bool m_write_comp_dir;
+ bool m_short_locs;
mutable type_ptr_map m_type_id_map;
mutable type_ptr_set_type m_emitted_type_set;
type_ptr_set_type m_emitted_decl_only_set;
m_show_locs(true),
m_write_architecture(true),
m_write_corpus_path(true),
- m_write_comp_dir(true)
+ m_write_comp_dir(true),
+ m_short_locs(false)
{}
/// Getter of the environment we are operating from.
set_write_comp_dir(bool f)
{m_write_comp_dir = f;}
+ /// Getter of the short-locs option.
+ ///
+ /// @return true iff short locations shall be emitted
+ bool
+ get_short_locs()
+ {return m_short_locs;}
+
+ /// Setter of the short-locs option
+ ///
+ /// @param f the new value of the flag.
+ void
+ set_short_locs(bool f)
+ {m_short_locs = f;}
/// Getter of the "show-locs" option.
///
ostream &o = ctxt.get_ostream();
+ if (ctxt.get_short_locs())
+ tools_utils::base_name(filepath, filepath);
+
o << " filepath='" << xml::escape_xml_string(filepath) << "'"
<< " line='" << line << "'"
<< " column='" << column << "'";
set_write_comp_dir(write_context& ctxt, bool flag)
{ctxt.set_write_comp_dir(flag);}
+/// Set the 'short-locs' flag.
+///
+/// When this flag is set then the XML writer will emit only file names
+/// rather than full paths.
+///
+/// @param ctxt the context to set this flag on to.
+///
+/// @param flag the new value of the 'short-locs' flag.
+void
+set_short_locs(write_context& ctxt, bool flag)
+{ctxt.set_short_locs(flag);}
+
/// Serialize a translation unit to an output stream.
///
/// @param ctxt the context of the serialization. It contains e.g,
if (tu.get_address_size() != 0)
o << " address-size='" << static_cast<int>(tu.get_address_size()) << "'";
- if (!tu.get_path().empty())
- o << " path='" << xml::escape_xml_string(tu.get_path()) << "'";
+ std::string tu_path = tu.get_path();
+ if (ctxt.get_short_locs())
+ tools_utils::base_name(tu_path, tu_path);
+ if (!tu_path.empty())
+ o << " path='" << xml::escape_xml_string(tu_path) << "'";
if (!tu.get_compilation_dir_path().empty() && ctxt.get_write_comp_dir())
o << " comp-dir-path='"
if (!ctxt.get_write_corpus_path())
{
if (member_of_group)
- {
- size_t pos = corpus_path.rfind('/');
- corpus_path
- = corpus_path.substr(pos != std::string::npos ? pos + 1 : 0);
- }
+ tools_utils::base_name(corpus_path, corpus_path);
else
corpus_path.clear();
}
+ else
+ {
+ if (ctxt.get_short_locs())
+ tools_utils::base_name(corpus_path, corpus_path);
+ }
if (!corpus_path.empty())
out << " path='" << xml::escape_xml_string(corpus_path) << "'";
bool write_architecture;
bool write_corpus_path;
bool write_comp_dir;
+ bool short_locs;
bool load_all_types;
bool linux_kernel_mode;
bool corpus_group_for_linux;
write_architecture(true),
write_corpus_path(true),
write_comp_dir(true),
+ short_locs(false),
load_all_types(),
linux_kernel_mode(true),
corpus_group_for_linux(false),
<< " --no-architecture do not emit architecture info in the output\n"
<< " --no-corpus-path do not take the path to the corpora into account\n"
<< " --no-show-locs do not show location information\n"
+ << " --short-locs only print filenames rather than paths\n"
<< " --no-comp-dir-path do not show compilation path information\n"
<< " --check-alternate-debug-info <elf-path> check alternate debug info "
"of <elf-path>\n"
opts.write_corpus_path = false;
else if (!strcmp(argv[i], "--no-show-locs"))
opts.show_locs = false;
+ else if (!strcmp(argv[i], "--short-locs"))
+ opts.short_locs = true;
else if (!strcmp(argv[i], "--no-comp-dir-path"))
opts.write_comp_dir = false;
else if (!strcmp(argv[i], "--check-alternate-debug-info")