/* FIXME: This is from the gdb source: You should call clear_proceed_status before calling proceed. */
proceed ((CORE_ADDR) -1, GDB_SIGNAL_0, 0);
inferior_created = TRUE;
FUNCX;
}
By this, we pass these issues in target.c/inferior.c, but then crashes later, but i can see that output almost the same as with 6.3a:
See, on x5k it recieve the same "Program received signal SIGBUS, Bus error." as it was with 6.3a, and pass the same stages, just then crashes in amigaos_xfer_memory().
Yeah looking at the Windows nat for instance, it didn't have to explicitly add the inferior, I may try debugging that to see how it deals with setting up its inferior.
add_inferior_with_spaces () is basically a wrapper around add_inferior (). I've been delving into the gdb internals manual at https://sourceware.org/gdb/wiki/Internals so see if that helps.
You're right in that currently it feels like trying to tweak the existing code and I'm not sure if we're adding the code in the right place for instance with this inferior stuff.
amigaos_create_inferior() creates the inferior absolutely fine, the issue is that the call to find_inferior_pid () at target.c:3249 returns NULL. The code for that is in inferior.c:
/* Looking for inferior pid == 0 is always wrong, and indicative of
a bug somewhere else. There may be more than one with pid == 0,
for instance. */
gdb_assert (pid != 0);
for (inf = inferior_list; inf; inf = inf->next)
if (inf->pid == pid)
return inf;
return NULL;
}
where inferior_list is a list of all the current inferiors and our amiga one isn't on there.
In inferior.c the api for adding inferiors to this list are
If we use add_inferior () which is essentially add_inferior_silent () with a log message, then at target.c:3251 we fail due to inf -> aspace being NULL
My bet we need to just write amigaos-nat from scratch now. Just function by function. So we will then understand everything. Firstly create_inferior, then one fetching registers, etc, etc. That will be easier than tweaking old stuff.
@billifish Tried on pegasos2 version with my changes in create_inferior : there i come to the point when it recieve Trace/breakpoint trap (exactly the place where X5000 fails with Program received signal SIGBUS, Bus error., so it mean that in amigaos-nat.c, "trap" signal is not recieved on x5k, at least we know now what it SIGBUSes).
Then on pegasos2 it then remove breakpoint, and tried to "Target_create_inferior() again, and then crashes after target_get_section_Table().
But so far alsmost going till end. So my changes in amigaos_create_inferior() seems more or less correct
My bet we need to just write amigaos-nat from scratch now. Just function by function. So we will then understand everything. Firstly create_inferior, then one fetching registers, etc, etc. That will be easier than tweaking old stuff.
I agree, I think the reason we're hitting issues like this are because we're using code that used the previous GDB API and we're better off adpating to the new API instead. we've got this source plus the morphos one (thanks for that!), and the code for spotless so we have enough examples so let's do each function in turn for the new API.
I agree, I think the reason we're hitting issues like this are because we're using code that used the previous GDB API and we're better off adpating to the new API instead. we've got this source plus the morphos one (thanks for that!), and the code for spotless so we have enough examples so let's do each function in turn for the new API.
So, let's start just by creating empty list stubs based on let's say rs6000.c and then adding function one by one in the way they need it. We even not need any debug hooks now, etc, just start from basics : inferior, etc,etc.
Here is a stripped back init_amigaos_ops (). we may have a lot to fill in! But this way we know that there won't be any uninitialised values in amigaos_ops. I'm expecting that quite a lot of them will be trivial no-op functions. There's more info at [link]https://www.embecosm.com/appnotes/ean3/embecosm-howto-gdb-porting-ean3-issue-2.html#sec_target_ops[/link]
/* Native-dependent code for AmigaOS on PowerPC
for GDB, the GNU debugger.
Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GDB.
This program 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 program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/** Called from init.c */
static void init_amigaos_ops (void);
/*
* STATIC FUNCTION DEFINITIONS
*/
static void init_amigaos_ops (void)
{
/*
* start by clearing all entries so we should get a NULL pointer
* if we try to access anything that hasn't been set. So
* in case an edit below removes a function pointer value, we'll
* get a NULL pointer exception rather than accesing a junk value
* in memory.
*/
memset (&amigaos_ops, sizeof (struct target_ops), 0);
/* To the target under this one. */
amigaos_ops.beneath = NULL;
/* Name this target type */
amigaos_ops.to_shortname = "subtask";
/* Name for printing */
amigaos_ops.to_longname = "Debug an Amiga process";
/*
* Documentation. Does not include trailing newline, and starts
* with a one-line description (probably similar to to_longname).
*/
amigaos_ops.to_doc = "Debug a Task/Process running on AmigaOS 4\n"
"Use \"target subtask <process_id>\" to attach";
/* The open routine takes the rest of the parameters from the
command, and (if successful) pushes a new target onto the
stack. Targets should supply this routine, if only to provide
an error message. */
amigaos_ops.to_open = NULL;
/* Old targets with a static target vector provide "to_close".
New re-entrant targets provide "to_xclose" and that is expected
to xfree everything (including the "struct target_ops"). */
amigaos_ops.to_xclose = NULL;
amigaos_ops.to_close = NULL;
amigaos_ops.to_attach = NULL;
amigaos_ops.to_post_attach = NULL;
amigaos_ops.to_detach = NULL;
amigaos_ops.to_disconnect = NULL;
amigaos_ops.to_resume = NULL;
amigaos_ops.to_wait = NULL;
amigaos_ops.to_fetch_registers = NULL;
amigaos_ops.to_store_registers = NULL;
amigaos_ops.to_prepare_to_store = NULL;
/* Transfer LEN bytes of memory between GDB address MYADDR and
target address MEMADDR. If WRITE, transfer them to the target, else
transfer them from the target. TARGET is the target from which we
get this function.
Return value, N, is one of the following:
0 means that we can't handle this. If errno has been set, it is the
error which prevented us from doing it (FIXME: What about bfd_error?).
positive (call it N) means that we have transferred N bytes
starting at MEMADDR. We might be able to handle more bytes
beyond this length, but no promises.
negative (call its absolute value N) means that we cannot
transfer right at MEMADDR, but we could transfer at least
something at MEMADDR + N.
NOTE: cagney/2004-10-01: This has been entirely superseeded by
to_xfer_partial and inferior inheritance. */
amigaos_ops.deprecated_xfer_memory = NULL;
/* Documentation of what the two routines below are expected to do is
provided with the corresponding target_* macros. */
amigaos_ops.to_remove_watchpoint = NULL;
amigaos_ops.to_insert_watchpoint = NULL;
/* find_memory_regions support method for gcore */
amigaos_ops.to_find_memory_regions = NULL;
/* make_corefile_notes support method for gcore */
amigaos_ops.to_make_corefile_notes = NULL;
/* get_bookmark support method for bookmarks */
amigaos_ops.to_get_bookmark = NULL;
/* goto_bookmark support method for bookmarks */
amigaos_ops.to_goto_bookmark = NULL;
/* Return the thread-local address at OFFSET in the
thread-local storage for the thread PTID and the shared library
or executable file given by OBJFILE. If that block of
thread-local storage hasn't been allocated yet, this function
may return an error. */
amigaos_ops.to_get_thread_local_address = NULL;
/* Request that OPS transfer up to LEN 8-bit bytes of the target's
OBJECT. The OFFSET, for a seekable object, specifies the
starting point. The ANNEX can be used to provide additional
data-specific information to the target.
Return the number of bytes actually transfered, zero when no
further transfer is possible, and -1 when the transfer is not
supported. Return of a positive value smaller than LEN does
not indicate the end of the object, only the end of the
transfer; higher level code should continue transferring if
desired. This is handled in target.c.
The interface does not support a "retry" mechanism. Instead it
assumes that at least one byte will be transfered on each
successful call.
NOTE: cagney/2003-10-17: The current interface can lead to
fragmented transfers. Lower target levels should not implement
hacks, such as enlarging the transfer, in an attempt to
compensate for this. Instead, the target stack should be
extended so that it implements supply/collect methods and a
look-aside object cache. With that available, the lowest
target can safely and freely "push" data up the stack.
See target_read and target_write for more information. One,
and only one, of readbuf or writebuf must be non-NULL. */
amigaos_ops.to_xfer_partial = NULL;
/* Returns the memory map for the target. A return value of NULL
means that no memory map is available. If a memory address
does not fall within any returned regions, it's assumed to be
RAM. The returned memory regions should not overlap.
The order of regions does not matter; target_memory_map will
sort regions by starting address. For that reason, this
function should not be called directly except via
target_memory_map.
This method should not cache data; if the memory map could
change unexpectedly, it should be invalidated, and higher
layers will re-fetch it. */
amigaos_ops.to_memory_map = NULL;
/* Erases the region of flash memory starting at ADDRESS, of
length LENGTH.
Precondition: both ADDRESS and ADDRESS+LENGTH should be aligned
on flash block boundaries, as reported by 'to_memory_map'. */
amigaos_ops.to_flash_erase = NULL;
/* Finishes a flash memory write sequence. After this operation
all flash memory should be available for writing and the result
of reading from areas written by 'to_flash_write' should be
equal to what was written. */
amigaos_ops.to_flash_done = NULL;
/* Describe the architecture-specific features of this target.
Returns the description found, or NULL if no description
was available. */
amigaos_ops.to_read_description = NULL;
/* Build the PTID of the thread on which a given task is running,
based on LWP and THREAD. These values are extracted from the
task Private_Data section of the Ada Task Control Block, and
their interpretation depends on the target. */
amigaos_ops.to_get_ada_task_ptid = NULL;
/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
Return 0 if *READPTR is already at the end of the buffer.
Return -1 if there is insufficient buffer for a whole entry.
Return 1 if an entry was read into *TYPEP and *VALP. */
amigaos_ops.to_auxv_parse = NULL;
/* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
sequence of bytes in PATTERN with length PATTERN_LEN.
The result is 1 if found, 0 if not found, and -1 if there was an error
requiring halting of the search (e.g. memory read error).
If the pattern is found the address is recorded in FOUND_ADDRP. */
amigaos_ops.to_search_memory = NULL;
/* Can target execute in reverse? */
amigaos_ops.to_can_execute_reverse = NULL;
/* The direction the target is currently executing. Must be
implemented on targets that support reverse execution and async
mode. The default simply returns forward execution. */
amigaos_ops.to_execution_direction = NULL;
/* Does this target support debugging multiple processes
simultaneously? */
amigaos_ops.to_supports_multi_process = NULL;
/* Does this target support enabling and disabling tracepoints while a trace
experiment is running? */
amigaos_ops.to_supports_enable_disable_tracepoint = NULL;
/* Does this target support disabling address space randomization? */
amigaos_ops.to_supports_disable_randomization = NULL;
/* Does this target support the tracenz bytecode for string collection? */
amigaos_ops.to_supports_string_tracing = NULL;
/* Does this target support evaluation of breakpoint conditions on its
end? */
amigaos_ops.to_supports_evaluation_of_breakpoint_conditions = NULL;
/* Does this target support evaluation of breakpoint commands on its
end? */
amigaos_ops.to_can_run_breakpoint_commands = NULL;
/* Determine current architecture of thread PTID.
The target is supposed to determine the architecture of the code where
the target is currently stopped at (on Cell, if a target is in spu_run,
to_thread_architecture would return SPU, otherwise PPC32 or PPC64).
This is architecture used to perform decr_pc_after_break adjustment,
and also determines the frame architecture of the innermost frame.
ptrace operations need to operate according to target_gdbarch.
The default implementation always returns target_gdbarch. */
amigaos_ops.to_thread_architecture = NULL;
/* Determine current address space of thread PTID.
The default implementation always returns the inferior's
address space. */
amigaos_ops.to_thread_address_space = NULL;
/* Target file operations. */
/* Open FILENAME on the target, using FLAGS and MODE. Return a
target file descriptor, or -1 if an error occurs (and set
*TARGET_ERRNO). */
amigaos_ops.to_fileio_open = NULL;
/* Write up to LEN bytes from WRITE_BUF to FD on the target.
Return the number of bytes written, or -1 if an error occurs
(and set *TARGET_ERRNO). */
amigaos_ops.to_fileio_pwrite = NULL;
/* Read up to LEN bytes FD on the target into READ_BUF.
Return the number of bytes read, or -1 if an error occurs
(and set *TARGET_ERRNO). */
amigaos_ops.to_fileio_pread = NULL;
/* Close FD on the target. Return 0, or -1 if an error occurs
(and set *TARGET_ERRNO). */
amigaos_ops.to_fileio_close = NULL;
/* Unlink FILENAME on the target. Return 0, or -1 if an error
occurs (and set *TARGET_ERRNO). */
amigaos_ops.to_fileio_unlink = NULL;
/* Read value of symbolic link FILENAME on the target. Return a
null-terminated string allocated via xmalloc, or NULL if an error
occurs (and set *TARGET_ERRNO). */
amigaos_ops.to_fileio_readlink = NULL;
/* Implement the "info proc" command. */
amigaos_ops.to_info_proc = NULL;
/* Tracepoint-related operations. */
/* Prepare the target for a tracing run. */
amigaos_ops.to_trace_init = NULL;
/* Send full details of a tracepoint location to the target. */
amigaos_ops.to_download_tracepoint = NULL;
/* Is the target able to download tracepoint locations in current
state? */
amigaos_ops.to_can_download_tracepoint = NULL;
/* Send full details of a trace state variable to the target. */
amigaos_ops.to_download_trace_state_variable = NULL;
/* Enable a tracepoint on the target. */
amigaos_ops.to_enable_tracepoint = NULL;
/* Disable a tracepoint on the target. */
amigaos_ops.to_disable_tracepoint = NULL;
/* Inform the target info of memory regions that are readonly
(such as text sections), and so it should return data from
those rather than look in the trace buffer. */
amigaos_ops.to_trace_set_readonly_regions = NULL;
/* Start a trace run. */
amigaos_ops.to_trace_start = NULL;
/* Get the current status of a tracing run. */
amigaos_ops.to_get_trace_status = NULL;
amigaos_ops.to_get_tracepoint_status = NULL;
/* Stop a trace run. */
amigaos_ops.to_trace_stop = NULL;
/* Ask the target to find a trace frame of the given type TYPE,
using NUM, ADDR1, and ADDR2 as search parameters. Returns the
number of the trace frame, and also the tracepoint number at
TPP. If no trace frame matches, return -1. May throw if the
operation fails. */
amigaos_ops.to_trace_find = NULL;
/* Get the value of the trace state variable number TSV, returning
1 if the value is known and writing the value itself into the
location pointed to by VAL, else returning 0. */
amigaos_ops.to_get_trace_state_variable_value = NULL;
/* Get the minimum length of instruction on which a fast tracepoint
may be set on the target. If this operation is unsupported,
return -1. If for some reason the minimum length cannot be
determined, return 0. */
amigaos_ops.to_get_min_fast_tracepoint_insn_len = NULL;
/* Set the target's tracing behavior in response to unexpected
disconnection - set VAL to 1 to keep tracing, 0 to stop. */
amigaos_ops.to_set_disconnected_tracing = NULL;
amigaos_ops.to_set_circular_trace_buffer = NULL;
/* Add/change textual notes about the trace run, returning 1 if
successful, 0 otherwise. */
amigaos_ops.to_set_trace_notes = NULL;
/* Return the processor core that thread PTID was last seen on.
This information is updated only when:
- update_thread_list is called
- thread stops
If the core cannot be determined -- either for the specified
thread, or right now, or in this debug session, or for this
target -- return -1. */
amigaos_ops.to_core_of_thread = NULL;
/* Verify that the memory in the [MEMADDR, MEMADDR+SIZE) range
matches the contents of [DATA,DATA+SIZE). Returns 1 if there's
a match, 0 if there's a mismatch, and -1 if an error is
encountered while reading memory. */
amigaos_ops.to_verify_memory = NULL;
/* Return the address of the start of the Thread Information Block
a Windows OS specific feature. */
amigaos_ops.to_get_tib_address = NULL;
/* Send the new settings of write permission variables. */
amigaos_ops.to_set_permissions = NULL;
/* Look for a static tracepoint marker at ADDR, and fill in MARKER
with its details. Return 1 on success, 0 on failure. */
amigaos_ops.to_static_tracepoint_marker_at = NULL;
/* Return a vector of all tracepoints markers string id ID, or all
markers if ID is NULL. */
amigaos_ops.to_static_tracepoint_markers_by_strid = NULL;
/* Return a traceframe info object describing the current
traceframe's contents. This method should not cache data;
higher layers take care of caching, invalidating, and
re-fetching when necessary. */
amigaos_ops.to_traceframe_info = NULL;
/* Ask the target to use or not to use agent according to USE. Return 1
successful, 0 otherwise. */
amigaos_ops.to_use_agent = NULL;
/* Is the target able to use agent in current state? */
amigaos_ops.to_can_use_agent = NULL;
amigaos_ops.to_magic = 0;
/* Need sub-structure for target machine related rather than comm related?
*/
}
@billyfish Thinking a bit more about: if we go the "full rewrite" route, maybe it worth doing so via v8.3 then? Or better to deal with 7.5.1 firstly, just so we will know how all things work/etc?
PS. The link on porting guide is good! It's from the year 2008, but gdb 7.5.1 is from the year 2012, but I think it's can be ok for most of the parts still.
And remove from exec.c adding of hooks (we need to get rid of that hack as well).
It runs, I can set a breakpoint, but when type "run", it says:
Starting program: /RAM Disk/test target_terminal_ours() Don't know how to run. Try "help target"
So, what next function to implement? create_inferior() ?
In porting guide saying "to_create_inferior. For targets that can execute, this initializes a program to run, ready for it to start executing. It is invoked by the GDB run command, which will subsequently call to_resume to start execution." and "The run command must create the inferior, insert any active breakpoints and watchpoints, and then start execution of the inferior. Control does not return to GDB until the target reports that it has stopped."
So probably create_inferior() is next? But we need to write it correctly now, so we will have no needs to add those ifdefs in the exec.c which feels a bit hackish. I.e. just by creating all necessary processes/subprocesses inside of amigaos-nat (just like for all other oses done). And we have no needs to use Permit/Forbid anymore too.
At first, we can just create pure "run/wait/stop" in create_inferior (without breakpoints, etc), so we will be able to just do "run" for full execute. And then go further after it works.
But nope, didn't see that printf. Seems it's not enough to just have create_inferior alone to be called, something else should be before too (or together with create_inferior)
EDIT2:
Also adding stubs for amigaos_resume(), amigaos_wait(), amigaos_stop(), amigaos_kill_inferior(), amigaos_create_inferior() and amigaos_mourn_inferior() - and nope, still "don't kow how to run. Try "help target" ". Seems something else need to be filled in.
Edited by kas1e on 2021/3/10 8:18:11 Edited by kas1e on 2021/3/10 8:32:23 Edited by kas1e on 2021/3/10 8:44:41
For some, god only knows why, reason, the makefile code generation that builds and adds the calls to the initialize functions in init.c requires that the functions begin with "_initialize" and must be at the start of a line, wtf!
then the function call wouldn't be added to be init.c! Whoever had that as an idea, especially without explictly documenting it in big letters, is not someone I'd like working for me!
The memset call that I added without compiling yesterday had the args the wrong way around, oops!
Now it runs to "PC register is bit available", so that's the next function to fill back in along with opening the required libs and interfaces like IElf, IDebug, IMMU, etc. which I'll add in too.
@billifish Yeah, I can see in all the "nat" files they do it like this: with _initialize being as the beginning of the string.
And yes, tried within one line as before, and with _initialize starting form new line: GDB binary different indeed, and in the case when _initialize at the beginning of string it works then! (before I just mess it thinking it will spawn prints when I hit "run", but it of course printfs early).
Through, I still have "Don't know how to run. Try help target", probably because some other functions need to be stubbed firstly as well? Like maybe to_fileio_open, etc?
Btw, now we can see that this was correct to start from scratch :) We surely will understand it all better.
PS. if you can, do commits to your github bit by bit as well, so we will not have one big push with all the changes (so we can compare things in the process)
Quote:
along with opening the required libs and interfaces like IElf, IDebug, IMMU, etc. which I'll add in too.
In our old current GDB they opened in constuctors and closde in descructors, like:
void amigaos_pre_init(void)
{
ElfBase = IExec->OpenLibrary("elf.library", 0);
if (!ElfBase)
error("Can't open elf.library. How did you run *this* program ?\n");
IElf = (struct ElfIFace *)IExec->GetInterface(ElfBase, "main", 1, 0);
if (!IElf)
error("Can't get elf.library::main\n");
IMMU = (struct MMUIFace *)IExec->GetInterface((struct Library *)SysBase, "mmu", 1, 0);
if (!IMMU)
error("Can't get MMU access\n");
}
Yup that's currently how I'm doing it. I've been incrementally adding in the required functions in the order that GDB is calling them and I'm almost there in having a version that can debug a file ok. It's now becoming a lot clearer on how it's all put together so we should have a better chance of understanding what's going on as we hit each problem.
I reckon I should be able to make a pull request in the next day or two.
@billifish Btw, I find out that for making the create_inferior call works, not only _initializ_amigaos_nat should be on a new string, but also "to_can_run" should be filled with functions returning 1, and then I meet the same "PC register is a bit available".
Will wait for your pull request then if you going pretty far already.. But if you will update in the meantime that also can be tasty to check where you are for now :)
@billyfish Tried your new commit: yeah, that what I talk about! Normal proper code! We go the right way for sure!
Tested what we have now on both x5000 and pegasos2, and on both, I can load up a test file, do "list" for source code, and do "run" file, so it runs, and exit properly.
Next, I tried to set a breakpoint, and it sets, but when I do "run", it again runs the same as if I set no breakpoint and exit properly. But I assume that just because "insert/remove breakpoints" functions not implemented currently? I only can see "taget_insert_breakpoint (0x010004d4, xxx) = 0".
So, did I understand right, that the next step is re-implementing amigaos_insert_breakpoint and amigaos_remove_breakpoint?
Cheers Roman Yeah it's still missing the breakpoint stuff and dealing with the messages in amigaos_wait () for any messages that aren't CTRL+C or CTRL+D.
I don't like the is_process_alive() function and having to call it, there's got to be a cleaner way of doing that. Similarly the way that I'm getting the seglist for passing to CreateNewProcTags () could well need to be improved.
I've just added another minor commit with some minor tidying up of the code.
I haven't made a pull request yet as the code is only half finished, if you want me to I can though, just say the word.
Yeah it's still missing the breakpoint stuff and dealing with the messages in amigaos_wait () for any messages that aren't CTRL+C or CTRL+D.
Do you think messages is important enough for now, or can wait in favor of breakpoints stuff ? (just with breakpoints stuff added, we can see all the issues left : i.e. if "bt" will works, if "show regs" will works, "disas" , stepping into systemcalls inside the kernel, etc,etc.
Quote:
I don't like the is_process_alive() function and having to call it, there's got to be a cleaner way of doing that. Similarly the way that I'm getting the seglist for passing to CreateNewProcTags () could well need to be improved.
Yeah, i noticed how you deal with SegList stuff, damn, it was really hacky before ! Why it wasn't like this, in clear way .. Probabaly just because it were done 15 years ago, and Thomas did it just like this just "So it works somehow".
Quote:
I haven't made a pull request yet as the code is only half finished, if you want me to I can though, just say the word.
Imho just after breakpoint stuff added we can pull request it: it then will be "kind of first working version", and then we will be able to check if x5000 will still fail (probabaly it will), but we will know wtf for now, as its all our new code.
At least we will be able to ask Thomas and other kernel-devs with having proper test-cases :)
EDIT: Btw, do you have a paypal acc ? Want to donate a bit for the work you already do and will happy to donate from time to time if we can deal to some working version :)
Edited by kas1e on 2021/3/12 18:40:13 Edited by kas1e on 2021/3/12 19:12:58
Do you think messages is important enough for now, or can wait in favor of breakpoints stuff ?
Can do, the messages will mainly be for exceptions like null pointer crashes or memory access errors. Should be easy to add in but no need to hold up breakpoints for it. So my current plan is make sure the elf relocation code is correct, as the breakpoint stuff needs that, then the breakpoints can go in. The messages handling would be pretty quick after that. The next part would be the partial memory transfer stuff which is the part of the updated gdb API which the old port didn't have.
Quote:
: Btw, do you have a paypal acc ? Want to donate a bit for the work you already do and will happy to donate from time to time if we can deal to some working version :)
Thanks Roman, however there's really no need. The reward of having an actual working debugger will be more than enough! 🙂
If we can get this working then development will become soooooo much easier. Personally I should be able to make much more progress on porting the latest libgit2 stuff, etc.
So my current plan is make sure the elf relocation code is correct, as the breakpoint stuff needs that, then the breakpoints can go in.
I check in old 6.3a sources amigaos_memory_insert_breakpoint(), and it didn't look like something _VERY_ hardcore. Mainly some relocation, then going to a superstate, save some bits, write breakpoint, restore some bits, and back to the user state.
Then check how it did on morphos: there I can't find at all this kind of functions, seems it all now "under the hood" somewhere else.
/* Set old attributes again */
IMMU->SetMemoryAttrs((APTR)addr, 4, oldAttr);
/* Return to old state */
if (stack)
IExec->UserState(stack);
}
IExec->CacheClearU();
return 0;
}
See, the same way how done in old GDB 6.3a, just a bit more clean code.
And Alfkil's spotless one:
int Breaks::memory_insert_break_instruction (uint32_t address, uint32_t *buffer)
{
/* Go supervisor */
APTR stack = IExec->SuperState();
/* Make sure to unprotect the memory area */
uint32 oldAttr = IMMU->GetMemoryAttrs ((APTR)address, 0);
IMMU->SetMemoryAttrs ((APTR)address, 4, MEMATTRF_READ_WRITE);
/* Set old attributes again */
IMMU->SetMemoryAttrs ((APTR)address, 4, oldAttr);
/* Return to old state */
if (stack) IExec->UserState (stack);
return 0;
}
So everywhere all the same. Just in SpotLess version seems a bit more "full" and in both DB101 and SpotLess he didn't do any address relocation (but that maybe done somewhere else in deep of code) ? Or maybe relocation in Alfkil's code is just this :