MAMEWorld >> EmuChat
Previous thread Previous  View all threads Index   Next thread Next   Flat Mode Flat  

ShimaPong
MAME Fan
Reged: 03/12/05
Posts: 783
Send PM
Debugger command 'symlist' bugs
11/25/10 03:16 PM Attachment: bygone.png 61 KB (0 downloads)


Tested version : 0.140u1

1) can't print global symbols when input this command without any parameter.
debughlp says "symlist : Displays the global symbol table." But printed data is always CPU's symbols even without parameter.

See debugcmd.c:execute_symlist()

Code:


/* validate parameters */
if (!debug_command_parameter_cpu(machine, param[0], &cpu))
return;

if (cpu != NULL)
{
symtable = &cpu->debug()->symtable();
debug_console_printf(machine, "CPU '%s' symbols:\n", cpu->tag());
}
else
{
symtable = debug_cpu_get_global_symtable(machine);
debug_console_printf(machine, "Global symbols:\n");
}


debug_command_parameter_cpu() attempts to return "visible CPU" in case that parameter strings is NULL so that "cpu != NULL" is always TRUE.
Simple solution is that change "cpu != NULL" to "params != 0" (or "params != 0 || cpu != NULL") though.


2) MAME crashes when try to get symbols for Z80 CPU.
I find this problem in bygone. Inputting "symlist maincpu" (or "symlist audiocpu") causes the crash.
This problem happens in the following sequence in execute_symlist()

Code:


/* iterate over symbols and print out relevant ones */
for (symnum = 0; symnum < count; symnum++)
{
const symbol_entry *entry = symtable->find(namelist[symnum]);
assert(entry != NULL);
UINT64 value = entry->value();

/* only display "register" type symbols */
debug_console_printf(machine, "%s = %s", namelist[symnum], core_i64_hex_format(value, 0));
if (!entry->is_lval())
debug_console_printf(machine, " (read-only)");
debug_console_printf(machine, "\n");
}


"value = entry->value()" causes NULL (entry) access after 8-bit register entry ("A", "B", "C", "D", "E", "H", "L", "I", "R").
I guess this is very similar to the problem for Testers Bug ID:4121 - Debugger cannot set 8bit registers with 'do' command.

find() returns NULL when matched hash is not found though. So I doubt the reliability of tagmap in case that a tag is a single character.
See tagmap.h

Code:

INLINE UINT32 tagmap_hash(const char *string)
{
UINT32 hash = (string[0] << 5) + string[1];
char c;

string += 2;
while ((c = *string++) != 0)
hash = ((hash << 5) | (hash >> 27)) + c;
return hash;
}


For example : "a" register, string[0] = 'a', string[1] = '\0' (stopper) but it attemps to calculate a character at "string +=2" (= string[2]) or later.
I don't know C/C++ guarantees a content after stopper character (I think it is "unknown"). But I guess this will be the reason of wrong hash calculation.

[ATTACHED IMAGE]

Attachment


"Any company has no power to stop people emulating"
MAME is the emulator of no giving in the pressure from any company even if they don't allow







Entire thread
Subject Posted by Posted on
* Debugger command 'symlist' bugs ShimaPong 11/25/10 03:16 PM
. * Re: Debugger command 'symlist' bugs ShimaPong  11/28/10 04:23 PM
. * Re: Debugger command 'symlist' bugs CrapBoardSoftware  11/28/10 09:16 PM
. * Re: Debugger command 'symlist' bugs ShimaPong  11/27/10 03:47 PM
. * Re: Debugger command 'symlist' bugs ShimaPong  11/26/10 03:30 PM
. * Re: Debugger command 'symlist' bugs pepinos  11/26/10 05:07 PM
. * Re: Debugger command 'symlist' bugs CrapBoardSoftware  11/26/10 07:50 PM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 672 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2187