/* Get node type */
strtok(line, " ");
strtok(NULL, " ");
- node_type = strtok(NULL, " ");
+ node_type = strdup(strtok(NULL, " "));
if(strcmp(node_type, "DW_TAG_subprogram") == 0){ /* New frame */
read = getline(&line, &n, fp);
+ free(node_type);
while(read != -1 && line[0] != '<'){
if(n == 0)
continue;
- node_type = strtok(line, " ");
+ node_type = strdup(strtok(line, " "));
if(node_type != NULL && strcmp(node_type, "DW_AT_name") == 0){
frame->name = strdup(frame_name);
frame->variables = xbt_dynar_new(sizeof(dw_local_variable_t), NULL);
frame->location = xbt_new0(s_dw_location_t, 1);
+ free(frame_name);
location_type = strtok(NULL, " ");
while(read != -1 && line[0] == '['){
strtok(line, "<");
- lowpc = strdup(strtok(NULL, "<"));
- highpc = strdup(strtok(NULL, ">"));
- tmp_location = strdup(strtok(NULL, ">"));
+ lowpc = strtok(NULL, "<");
+ highpc = strtok(NULL, ">");
+ tmp_location = strtok(NULL, ">");
lowpc[strlen(lowpc) - 1] = '\0'; /* Remove last character '>' */
dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
read = getline(&line, &n, fp);
xbt_str_ltrim(line, NULL);
+
}
}else{
read = getline(&line, &n, fp);
- }
+ }
+
+ free(node_type);
}
}else if(strcmp(node_type, "DW_TAG_variable") == 0){ /* New variable */
- variable_name = NULL;
- location_type = NULL;
-
read = getline(&line, &n, fp);
+ free(node_type);
while(read != -1 && line[0] != '<'){
tmp_line = strdup(line);
- node_type = strtok(line, " ");
+ node_type = strdup(strtok(line, " "));
if(node_type != NULL && strcmp(node_type, "DW_AT_name") == 0){
if(valid_variable == 1){
- location_type = strdup(strtok(NULL, " "));
+ location_type = strtok(NULL, " ");
dw_local_variable_t variable = xbt_new0(s_dw_local_variable_t, 1);
variable->name = strdup(variable_name);
variable->location = xbt_new0(s_dw_location_t, 1);
+ free(variable_name);
if(strcmp(location_type, "<loclist") == 0){
while(read != -1 && line[0] == '['){
strtok(line, "<");
- lowpc = strdup(strtok(NULL, "<"));
- highpc = strdup(strtok(NULL, ">"));
- tmp_location = strdup(strtok(NULL, ">"));
+ lowpc = strtok(NULL, "<");
+ highpc = strtok(NULL, ">");
+ tmp_location = strtok(NULL, ">");
lowpc[strlen(lowpc) - 1] = '\0'; /* Remove last character '>' */
dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
read = getline(&line, &n, fp);
xbt_str_ltrim(line, NULL);
+
}
}else{
read = getline(&line, &n, fp);
}
+
+ free(node_type);
+ free(tmp_line);
}
}else if(strcmp(node_type, "DW_TAG_compile_unit") == 0){
+ free(node_type);
read = getline(&line, &n, fp);
while(read != -1 && line[0] != '<'){
if(n == 0)
continue;
- node_type = strtok(line, " ");
+ node_type = strdup(strtok(line, " "));
if(node_type != NULL && strcmp(node_type, "DW_AT_low_pc") == 0){
low_pc = (void *) strtoul(strtok(NULL, " "), NULL, 16);
read = getline(&line, &n, fp);
+ free(node_type);
+
}
}else{
read = getline(&line, &n, fp);
+ free(node_type);
}
+
}else{
read = getline(&line, &n, fp);
}
+
}
- free(line); free(tmp_line); free(tmp_location); free(frame_name);
- free(location_type); free(variable_name); free(lowpc); free(highpc);
+ free(line);
free(command);
pclose(fp);
entry->type = e_dw_unsupported;
}
- free(tok);
- free(tmp_tok);
xbt_dynar_free(&tokens);
return entry->type;