- p2 = strrchr(p,'(');
- if (p2) *p2= '\0';
- p2 = strrchr(p,' ');
- if(p2) *p2= '\0';
-
- /* Here we go, fire an addr2line up */
- subcmd = bprintf("%s -f -e %s %s",ADDR2LINE,p, addrs[i]);
- free(p);
- VERB1("Fire a new command: '%s'",subcmd);
- subpipe = popen(subcmd,"r");
- if (!subpipe) {
- CRITICAL0("Cannot fork addr2line to display the backtrace");
- abort();
- }
- fgets(line_func,1024,subpipe);
- line_func[strlen(line_func)-1]='\0';
- fgets(line_pos,1024,subpipe);
- line_pos[strlen(line_pos)-1]='\0';
- pclose(subpipe);
- free(subcmd);
+ p2 = strrchr(p, '(');
+ if (p2)
+ *p2 = '\0';
+ p2 = strrchr(p, ' ');
+ if (p2)
+ *p2 = '\0';
+
+ /* Here we go, fire an addr2line up */
+ subcmd = bprintf("%s -f -e %s %s", ADDR2LINE, p, addrs[i]);
+ free(p);
+ XBT_VERB("Fire a new command: '%s'", subcmd);
+ subpipe = popen(subcmd, "r");
+ if (!subpipe) {
+ XBT_CRITICAL("Cannot fork addr2line to display the backtrace");
+ abort();
+ }
+ fgets_res = fgets(line_func, 1024, subpipe);
+ if (fgets_res == NULL)
+ THROW1(system_error, 0, "Cannot read result of subcommand %s",
+ subcmd);
+ line_func[strlen(line_func) - 1] = '\0';
+ fgets_res = fgets(line_pos, 1024, subpipe);
+ if (fgets_res == NULL)
+ THROW1(system_error, 0, "Cannot read result of subcommand %s",
+ subcmd);
+ line_pos[strlen(line_pos) - 1] = '\0';
+ pclose(subpipe);
+ free(subcmd);