Jan Kratochvil af2c2a5
Index: gdb-7.12.50.20170207/gdb/valops.c
e5611bf
===================================================================
Jan Kratochvil af2c2a5
--- gdb-7.12.50.20170207.orig/gdb/valops.c	2017-02-26 17:26:43.839146565 +0100
Jan Kratochvil af2c2a5
+++ gdb-7.12.50.20170207/gdb/valops.c	2017-02-26 17:28:40.840988272 +0100
Jan Kratochvil af2c2a5
@@ -1112,6 +1112,8 @@
e5611bf
 	struct gdbarch *gdbarch;
3a094fb
 	int value_reg;
3a094fb
 
Jan Kratochvil af2c2a5
+	value_reg = VALUE_REGNUM (toval);
Jan Kratochvil af2c2a5
+
Jan Kratochvil af2c2a5
 	/* Figure out which frame this is in currently.
Jan Kratochvil af2c2a5
 	
Jan Kratochvil af2c2a5
 	   We use VALUE_FRAME_ID for obtaining the value's frame id instead of
Jan Kratochvil af2c2a5
@@ -1121,8 +1123,14 @@
Jan Kratochvil af2c2a5
 	   frame.  */
Jan Kratochvil af2c2a5
 	frame = frame_find_by_id (VALUE_FRAME_ID (toval));
3a094fb
 
Jan Kratochvil af2c2a5
-	value_reg = VALUE_REGNUM (toval);
Jan Kratochvil af2c2a5
-
3a094fb
+	/* "set $reg+=1" should work on programs with no debug info,
3a094fb
+	   but frame_find_by_id returns NULL here (RH bug 436037).
3a094fb
+	   Use current frame, it represents CPU state in this case.
3a094fb
+	   If frame_find_by_id is changed to do it internally
3a094fb
+	   (it is contemplated there), remove this.  */
3a094fb
+	if (!frame)
3a094fb
+	  frame = get_current_frame ();
3a094fb
+	/* Probably never happens.  */
3a094fb
 	if (!frame)
3a094fb
 	  error (_("Value being assigned to is no longer active."));
e5611bf