Skip to content

Instantly share code, notes, and snippets.

@zhuizhuhaomeng
Last active November 2, 2022 00:24
Show Gist options
  • Save zhuizhuhaomeng/8c01224a5f1fee1add254a688951c054 to your computer and use it in GitHub Desktop.
Save zhuizhuhaomeng/8c01224a5f1fee1add254a688951c054 to your computer and use it in GitHub Desktop.
diff --git a/dwflpp.cxx b/dwflpp.cxx
index c2fdb05f5..96d55490e 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -2892,7 +2892,7 @@ dwflpp::find_variable_and_frame_base (vector<Dwarf_Die>& scopes,
// version is recent enough to not need this workaround if
// we would see an imported unit.
if (dwarf_tag (vardie) == DW_TAG_variable
- && strcmp (dwarf_diename (vardie), local.c_str ()) == 0
+ && strcmp (dwarf_diename (vardie) ?: "<unknown>", local.c_str ()) == 0
&& (dwarf_attr_integrate (vardie, DW_AT_external, &attr_mem)
!= NULL)
&& ((dwarf_attr_integrate (vardie, DW_AT_const_value, &attr_mem)
diff --git a/loc2stap.cxx b/loc2stap.cxx
index 74e753187..efc78cc57 100644
--- a/loc2stap.cxx
+++ b/loc2stap.cxx
@@ -1510,7 +1510,7 @@ max_fetch_size (Dwarf_Die *die)
if (cu == NULL)
throw SEMANTIC_ERROR(std::string("cannot determine compilation unit "
"address size from ")
- + dwarf_diename (die)
+ + (dwarf_diename (die) ?: "<anonymous>")
+ " " + dwarf_errmsg (-1));
return address_size;
diff --git a/tapsets.cxx b/tapsets.cxx
index 1fed5dfd6..0ec71ebda 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -12605,7 +12605,7 @@ tracepoint_query::handle_query_type(Dwarf_Die * type)
if (!dwarf_hasattr(type, DW_AT_name))
return DWARF_CB_OK;
- std::string name(dwarf_diename(type));
+ std::string name(dwarf_diename(type) ?: "<unknown type>");
if (!dw.function_name_matches_pattern(name, "stapprobe_" + tracepoint)
|| startswith(name, "stapprobe_template_"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment