TCF Agent: Symbols service: fixed retrieving address of C/C++ label
diff --git a/agent/tcf/main/test.c b/agent/tcf/main/test.c
index 49a2063..9b37a70 100644
--- a/agent/tcf/main/test.c
+++ b/agent/tcf/main/test.c
@@ -158,6 +158,7 @@
 /* Main purpose of this declaration is to pull basic types info into DWARF */
 char tcf_test_char = 0;
 short tcf_test_short = 0;
+int tcf_test_int = 0;
 long tcf_test_long = 0;
 const char * tcf_test_str = "abc";
 
@@ -197,6 +198,9 @@
     test_bitfields func2_local5 = { 0, 1, 2, 3, 4, 7, 9, 17, 1, 2, 3, 4, 7, 9, 17 };
     const char * func2_local_str = "bcd";
 
+func2_label:
+    if (tcf_test_int) goto func2_label;
+
     func2_local3.f_struct = &func2_local3;
     tcf_test_short++;
     errno = tcf_test_short;
diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c
index 3fef938..5ac250f 100644
--- a/agent/tcf/services/expressions.c
+++ b/agent/tcf/services/expressions.c
@@ -1566,7 +1566,10 @@
         v->value = buf;
         v->remote = 0;
     }
-    else if (v->value == NULL) {
+    else if (v->value != NULL) {
+        /* OK */
+    }
+    else if (v->loc != NULL) {
         size_t size = 0;
         void * value = NULL;
         LocationExpressionState * loc = v->loc;
@@ -1576,6 +1579,9 @@
         v->size = (ContextAddress)size;
         sign_extend(v, loc);
     }
+    else {
+        error(ERR_OTHER, "Has no value");
+    }
 }
 
 static int is_number(Value * v) {
@@ -2962,7 +2968,7 @@
         if (get_symbol_type(type, &next) < 0) {
             error(errno, "Cannot retrieve symbol type");
         }
-        if (next == type) break;
+        if (next == NULL || next == type) break;
         type = next;
     }
 #endif
diff --git a/agent/tcf/services/symbols_elf.c b/agent/tcf/services/symbols_elf.c
index 752f4ff..de8c52a 100644
--- a/agent/tcf/services/symbols_elf.c
+++ b/agent/tcf/services/symbols_elf.c
@@ -674,6 +674,7 @@
         sym->sym_class = SYM_CLASS_VARIANT;
         break;
     case TAG_label:
+        sym->sym_class = SYM_CLASS_REFERENCE;
         /* LLVM compiler uses TAG_label for assembly functions */
         is_assembly_function(sym);
         if (!sym->assembly_function) break;
@@ -4032,6 +4033,12 @@
                 return -1;
             }
         }
+        if (obj->mTag == TAG_label && (obj->mFlags & DOIF_ranges) == 0 && (obj->mFlags & DOIF_low_pc) != 0) {
+            ContextAddress addr = elf_map_to_run_time_address(sym_ctx, obj->mCompUnit->mFile, obj->u.mCode.mSection, obj->u.mCode.mLowPC);
+            if (errno) return -1;
+            add_location_command(info, SFT_CMD_NUMBER)->args.num = addr;
+            return 0;
+        }
 #if 0
 #if SERVICE_StackTrace || ENABLE_ContextProxy
         if (obj->mTag == TAG_formal_parameter) {