1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
|
-----------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2000-2010, AdaCore --
-- --
-- GVD is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this library; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with GNAT.Strings; use GNAT.Strings;
with Glib; use Glib;
with Glib.Object; use Glib.Object;
with Gdk.Bitmap; use Gdk.Bitmap;
with Gdk.Color; use Gdk.Color;
with Gdk.Event; use Gdk.Event;
with Gdk.Pixmap; use Gdk.Pixmap;
with Gdk.Types;
with Gdk.Types.Keysyms; use Gdk.Types.Keysyms;
with Gdk.Window; use Gdk.Window;
with Gtk; use Gtk;
with Gtk.Arguments; use Gtk.Arguments;
with Gtk.Box; use Gtk.Box;
with Gtk.Button; use Gtk.Button;
with Gtk.Check_Button; use Gtk.Check_Button;
with Gtk.Combo; use Gtk.Combo;
with Gtk.Dialog; use Gtk.Dialog;
with Gtk.Enums; use Gtk.Enums;
with Gtk.GEntry; use Gtk.GEntry;
with Gtk.List; use Gtk.List;
with Gtk.Main; use Gtk.Main;
with Gtk.Notebook; use Gtk.Notebook;
with Gtk.Radio_Button; use Gtk.Radio_Button;
with Gtk.Spin_Button; use Gtk.Spin_Button;
with Gtk.Style; use Gtk.Style;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Window; use Gtk.Window;
with Gtk.Text_View; use Gtk.Text_View;
with Gtk.Text_Buffer; use Gtk.Text_Buffer;
with Gtk.Text_Iter; use Gtk.Text_Iter;
with Gtk.Tree_View; use Gtk.Tree_View;
with Gtk.Tree_Model; use Gtk.Tree_Model;
with Gtk.Tree_Store; use Gtk.Tree_Store;
with Gtk.Tree_Selection; use Gtk.Tree_Selection;
with Gtk.Tree_View_Column; use Gtk.Tree_View_Column;
with Advanced_Breakpoint_Pkg; use Advanced_Breakpoint_Pkg;
with Breakpoints_Pkg; use Breakpoints_Pkg;
with Gtkada.Handlers; use Gtkada.Handlers;
with Gtkada.MDI; use Gtkada.MDI;
with GPS.Intl; use GPS.Intl;
with GPS.Kernel.Hooks; use GPS.Kernel.Hooks;
with GPS.Kernel.MDI; use GPS.Kernel, GPS.Kernel.MDI;
with GPS.Kernel.Modules.UI; use GPS.Kernel.Modules.UI;
with Pixmaps_IDE; use Pixmaps_IDE;
with GVD_Module; use GVD_Module;
with GVD.Code_Editors; use GVD, GVD.Code_Editors;
with GVD.Process; use GVD.Process;
with GVD.Scripts; use GVD.Scripts;
with GVD.Types; use GVD.Types;
with GVD.Views; use GVD.Views;
with GUI_Utils; use GUI_Utils;
with Debugger; use Debugger;
with GNATCOLL.VFS; use GNATCOLL.VFS;
with Process_Proxies; use Process_Proxies;
with Traces; use Traces;
with Ada.Characters.Handling; use Ada.Characters.Handling;
package body Breakpoints_Editor is
type Breakpoint_Editor_Record is new Boxed_Views.Process_View_Record with
record
Editor : Breakpoints_Access;
Advanced_Breakpoints : Advanced_Breakpoint_Access;
Enabled_Pixmap : Gdk.Pixmap.Gdk_Pixmap;
Enabled_Mask : Gdk.Bitmap.Gdk_Bitmap;
end record;
type Breakpoint_Editor is access all Breakpoint_Editor_Record'Class;
overriding procedure Update (View : access Breakpoint_Editor_Record);
overriding procedure On_Process_Terminated
(View : access Breakpoint_Editor_Record);
-- See inherited documentation
function Initialize
(Widget : access Breakpoint_Editor_Record'Class;
Kernel : access Kernel_Handle_Record'Class) return Gtk_Widget;
-- Internal initialization function
-- Returns the focus child
function Get_View
(Process : access Visual_Debugger_Record'Class)
return Gtk_Box;
procedure Set_View
(Process : access Visual_Debugger_Record'Class;
View : Gtk_Box);
-- Store or retrieve the view from the process
package Simple_Views is new Boxed_Views.Simple_Views
(Module_Name => "Breakpoints",
View_Name => -"Breakpoints",
Formal_View_Record => Breakpoint_Editor_Record,
Get_View => Get_View,
Set_View => Set_View,
Group => Group_Debugger_Stack,
Position => Position_Right,
Initialize => Initialize);
procedure On_Edit_Breakpoints
(Widget : access GObject_Record'Class; Kernel : Kernel_Handle);
-- Debug->Data->Breakpoints
procedure On_Breakpoints_Changed
(Kernel : access GPS.Kernel.Kernel_Handle_Record'Class;
Data : access GPS.Kernel.Hooks.Hooks_Data'Class);
-- Hook for "debugger_breakpoints_changed"
procedure Update_Breakpoint_List
(View : access Breakpoint_Editor_Record'Class);
-- Update the list of breakpoints in the dialog.
-- The list is taken from the one stored in the current debugger session.
function Get_Selection_Index
(View : access Breakpoint_Editor_Record'Class) return Integer;
-- Return the index of the currently selected line in the breakpoint
-- editor. The index is the element in Editor.Process.Breakpoints, or
-- -1 if there is no selection
procedure Breakpoint_Row_Selection_Change
(Widget : access Gtk_Widget_Record'Class;
Args : Gtk.Arguments.Gtk_Args);
-- Called when a row of the breakpoint editor was selected.
function Breakpoint_Clicked
(Widget : access Gtk_Widget_Record'Class;
Event : Gdk_Event) return Boolean;
-- Called when receiving a click on the breakpoint tree.
procedure On_Advanced_Location_Clicked
(Object : access Gtk_Widget_Record'Class);
-- Run the advanced breakpoints dialog
procedure On_Add_Location_Clicked (Object : access Gtk_Widget_Record'Class);
-- Set the breakpoint that is currently described in the location page.
-- If Current is not -1, then the breakpoint currently displayed at line
-- Current is updated (first removed if some of the information has
-- changed).
procedure On_Load_Exception_List_Clicked
(Object : access Gtk_Widget_Record'Class);
procedure On_Remove_Clicked
(Object : access Gtk_Widget_Record'Class);
procedure On_View_Clicked
(Object : access Gtk_Widget_Record'Class);
function On_Breakpoints_Key_Press_Event
(Object : access Gtk_Widget_Record'Class;
Params : Gtk.Arguments.Gtk_Args) return Boolean;
-- Callbacks for the various buttons
procedure On_Add_Exception_Clicked
(Object : access Gtk_Widget_Record'Class);
-- Set the breakpoint that is currently described in the exception page.
procedure On_Add_Watchpoint_Clicked
(Object : access Gtk_Widget_Record'Class);
-- Set the watchpoint that is currently described in the variables page.
procedure Fill_Advanced_Dialog
(Advanced : Advanced_Breakpoint_Access; Br : Breakpoint_Data);
-- Fills the contents of the Advanced dialog with the values contained in
-- Br.
procedure Set_Advanced
(View : access Breakpoint_Editor_Record'Class;
Br : Breakpoint_Data);
-- Set the advanced options for the breakpoint Br, based on the contents
-- of its advanced breakpoint editor.
--------------
-- Get_View --
--------------
function Get_View
(Process : access Visual_Debugger_Record'Class)
return Gtk_Box is
begin
return Gtk_Box (Process.Breakpoints_Editor);
end Get_View;
--------------
-- Set_View --
--------------
procedure Set_View
(Process : access Visual_Debugger_Record'Class;
View : Gtk_Box)
is
Old : constant Breakpoint_Editor :=
Breakpoint_Editor (Process.Breakpoints_Editor);
begin
Process.Breakpoints_Editor := Gtk_Widget (View);
-- If we are detaching, clear the old view. This can only be done after
-- the above, since otherwise the action on the GUI will result into
-- actions on the debugger.
if View = null and then Old /= null then
On_Process_Terminated (Old);
end if;
end Set_View;
-------------------------
-- On_Edit_Breakpoints --
-------------------------
procedure On_Edit_Breakpoints
(Widget : access GObject_Record'Class; Kernel : Kernel_Handle)
is
pragma Unreferenced (Widget);
Process : Visual_Debugger;
List : Debugger_List_Link := Get_Debugger_List (Kernel);
begin
while List /= null loop
Process := Visual_Debugger (List.Debugger);
if Process.Debugger /= null then
Attach_To_Breakpoints (Process, Create_If_Necessary => True);
end if;
List := List.Next;
end loop;
exception
when E : others =>
Trace (Exception_Handle, E);
end On_Edit_Breakpoints;
----------------------------
-- Update_Breakpoint_List --
----------------------------
procedure Update_Breakpoint_List
(View : access Breakpoint_Editor_Record'Class)
is
Process : constant Visual_Debugger := Get_Process (View);
Selection : constant Integer := Get_Selection_Index (View);
Selected : Breakpoint_Identifier := 0;
Br : Breakpoint_Data;
Size : Gint;
pragma Unreferenced (Size);
Model : constant Gtk_Tree_Store := Gtk_Tree_Store
(Get_Model (View.Editor.Breakpoint_List));
Iter : Gtk_Tree_Iter;
Selected_Iter : Gtk_Tree_Iter := Null_Iter;
begin
Clear (Model);
if Selection /= -1 then
Selected := Process.Breakpoints (Selection).Num;
end if;
if Process.Breakpoints = null
or else Process.Breakpoints'Length <= 0
then
return;
end if;
for B in Process.Breakpoints'Range loop
Br := Process.Breakpoints (B);
-- Create a new line
Append (Model, Iter, Null_Iter);
Set (Model, Iter, Col_Num, Breakpoint_Identifier'Image (Br.Num));
if Selection /= -1 and then Br.Num = Selected then
Selected_Iter := Iter;
end if;
Set (Model, Iter, Col_Enb, Br.Enabled);
case Br.The_Type is
when Breakpoint =>
Set (Model, Iter, Col_Type, -"break");
when Watchpoint =>
Set (Model, Iter, Col_Type, -"watch");
end case;
Set (Model, Iter, Col_Disp, To_Lower (Br.Disposition'Img));
if Br.Expression /= null then
Set (Model, Iter, Col_File, Br.Expression.all);
end if;
if Br.File /= GNATCOLL.VFS.No_File then
Set (Model, Iter, Col_File, +Base_Name (Br.File));
Set (Model, Iter, Col_Line, Integer'Image (Br.Line));
end if;
if Br.Except /= null then
Set (Model, Iter, Col_Exception, Br.Except.all);
end if;
if Br.Subprogram /= null then
Set (Model, Iter, Col_Subprogs, Br.Subprogram.all);
end if;
end loop;
-- Reselect the same item as before
if Selected_Iter /= Null_Iter then
Select_Iter
(Get_Selection (View.Editor.Breakpoint_List), Selected_Iter);
end if;
end Update_Breakpoint_List;
------------
-- Update --
------------
overriding procedure Update (View : access Breakpoint_Editor_Record) is
Process : Process_Proxy_Access;
begin
if Get_Process (View) /= null then
Process := Get_Process (Get_Process (View).Debugger);
end if;
-- If the debugger was killed, no need to refresh
if Process = null then
return;
end if;
Update_Breakpoint_List (View);
-- Reinitialize the contents of the file combo boxes
Set_Text
(Gtk_Entry (Get_Entry (View.Editor.File_Combo)),
+Base_Name (Get_Current_File (Get_Process (View).Editor_Text)));
-- ??? What if the filesystem path is non-UTF8?
-- Clear the contents of the exceptions combo (its contents is in fact
-- cached in gdb, so it is fast enough to call "info exceptions" again)
Clear_Items (Gtk_List (Get_List (View.Editor.Exception_Name)), 0, -1);
Add_Unique_Combo_Entry
(View.Editor.Exception_Name, -"All exceptions");
Add_Unique_Combo_Entry
(View.Editor.Exception_Name, -"All assertions");
-- Reset the Exception page
Set_Sensitive (View.Editor.Hbox4, True);
end Update;
----------------------------
-- On_Breakpoints_Changed --
----------------------------
procedure On_Breakpoints_Changed
(Kernel : access GPS.Kernel.Kernel_Handle_Record'Class;
Data : access GPS.Kernel.Hooks.Hooks_Data'Class)
is
pragma Unreferenced (Kernel);
Process : constant Visual_Debugger :=
Get_Process (Debugger_Hooks_Data_Access (Data));
View : constant Breakpoint_Editor :=
Breakpoint_Editor (Process.Breakpoints_Editor);
begin
if View /= null then
Update_Breakpoint_List (View);
end if;
end On_Breakpoints_Changed;
---------------------------
-- On_Process_Terminated --
---------------------------
overriding procedure On_Process_Terminated
(View : access Breakpoint_Editor_Record)
is
Model : constant Gtk_Tree_Store := Gtk_Tree_Store
(Get_Model (View.Editor.Breakpoint_List));
begin
Clear (Model);
end On_Process_Terminated;
----------------
-- Initialize --
----------------
function Initialize
(Widget : access Breakpoint_Editor_Record'Class;
Kernel : access Kernel_Handle_Record'Class) return Gtk_Widget
is
Style : Gtk_Style;
begin
Gtk.Box.Initialize_Hbox (Widget);
Gtk_New (Widget.Editor);
Pack_Start (Widget, Widget.Editor, False, Padding => 4);
Set_Sensitive (Widget.Editor.Advanced_Location, False);
Set_Sensitive (Widget.Editor.Remove, False);
Set_Sensitive (Widget.Editor.View, False);
Create_From_Xpm_D
(Widget.Enabled_Pixmap,
Get_Window (Get_Main_Window (Kernel)),
Widget.Enabled_Mask,
White (Get_Default_Colormap),
break_xpm);
-- Grey background when the combo boxes are insensitive
Gtk_New (Style);
Set_Base
(Style, State_Insensitive,
Gdk_Color'
(Get_Background (Get_Style (Widget), State_Normal)));
Set_Style (Gtk_Entry (Get_Entry (Widget.Editor.File_Combo)), Style);
Set_Style (Gtk_Entry (Get_Entry (Widget.Editor.Address_Combo)), Style);
Set_Style (Gtk_Entry (Get_Entry (Widget.Editor.Subprogram_Combo)), Style);
Set_Style (Gtk_Entry (Get_Entry (Widget.Editor.Regexp_Combo)), Style);
-- Return in the combo boxes should activate them
Disable_Activate (Widget.Editor.File_Combo);
Widget_Callback.Object_Connect
(Get_Entry (Widget.Editor.File_Combo), Gtk.GEntry.Signal_Activate,
Widget_Callback.To_Marshaller (On_Add_Location_Clicked'Access),
Widget);
Disable_Activate (Widget.Editor.Address_Combo);
Widget_Callback.Object_Connect
(Get_Entry (Widget.Editor.Address_Combo), Gtk.GEntry.Signal_Activate,
Widget_Callback.To_Marshaller (On_Add_Location_Clicked'Access),
Widget);
Disable_Activate (Widget.Editor.Subprogram_Combo);
Widget_Callback.Object_Connect
(Get_Entry (Widget.Editor.Subprogram_Combo),
Gtk.GEntry.Signal_Activate,
Widget_Callback.To_Marshaller (On_Add_Location_Clicked'Access),
Widget);
Disable_Activate (Widget.Editor.Regexp_Combo);
Widget_Callback.Object_Connect
(Get_Entry (Widget.Editor.Regexp_Combo), Gtk.GEntry.Signal_Activate,
Widget_Callback.To_Marshaller (On_Add_Location_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Get_Selection (Widget.Editor.Breakpoint_List),
Gtk.Tree_Selection.Signal_Changed,
Breakpoint_Row_Selection_Change'Access,
Slot_Object => Widget,
After => True);
Return_Callback.Object_Connect
(Widget.Editor, Signal_Key_Press_Event,
On_Breakpoints_Key_Press_Event'Access, Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Add_Location, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Add_Location_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Add_Watchpoint, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Add_Watchpoint_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Add_Exception, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Add_Exception_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Advanced_Location, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Advanced_Location_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Load_Exception_List, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Load_Exception_List_Clicked'Access),
Widget);
Widget_Callback.Object_Connect
(Widget.Editor.Remove, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_Remove_Clicked'Access), Widget);
Widget_Callback.Object_Connect
(Widget.Editor.View, Gtk.Button.Signal_Clicked,
Widget_Callback.To_Marshaller (On_View_Clicked'Access), Widget);
Gtkada.Handlers.Return_Callback.Object_Connect
(Widget.Editor.Breakpoint_List,
Signal_Button_Press_Event,
Gtkada.Handlers.Return_Callback.To_Marshaller
(Breakpoint_Clicked'Access),
Slot_Object => Widget,
After => False);
Add_Hook
(Kernel, Debugger_Breakpoints_Changed_Hook,
Wrapper (On_Breakpoints_Changed'Access),
Watch => GObject (Widget),
Name => "breakpoints_editor.on_breakpoints_changed");
Set_Page (Widget.Editor.Notebook1, 0);
Show_All (Widget);
return Gtk_Widget (Widget);
end Initialize;
---------------------------
-- Attach_To_Breakpoints --
---------------------------
procedure Attach_To_Breakpoints
(Debugger : access GVD.Process.Visual_Debugger_Record'Class;
Create_If_Necessary : Boolean)
renames Simple_Views.Attach_To_View;
---------------------
-- Register_Module --
---------------------
procedure Register_Module
(Kernel : access GPS.Kernel.Kernel_Handle_Record'Class)
is
Debug : constant String := '/' & (-"_Debug") & '/';
Data_Sub : constant String := Debug & (-"D_ata") & '/';
begin
Simple_Views.Register_Desktop_Functions (Kernel);
Register_Menu (Kernel, Data_Sub, -"Edit _Breakpoints", "",
On_Edit_Breakpoints'Access);
end Register_Module;
-------------------------------------
-- Breakpoint_Row_Selection_Change --
-------------------------------------
procedure Breakpoint_Row_Selection_Change
(Widget : access Gtk_Widget_Record'Class;
Args : Gtk_Args)
is
pragma Unreferenced (Args);
View : constant Breakpoint_Editor := Breakpoint_Editor (Widget);
Process : constant Visual_Debugger := Get_Process (View);
Model : Gtk_Tree_Model;
Iter : Gtk_Tree_Iter;
Br : Breakpoint_Data;
Br_Num : Breakpoint_Identifier;
begin
Get_Selected (Get_Selection (View.Editor.Breakpoint_List), Model, Iter);
if Iter = Null_Iter then
Set_Sensitive (View.Editor.Advanced_Location, False);
Set_Sensitive (View.Editor.Remove, False);
Set_Sensitive (View.Editor.View, False);
return;
end if;
Br_Num := Breakpoint_Identifier'Value
(Get_String (Model, Iter, Col_Num));
for B in Process.Breakpoints'Range loop
if Process.Breakpoints (B).Num = Br_Num then
Br := Process.Breakpoints (B);
exit;
end if;
end loop;
-- Fill the information
if Br.Except /= null then
Set_Page (View.Editor.Notebook1, 2);
Set_Active (View.Editor.Stop_Always_Exception, True);
if Br.Except.all = "all" then
Set_Text
(Gtk_Entry (Get_Entry (View.Editor.Exception_Name)), -"All exceptions");
elsif Br.Except.all = "unhandled" then
Set_Text
(Gtk_Entry (Get_Entry (View.Editor.Exception_Name)), -"All exceptions");
Set_Active (View.Editor.Stop_Not_Handled_Exception, True);
else
Add_Unique_Combo_Entry (View.Editor.Exception_Name, Br.Except.all);
Set_Text (Gtk_Entry (Get_Entry (View.Editor.Exception_Name)), Br.Except.all);
end if;
Set_Active (View.Editor.Temporary_Exception, Br.Disposition /= Keep);
else
Set_Page (View.Editor.Notebook1, 0);
if Br.File /= GNATCOLL.VFS.No_File then
Set_Active (View.Editor.Location_Selected, True);
Add_Unique_Combo_Entry
(View.Editor.File_Combo, +Base_Name (Br.File));
-- ??? What if the filesystem path is non-UTF8?
Set_Text
(Gtk_Entry (Get_Entry (View.Editor.File_Combo)), +Base_Name (Br.File));
-- ??? What if the filesystem path is non-UTF8?
Set_Value (View.Editor.Line_Spin, Grange_Float (Br.Line));
else
Set_Active (View.Editor.Address_Selected, True);
Add_Unique_Combo_Entry
(View.Editor.Address_Combo, Address_To_String (Br.Address));
Set_Text
(Gtk_Entry (Get_Entry (View.Editor.Address_Combo)),
Address_To_String (Br.Address));
end if;
end if;
Set_Sensitive (View.Editor.Advanced_Location, True);
Set_Sensitive (View.Editor.Remove, True);
Set_Sensitive (View.Editor.View, True);
exception
when E : others =>
Trace (Exception_Handle, E);
end Breakpoint_Row_Selection_Change;
------------------------
-- Breakpoint_Clicked --
------------------------
function Breakpoint_Clicked
(Widget : access Gtk_Widget_Record'Class;
Event : Gdk_Event) return Boolean
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Widget);
Iter : Gtk_Tree_Iter;
Col : Gtk_Tree_View_Column;
Model : constant Gtk_Tree_Store := Gtk_Tree_Store
(Get_Model (View.Editor.Breakpoint_List));
begin
if Get_Button (Event) = 1
and then Get_Event_Type (Event) = Button_Press
then
Coordinates_For_Event
(View.Editor.Breakpoint_List,
Get_Model (View.Editor.Breakpoint_List),
Event, Iter, Col);
if Col = Get_Column (View.Editor.Breakpoint_List, Col_Enb) then
-- Click in the second column => change the enable/disable state
-- For efficiency, no need to reparse the list of breakpoints,
-- since only the state of one of them as changed and we know all
-- about it.
Set (Model, Iter, Col_Enb,
Toggle_Breakpoint_State
(Get_Process (View),
Breakpoint_Num => Breakpoint_Identifier'Value
(Get_String (Model, Iter, Col_Num))));
-- Stop propagation of the current signal, to avoid extra calls
-- to Select/Unselect row.
return True;
end if;
elsif Get_Button (Event) = 1
and then Get_Event_Type (Event) = Gdk_2button_Press
then
On_View_Clicked (View.Editor);
end if;
return False;
exception
when E : others => Trace (Exception_Handle, E);
return False;
end Breakpoint_Clicked;
-------------------------
-- Get_Selection_Index --
-------------------------
function Get_Selection_Index
(View : access Breakpoint_Editor_Record'Class) return Integer
is
use Gint_List;
Process : constant Visual_Debugger := Get_Process (View);
Br_Num : Breakpoint_Identifier;
Iter : Gtk_Tree_Iter;
The_Model : Gtk_Tree_Model;
begin
Get_Selected
(Get_Selection (View.Editor.Breakpoint_List), The_Model, Iter);
if Iter /= Null_Iter then
Br_Num := Breakpoint_Identifier'Value
(Get_String (The_Model, Iter, Col_Num));
for B in Process.Breakpoints'Range loop
if Process.Breakpoints (B).Num = Br_Num then
return B;
end if;
end loop;
end if;
return -1;
end Get_Selection_Index;
--------------------------
-- Fill_Advanced_Dialog --
--------------------------
procedure Fill_Advanced_Dialog
(Advanced : Advanced_Breakpoint_Access; Br : Breakpoint_Data)
is
Start, The_End : Gtk_Text_Iter;
Buffer : Gtk_Text_Buffer;
begin
if Advanced = null then
return;
end if;
if Br.Condition /= null then
Add_Unique_Combo_Entry
(Advanced.Condition_Combo, Br.Condition.all);
Set_Text (Gtk_Entry (Get_Entry (Advanced.Condition_Combo)), Br.Condition.all);
else
Set_Text (Gtk_Entry (Get_Entry (Advanced.Condition_Combo)), "");
end if;
Set_Value (Advanced.Ignore_Count_Combo, Grange_Float (Br.Ignore));
Buffer := Get_Buffer (Advanced.Command_Descr);
Get_Bounds (Buffer, Start, The_End);
Delete (Buffer, Start, The_End);
if Br.Commands /= null then
Insert_At_Cursor (Buffer, Br.Commands.all);
end if;
-- Set the scope and action, if appropriate
if Br.Scope /= No_Scope then
if Br.Scope = Current_Task then
Set_Active (Advanced.Scope_Task, True);
elsif Br.Scope = Tasks_In_PD then
Set_Active (Advanced.Scope_Pd, True);
elsif Br.Scope = Any_Task then
Set_Active (Advanced.Scope_Any, True);
end if;
end if;
if Br.Action /= No_Action then
if Br.Action = Current_Task then
Set_Active (Advanced.Action_Task, True);
elsif Br.Action = Tasks_In_PD then
Set_Active (Advanced.Action_Pd, True);
elsif Br.Action = All_Tasks then
Set_Active (Advanced.Action_All, True);
end if;
end if;
Set_Active (Advanced.Set_Default, False);
end Fill_Advanced_Dialog;
------------------
-- Set_Advanced --
------------------
procedure Set_Advanced
(View : access Breakpoint_Editor_Record'Class;
Br : Breakpoint_Data)
is
Adv : constant Advanced_Breakpoint_Access := View.Advanced_Breakpoints;
Process : constant Visual_Debugger := Get_Process (View);
Modified : Boolean := False;
Start, The_End : Gtk_Text_Iter;
begin
if Visible_Is_Set (Adv.Condition_Box) then
Get_Bounds (Get_Buffer (Adv.Command_Descr), Start, The_End);
declare
S : constant String :=
Get_Text (Gtk_Entry (Get_Entry (Adv.Condition_Combo)));
C : constant Integer :=
Integer (Get_Value_As_Int (Adv.Ignore_Count_Combo));
T : constant String := Get_Text
(Get_Buffer (Adv.Command_Descr), Start, The_End);
begin
-- Send all these commands in "internal" mode, so that no
-- "info breakpoint" is emitted each time. However, we must
-- make sure to send at least one.
if S /= ""
or else (Br.Condition /= null and then Br.Condition.all /= "")
then
Set_Breakpoint_Condition
(Process.Debugger, Br.Num, S, Internal);
Modified := True;
end if;
if C /= 0
or else Br.Ignore /= 0
then
Set_Breakpoint_Ignore_Count
(Process.Debugger, Br.Num, C, Internal);
Modified := True;
end if;
if T /= ""
or else (Br.Commands /= null and then Br.Commands.all /= "")
then
Set_Breakpoint_Command
(Process.Debugger, Br.Num, T, Internal);
Modified := True;
end if;
if Modified then
Update_Breakpoints (Process, Force => True);
end if;
end;
end if;
end Set_Advanced;
------------------------------
-- On_Add_Exception_Clicked --
------------------------------
procedure On_Add_Exception_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Current : constant Integer := -1;
Temporary : Boolean;
Process : constant Visual_Debugger := Get_Process (View);
Name : constant String :=
Get_Text (Gtk_Entry (Get_Entry (View.Editor.Exception_Name)));
Unhandled : constant Boolean :=
Get_Active (View.Editor.Stop_Not_Handled_Exception);
Br : Breakpoint_Data;
Remove : Boolean := False;
begin
if Current /= -1 then
Br := Process.Breakpoints (Current);
end if;
Temporary := Get_Active (View.Editor.Temporary_Exception);
-- Some of the strings below deal with the GUI, and thus should be
-- translated for internationalization. Others come from gdb, and
-- should not be translated.
-- This explains why some are preceded by '-'.
if Name = -"All exceptions" then
if Current = -1
or else Br.Except = null
or else (Unhandled and then Br.Except.all /= "unhandled exception")
or else (not Unhandled and then Br.Except.all /= "all exceptions")
then
Remove := True;
Break_Exception
(Process.Debugger,
Name => "",
Unhandled => Unhandled,
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
elsif Name = -"All assertions" then
if Current = -1
or else Br.Except = null
or else Br.Except.all /= "assert failure"
then
Remove := True;
Break_Subprogram
(Process.Debugger,
Name => "assert",
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
elsif Current = -1
or else Br.Except = null
or else (not Unhandled and then Br.Except.all /= Name)
or else (Unhandled and then Br.Except.all /= "unhandled exception")
then
Remove := True;
Break_Exception
(Process.Debugger,
Name => Name,
Unhandled => Unhandled,
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
if Remove and then Current /= -1 then
Remove_Breakpoint
(Process.Debugger,
Process.Breakpoints (Current).Num);
end if;
end On_Add_Exception_Clicked;
-----------------------------
-- On_Add_Location_Clicked --
-----------------------------
procedure On_Add_Location_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Current : constant Integer := -1;
Process : constant Visual_Debugger := Get_Process (View);
Temporary : Boolean;
Br : Breakpoint_Data;
Remove : Boolean := False;
begin
if Current /= -1 then
Br := Process.Breakpoints (Current);
end if;
Temporary := Get_Active (View.Editor.Temporary_Location);
if Get_Active (View.Editor.Location_Selected) then
declare
File : constant Filesystem_String :=
+Get_Text (Gtk_Entry (Get_Entry (View.Editor.File_Combo)));
-- ??? What if the filesystem path is non-UTF8?
Line : constant Integer :=
Integer (Get_Value_As_Int (View.Editor.Line_Spin));
begin
-- ??? Should also check Temporary
if Current = -1
or else not Equal (Base_Name (Br.File), File)
or else Br.Line /= Line
then
Remove := True;
Break_Source
(Process.Debugger,
File => Create_From_Base (File),
Line => Line,
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
end;
elsif Get_Active (View.Editor.Subprogram_Selected) then
declare
Name : constant String :=
Get_Text (Gtk_Entry (Get_Entry (View.Editor.Subprogram_Combo)));
begin
-- ??? Should also check Temporary
if Current = -1
or else Br.Except = null
or else Br.Except.all = Name
then
Remove := True;
Break_Subprogram
(Process.Debugger,
Name => Name,
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
end;
elsif Get_Active (View.Editor.Address_Selected) then
declare
Address : constant Address_Type :=
String_To_Address
(Get_Text (Gtk_Entry (Get_Entry (View.Editor.Address_Combo))));
begin
if Current = -1
or else Br.Address = Invalid_Address
or else Br.Address = Address
then
Remove := True;
Break_Address
(Process.Debugger,
Address => Address,
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
end;
else
Remove := True;
Break_Regexp
(Process.Debugger,
Regexp => Get_Text (Gtk_Entry (Get_Entry (View.Editor.Regexp_Combo))),
Temporary => Temporary,
Mode => GVD.Types.Visible);
end if;
if Remove and then Current /= -1 then
Remove_Breakpoint (Process.Debugger, Br.Num);
end if;
end On_Add_Location_Clicked;
----------------------------------
-- On_Advanced_Location_Clicked --
----------------------------------
procedure On_Advanced_Location_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Current : constant Integer := Get_Selection_Index (View);
Process : constant Visual_Debugger := Get_Process (View);
Adv : Advanced_Breakpoint_Access := View.Advanced_Breakpoints;
begin
if Current = -1 then
return;
end if;
-- Create all three dialogs
if Adv = null then
Gtk_New (View.Advanced_Breakpoints);
Adv := View.Advanced_Breakpoints;
Set_Sensitive (Adv.Record_Button, False);
Set_Sensitive (Adv.End_Button, False);
end if;
Fill_Advanced_Dialog (Adv, Process.Breakpoints (Current));
Show_All (Adv);
if VxWorks_Version (Process.Debugger) = Vx653 then
Set_Show_Tabs (Adv.Main_Notebook);
else
Hide (Adv.Scope_Box);
Set_Show_Tabs (Adv.Main_Notebook, False);
end if;
Adv.Response_Action := Gtk_Response_None;
Gtk.Main.Main;
if Adv.Response_Action = Gtk_Response_Apply then
-- If we are using AE and the user has activated the "Set as
-- default" checkbox for the scope and action values, send the
-- appropriate commands to the debugger
if VxWorks_Version (Process.Debugger) = Vx653 then
declare
Scope_Value : Scope_Type;
Action_Value : Action_Type;
begin
if Get_Active (Adv.Scope_Task) then
Scope_Value := Current_Task;
elsif Get_Active (Adv.Scope_Pd) then
Scope_Value := Tasks_In_PD;
elsif Get_Active (Adv.Scope_Any) then
Scope_Value := Any_Task;
end if;
if Get_Active (Adv.Action_Task) then
Action_Value := Current_Task;
elsif Get_Active (Adv.Action_Pd) then
Action_Value := Tasks_In_PD;
elsif Get_Active (Adv.Action_All) then
Action_Value := All_Tasks;
end if;
if Get_Active (Adv.Set_Default) then
Set_Scope_Action
(Process.Debugger, Scope_Value, Action_Value);
end if;
Set_Scope_Action
(Process.Debugger, Scope_Value,
Action_Value, Process.Breakpoints (Current).Num);
end;
end if;
Set_Advanced (View, Process.Breakpoints (Current));
end if;
end On_Advanced_Location_Clicked;
-------------------------------
-- On_Add_Watchpoint_Clicked --
-------------------------------
procedure On_Add_Watchpoint_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Current : constant Integer := -1;
Process : constant Visual_Debugger := Get_Process (View);
Watchpoint_Name : constant String :=
Get_Text (View.Editor.Watchpoint_Name);
Watchpoint_Type : constant String :=
Get_Text (Gtk_Entry (Get_Entry (View.Editor.Watchpoint_Type)));
Watchpoint_Cond : constant String :=
Get_Text (View.Editor.Watchpoint_Cond);
Trigger : GVD.Types.Watchpoint_Trigger;
-- Encodes the value we get from Watchpoint_Type for the call to Watch
Br : Breakpoint_Data;
-- Used to manipulate breakpoint list if Current is set
Remove : Boolean := False;
-- If set, will remove the currently selected breakpoint from the
-- breakpoint list.
begin
if Current /= -1 then
Br := Process.Breakpoints (Current);
end if;
if Watchpoint_Type = -"read" then
Trigger := GVD.Types.Read;
elsif Watchpoint_Type = -"read or written" then
Trigger := GVD.Types.Read_Write;
else
-- presumably, Watchpoint_Type = -"written"
Trigger := GVD.Types.Write;
end if;
if Current = -1
or else Br.Expression.all /= Watchpoint_Name
or else Br.Trigger /= Trigger
or else Br.Condition.all /= Watchpoint_Cond
then
Remove := True;
Watch
(Process.Debugger,
Name => Watchpoint_Name,
Trigger => Trigger,
Condition => Watchpoint_Cond,
Mode => GVD.Types.Visible);
end if;
if Remove and Current /= -1 then
Remove_Breakpoint (Process.Debugger, Br.Num);
end if;
end On_Add_Watchpoint_Clicked;
------------------------------------
-- On_Load_Exception_List_Clicked --
------------------------------------
procedure On_Load_Exception_List_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Process : constant Visual_Debugger := Get_Process (View);
begin
Set_Busy (Process, True);
declare
Exception_Arr : Exception_Array := List_Exceptions (Process.Debugger);
begin
if Exception_Arr'Length > 0 then
Set_Sensitive (View.Editor.Hbox4, True);
Add_Unique_Combo_Entry
(View.Editor.Exception_Name, -"All exceptions");
Add_Unique_Combo_Entry
(View.Editor.Exception_Name, -"All assertions");
for J in Exception_Arr'Range loop
Add_Unique_Combo_Entry
(View.Editor.Exception_Name, Exception_Arr (J).Name.all);
end loop;
else
Set_Sensitive (View.Editor.Hbox4, False);
end if;
Free (Exception_Arr);
end;
Set_Busy (Process, False);
exception
when E : others =>
Trace (Exception_Handle, E);
end On_Load_Exception_List_Clicked;
-----------------------
-- On_Remove_Clicked --
-----------------------
procedure On_Remove_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Process : constant Visual_Debugger := Get_Process (View);
Model : constant Gtk_Tree_Store := Gtk_Tree_Store
(Get_Model (View.Editor.Breakpoint_List));
Selection : constant Integer := Get_Selection_Index (View);
begin
if Selection /= -1 then
Remove_Breakpoint
(Process.Debugger,
Process.Breakpoints (Selection).Num,
Mode => GVD.Types.Visible);
-- Reselect the next line for convenience, so that the user can
-- press "Remove" several times in a row
if Gint (Selection) >= N_Children (Model, Null_Iter) then
Select_Iter
(Get_Selection (View.Editor.Breakpoint_List),
Nth_Child
(Model,
Parent => Null_Iter,
N => N_Children (Model, Null_Iter) - 1));
else
Select_Iter
(Get_Selection (View.Editor.Breakpoint_List),
Nth_Child
(Model,
Parent => Null_Iter,
N => Gint (Selection)));
end if;
end if;
exception
when E : others =>
Trace (Exception_Handle, E);
end On_Remove_Clicked;
---------------------
-- On_View_Clicked --
---------------------
procedure On_View_Clicked
(Object : access Gtk_Widget_Record'Class)
is
View : constant Breakpoint_Editor := Breakpoint_Editor (Object);
Process : constant Visual_Debugger := Get_Process (View);
Selection : constant Integer := Get_Selection_Index (View);
begin
if Selection /= -1 then
Load_File
(Process.Editor_Text,
Process.Breakpoints (Selection).File);
Set_Line
(Process.Editor_Text,
Process.Breakpoints (Selection).Line,
GObject (Process));
end if;
exception
when E : others =>
Trace (Exception_Handle, E);
end On_View_Clicked;
------------------------------------
-- On_Breakpoints_Key_Press_Event --
------------------------------------
function On_Breakpoints_Key_Press_Event
(Object : access Gtk_Widget_Record'Class;
Params : Gtk.Arguments.Gtk_Args) return Boolean
is
Event : constant Gdk_Event := To_Event (Params, 1);
use type Gdk.Types.Gdk_Key_Type;
begin
if Get_Key_Val (Event) = GDK_Delete then
On_Remove_Clicked (Object);
end if;
return False;
exception
when E : others => Trace (Exception_Handle, E);
return False;
end On_Breakpoints_Key_Press_Event;
end Breakpoints_Editor;
|