event_location_up copy_event_location (const struct event_location *src) { struct event_location *dst; dst = XCNEW (struct event_location); EL_TYPE (dst) = EL_TYPE (src); if (EL_STRING (src) != NULL) EL_STRING (dst) = xstrdup (EL_STRING (src)); switch (EL_TYPE (src)) { case LINESPEC_LOCATION: EL_LINESPEC (dst)->match_type = EL_LINESPEC (src)->match_type; if (EL_LINESPEC (src)->spec_string != NULL) EL_LINESPEC (dst)->spec_string = xstrdup (EL_LINESPEC (src)->spec_string); break; case ADDRESS_LOCATION: EL_ADDRESS (dst) = EL_ADDRESS (src); break; case EXPLICIT_LOCATION: EL_EXPLICIT (dst)->func_name_match_type = EL_EXPLICIT (src)->func_name_match_type; if (EL_EXPLICIT (src)->source_filename != NULL) EL_EXPLICIT (dst)->source_filename = xstrdup (EL_EXPLICIT (src)->source_filename); if (EL_EXPLICIT (src)->function_name != NULL) EL_EXPLICIT (dst)->function_name = xstrdup (EL_EXPLICIT (src)->function_name); if (EL_EXPLICIT (src)->label_name != NULL) EL_EXPLICIT (dst)->label_name = xstrdup (EL_EXPLICIT (src)->label_name); EL_EXPLICIT (dst)->line_offset = EL_EXPLICIT (src)->line_offset; break; case PROBE_LOCATION: if (EL_PROBE (src) != NULL) EL_PROBE (dst) = xstrdup (EL_PROBE (src)); break; default: gdb_assert_not_reached ("unknown event location type"); } return event_location_up (dst); }
int event_location_empty_p (const struct event_location *location) { switch (EL_TYPE (location)) { case LINESPEC_LOCATION: /* Linespecs are never "empty." (NULL is a valid linespec) */ return 0; case ADDRESS_LOCATION: return 0; case EXPLICIT_LOCATION: return (EL_EXPLICIT (location) == NULL || (EL_EXPLICIT (location)->source_filename == NULL && EL_EXPLICIT (location)->function_name == NULL && EL_EXPLICIT (location)->label_name == NULL && (EL_EXPLICIT (location)->line_offset.sign == LINE_OFFSET_UNKNOWN))); case PROBE_LOCATION: return EL_PROBE (location) == NULL; default: gdb_assert_not_reached ("unknown event location type"); } }
const char * event_location_to_string (struct event_location *location) { if (EL_STRING (location) == NULL) { switch (EL_TYPE (location)) { case LINESPEC_LOCATION: if (EL_LINESPEC (location) != NULL) EL_STRING (location) = xstrdup (EL_LINESPEC (location)); break; case ADDRESS_LOCATION: EL_STRING (location) = xstrprintf ("*%s", core_addr_to_string (EL_ADDRESS (location))); break; case EXPLICIT_LOCATION: EL_STRING (location) = explicit_location_to_string (EL_EXPLICIT (location)); break; case PROBE_LOCATION: EL_STRING (location) = xstrdup (EL_PROBE (location)); break; default: gdb_assert_not_reached ("unknown event location type"); } } return EL_STRING (location); }
void event_location_deleter::operator() (event_location *location) const { if (location != NULL) { xfree (EL_STRING (location)); switch (EL_TYPE (location)) { case LINESPEC_LOCATION: xfree (EL_LINESPEC (location)); break; case ADDRESS_LOCATION: /* Nothing to do. */ break; case EXPLICIT_LOCATION: xfree (EL_EXPLICIT (location)->source_filename); xfree (EL_EXPLICIT (location)->function_name); xfree (EL_EXPLICIT (location)->label_name); break; case PROBE_LOCATION: xfree (EL_PROBE (location)); break; default: gdb_assert_not_reached ("unknown event location type"); } xfree (location); } }
event_location_up new_explicit_location (const struct explicit_location *explicit_loc) { struct event_location tmp; memset (&tmp, 0, sizeof (struct event_location)); EL_TYPE (&tmp) = EXPLICIT_LOCATION; initialize_explicit_location (EL_EXPLICIT (&tmp)); if (explicit_loc != NULL) { if (explicit_loc->source_filename != NULL) { EL_EXPLICIT (&tmp)->source_filename = explicit_loc->source_filename; } if (explicit_loc->function_name != NULL) EL_EXPLICIT (&tmp)->function_name = explicit_loc->function_name; if (explicit_loc->label_name != NULL) EL_EXPLICIT (&tmp)->label_name = explicit_loc->label_name; if (explicit_loc->line_offset.sign != LINE_OFFSET_UNKNOWN) EL_EXPLICIT (&tmp)->line_offset = explicit_loc->line_offset; } return copy_event_location (&tmp); }
event_location_up new_probe_location (const char *probe) { struct event_location *location; location = XCNEW (struct event_location); EL_TYPE (location) = PROBE_LOCATION; if (probe != NULL) EL_PROBE (location) = xstrdup (probe); return event_location_up (location); }
event_location_up new_address_location (CORE_ADDR addr, const char *addr_string, int addr_string_len) { struct event_location *location; location = XCNEW (struct event_location); EL_TYPE (location) = ADDRESS_LOCATION; EL_ADDRESS (location) = addr; if (addr_string != NULL) EL_STRING (location) = xstrndup (addr_string, addr_string_len); return event_location_up (location); }
event_location_up new_linespec_location (char **linespec) { struct event_location *location; location = XCNEW (struct event_location); EL_TYPE (location) = LINESPEC_LOCATION; if (*linespec != NULL) { char *p; char *orig = *linespec; linespec_lex_to_end (linespec); p = remove_trailing_whitespace (orig, *linespec); if ((p - orig) > 0) EL_LINESPEC (location) = savestring (orig, p - orig); } return event_location_up (location); }
const char * event_location_to_string (struct event_location *location) { if (EL_STRING (location) == NULL) { switch (EL_TYPE (location)) { case LINESPEC_LOCATION: if (EL_LINESPEC (location)->spec_string != NULL) { linespec_location *ls = EL_LINESPEC (location); if (ls->match_type == symbol_name_match_type::FULL) { EL_STRING (location) = concat ("-qualified ", ls->spec_string, (char *) NULL); } else EL_STRING (location) = xstrdup (ls->spec_string); } break; case ADDRESS_LOCATION: EL_STRING (location) = xstrprintf ("*%s", core_addr_to_string (EL_ADDRESS (location))); break; case EXPLICIT_LOCATION: EL_STRING (location) = explicit_location_to_string (EL_EXPLICIT (location)); break; case PROBE_LOCATION: EL_STRING (location) = xstrdup (EL_PROBE (location)); break; default: gdb_assert_not_reached ("unknown event location type"); } } return EL_STRING (location); }
event_location_up new_linespec_location (const char **linespec, symbol_name_match_type match_type) { struct event_location *location; location = XCNEW (struct event_location); EL_TYPE (location) = LINESPEC_LOCATION; EL_LINESPEC (location)->match_type = match_type; if (*linespec != NULL) { const char *p; const char *orig = *linespec; linespec_lex_to_end (linespec); p = remove_trailing_whitespace (orig, *linespec); if ((p - orig) > 0) EL_LINESPEC (location)->spec_string = savestring (orig, p - orig); } return event_location_up (location); }
enum event_location_type event_location_type (const struct event_location *location) { return EL_TYPE (location); }
const struct explicit_location * get_explicit_location_const (const struct event_location *location) { gdb_assert (EL_TYPE (location) == EXPLICIT_LOCATION); return EL_EXPLICIT (location); }
const char * get_probe_location (const struct event_location *location) { gdb_assert (EL_TYPE (location) == PROBE_LOCATION); return EL_PROBE (location); }
const char * get_address_string_location (const struct event_location *location) { gdb_assert (EL_TYPE (location) == ADDRESS_LOCATION); return EL_STRING (location); }
CORE_ADDR get_address_location (const struct event_location *location) { gdb_assert (EL_TYPE (location) == ADDRESS_LOCATION); return EL_ADDRESS (location); }
const char * get_linespec_location (const struct event_location *location) { gdb_assert (EL_TYPE (location) == LINESPEC_LOCATION); return EL_LINESPEC (location); }