MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / set_parameter_string

Function set_parameter_string

src/backward.h:2887–2996  ·  view source on GitHub ↗

Types are resolved from right to left: we get the variable name first and then all specifiers (like const or pointer) in a chain of DW_AT_type DIEs. Call this function recursively until we get a complete type string.

Source from the content-addressed store, hash-verified

2885 // DIEs. Call this function recursively until we get a complete type
2886 // string.
2887 static void set_parameter_string(dwarf_fileobject& fobj, Dwarf_Die die, type_context_t& context)
2888 {
2889 char* name;
2890 Dwarf_Error error = DW_DLE_NE;
2891
2892 // typedefs contain also the base type, so we skip it and only
2893 // print the typedef name
2894 if (!context.is_typedef) {
2895 if (dwarf_diename(die, &name, &error) == DW_DLV_OK) {
2896 if (!context.text.empty()) {
2897 context.text.insert(0, " ");
2898 }
2899 context.text.insert(0, std::string(name));
2900 dwarf_dealloc(fobj.dwarf_handle.get(), name, DW_DLA_STRING);
2901 }
2902 }
2903 else {
2904 context.is_typedef = false;
2905 context.has_type = true;
2906 if (context.is_const) {
2907 context.text.insert(0, "const ");
2908 context.is_const = false;
2909 }
2910 }
2911
2912 bool next_type_is_const = false;
2913 bool is_keyword = true;
2914
2915 Dwarf_Half tag = 0;
2916 Dwarf_Bool has_attr = 0;
2917 if (dwarf_tag(die, &tag, &error) == DW_DLV_OK) {
2918 switch (tag) {
2919 case DW_TAG_structure_type:
2920 case DW_TAG_union_type:
2921 case DW_TAG_class_type:
2922 case DW_TAG_enumeration_type:
2923 context.has_type = true;
2924 if (dwarf_hasattr(die, DW_AT_signature, &has_attr, &error) == DW_DLV_OK) {
2925 // If we have a signature it means the type is defined
2926 // in .debug_types, so we need to load the DIE pointed
2927 // at by the signature and resolve it
2928 if (has_attr) {
2929 std::string type = get_type_by_signature(fobj.dwarf_handle.get(), die);
2930 if (context.is_const)
2931 type.insert(0, "const ");
2932
2933 if (!context.text.empty())
2934 context.text.insert(0, " ");
2935 context.text.insert(0, type);
2936 }
2937
2938 // Treat enums like typedefs, and skip printing its
2939 // base type
2940 context.is_typedef = (tag == DW_TAG_enumeration_type);
2941 }
2942 break;
2943 case DW_TAG_const_type:
2944 next_type_is_const = true;

Callers 1

set_function_parametersFunction · 0.85

Calls 3

get_type_by_signatureFunction · 0.85
get_referenced_dieFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected