ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); this->reset (); this->set (address, address_family); }
ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); this->reset (); this->set (addr, len); }
ACE_INET_Addr::ACE_INET_Addr (u_short port_number, ACE_UINT32 inet_address) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); }
ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], ACE_UINT32 inet_address, const wchar_t protocol[]) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); }
ACE_INET_Addr::ACE_INET_Addr (const char port_name[], const char host_name[], const char protocol[]) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); if (this->set (port_name, host_name, protocol) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); }
/* ret 0 or -err */ int ReaddirOp::do_op(const char *path, unsigned char /* isfile */, IOStore *store) { int ret; IOSDirHandle *dir; struct dirent entstore, *ent; dir = store->Opendir(path,ret); if (dir == NULL) { return ret; } while ((ret = dir->Readdir_r(&entstore, &ent)) == 0 && ent != NULL) { if (skip_dots && (!strcmp(ent->d_name,".")|| !strcmp(ent->d_name,".."))) { continue; // skip the dots } if (filters.size()) { bool match = false; set<string>::iterator itr; for(itr=filters.begin(); itr!=filters.end(); itr++) { mlog(FOP_DCOMMON, "%s checking first %lu of filter %s on %s", __FUNCTION__, (unsigned long)itr->length(), itr->c_str(), ent->d_name); // don't know why itr->compare isn't working. driving me nuts. //if(itr->compare(0,itr->length()-1,ent->d_name)==0) { if(strncmp(itr->c_str(),ent->d_name,itr->length()-1)==0) { match = true; break; } } if(!match) { continue; // else, it passed the filters so descend } } string file; if (expand) { file = path; file += "/"; file += ent->d_name; } else { file = ent->d_name; } mlog(FOP_DCOMMON, "%s inserting %s", __FUNCTION__, file.c_str()); if (entries) (*entries)[file] = (ent->d_type != DT_UNKNOWN) ? ent->d_type : determine_type(store, path, ent->d_name); if (names) { names->insert(file); } } store->Closedir(dir); return ret; }
/* Function to load in all the nodes read from the file supplied (probably named "nodes.txt"). */ int nodes_file_load(event_ptr event, char* file_name) { FILE *nodes_file; /* File pointer. */ int load_status; char type_input[3]; int number; node *new_node; event->node_head = NULL; if ((nodes_file = fopen(file_name, "r")) == NULL) { /* Open file with read permissions only and check file opened. */ printf("Please enter in a valid file path and name.\n"); return FAILURE; } while ((load_status = fscanf(nodes_file, " %d %2s", &number, type_input)) != EOF && load_status == 2) { if (event->number_of_nodes == 0) { new_node = malloc(sizeof (struct node)); /* Allocates memory for a new node. */ } else { new_node->next_node = malloc(sizeof (struct node)); /* Allocates memory for the next node. */ new_node = new_node->next_node; } /* Initialises new node: */ new_node->number = number; new_node->type = determine_type(type_input); new_node->next_node = NULL; /*-----------------------------------------------------------------------*/ /* Adds new node to linked list: */ if (event->node_head == NULL) { event->node_head = new_node; printf("Head Node: Number: %d, Type: %d = %2s\n", new_node->number, new_node->type, type_input); } else { printf("Node: Number: %d, Type: %d = %2s\n", new_node->number, new_node->type, type_input); } /*-----------------------------------------------------------------------*/ event->number_of_nodes++; } if (load_status == EOF) { printf("\nNodes file loaded in successfully.\n"); fclose(nodes_file); /* Closes file as no longer needed. */ return SUCCESS; } else if (load_status != 2) { /* Expected 2 inputs. */ printf("Error loading in file, possible pattern mismatch.\n"); fclose(nodes_file); /* Closes file as no longer needed. */ return FAILURE; } }
ACE_INET_Addr::ACE_INET_Addr (u_short port_number, const char host_name[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->set (port_number, host_name, 1, address_family) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr: %p\n"), ACE_TEXT_CHAR_TO_TCHAR ((host_name == 0) ? "<unknown>" : host_name))); }
expr_val * compile_assignment(binary_op_node * ass, scope * scope, str_list * lines) { expr_val * name = compile_statement(ass->left, scope, lines); expr_val * val = compile_statement(ass->right, scope, lines); if (!determine_type(ass->op, name->type, val->type)) return NULL; char * name_value = name->val; char * right_value = val->val; int len = strlen(name_value) + strlen(right_value) + 5; char * output = (char *) malloc(len); snprintf(output, len, "%s = %s;", name_value, right_value); insert_array(lines, output); return new_expr_val(name_value, val->type); }
ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], ACE_UINT32 inet_address, const wchar_t protocol[]) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); #if !defined (ACE_LACKS_HTONL) this->reset (); if (this->set (port_name, htonl (inet_address), protocol) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_INET_Addr::ACE_INET_Addr"))); #else ACE_UNUSED_ARG (port_name); ACE_UNUSED_ARG (inet_address); ACE_UNUSED_ARG (protocol); #endif }
expr_val * compile_addition(binary_op_node * node, scope * scope, str_list * lines) { int op = node->op; expr_val * left = compile_statement(node->left, scope, lines); expr_val * right = compile_statement(node->right, scope, lines); // Determine if types are compatible expr_type type; if(!(type = determine_type(op, left->type, right->type))) return NULL; expr_val * var = get_new_var(type, scope, lines); // Extracting values char * var_val = var->val; char * left_val = left->val; char * right_val = right->val; int len = strlen(var_val) + strlen(left_val) + strlen(right_val) + 8; char * output = (char *) malloc(len); snprintf(output, len, "%s = %s + %s;", var_val, left_val, right_val); insert_array(lines, output); return new_expr_val(var_val, INT_TYPE); }
ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); this->reset (); }
/* Parse one line of text */ void parse (char string[]) { struct node *list_ptr /*, *node_ptr */; static int vartype = NOP, state = NOP; char *ptr = string, *title_ptr, *temp; if (((string[0] == ' ') && (strlen(string) > 6)) || ((string[0] == '\t') && (strlen(string) > 2))) { /* The current line is not a comment */ if (string[0] == '\t') ptr++; else ptr += 5; if ((isspace (*ptr)) || ((state != COMMON_CONTINUE) && (state != REGISTER_CONTINUE))) { ptr = skip_blanks (ptr); vartype = determine_type (ptr); state = vartype; if (strncmp_i("double precision", ptr, 16) == 0) ptr = skip_blanks (skip_nonblanks (ptr)); } if ((vartype != NOP) && (vartype != PARAMETER) && (vartype != EQUIV)) { /* The current line is a list of variables */ if (state == COMMON_CONTINUE) { /* The current line is the continuation of a common block */ list_ptr = common_start; ptr++; } else if (state == COMMON) { /* The current line is a common block */ list_ptr = common_start; ptr = find_char (find_char (ptr, '/'), '/'); state = COMMON_CONTINUE; } else if (state == REGISTER_CONTINUE) { /* The current line is the continuation of a register statement */ list_ptr = register_start; ptr++; } else { /* The current line contains variables to be registered */ list_ptr = register_start; ptr = skip_nonblanks (ptr); state = REGISTER_CONTINUE; } ptr = skip_blanks (ptr); /* Obtain the title string */ title_ptr = string; if (find_char (ptr, ',') > find_char (ptr, '!')) { while (*title_ptr != '!') title_ptr++; title_ptr = skip_blanks (title_ptr+1); if (*title_ptr == '\0') title_ptr = NULL; } else title_ptr = NULL; /* Convert ' to '' in title string */ if (title_ptr != NULL) { temp = title_ptr; while (*temp != '\0') { if (*temp == '\'') shift_left (temp++); temp++; } } /* Add each variable to the linked list */ while ((ptr < find_char (string, '!')) && (*ptr != '!')) { if ((find_char (ptr, '(') < find_char (ptr, ',')) && (find_char (ptr, '(') < find_char (ptr, '!'))) { /* The variable is an array */ create (list_ptr, vartype, ptr, title_ptr); if (vartype >= 0) array_flags[current_calltype][vartype] = 1; ptr = skip_blanks (find_char (find_char (ptr, ')'), ',')); } else { /* The variable is not an array */ create (list_ptr, vartype, ptr, title_ptr); if (vartype >=0) variable_flags[current_calltype][vartype] = 1; ptr = skip_blanks (find_char (ptr, ',')); } } } if (vartype == PARAMETER) /* If the line is a parameter statement, then ignore the variable */ mark_node (register_start, skip_blanks(find_char (ptr, '(')), IGNORE); if (vartype == EQUIV) { /* If the line is an equivalence statement, then skip the variables */ ptr = skip_blanks (find_char (ptr, '(')); mark_node (register_start, ptr, SKIP); if (find_char(ptr,'(') < find_char(ptr,',')) ptr = find_char(ptr,')'); ptr = skip_blanks (find_char (ptr, ',')); mark_node (register_start, ptr, SKIP); } } }
// Initialization void DispValue::init(DispValue *parent, int depth, string& value, DispValueType given_type) { #if LOG_CREATE_VALUES std::clog << "Building value from " << quote(value) << "\n"; #endif // Be sure the value is not changed in memory value.consuming(true); const char *initial_value = value.chars(); static const DispValueArray empty(0); _children = empty; if (background(value.length())) { clear(); mytype = Simple; _value = "(Aborted)"; value = "Aborted\n"; return; } mytype = given_type; if (mytype == UnknownType && (parent == 0 || parent->type() == List) && print_name.empty()) mytype = Text; if (mytype == UnknownType && parent == 0 && is_user_command(print_name)) mytype = List; if (mytype == UnknownType) mytype = determine_type(value); bool ignore_repeats = (parent != 0 && parent->type() == Array); char perl_type = '\0'; switch (mytype) { case Simple: { _value = read_simple_value(value, depth, ignore_repeats); #if LOG_CREATE_VALUES std::clog << mytype << ": " << quote(_value) << "\n"; #endif perl_type = '$'; break; } case Text: { // Read in a line of text if (value.contains('\n')) _value = value.through('\n'); else _value = value; value = value.after('\n'); #if LOG_CREATE_VALUES std::clog << mytype << ": " << quote(_value) << "\n"; #endif perl_type = '$'; break; } case Pointer: { _value = read_pointer_value(value, ignore_repeats); _dereferenced = false; #if LOG_CREATE_VALUES std::clog << mytype << ": " << quote(_value) << "\n"; #endif // Hide vtable pointers. if (_value.contains("virtual table") || _value.contains("vtable")) myexpanded = false; perl_type = '$'; // In Perl, pointers may be followed by indented `pointed to' // info. Skip this. if (gdb->type() == PERL) { while (value.contains("\n ", 0)) { value = value.after("\n "); value = value.from("\n"); } } break; } case Array: { string base = normalize_base(myfull_name); _orientation = app_data.array_orientation; #if LOG_CREATE_VALUES std::clog << mytype << ": " << "\n"; #endif read_array_begin(value, myaddr); // Check for `vtable entries' prefix. string vtable_entries = read_vtable_entries(value); if (!vtable_entries.empty()) { _children += parse_child(depth, vtable_entries, myfull_name); } // Read the array elements. Assume that the type is the // same across all elements. DispValueType member_type = UnknownType; if (!_have_index_base) { _index_base = index_base(base, depth); _have_index_base = true; } int array_index = _index_base; // The array has at least one element. Otherwise, GDB // would treat it as a pointer. do { const char *repeated_value = value.chars(); string member_name = gdb->index_expr("", itostring(array_index++)); DispValue *dv = parse_child(depth, value, add_member_name(base, member_name), member_name, member_type); member_type = dv->type(); _children += dv; int repeats = read_repeats(value); if (expand_repeated_values) { // Create one value per repeat while (--repeats > 0) { member_name = gdb->index_expr("", itostring(array_index++)); string val = repeated_value; DispValue *repeated_dv = parse_child(depth, val, add_member_name(base, member_name), member_name, member_type); _children += repeated_dv; } } else { // Show repetition in member if (repeats > 1) { array_index--; #if 0 // We use the GDB `artificial array' notation here, // since repeat recognition is supported in GDB only. member_name += "@" + itostring(repeats); dv->full_name() = add_member_name(base, member_name); dv->name() = member_name; #endif dv->repeats() = repeats; array_index += repeats; } } if (background(value.length())) { init(parent, depth, value); return; } } while (read_array_next(value)); read_array_end(value); // Expand only if at top-level. myexpanded = (depth == 0 || nchildren() <= 1); #if LOG_CREATE_VALUES std::clog << mytype << " has " << nchildren() << " members\n"; #endif perl_type = '@'; break; } case List: // Some DBXes issue the local variables via a frame line, just // like `set_date(d = 0x10003060, day_of_week = Sat, day = 24, // month = 12, year = 1994)'. Make this more readable. munch_dump_line(value); // FALL THROUGH case Struct: { _orientation = app_data.struct_orientation; _member_names = app_data.show_member_names; bool found_struct_begin = false; bool read_multiple_values = false; #if LOG_CREATE_VALUES std::clog << mytype << " " << quote(myfull_name) << "\n"; #endif string member_prefix = myfull_name; string member_suffix = ""; if (mytype == List) { member_prefix = ""; read_multiple_values = true; } else { // In C and Java, `*' binds tighter than `.' if (member_prefix.contains('*', 0)) { if (gdb->program_language() == LANGUAGE_C) { // Use the C `->' operator instead member_prefix.del("*"); if (member_prefix.contains('(', 0) && member_prefix.contains(')', -1)) member_prefix = unquote(member_prefix); #if RUNTIME_REGEX static regex rxchain("[-a-zA-Z0-9::_>.`]+"); #endif if (member_prefix.matches(rxchain)) { // Simple chain of identifiers - prepend `->' member_prefix += "->"; } else { member_prefix.prepend("("); member_prefix += ")->"; } } else { member_prefix.prepend("("); member_prefix += ")."; } } else if (gdb->program_language() == LANGUAGE_PERL) { // In Perl, members of A are accessed as A{'MEMBER_NAME'} member_prefix = normalize_base(member_prefix) + "{'"; member_suffix = "'}"; } else if (gdb->program_language() == LANGUAGE_PHP) { // In PHP, members of $A are accessed as $A['MEMBER_NAME'] member_prefix = normalize_base(member_prefix) + "['"; member_suffix = "']"; } else if (gdb->program_language() == LANGUAGE_FORTRAN) { // In Fortran, members of A are accessed as A%B member_prefix = normalize_base(member_prefix) + "%"; } else { // In all other languages, members are accessed as A.B member_prefix = normalize_base(member_prefix) + "."; } // In case we do not find a struct beginning, read only one value found_struct_begin = read_struct_begin(value, myaddr); read_multiple_values = found_struct_begin; } // Prepend base class in case of multiple inheritance // FIXME: This should be passed as an argument static string baseclass_prefix; member_prefix += baseclass_prefix; int base_classes = 0; bool more_values = true; while (more_values) { // In a List, we may have `member' names like `(a + b)'. // Don't be picky about this. bool picky = (mytype == Struct); string member_name = read_member_name(value, picky); if (member_name.empty()) { // Some struct stuff that is not a member DispValue *dv = parse_child(depth, value, myfull_name, ""); if (dv->type() == Struct) { // What's this - a struct within a struct? Just // adopt the members. // (This happens when we finally found the struct // after having read all the AIX DBX base classes.) for (int i = 0; i < dv->nchildren(); i++) { DispValue *dv2 = dv->child(i)->link(); _children += dv2; } dv->unlink(); } else { _children += dv; } more_values = read_multiple_values && read_struct_next(value); } else if (is_BaseClass_name(member_name)) { // Base class member string saved_baseclass_prefix = baseclass_prefix; base_classes++; if (base_classes > 1) { // Multiple inheritance. Be sure to // reference further members unambiguously. // // Note: we don't do that for the first base class, // because this might turn ambiguous again. // // Example: // // Base // | | // I1 I2 // \ / // C // // Members of I1::Base are not prefixed, members // of I2::Base get `I2::' as base class prefix. // If we did this already for the first base class, // members of both I1 and I2 would get `Base::' as // base class prefix. switch (gdb->program_language()) { case LANGUAGE_C: // C++ baseclass_prefix = unquote(member_name) + "::"; break; default: // Do nothing (yet) break; } } DispValue *dv = parse_child(depth, value, myfull_name, member_name); _children += dv; baseclass_prefix = saved_baseclass_prefix; more_values = read_multiple_values && read_struct_next(value); // Skip a possible `members of CLASS:' prefix read_members_prefix(value); // AIX DBX does not place a separator between base // classes and the other members, so we always // continue reading after having found a base // class. After all, the own class members are // still missing. if (mytype == Struct && !found_struct_begin) more_values = true; } else { // Ordinary member string full_name = ""; if (member_name == " ") { // Anonymous union full_name = myfull_name; } if (member_name.contains('.')) { if (gdb->has_quotes()) { // The member name contains `.' => quote it. This // happens with vtable pointers on Linux (`_vptr.'). full_name = member_prefix + quote(member_name, '\'') + member_suffix; } else { // JDB (and others?) prepend the class name // to inherited members. Omit this. full_name = member_prefix + member_name.after('.', -1) + member_suffix; } } if (full_name.empty()) { // Ordinary member full_name = member_prefix + member_name + member_suffix; } DispValue *child = parse_child(depth, value, full_name, member_name); if (child->type() == Text) { // Found a text as child - child value must be empty string empty = ""; _children += parse_child(depth, empty, full_name, member_name); string v = child->value(); strip_space(v); if (!v.empty()) _children += child; } else { _children += child; } more_values = read_multiple_values && read_struct_next(value); } if (background(value.length())) { init(parent, depth, value); return; } } if (mytype == List && !value.empty()) { // Add remaining value as text _children += parse_child(depth, value, ""); } if (found_struct_begin) { // Skip the remainder read_struct_end(value); } // Expand only if at top-level. myexpanded = (depth == 0 || nchildren() <= 1); #if LOG_CREATE_VALUES std::clog << mytype << " " << quote(myfull_name) << " has " << nchildren() << " members\n"; #endif perl_type = '%'; break; } case Reference: { myexpanded = true; int sep = value.index('@'); sep = value.index(':', sep); string ref = value.before(sep); value = value.after(sep); string addr = gdb->address_expr(myfull_name); _children += parse_child(depth, ref, addr, myfull_name, Pointer); _children += parse_child(depth, value, myfull_name); if (background(value.length())) { init(parent, depth, value); return; } perl_type = '$'; // No such thing in Perl... break; } case Sequence: case UnknownType: assert(0); abort(); } // Handle trailing stuff (`sequences') if (parent == 0 || parent->type() != Sequence) { bool need_clear = true; while (sequence_pending(value, parent)) { if (need_clear) { #if LOG_CREATE_VALUES std::clog << "Sequence detected at " << quote(value) << "\n"; #endif clear(); value = initial_value; mytype = Sequence; #if LOG_CREATE_VALUES std::clog << mytype << " " << quote(myfull_name) << "\n"; #endif need_clear = false; } const char *old_value = value.chars(); DispValue *dv = parse_child(depth, value, myfull_name); if (value == old_value) { // Nothing consumed - stop here dv->unlink(); break; } else if (dv->type() == Simple && dv->value().empty()) { // Empty value - ignore dv->unlink(); } else { _children += dv; } } #if LOG_CREATE_VALUES if (!need_clear) { std::clog << mytype << " " << quote(myfull_name) << " has " << nchildren() << " members\n"; } #endif } if (gdb->program_language() == LANGUAGE_PERL && is_perl_prefix(perl_type)) { // Set new type if (!myfull_name.empty() && is_perl_prefix(myfull_name[0])) myfull_name[0] = perl_type; } background(value.length()); changed = true; }