Skip to content

Instantly share code, notes, and snippets.

@zhuizhuhaomeng
Last active November 2, 2022 00:24
Show Gist options
  • Select an option

  • Save zhuizhuhaomeng/8c01224a5f1fee1add254a688951c054 to your computer and use it in GitHub Desktop.

Select an option

Save zhuizhuhaomeng/8c01224a5f1fee1add254a688951c054 to your computer and use it in GitHub Desktop.

Revisions

  1. zhuizhuhaomeng revised this gist Nov 2, 2022. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions die_name.patch
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,27 @@
    diff --git a/dwflpp.cxx b/dwflpp.cxx
    index c2fdb05f5..95ef40b31 100644
    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) ?: "<unknow>", local.c_str ()) == 0
    && (dwarf_attr_integrate (vardie, DW_AT_external, &attr_mem)
    != NULL)
    && ((dwarf_attr_integrate (vardie, DW_AT_const_value, &attr_mem)
    // 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));
    "address size from ")
    - + dwarf_diename (die)
    + + (dwarf_diename (die) ?: "<anonymous>")
    + " " + dwarf_errmsg (-1));

    return address_size;
    diff --git a/tapsets.cxx b/tapsets.cxx
  2. zhuizhuhaomeng created this gist Oct 27, 2022.
    39 changes: 39 additions & 0 deletions die_name.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    diff --git a/dwflpp.cxx b/dwflpp.cxx
    index c2fdb05f5..95ef40b31 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) ?: "<unknow>", 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_"))