unknown.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* unknown.c -- used when backtrace configury does not know file format.
  2. Copyright (C) 2012-2022 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor, Google.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are
  6. met:
  7. (1) Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. (2) Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in
  11. the documentation and/or other materials provided with the
  12. distribution.
  13. (3) The name of the author may not be used to
  14. endorse or promote products derived from this software without
  15. specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  20. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  24. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  25. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26. POSSIBILITY OF SUCH DAMAGE. */
  27. #include "config.h"
  28. #include <sys/types.h>
  29. #include "backtrace.h"
  30. #include "internal.h"
  31. /* A trivial routine that always fails to find fileline data. */
  32. static int
  33. unknown_fileline (struct backtrace_state *state ATTRIBUTE_UNUSED,
  34. uintptr_t pc, backtrace_full_callback callback,
  35. backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
  36. void *data)
  37. {
  38. return callback (data, pc, NULL, 0, NULL);
  39. }
  40. /* Initialize the backtrace data when we don't know how to read the
  41. debug info. */
  42. int
  43. backtrace_initialize (struct backtrace_state *state ATTRIBUTE_UNUSED,
  44. const char *filename ATTRIBUTE_UNUSED,
  45. int descriptor ATTRIBUTE_UNUSED,
  46. backtrace_error_callback error_callback ATTRIBUTE_UNUSED,
  47. void *data ATTRIBUTE_UNUSED, fileline *fileline_fn)
  48. {
  49. state->fileline_data = NULL;
  50. *fileline_fn = unknown_fileline;
  51. return 1;
  52. }