tui-location.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2021-2022 Free Software Foundation, Inc.
  2. This file is part of GDB.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #include "defs.h"
  14. #include "tui/tui.h"
  15. #include "tui/tui-stack.h"
  16. #include "tui/tui-data.h"
  17. #include "tui/tui-location.h"
  18. #include "symtab.h"
  19. #include "source.h"
  20. /* See tui/tui-location.h. */
  21. tui_location_tracker tui_location;
  22. /* See tui/tui-location.h. */
  23. bool
  24. tui_location_tracker::set_location (struct gdbarch *gdbarch,
  25. const struct symtab_and_line &sal,
  26. const char *procname)
  27. {
  28. gdb_assert (procname != nullptr);
  29. bool location_changed_p = set_fullname (sal.symtab);
  30. location_changed_p |= procname != m_proc_name;
  31. location_changed_p |= sal.line != m_line_no;
  32. location_changed_p |= sal.pc != m_addr;
  33. location_changed_p |= gdbarch != m_gdbarch;
  34. m_proc_name = procname;
  35. m_line_no = sal.line;
  36. m_addr = sal.pc;
  37. m_gdbarch = gdbarch;
  38. if (location_changed_p)
  39. tui_show_locator_content ();
  40. return location_changed_p;
  41. }
  42. /* See tui/tui-location.h. */
  43. bool
  44. tui_location_tracker::set_location (struct symtab *symtab)
  45. {
  46. bool location_changed_p = set_fullname (symtab);
  47. if (location_changed_p)
  48. tui_show_locator_content ();
  49. return location_changed_p;
  50. }
  51. /* See tui/tui-location.h. */
  52. bool
  53. tui_location_tracker::set_fullname (struct symtab *symtab)
  54. {
  55. const char *fullname = (symtab == nullptr
  56. ? "??"
  57. : symtab_to_fullname (symtab));
  58. bool location_changed_p = fullname != m_full_name;
  59. m_full_name = std::string (fullname);
  60. return location_changed_p;
  61. }