)]}'
{
  "commit": "c85bfef3d95459087c04c5e77e44ab4265a895b7",
  "tree": "a93eb0458cbd4cf9d820b2c9dbd4bf19a93a13d3",
  "parents": [
    "cbd6f6bf80881be4628622e369baafb337589578"
  ],
  "author": {
    "name": "Pedro Alves",
    "email": "palves@redhat.com",
    "time": "Wed Oct 29 18:27:38 2014 +0000"
  },
  "committer": {
    "name": "Pedro Alves",
    "email": "palves@redhat.com",
    "time": "Wed Oct 29 18:27:54 2014 +0000"
  },
  "message": "PR 17408 - assertion failure in switch_back_to_stepped_thread\n\nThis PR shows that GDB can easily trigger an assertion here, in\ninfrun.c:\n\n 5392              /* Did we find the stepping thread?  */\n 5393              if (tp-\u003econtrol.step_range_end)\n 5394                {\n 5395                  /* Yep.  There should only one though.  */\n 5396                  gdb_assert (stepping_thread \u003d\u003d NULL);\n 5397\n 5398                  /* The event thread is handled at the top, before we\n 5399                     enter this loop.  */\n 5400                  gdb_assert (tp !\u003d ecs-\u003eevent_thread);\n 5401\n 5402                  /* If some thread other than the event thread is\n 5403                     stepping, then scheduler locking can\u0027t be in effect,\n 5404                     otherwise we wouldn\u0027t have resumed the current event\n 5405                     thread in the first place.  */\n 5406                  gdb_assert (!schedlock_applies (currently_stepping (tp)));\n 5407\n 5408                  stepping_thread \u003d tp;\n 5409                }\n\nLike:\n\n gdb/infrun.c:5406: internal-error: switch_back_to_stepped_thread: Assertion `!schedlock_applies (1)\u0027 failed.\n\nThe way the assertion is written is assuming that with schedlock\u003dstep\nwe\u0027ll always leave threads other than the one with the stepping range\nlocked, while that\u0027s not true with the \"next\" command.  With schedlock\n\"step\", other threads still run unlocked when \"next\" detects a\nfunction call and steps over it.  Whether that makes sense or not,\nstill, it\u0027s documented that way in the manual.  If another thread hits\nan event that doesn\u0027t cause a stop while the nexting thread steps over\na function call, we\u0027ll get here and fail the assertion.\n\nThe fix is just to adjust the assertion.  Even though we found the\nstepping thread, we\u0027ll still step-over the breakpoint that just\ntriggered correctly.\n\nSurprisingly, gdb.threads/schedlock.exp doesn\u0027t have any test that\nsteps over a function call.  This commits fixes that.  This ensures\nthat \"next\" doesn\u0027t switch focus to another thread, and checks whether\nother threads run locked or not, depending on scheduler locking mode\nand command.  There\u0027s a lot of duplication in that file that this ends\ncleaning up.  There\u0027s more that could be cleaned up, but that would\nend up an unrelated change, best done separately.\n\nThis new coverage in schedlock.exp happens to trigger the internal\nerror in question, like so:\n\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next to increment (1) (GDB internal error)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next to increment (3) (GDB internal error)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next to increment (5) (GDB internal error)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next to increment (7) (GDB internal error)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next to increment (9) (GDB internal error)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: next does not change thread (switched to thread 0)\n FAIL: gdb.threads/schedlock.exp: schedlock\u003dstep: cmd\u003dnext: call_function\u003d1: current thread advanced - unlocked (wrong amount)\n\nThat\u0027s because we have more than one thread running the same loop, and\nwhile one thread is stepping over a function call, the other thread\nhits the step-resume breakpoint of the first, which needs to be\nstepped over, and we end up in switch_back_to_stepped_thread exactly\nin the problem case.\n\nI think a simpler and more directed test is also useful, to not rely\non internal breakpoint magics.  So this commit also adds a test that\nhas a thread trip on a conditional breakpoint that doesn\u0027t cause a\nuser-visible stop while another thread is stepping over a call.  That\ncurrently fails like this:\n\n FAIL: gdb.threads/next-bp-other-thread.exp: schedlock\u003dstep: next over function call (GDB internal error)\n\nTested on x86_64 Fedora 20.\n\ngdb/\n2014-10-29  Pedro Alves  \u003cpalves@redhat.com\u003e\n\n\tPR gdb/17408\n\t* infrun.c (switch_back_to_stepped_thread): Use currently_stepping\n\tinstead of assuming a thread with a stepping range is always\n\tstepping.\n\ngdb/testsuite/\n2014-10-29  Pedro Alves  \u003cpalves@redhat.com\u003e\n\n\tPR gdb/17408\n\t* gdb.threads/schedlock.c (some_function): New function.\n\t(call_function): New global.\n\t(MAYBE_CALL_SOME_FUNCTION): New macro.\n\t(thread_function): Call it.\n\t* gdb.threads/schedlock.exp (get_args): Add description parameter,\n\tand use it instead of a global counter.  Adjust all callers.\n\t(get_current_thread): Use \"find current thread\" for test message\n\there rather than having all callers pass down the same string.\n\t(goto_loop): New procedure, factored out from ...\n\t(my_continue): ... this.\n\t(step_ten_loops): Change parameter from test message to command to\n\tuse.  Adjust.\n\t(list_count): Delete global.\n\t(check_result): New procedure, factored out from duplicate top\n\tlevel code.\n\t(continue tests): Wrap in with_test_prefix.\n\t(test_step): New procedure, factored out from duplicate top level\n\tcode.\n\t(top level): Test \"step\" in combination with all scheduler-locking\n\tmodes.  Test \"next\" in combination with all scheduler-locking\n\tmodes, and in combination with stepping over a function call or\n\tnot.\n\t* gdb.threads/next-bp-other-thread.c: New file.\n\t* gdb.threads/next-bp-other-thread.exp: New file.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "07df05bbe0fd7ff6dc2a8f3ee39d9432ee754f50",
      "old_mode": 33188,
      "old_path": "gdb/ChangeLog",
      "new_id": "b6dc3eaec08c88fb55cd1db25108c23d3925dad4",
      "new_mode": 33188,
      "new_path": "gdb/ChangeLog"
    },
    {
      "type": "modify",
      "old_id": "3c3c1e9898cd80382a30fa546f1af4075d8b81d1",
      "old_mode": 33188,
      "old_path": "gdb/infrun.c",
      "new_id": "2fe7d2977a9cc323131e24470328695115e38ef9",
      "new_mode": 33188,
      "new_path": "gdb/infrun.c"
    },
    {
      "type": "modify",
      "old_id": "1f87e92f85d8fac43e45ddd31c97ce60f08dfd5f",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/ChangeLog",
      "new_id": "ab45b909fd0c0043d97390917c6ab9021ae4da26",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/ChangeLog"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "e931305c20dbc234b11a6c94a19727bd3a039578",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/next-bp-other-thread.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "c2361fab795497e5a6dfbd0d0563d62674615713",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/next-bp-other-thread.exp"
    },
    {
      "type": "modify",
      "old_id": "2d8c7ab6f447f256bd28998b7ac836943633c038",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.threads/schedlock.c",
      "new_id": "11e4bbc488f8467ff917dd74927ab9f21414584c",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/schedlock.c"
    },
    {
      "type": "modify",
      "old_id": "e10568922b995529985490efe95f72de1805146f",
      "old_mode": 33188,
      "old_path": "gdb/testsuite/gdb.threads/schedlock.exp",
      "new_id": "cd9984449a797c47c2831955abfb59a99ebc4c8e",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.threads/schedlock.exp"
    }
  ]
}
