Resolve the function return type and parameters
| 2961 | |
| 2962 | // Resolve the function return type and parameters |
| 2963 | static void set_function_parameters(std::string &function_name, |
| 2964 | std::vector<std::string> &ns, |
| 2965 | dwarf_fileobject &fobj, Dwarf_Die die) { |
| 2966 | Dwarf_Debug dwarf = fobj.dwarf_handle.get(); |
| 2967 | Dwarf_Error error = DW_DLE_NE; |
| 2968 | Dwarf_Die current_die = 0; |
| 2969 | std::string parameters; |
| 2970 | bool has_spec = true; |
| 2971 | // Check if we have a spec DIE. If we do we use it as it contains |
| 2972 | // more information, like parameter names. |
| 2973 | Dwarf_Die spec_die = get_spec_die(fobj, die); |
| 2974 | if (!spec_die) { |
| 2975 | has_spec = false; |
| 2976 | spec_die = die; |
| 2977 | } |
| 2978 | |
| 2979 | std::vector<std::string>::const_iterator it = ns.begin(); |
| 2980 | std::string ns_name; |
| 2981 | for (it = ns.begin(); it < ns.end(); ++it) { |
| 2982 | ns_name.append(*it).append("::"); |
| 2983 | } |
| 2984 | |
| 2985 | if (!ns_name.empty()) { |
| 2986 | function_name.insert(0, ns_name); |
| 2987 | } |
| 2988 | |
| 2989 | // See if we have a function return type. It can be either on the |
| 2990 | // current die or in its spec one (usually true for inlined functions) |
| 2991 | std::string return_type = |
| 2992 | get_referenced_die_name(dwarf, die, DW_AT_type, true); |
| 2993 | if (return_type.empty()) { |
| 2994 | return_type = get_referenced_die_name(dwarf, spec_die, DW_AT_type, true); |
| 2995 | } |
| 2996 | if (!return_type.empty()) { |
| 2997 | return_type.append(" "); |
| 2998 | function_name.insert(0, return_type); |
| 2999 | } |
| 3000 | |
| 3001 | if (dwarf_child(spec_die, ¤t_die, &error) == DW_DLV_OK) { |
| 3002 | for (;;) { |
| 3003 | Dwarf_Die sibling_die = 0; |
| 3004 | |
| 3005 | Dwarf_Half tag_value; |
| 3006 | dwarf_tag(current_die, &tag_value, &error); |
| 3007 | |
| 3008 | if (tag_value == DW_TAG_formal_parameter) { |
| 3009 | // Ignore artificial (ie, compiler generated) parameters |
| 3010 | bool is_artificial = false; |
| 3011 | Dwarf_Attribute attr_mem; |
| 3012 | if (dwarf_attr(current_die, DW_AT_artificial, &attr_mem, &error) == |
| 3013 | DW_DLV_OK) { |
| 3014 | Dwarf_Bool flag = 0; |
| 3015 | if (dwarf_formflag(attr_mem, &flag, &error) == DW_DLV_OK) { |
| 3016 | is_artificial = flag != 0; |
| 3017 | } |
| 3018 | dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); |
| 3019 | } |
| 3020 |
no test coverage detected