001 package nl.cwi.sen1.tide.adapters.gdb; 002 003 import java.util.regex.Matcher; 004 import java.util.regex.Pattern; 005 006 public class RetrievePidCmd extends Command 007 { 008 private static Pattern patternInfo; 009 private GdbProcess process; 010 011 static { 012 patternInfo = Pattern.compile("process ([0-9]+)"); 013 } 014 015 public RetrievePidCmd(GdbAdapter adapter, GdbProcess process) 016 { 017 super(adapter); 018 this.process = process; 019 } 020 021 public String command() 022 { 023 return "info proc\n"; 024 } 025 026 public boolean response(String line) 027 { 028 if(line.startsWith("Process status flags:")) { 029 return false; 030 } 031 032 if(line.startsWith("Reason for stopping:")) { 033 return false; 034 } 035 036 if(line.startsWith("Additional signal/fault info:")) { 037 return true; 038 } 039 040 Matcher matcher = patternInfo.matcher(line); 041 042 if(matcher.matches()) { 043 int pid = Integer.parseInt(matcher.group(1)); 044 debugMsg("*** PID: " + pid); 045 // TODO: get this working again, now the pid is set to 0 always. 046 process.setPid(pid); 047 return true; 048 } 049 050 debugMsg("line '" + line + "' does not match with patternInfo"); 051 return false; 052 053 } 054 }