From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93287 invoked by alias); 16 Jan 2020 19:56:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 93275 invoked by uid 89); 16 Jan 2020 19:56:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jan 2020 19:56:46 +0000 Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BC1751E4A4; Thu, 16 Jan 2020 14:56:43 -0500 (EST) Subject: Re: [PATCH v2] Add type for $_tlb->process_environment_block->process_parameters To: Hannes Domani , gdb-patches@sourceware.org References: <20200116180050.15777-1-ssbssa.ref@yahoo.de> <20200116180050.15777-1-ssbssa@yahoo.de> From: Simon Marchi Message-ID: Date: Thu, 16 Jan 2020 20:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200116180050.15777-1-ssbssa@yahoo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-01/txt/msg00464.txt.bz2 On 2020-01-16 1:00 p.m., Hannes Domani via gdb-patches wrote: > The type then looks like this: > > (gdb) pt $_tlb->process_environment_block->process_parameters > type = struct rtl_user_process_parameters { > DWORD32 maximum_length; > DWORD32 length; > DWORD32 flags; > DWORD32 debug_flags; > void *console_handle; > DWORD32 console_flags; > void *standard_input; > void *standard_output; > void *standard_error; > unicode_string current_directory; > void *current_directory_handle; > unicode_string dll_path; > unicode_string image_path_name; > unicode_string command_line; > void *environment; > DWORD32 starting_x; > DWORD32 starting_y; > DWORD32 count_x; > DWORD32 count_y; > DWORD32 count_chars_x; > DWORD32 count_chars_y; > DWORD32 fill_attribute; > DWORD32 window_flags; > DWORD32 show_window_flags; > unicode_string window_title; > unicode_string desktop_info; > unicode_string shell_info; > unicode_string runtime_data; > } * > > It's mainly useful to get the current directory, or the full command line: > > (gdb) p $_tlb->process_environment_block->process_parameters->current_directory > $1 = { > length = 26, > maximum_length = 520, > buffer = 0xe36c8 L"C:\\src\\tests\\" > } > (gdb) p $_tlb->process_environment_block->process_parameters->command_line > $2 = { > length = 94, > maximum_length = 96, > buffer = 0xe32aa L"\"C:\\gdb\\build64\\gdb-git\\gdb\\gdb.exe\" access.exe" > } > > The type names are all lowercase because the existing types created > by windows_get_tlb_type are also lowercase. > > Type unicode_string is documented at [1]. > The official documentation [2] for rtl_user_process_parameters is limited, > so I've used this other page [3]. > > [1] https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_unicode_string > [2] https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters > [3] https://www.nirsoft.net/kernel_struct/vista/RTL_USER_PROCESS_PARAMETERS.html > > gdb/ChangeLog: > > 2020-01-16 Hannes Domani > > * windows-tdep.c (windows_get_tlb_type): > Add rtl_user_process_parameters type. Thanks, the patch LGTM. I have noted a small comment, but there's no need for another version, you can push it with that fixed (if you agree with the comment). > @@ -219,6 +227,58 @@ windows_get_tlb_type (struct gdbarch *gdbarch) > NULL); > TYPE_TARGET_TYPE (peb_ldr_ptr_type) = peb_ldr_type; > > + /* struct UNICODE_STRING */ > + uni_str_type = arch_composite_type (gdbarch, xstrdup ("unicode_string"), > + TYPE_CODE_STRUCT); > + > + append_composite_type_field (uni_str_type, "length", word_type); > + append_composite_type_field (uni_str_type, "maximum_length", word_type); > + append_composite_type_field_aligned (uni_str_type, "buffer", > + wchar_ptr_type, > + TYPE_LENGTH (wchar_ptr_type)); > + > + /* struct _RTL_USER_PROCESS_PARAMETERS */ > + rupp_type = arch_composite_type (gdbarch, > + xstrdup ("rtl_user_process_parameters"), > + TYPE_CODE_STRUCT); I'm pretty sure it would be fine to not xstrdup the names. gdbarch types are never freed (we don't delete gdbarch objects), and even then they don't assume that their name has been dynamically allocated, they would not try to free it. Simon