diff --git a/src/HSADebugAgent/CommandLoop.cpp b/src/HSADebugAgent/CommandLoop.cpp index 1b770fd2..e457ff5e 100644 --- a/src/HSADebugAgent/CommandLoop.cpp +++ b/src/HSADebugAgent/CommandLoop.cpp @@ -303,6 +303,19 @@ static HsailParentStatus CheckParentStatus(const AgentContext* pActiveContext) return parentStatus; } +/* GDB will install a breakpoint on this function that will be used when + * a GPU kernel breakpoint is hit. + * It is defined as extern C to facilitate the name lookup by GDB. This + * could be changed to use exported symbol referring to locations + * as it is done in the in-process agent library. + */ +extern "C" { + void __attribute__((optimize("O0"))) TriggerGPUBreakpointStop(void) + { + return; + } +} + /// The DebugEvent loop is run as a separate thread. /// It is launched from the predispatch callback. /// The predispatch callback will have created a breakpoint, so we can @@ -390,23 +403,13 @@ void* DebugEventThread(void* pArgs) if (isStopNeeded) { - // Hand control to GDB - Send signal to GDB - // Using pthread_kill vs regular kill gives better control over - // the stopping location. - // It is the same old notion of multithreaded signalling where - // using a kill can result in a signal that be delivered - // to any thread in a process - if (pthread_kill(pthread_self(), SIGUSR2) == -1) - { - // Get out of the thread, - // I am not sure on how to handle signaling failure - AGENT_ERROR("Could not signal gdb"); - exitSignal = 1; - } - else - { - AGENT_LOG("DebugEventThread: Raise SIGUSR2 to stop"); - } + // Hand control to GDB + // GDB will have inserted a breakpoint + // in TriggerGPUBreakpointStop during + // initialisation. Calling this function + // will notify GDB that a GPU breakpoint + // has been hit. + TriggerGPUBreakpointStop(); } else { diff --git a/src/HSADebugAgent/HSADebugAgent.cpp b/src/HSADebugAgent/HSADebugAgent.cpp index 6052e81f..ec4b3fbc 100644 --- a/src/HSADebugAgent/HSADebugAgent.cpp +++ b/src/HSADebugAgent/HSADebugAgent.cpp @@ -104,22 +104,6 @@ void tempHandleSIGUSR1(int signal) return; } -void tempHandleSIGUSR2(int signal) -{ - if (signal != SIGUSR2) - { - AGENT_ERROR("A spurious signal detected when we expect SIGUSR2"); - AGENT_ERROR("We don't know what to do"); - } - else - { - AGENT_LOG("tempHandleSIGUSR2: Handling SIGUSR2 by doing nothing"); - } - - return; -} - - // We initialize the AgentContext object by calling this function // on the library load and then pass it to the predispatch callback static void CreateHsaAgentContext() @@ -201,10 +185,6 @@ static void InitHsaAgent() signal(SIGUSR1, tempHandleSIGUSR1); - // Add a do nothing handler on SIGUSR2. - // Needed since HCC or the HSA runtime seem to mess with handlers - signal(SIGUSR2, tempHandleSIGUSR2); - AgentTriggerGDBEventLoop(); status = InitFifoWriteEnd(); diff --git a/src/HSADebugAgent/Include/CommunicationControl.h b/src/HSADebugAgent/Include/CommunicationControl.h index 2f0515dc..f92773e5 100644 --- a/src/HSADebugAgent/Include/CommunicationControl.h +++ b/src/HSADebugAgent/Include/CommunicationControl.h @@ -31,7 +31,7 @@ typedef enum HSAIL_COMMAND_MOMENTARY_BREAKPOINT, // Set an HSAIL momentary breakpoint (which is automatically deleted) HSAIL_COMMAND_CONTINUE, // Continue the inferior process HSAIL_COMMAND_SET_LOGGING, // Configure the logging in the Agent - HSAIL_COMMAND_SET_ISA_DUMP // Configure dumping of ISA + HSAIL_COMMAND_SET_ISA_DUMP // Configure dumping of ISA } HsailCommand; typedef enum