mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:27:35 +00:00
Kernel: Store process arguments and environment in coredumps
Currently they're only pushed onto the stack but not easily accessible from the Process class, so this adds a Vector<String> for both.
This commit is contained in:
parent
7668e968af
commit
1ccc2e6482
4 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019-2020, Jesse Buhagiar <jooster669@gmail.com>
|
* Copyright (c) 2019-2020, Jesse Buhagiar <jooster669@gmail.com>
|
||||||
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
||||||
|
* Copyright (c) 2020-2021, Linus Groh <mail@linusgroh.de>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/ByteBuffer.h>
|
||||||
|
#include <AK/JsonArray.h>
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <Kernel/CoreDump.h>
|
#include <Kernel/CoreDump.h>
|
||||||
#include <Kernel/FileSystem/Custody.h>
|
#include <Kernel/FileSystem/Custody.h>
|
||||||
|
@ -225,6 +227,8 @@ ByteBuffer CoreDump::create_notes_process_data() const
|
||||||
process_obj.set("pid", m_process->pid().value());
|
process_obj.set("pid", m_process->pid().value());
|
||||||
process_obj.set("termination_signal", m_process->termination_signal());
|
process_obj.set("termination_signal", m_process->termination_signal());
|
||||||
process_obj.set("executable_path", m_process->executable() ? m_process->executable()->absolute_path() : String::empty());
|
process_obj.set("executable_path", m_process->executable() ? m_process->executable()->absolute_path() : String::empty());
|
||||||
|
process_obj.set("arguments", JsonArray(m_process->arguments()));
|
||||||
|
process_obj.set("environment", JsonArray(m_process->environment()));
|
||||||
|
|
||||||
auto json_data = process_obj.to_string();
|
auto json_data = process_obj.to_string();
|
||||||
process_data.append(json_data.characters(), json_data.length() + 1);
|
process_data.append(json_data.characters(), json_data.length() + 1);
|
||||||
|
|
|
@ -641,6 +641,8 @@ void Process::finalize()
|
||||||
m_cwd = nullptr;
|
m_cwd = nullptr;
|
||||||
m_root_directory = nullptr;
|
m_root_directory = nullptr;
|
||||||
m_root_directory_relative_to_global_root = nullptr;
|
m_root_directory_relative_to_global_root = nullptr;
|
||||||
|
m_arguments.clear();
|
||||||
|
m_environment.clear();
|
||||||
|
|
||||||
m_dead = true;
|
m_dead = true;
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,9 @@ public:
|
||||||
Custody* executable() { return m_executable.ptr(); }
|
Custody* executable() { return m_executable.ptr(); }
|
||||||
const Custody* executable() const { return m_executable.ptr(); }
|
const Custody* executable() const { return m_executable.ptr(); }
|
||||||
|
|
||||||
|
const Vector<String>& arguments() const { return m_arguments; };
|
||||||
|
const Vector<String>& environment() const { return m_environment; };
|
||||||
|
|
||||||
int number_of_open_file_descriptors() const;
|
int number_of_open_file_descriptors() const;
|
||||||
int max_open_file_descriptors() const
|
int max_open_file_descriptors() const
|
||||||
{
|
{
|
||||||
|
@ -614,6 +617,9 @@ private:
|
||||||
RefPtr<Custody> m_root_directory;
|
RefPtr<Custody> m_root_directory;
|
||||||
RefPtr<Custody> m_root_directory_relative_to_global_root;
|
RefPtr<Custody> m_root_directory_relative_to_global_root;
|
||||||
|
|
||||||
|
Vector<String> m_arguments;
|
||||||
|
Vector<String> m_environment;
|
||||||
|
|
||||||
RefPtr<TTY> m_tty;
|
RefPtr<TTY> m_tty;
|
||||||
|
|
||||||
Region* find_region_from_range(const Range&);
|
Region* find_region_from_range(const Range&);
|
||||||
|
|
|
@ -507,6 +507,8 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_executable = main_program_description->custody();
|
m_executable = main_program_description->custody();
|
||||||
|
m_arguments = arguments;
|
||||||
|
m_environment = environment;
|
||||||
|
|
||||||
m_promises = m_execpromises;
|
m_promises = m_execpromises;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue