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); }
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); }
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); } }
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); }
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 * get_linespec_location (const struct event_location *location) { gdb_assert (EL_TYPE (location) == LINESPEC_LOCATION); return EL_LINESPEC (location); }