Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Using breakpoint instead of SIGUSR2 #1

Merged
merged 5 commits into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gdb-7.8/amd/include/CommunicationControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 65 additions & 0 deletions gdb-7.8/gdb/breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ static struct breakpoint_ops longjmp_breakpoint_ops;
breakpoints. */
struct breakpoint_ops bkpt_breakpoint_ops;

/* The breakpoint_ops structure to be used in HSA library breakpoint */
struct breakpoint_ops gpu_breakpoint_trigger_ops;

/* Breakpoints set on probes. */
static struct breakpoint_ops bkpt_probe_breakpoint_ops;

Expand Down Expand Up @@ -13613,6 +13616,39 @@ bkpt_resources_needed (const struct bp_location *bl)
return 1;
}

static enum print_stop_action
gpu_bkpt_trigger_print_it (bpstat bs)
{
struct breakpoint *b;
const struct bp_location *bl;
int bp_temp;
struct ui_out *uiout = current_uiout;

gdb_assert (bs->bp_location_at != NULL);

bl = bs->bp_location_at;
b = bs->breakpoint_at;

bp_temp = b->disposition == disp_del;
if (bl->address != bl->requested_address)
breakpoint_adjustment_warning (bl->requested_address,
bl->address,
b->number, 1);
annotate_breakpoint (b->number);
if (bp_temp)
ui_out_text (uiout, "\nTemporary breakpoint triggered by GPU Kernel Breakpoint\n");
else
ui_out_text (uiout, "\nStopped on GPU Breakpoint\n");
if (ui_out_is_mi_like_p (uiout))
{
ui_out_field_string (uiout, "reason",
async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
ui_out_field_string (uiout, "disp", bpdisp_text (b->disposition));
}

return PRINT_NOTHING;
}

static enum print_stop_action
bkpt_print_it (bpstat bs)
{
Expand Down Expand Up @@ -16598,6 +16634,11 @@ initialize_breakpoint_ops (void)
ops->print_mention = bkpt_print_mention;
ops->print_recreate = bkpt_print_recreate;

/* The HSA breakpoint structure that will be hit when the GPU hits a breakpoint. */
ops = &gpu_breakpoint_trigger_ops;
*ops = bkpt_breakpoint_ops;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above about the name "gpu_breakpoint_trigger_ops".

ops->print_it = gpu_bkpt_trigger_print_it;

/* Ranged breakpoints. */
ops = &ranged_breakpoint_ops;
*ops = bkpt_breakpoint_ops;
Expand Down Expand Up @@ -16761,6 +16802,30 @@ initialize_breakpoint_ops (void)
ops->breakpoint_hit = dprintf_breakpoint_hit;
}

void
create_hsa_gpu_breakpoint_trigger(char *location)
{
/* A copy to a local buffer is used, as
* location might be in a read-only memory
* and create_breakpoint takes a non constant
* char *.
*/
char buffer[30];
strncpy(buffer, location,30);
create_breakpoint(get_current_arch(),
buffer,
NULL, 0, NULL, 1,
0, bp_breakpoint,
0,
pending_break_support,
&gpu_breakpoint_trigger_ops,
1,
1, /* Is enabled. */
1, /* Internal breakpoint. */
0); /* No flags */

}

/* Chain containing all defined "enable breakpoint" subcommands. */

static struct cmd_list_element *enablebreaklist = NULL;
Expand Down
2 changes: 2 additions & 0 deletions gdb-7.8/gdb/breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,8 @@ extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
int enabled,
int internal, unsigned flags);

extern void create_hsa_gpu_breakpoint_trigger (char *location);

extern void insert_breakpoints (void);

extern int remove_breakpoints (void);
Expand Down
7 changes: 7 additions & 0 deletions gdb-7.8/gdb/hsail-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ void hsail_linux_initialize_stg2(void)
* */

struct ui_out* uiout = current_uiout;
char * hsaBreakpointLocation = "TriggerGPUBreakpointStop";

int fd = 0;

gdb_assert(NULL != uiout);
Expand All @@ -127,6 +129,11 @@ void hsail_linux_initialize_stg2(void)
g_hsail_fifo_descriptor = fd;
}

/* Place the breakpoint in the GPUDebugSDK library
* that will be hit when a gpu breakpoint is hit.
*/
create_hsa_gpu_breakpoint_trigger(hsaBreakpointLocation);

/*
* The shared memory for the dbe binary is created in the agent
*/
Expand Down