Esempio n. 1
0
void wm_set_name(Display *display, Window shell_window,
		 string title, string icon)
{
    strip_space(title);
    strip_space(icon);

    if (!title.empty())
	XStoreName(display, shell_window, title.chars());
    if (!icon.empty())
	XSetIconName(display, shell_window, icon.chars());
}
Esempio n. 2
0
void wm_set_name(Widget shell, string title, string icon)
{
    strip_space(title);
    strip_space(icon);

    XtVaSetValues(shell,
		  XmNiconName, icon.chars(),
		  XmNtitle,    title.chars(),
		  XtPointer(0));
    
#if 0				// This should be done by the shell.
    wm_set_name(XtDisplay(shell), XtWindow(shell), title, icon);
#endif
}
Esempio n. 3
0
// Add command COMMAND to history.
void UndoBuffer::add_command(const string& command, bool exec)
{
    string c = command;
    strip_space(c);
    if (c.empty())
	return;

    string command_key = exec ? UB_EXEC_COMMAND : UB_COMMAND;

    if (!undoing)
    {
	// Regular command
	add_status(command_key, c + "\n" + collector[command_key]);
	return;
    }

    // We're called from undo or redo via process_command() - 
    // replace currently executed command by its undo command.

#if LOG_UNDO_BUFFER
    std::clog << "Adding " << command_key << " = " << quote(command) << "\n";
#endif

    assert (history.size() > 0);
    assert (current_entry >= 0 && current_entry < history.size());

    UndoBufferEntry& entry = history[current_entry];

    if (entry.has(command_key))
	entry[command_key].prepend(c + '\n');
    else
	entry[command_key] = c;

    done();
}
Esempio n. 4
0
// store scene to sdcard at name
void files_store_scene_name(const char* name, u8 ext) {
  //u32 i;
  void* fp;
  char namebuf[64] = SCENES_PATH;
  u8* pScene;

  app_pause();

  strcat(namebuf, name);

  if(ext) {
    // weird..
    strip_space(namebuf, 32);
    strcat(namebuf, ".scn");
  }

  print_dbg("\r\n opening scene file for writing: ");
  print_dbg(namebuf);

  // fill the scene RAM buffer from current state of system
  scene_write_buf(); 
  // open FP for writing
  fp = fl_fopen(namebuf, "wb");
  pScene = (u8*)sceneData;
  fl_fwrite((const void*)pScene, sizeof(sceneData_t), 1, fp);
  fl_fclose(fp);
  // rescan
  list_scan(&sceneList, SCENES_PATH);
  delay_ms(10);

  app_resume();
}
Esempio n. 5
0
void BreakPoint::process_jdb(string& info_output)
{
    int colon = info_output.index(':');
    if (colon >= 0)
    {
	string class_name = info_output.before(colon);
	int line_no = get_positive_nr(info_output.after(colon));
	if (line_no >= 0 && !class_name.empty())
	{
	    // Strip JDB 1.2 info like `breakpoint', etc.
	    strip_space(class_name);
	    int last_space = class_name.index(" ", -1);
	    if (last_space > 0)
		class_name = class_name.after(last_space);

	    myfile_name = class_name;
	    myline_nr   = line_no;

	    // Kill this line
	    int beginning_of_line = colon;
	    while (beginning_of_line >= 0 && 
		   info_output[beginning_of_line] != '\n')
		beginning_of_line--;
	    beginning_of_line++;

	    int next_nl = info_output.index('\n', colon);
	    if (next_nl >= 0)
		info_output = info_output.before(beginning_of_line)
		    + info_output.from(next_nl);
	    else
		info_output = info_output.before(beginning_of_line);
	}
    }
}
Esempio n. 6
0
static void update_sources(Widget sources, Widget filter)
{
    StatusDelay delay("Getting sources");
    get_gdb_sources(all_sources);

    String pattern_s = XmTextFieldGetString(filter);
    string pattern = pattern_s;
    XtFree(pattern_s);

    strip_space(pattern);
    if (pattern.empty())
	pattern = "*";
    XmTextFieldSetString(filter, XMST(pattern.chars()));

    StringArray labels;
    uniquify(all_sources, labels);

    // Sort and remove duplicates
    sort(labels, all_sources);
    uniq(labels, all_sources);

    // Filter pattern
    filter_sources(labels, all_sources, pattern);

    // Now set the selection.
    bool *selected = new bool[labels.size()];
    for (int i = 0; i < labels.size(); i++)
	selected[i] = false;

    setLabelList(sources, labels.values(),
		 selected, labels.size(), false, false);

    delete[] selected;
}
Esempio n. 7
0
std::string getFTSEndpoint()
{
const char* path[2] = {"/etc/glite-sd2cache-cron.conf","/opt/glite/etc/glite-sd2cache-cron.conf"};
string line;
vector<std::string>::iterator myVectorIterator;
std::string fts = "";
std::string result = "";
 
 for(int index=0; index<2; index++){
        string ifname(path[index]);
        ifstream in(ifname.c_str());
        if(!in){
	 continue;
	}
	 
        string line;
        while (!in.eof()) {
            getline(in, line);	    
            line = strip_space(line);
            if (line.length() && line[0] != '#') {
                size_t pos = line.find("=");
                if (pos != string::npos) {
                    string key = strip_space(line.substr(0, pos));
                    string value = strip_space(line.substr(pos + 1));
                    ftsendpoint.insert(make_pair(key, value));
                }
            }
        }

        map <string, string> ::const_iterator iter = ftsendpoint.find("FTS_HOST"); 
	if (iter != ftsendpoint.end()) {
            fts = ftsendpoint.find("FTS_HOST")->second;
            if (fts.length() == 0)
		fts = "";
        }	
  }
  if(fts.length() > 0)
  {
    fts.erase(0, 1);
    fts.erase(fts.length()-1, fts.length());
    result = "https://";
    result += fts;
    result += ":8443/glite-data-transfer-fts/services/FileTransfer";
  }
  return result;
}
Esempio n. 8
0
// If the name has the form (PREFIX)(INDEX)(SUFFIX), return INDEX
string DispValue::index(const string& prefix, const string& suffix) const
{
    string idx = full_name();
    idx = idx.from(int(prefix.length()));
    idx = idx.before(int(idx.length() - suffix.length()));
    strip_space(idx);

    return idx;
}
Esempio n. 9
0
void write_scn(void) {
  char str[128];
  memset(str, '\0', 64);
  strcpy(str, workingDir);
  strcat( str, scene_get_name());
  strip_space(str, 64);
  strcat(str, ".scn");
  printf("\r\n writing .scn binary; name: %s", str);
  files_store_scene_name(str);
}
Esempio n. 10
0
// Get assigned variable
string get_assign_variable(const string& _cmd)
{
    string cmd = _cmd;
    strip_space(cmd);

    if (cmd.contains(":="))
	cmd = cmd.before(":=");
    else
	cmd = cmd.before('=');	// Remove assignment and assigned value

    if (cmd.contains("set var", 0))
	cmd = cmd.after(' ');	// Special case `set variable': two-word cmd

    if (cmd.contains(' '))
	cmd = cmd.after(' ');	// Return argument

    strip_space(cmd);
    return cmd;
}
Esempio n. 11
0
// True if ARG has the form `FILE:LINE'
bool is_file_pos(const string& arg)
{
#if RUNTIME_REGEX
    static regex rxfilepos("[^:]*:[1-9][0-9]*");
#endif

    string a = arg;
    strip_space(a);
    return a.matches(rxfilepos);
}
Esempio n. 12
0
File: xml.c Progetto: imp/slist
static Boolean_t
node_name(tgt_node_t *x, const xmlChar *n)
{
	assert(x->x_state == NodeAlloc);
	if ((n == NULL) || (strlen((char *)n) == 0))
		return (False);

	x->x_state = NodeName;
	x->x_name = strip_space((char *)n);
	return (True);
}
Esempio n. 13
0
void write_json(void) {
  char str[128];
  memset(str, '\0', 64);
  strcpy(str, workingDir);
  strcat( str, scene_get_name());
  strip_space(str, 64);
  strcat(str, ".json");
  printf("\r\n writing %s...", str);
  net_write_json_native(str);
  printf("\r\n done.");
}
Esempio n. 14
0
File: xml.c Progetto: imp/slist
static Boolean_t
node_value(tgt_node_t *x, const xmlChar *n, Boolean_t do_strip)
{
	assert(x->x_state == NodeName);
	if ((n == NULL) || (strlen((char *)n) == NULL))
		return (False);

	x->x_state = NodeValue;
	x->x_value = (do_strip == True) ?
	    strip_space((char *)n) : strdup((char *)n);
	return (True);
}
Esempio n. 15
0
// Forward Gnuplot error messages to DDD status line
static void SetStatusHP(Agent *, void *client_data, void *call_data)
{
    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;
    DataLength* dl = (DataLength *) call_data;
    string s(dl->data, dl->length);

    (void) plot;		// Use it
#if 0
    if (!plot->active)
    {
	// Probably an invocation problem
	post_gdb_message(s);
	return;
    }
#endif

    if (plot->command != 0)
    {
	string msg = s;
	strip_space(msg);
	MString xmsg = tb(msg);
	XmCommandError(plot->command, xmsg.xmstring());
    }

    while (!s.empty())
    {
	string line;
	if (s.contains('\n'))
	    line = s.before('\n');
	else
	    line = s;
	s = s.after('\n');
	strip_space(line);

	if (!line.empty())
	    set_status(line);
    }
}
Esempio n. 16
0
void write_gv(void) {
  char str[128];
  void* fp;
  memset(str, '\0', 64);
  strcpy(str, workingDir);
  strcat( str, scene_get_name());
  strip_space(str, 64);
  strcat(str, ".gv");
  fp = fopen(str, "w");

  net_write_dot(fp);

  fclose(fp);
}
Esempio n. 17
0
// store scene to sdcard at name
void files_store_scene_name(const char* name, u8 ext) {
  //u32 i;
  void* fp;
  char namebuf[64] = SCENES_PATH;
  u8* pScene;

  app_pause();

  strcat(namebuf, name);

  if(ext) {
    // weird..
    strip_space(namebuf, 32);
    strcat(namebuf, ".scn");
  }

  print_dbg("\r\n opening scene file for writing: ");
  print_dbg(namebuf);

  // fill the scene RAM buffer from current state of system
  scene_write_buf(); 
  print_dbg("\r\n filled scene binary buffer");

  // open FP for writing
  fp = fl_fopen(namebuf, "wb");
  print_dbg("\r\n opened file for binary write at 0x");
  print_dbg_hex((u32)fp);

  pScene = (u8*)sceneData;
  print_dbg("\r\n writing data from scene buffer at 0x");
  print_dbg_hex((u32)pScene);
  print_dbg(", size : ");
  print_dbg_hex(sizeof(sceneData_t));
  

  // dump the scene data to debug output...

  fl_fwrite((const void*)pScene, sizeof(sceneData_t), 1, fp);
  fl_fclose(fp);

  print_dbg("\r\n ... finished writing, closed file pointer");

  // rescan
  list_scan(&sceneList, SCENES_PATH);
  delay_ms(10);

  print_dbg("\r\n re-scanned scene file list and waited.");

  app_resume();
}
Esempio n. 18
0
string display_history_filter(const string& cmd)
{
    if (cmd.contains("graph display ", 0))
    {
	string arg = cmd.after("graph display ");
	if (arg.contains("dependent on"))
	    arg = arg.before("dependent on");
	if (arg.contains("now or"))
	    arg = arg.before("now or");
	if (arg.contains("when in"))
	    arg = arg.before("when in");

	strip_space(arg);

	// Strip format stuff
	while (arg.contains('/', 0))
	    arg = arg.after(' ');

	strip_space(arg);
	return arg;
    }

    return "";
}
Esempio n. 19
0
string watch_history_filter(const string& cmd)
{
    string arg;

    if (try_arg(cmd, gdb->watch_command("", WATCH_CHANGE), arg) ||
	try_arg(cmd, gdb->watch_command("", WATCH_READ), arg) ||
	try_arg(cmd, gdb->watch_command("", WATCH_WRITE), arg) ||
	try_arg(cmd, gdb->watch_command("", WATCH_ACCESS), arg))
    {
	strip_space(arg);
	return arg;
    }

    return "";
}
Esempio n. 20
0
// Action descriptions
string UndoBuffer::action(const string& command)
{
    string c = command;

    while (c.contains(REMAP_COMMAND, 0))
	c = c.after('\n');

    if (c.contains("graph ", 0))
	c = c.after("graph ");

    if (c.contains(' '))
	c = c.before(' ');

    strip_space(c);
    c.capitalize();
    return c;
}
Esempio n. 21
0
string set_history_filter(const string& cmd)
{
    string arg;

    if (cmd.contains(" = "))
	arg = cmd.after(" = ");
    else if (cmd.contains(" := "))
	arg = cmd.after(" := ");

    if (!arg.empty())
    {
	strip_space(arg);
	return arg;
    }

    return "";
}
Esempio n. 22
0
static bool try_arg(const string& cmd, const string& prefix_, string& arg)
{
    if (prefix_.empty())
	return false;		// No such command
    string prefix( prefix_ );
    if (!prefix.contains(" ", -1))
	prefix += " ";

    if (cmd.contains(prefix, 0))
    {
	arg = cmd.after(prefix);
	strip_space(arg);

	// Strip format stuff
	while (arg.contains('/', 0))
	    arg = arg.after(' ');

	if (arg.contains("'", 0))
	{
	    // Quoted arg -- add as unquoted
	    arg = unquote(arg);
	    return true;
	}
	else if (is_file_pos(arg))
	{
	    // FILE:LINE arg -- ignore
	    return false;
	}
	else if (arg.matches(rxint))
	{
	    // LINE arg -- ignore
	    return false;
	}
	else
	{
	    // Other arg -- add unchanged
	    return true;
	}
    }

    // Bad prefix -- ignore
    return false;
}
Esempio n. 23
0
void get_cfg_name(char *src, char *name, const char sep)
{
	char buf[NAME_MAX];
	char *begin = src;
	char *end = strchr(src, sep);
	size_t nlen;
	if (!end) {
		fprintf(stderr, "No valid separator in 'get_cfg_name()': %c\n",
				sep);
		exit(EXIT_FAILURE);
	}
	nlen = end - begin;
	if (nlen > NAME_MAX - 1) {
		fprintf(stderr, "String too large in 'get_cfg_name()': %lu\n",
				nlen);
		exit(EXIT_FAILURE);
	}
	strncpy(buf, begin, nlen);
	buf[nlen] = '\0';
	strip_space(buf);
	strcpy(name, buf);
} // get_cfg_name()
Esempio n. 24
0
void get_cfg_value(char *src, char *val, const char sep)
{
	char buf[NAME_MAX];
	char *begin = strchr(src, sep);
	if (!begin) {
		fprintf(stderr, "No valid separator in 'get_cfg_value()': %c\n",
				sep);
		exit(EXIT_FAILURE);
	}
	begin++;	// get past sep
	char *end = begin + strlen(src) - 1;
	size_t nlen;
	nlen = end - begin;
	if (nlen > NAME_MAX - 1) {
		fprintf(stderr, "String too large in 'get_cfg_value()': %lu\n",
				nlen);
		exit(EXIT_FAILURE);
	}
	strncpy(buf, begin, nlen);
	buf[nlen] = '\0';
	strip_space(buf);
	strcpy(val, buf);
} // get_cfg_value()
Esempio n. 25
0
string break_history_filter(const string& cmd)
{
    string arg;

    if (try_arg(cmd, "break", arg) ||
	try_arg(cmd, "tbreak", arg) ||
	try_arg(cmd, "clear", arg) ||
	try_arg(cmd, "stop in", arg) ||
	try_arg(cmd, "stop at", arg) ||
	try_arg(cmd, "b", arg) ||
	try_arg(cmd, "ba", arg))
    {
	strip_space(arg);
	if (arg.contains(" if "))
	    arg = arg.before(" if ");
	if (arg.contains(" -if "))
	    arg = arg.before(" -if ");
	if (arg.contains(" {if "))
	    arg = arg.before(" {if ");
	return arg;
    }

    return "";
}
Esempio n. 26
0
File: main.c Progetto: S010/misc
char *
normalize_path(const char *path) {
    size_t        nslashes;
    char         *buf,
                 *dotdot,
                 *p;
    int           do_loop;
    const char   *dotdot_str = "..",
                 *slash_dotdot_str = "/..";
    const size_t  dotdot_str_len       = sizeof(dotdot_str) - 1,
                  slash_dotdot_str_len = sizeof(slash_dotdot_str) - 1;

    assert(path);

    buf = strip_space(path);
    if (*buf == '\0') {
        free(buf);
        return strdup("/");
    }

    do {
        do_loop = 0;

        /* first, get rid of slases in the end,
         * as well as repeating slashes
         */
        p = strrchr(buf, '\0');
        while (*--p == '/' && p > buf) /* we handled the "" case above, so it's ok to *--p */
            *p = '\0';
        for (p = buf; p = strchr(p, '/'); ++p) {
            for (nslashes = 1; *(p + nslashes) == '/'; ++nslashes)
                /* empty */;
            if (nslashes > 1)
                memmove(p, p + nslashes - 1, strlen(p + nslashes - 1) + 1);
        }

        /* now take care of ".." */
        while (dotdot = strstr(buf, slash_dotdot_str)) {
            /* while dealing with .. we might introduce
             * repeating slashes, so loop the outer loop
             * once more...
             */
            do_loop = 1;
            if (dotdot == buf) {
                free(buf);
                return strdup("/");
            } else if (p = rstrchr(buf, dotdot - 1, '/')) {
                memmove(p, dotdot + slash_dotdot_str_len, strlen(dotdot + slash_dotdot_str_len) + 1);
            } else {
                free(buf);
                return strdup("/");
            }
        }

        for (dotdot = buf; dotdot = strstr(dotdot, dotdot_str); dotdot += dotdot_str_len) {
            if (dotdot == buf || *(dotdot - 1) != '/') {
                free(buf);
                return strdup("/");
            }
        }

        if (!strchr(buf, '/')) {
            free(buf);
            return strdup("/");
        }

    } while (do_loop);

    return buf;
}
Esempio n. 27
0
void document_propertiest::get_code(
  const source_locationt &source_location,
  std::string &dest)
{
  dest="";

  const irep_idt &file=source_location.get_file();
  const irep_idt &line=source_location.get_line();

  if(file=="" || line=="") return;

  std::ifstream in(id2string(file));

  if(!in)
  {
    dest+="ERROR: unable to open ";
    dest+=id2string(file);
    dest+="\n";
    return;
  }

  int line_int=unsafe_string2int(id2string(line));

  int line_start=line_int-3,
      line_end=line_int+3;

  if(line_start<=1) line_start=1;

  // skip line_start-1 lines

  for(int l=0; l<line_start-1; l++)
  {
    std::string tmp;
    std::getline(in, tmp);
  }

  // read till line_end

  std::list<linet> lines;

  for(int l=line_start; l<=line_end && in; l++)
  {
    lines.push_back(linet());

    std::string &line=lines.back().text;
    std::getline(in, line);

    if(!line.empty() && line[line.size()-1]=='\r')
      line.resize(line.size()-1);

    lines.back().line_number=l;
  }

  // remove empty lines at the end and at the beginning

  for(std::list<linet>::iterator it=lines.begin();
      it!=lines.end();)
  {
    if(is_empty(it->text))
      it=lines.erase(it);
    else
      break;
  }

  for(std::list<linet>::iterator it=lines.end();
      it!=lines.begin();)
  {
    it--;

    if(is_empty(it->text))
      it=lines.erase(it);
    else
      break;
  }

  // strip space
  strip_space(lines);

  // build dest

  for(std::list<linet>::iterator it=lines.begin();
      it!=lines.end(); it++)
  {
    std::string line_no=std::to_string(it->line_number);

    std::string tmp;

    switch(format)
    {
    case LATEX:
      while(line_no.size()<4)
        line_no=" "+line_no;

      line_no+"  ";

      tmp+=escape_latex(it->text, true);

      if(it->line_number==line_int)
        tmp="{\\ttb{}"+tmp+"}";

      break;

    case HTML:
      while(line_no.size()<4)
        line_no="&nbsp;"+line_no;

      line_no+"&nbsp;&nbsp;";

      tmp+=escape_html(it->text);

      if(it->line_number==line_int)
        tmp="<em>"+tmp+"</em>";

      break;
    }

    dest+=tmp+"\n";
  }
}
Esempio n. 28
0
// Get information on current debuggee
ProgramInfo::ProgramInfo()
    : file(NO_GDB_ANSWER),
      core(NO_GDB_ANSWER),
      pid(0),
      attached(false),
      running(false),
      state()
{
    if (source_view->have_exec_pos())
    {
	state = "has stopped";
	running = true;
    }
    else
    {
	state = "is not being run";
	running = false;
    }

    switch(gdb->type())
    {
    case GDB:
    case PYDB:
    case DBG:
    {
    	string ans;

    	if (gdb->is_windriver_gdb())
	{
	    // Windriver GDB (VxWorks).

	    // VxWorks allows multiple dynamically relocatable
	    // programs to be loaded simultaneously. Before a program
	    // is run, the 'info source' command can report
	    // information from a source file not related to the
	    // program just downloaded for debugging. (The WindRiver
	    // version of gdb does not support the 'info files'
	    // command.)

	    // In order to tell DDD that there is indeed a source file
	    // available, we need to first see if a program has
	    // already been started. If so, then the 'info source'
	    // command can be used.

	    // Otherwise, the 'info sources' command is used, and the
	    // first file in the list is used, assuming it is related
	    // to the current program that was downloaded.

	    // See if the program has been run first
	    ans = gdb_question("info frame");
	    if (ans == NO_GDB_ANSWER)
		break;

	    file = "";
	    if (ans.contains("No stack"))
	    {
		// Then try using info sources and use first file listed
		ans = gdb_question("info sources");
		if (ans == NO_GDB_ANSWER)
		    break;

		if (ans.contains("Source files for which "
				 "symbols have been read in:"))
		{
		    file = ans.after("\n");
		    file = file.before(" ");
		    file = unquote(file);
		}
	    }
	    else
	    {
	    	// Try using `info source'.
		ans = gdb_question("info source");
		if (ans == NO_GDB_ANSWER)
		    break;

		if (ans.contains("Current source file is "))
		{
		    file = ans.after("Current source file is ");
		    file = file.before(".\n");
		    file = unquote(file);
		}
	    }
	}
	else
	{
	    // Ordinary GDB.
	    ans = gdb_question("info files");
	    if (ans == NO_GDB_ANSWER)
		break;

	    file = "";
	    if (ans.contains("Symbols from "))
	    {
		file = ans.after("Symbols from ");
		file = file.before(".\n");
		file = unquote(file);
	    }

	}
	core = "";
	if (ans.contains("core dump"))
	{
	    core = ans.after("core dump");
	    core = core.after('`');
	    core = core.before("',");
	}

	if (ans.contains("process "))
	{
	    string p = ans.after("process ");
	    pid = atoi(p.chars());
	}

	attached = ans.contains("attached process ");

	ans = gdb_question("info program");
	if (ans == NO_GDB_ANSWER)
	    break;

	if (ans.contains("not being run"))
	    running = false;
	else if (ans.contains("\nIt stopped "))
	{
	    state = ans.from("\nIt stopped ");
	    state = "has " + state.after("\nIt ");
	    state = state.before('.');
	    running = true;
	}
	break;
    }

    case DBX:
    {
	if (gdb->is_ladebug())
	{
	    string ans = gdb_question("show process");
	    // typical answers:
	    // 1:no process 
	    // There are no processes being debugged.
	    // 2: process has been paused.
	    // Current Process: localhost:26177 (a.out) paused.
	    // 3: process terminated
	    // Current Process: localhost:13614 (ddd) terminated.
	    // TODO: treat the terminated case 
     
	    if (ans != NO_GDB_ANSWER && 
		!ans.contains("no processes being debugged"))
	    {
		if (ans.contains("Current Process: "))
		{
		    ans = ans.after(": ");
		    {
			string p = ans.after(":");
			p = p.before(" ");
			pid = atoi(p.chars());
		    }
		    ans = ans.after(" (");
		    file = ans.before(")");

		    ans = ans.after(") ");
		    running = ans.contains("paused");
		    // ladebug always creates a process.
		    // It may be "loaded" or attached.
		    attached = true;
		}
	    }	    
	}

	// AD TODO: shouldn't it be an "else" ?

	string ans = gdb_question(gdb->debug_command());
	if (ans != NO_GDB_ANSWER)
	{
	    if (ans.contains("Current givenfile is ", 0))
		ans = ans.after("Current givenfile is ");
	    else if (ans.contains("Debugging: ", 0))
		ans = ans.after(": ");

	    strip_space(ans);
	    if (!ans.contains(' ')) // Sanity check
		file = ans;
	}
	break;
    }

    case XDB:
	break;			// FIXME

    case PERL:
	// Use the program we were invoked with
	file = gdb->program();
	if (file.matches(rxint))
	    file = "";		// Invoked with a constant expression

	if (file.empty())
	{
	    // Not invoked with a program?  Use the current file, then.
	    file = source_view->file_of_cursor();
	    file = file.before(":");
	}
	core = "";
	break;

    case BASH:
	// Use the program we were invoked with
	file = gdb->program();
	if (file.matches(rxint))
	    file = "";		// Invoked with a constant expression

	if (file.empty())
	{
	    // Not invoked with a program?  Use the current file, then.
	    file = source_view->file_of_cursor();
	    file = file.before(":");
	}
	core = "";
	break;

    case JDB:
	// Just use the current class.
	file = source_view->line_of_cursor();
	file = file.before(":");
	core = "";

	// Save whether JDB's VM is running
	static int last_jdb_pid = -1;
	static bool jvm_running = false;

	if (gdb->pid() != last_jdb_pid)
	{
	    // New JDB: reset info
	    jvm_running = false;
	    last_jdb_pid = gdb->pid();
	}

	// The VM is running iff the prompt contains a backtrace
	// level ("[n]").
	if (!jvm_running && gdb->prompt().contains("["))
	    jvm_running = true;

	running = jvm_running;
	break;
    }

    if (file == NO_GDB_ANSWER)
    {
	// As a fallback, get core file and executable from argument list.
	// Works only on local file system and is more a guess.
	char **argv = saved_argv();
	int argc = 0;
	while (argv[argc] != 0)
	    argc++;

	for (int i = argc - 1; i > 0 && file == NO_GDB_ANSWER; i--)
	{
	    // All debuggers supported by DDD have [EXEC [CORE]] as
	    // their last arguments.
	    string arg = argv[i];
	    if (is_core_file(arg))
		core = arg;
	    else if (is_debuggee_file(arg))
		file = arg;
	}
    }

    if (file != NO_GDB_ANSWER)
	add_to_recent(file);
}
Esempio n. 29
0
void BreakPoint::process_perl(string& info_output)
{
    // Format: [FILE:]
    //          LINE_NO: LINE
    //           INFO 1
    //           INFO 2 ...

    if (!info_output.contains(' ', 0))
    {
	const string first_line = info_output.before('\n');
	if (first_line.contains(':', -1))
	{
	    // Get leading file name
	    myfile_name = first_line.before(':');
	    info_output = info_output.after('\n');
	}
    }

    static const StringArray empty;
    mycommands = empty;
    myline_nr = atoi(info_output.chars());
    info_output = info_output.after('\n');
    bool break_seen = false;
    while (info_output.contains("  ", 0))
    {
	string info = info_output.before('\n');
	info_output = info_output.after('\n');

	strip_space(info);
	if (info.contains("break if ", 0))
	{
	    string cond = info.after(" if ");
	    while (cond.contains('(', 0) && cond.contains(')', -1))
		cond = unquote(cond);
	    if (cond == "1")
		cond = "";
	    mycondition = cond;
	    break_seen = true;
	}
	else if (info.contains("action: ", 0))
	{
	    string commands = info.after(':');
	    strip_space(commands);

	    if (commands.contains("d " + itostring(line_nr())))
		mydispo = BPDEL; // Temporary breakpoint

	    string command = "";
	    while (!commands.empty())
	    {
		const string token = read_token(commands);
		if (token != ";")
		    command += token;

		if (token == ";" || commands.empty())
		{
		    strip_space(command);
		    if (!command.empty())
		    {
			mycommands += command;
			command = "";
		    }
		}
	    }
	}
	else
	{
	    myinfos += info + '\n';
	}
    }

    if (!break_seen)
	mytype = ACTIONPOINT;
}
Esempio n. 30
0
void BreakPoint::process_xdb(string& info_output)
{
    // Strip leading `:'.
    // Bob Wiegand <*****@*****.**>
    if (info_output.contains(':', 0))
	info_output = info_output.after(0);

    strip_leading_space(info_output);

    // Skip `count: N'
    if (info_output.contains("count:", 0))
    {
	info_output = info_output.after("count:");
	strip_leading_space(info_output);
	string count = info_output.before(rxblanks_or_tabs);
	info_output = info_output.after(rxblanks_or_tabs);

	myignore_count = atoi(count.chars());
    }
	    
    // Check for `Active' or `Suspended' and strip them
    // Bob Wiegand <*****@*****.**>
    if (info_output.contains("Active", 0))
    {
	info_output = info_output.after("Active");
	myenabled   = true;
    }
    else if (info_output.contains("Suspended", 0))
    {
	info_output = info_output.after("Suspended");
	myenabled   = false;
    }

    // Get function name and position
    info_output = info_output.after(rxblanks_or_tabs);
    myfunc = info_output.before(": ");

    const string pos = dbx_lookup(myfunc);
    if (!pos.empty())
    {
	myfile_name = pos.before(":");
    }

    info_output = info_output.after(": ");
    myline_nr = get_positive_nr(info_output);

    info_output = info_output.after('\n');

    // Examine commands for condition
    string commands = info_output;
    strip_leading_space(commands);
    if (commands.contains('{', 0))
    {
	// A condition has the form `{if COND {} {Q; c}}'.
	if (commands.contains("{if ", 0))
	{
	    string cond = commands.after("{if ");
	    cond = cond.before('{');
	    strip_space(cond);
	    mycondition = cond;
	}

	// Skip this line, too
	info_output = info_output.after('\n');
    }
}